-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partial SVG backend #112
Partial SVG backend #112
Conversation
Implementing Images present a different challenge: we can embed base64'd png or jpeg (or other?) data, but calling out to an image encoder when someone calls |
45d9545
to
13301da
Compare
A better solution to the text issue might be to render text as paths, for which there at least exists an authoritative answer to the queries. Shame not to have working copy/paste though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally this looks like a good start. I'm ok with this going in unfinished, but would like at least a short docstring at the module level explaining that, and at least a one line docstring for all public interfaces.
From what I can tell, images are largely a function of resource linking. But these could be done as base64 data uri's?
Text is going to be difficult. I'm not a fan of flattening to paths, as I think a large part of the value of SVG is preserving some structure. Longer term, we should probably have some plan for working with real fonts, but they present at least as many problems as images.
piet-svg/examples/demo.rs
Outdated
@@ -0,0 +1,18 @@ | |||
//! Basic example of rendering to a SVG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming doesn't follow the pattern, this should be "basic-svg.rs". That said, I agree the naming scheme is not ideal, and the d2d one also doesn't follow the pattern.
Thanks for the review!
We can easily add backend-specific methods for linking external resources, and probably that's what we should direct users towards here. My concern is mainly about implementing |
AFAIK, SVG allows only |
It's a good question. It's certainly possible to generate a PNG without actually doing compression, so if we really didn't want to depend on any other crates, it's possible. But I think perhaps the best thing to do here is pull in the png crate - that crate alone is not a super heavy dependency. It's starting to seem like there might need to be a more general mechanism for resources that are not generated through factory methods on the render context. I can see that coming into play, for example, for images that are generated gpu-side, for the other backends. I'll continue to think about this. |
Added (very) brief documentation and renamed the example, and tweaked types for better forwards-compatibility. |
What's the status of this? |
I think this is ready to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, what was the original motivation for this?
I have one little nit about version numbers but otherwise I'm happy. It might be good to have an issue outlining the work that's missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! :)
Lightly tested; produces output similar to the cairo backend for test images 1, 3 and 4. Attempts to use text and images will produce
NotSupported
error; theunimplemented
invocations are all statically unreachable as a result.For some reason I couldn't get SVG line elements to display, but paths work fine and are more concise anyway.