Comments (10)
Hi Noel,
Is this what is needed here??
https://stackoverflow.com/questions/13605248/java-converting-image-to-bufferedimage
from doodle.
That's not really the issue. This is about having a way to convert the Picture
type in Doodle into a BufferedImage
. All the code already exists, it just needs to presented in a stable API.
from doodle.
I have one question about the end result. After the succesful implementation we want to be able to do something like:
val picture = circle(100)
val bi = picture.fromPicture
where bi is a BufferedImage
or we want this function to evaluate the picture as well and get something like:
val picture = circle(100)
val (res, bi) = picture.fromPicture
Another possibility is to have a method .bufferedImage
on picture that converts to the BufferedImage
since there is such a method for the base64
from doodle.
The closest equivalent is the Base64 effect.
I think the following is probably what is needed:
- An effect with a single method
def bufferedImage[A](picture: Picture[Alg, A]): IO[(A, BufferedImage)]
-
Syntax to make it easier to use.
-
An implementation for the Java2D backend. (Code already exists to do this conversion. It just needs to be exposed in this API.)
from doodle.
The function renderBufferedImage()
takes more arguments than just a picture:
Should we also make the user to specify those arguments in the effect? Also this function returns the IO with the types inside in a different order than the base64 function does:
Is that intended and should the effect also return this in that order?
from doodle.
Yes, I think you're right. The parameters to renderBufferedImage
are essentially the elements of Frame
. So I think the correct signature is
def bufferedImage[A](frame: Frame, picture: Picture[Alg, A]): IO[(A, BufferedImage)]
The different order of types is just an accident. The external APIs should be as consistent as possible, and hence should follow the precedent in base64
.
from doodle.
Does the binary compatibillity check failing mean that I cannot make the Java2dWriter
extend the BufferedImageConverter
and should create a separate class for that?
from doodle.
You can ignore binary compatibility issues. If you bump the base version defined in build.sbt
the problem will go away.
from doodle.
I made everything specific for java2d backend but now I started thinking that maybe the approach of making the converter generic with respect to the bitmap is better as other backends might have their own bitmap classes and that could be helpful for example if we want draw pixels on the screen or do the convolutions (#94)
from doodle.
I made everything specific for java2d backend but now I started thinking that maybe the approach of making the converter generic with respect to the bitmap is better as other backends might have their own bitmap classes and that could be helpful for example if we want draw pixels on the screen or do the convolutions (#94)
Agreed with this. To avoid scope creep I opened another issue (#145) that includes this.
from doodle.
Related Issues (20)
- Implement `flatMap` for `Picture`
- Add `boundingBox` syntax for `Size`
- Improve type inference HOT 1
- Add SVG documentation
- Parse hex strings into `Color`
- SVG must not fill open paths HOT 2
- Support perceptually-based color description
- Port minitest tests to munit
- Image saved to file does not have size of Frame HOT 1
- Question: How do we set a shape position relative to a Frame origin HOT 4
- Unexpected behaviour with `Picture` monad and Java2D renderer HOT 2
- BufferedImageConverter cleanup HOT 3
- Consistent naming of writers HOT 2
- Add tests for `BufferedImageWriter`
- Abstract default frame HOT 3
- Writer conveniences
- Java Implementation Cleanup
- Configurable delay between frames in animated GIF HOT 2
- Allow directly setting the width and height of the bounding box
- Create browser canvas backend
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from doodle.