Graphite icon indicating copy to clipboard operation
Graphite copied to clipboard

Node to rasterize vector graphics

Open Keavon opened this issue 1 year ago • 8 comments

Using the arbitrary canvas targets for rendering introduced in #1256, we can easily repurpose that to render SVG content and read back the rendered canvas data. This lets us avoid needing to switch to Vello quite so soon.

Keavon avatar Jun 02 '23 07:06 Keavon

@TrueDoctor In regards to the RenderNode you've discussed (which I'm not too privy to with its functionality), how does that pertain to the current status of this issue? Should this be closed, or modified to reflect some desired changes to the RenderNode to make it more useful/capable/general? Or should it be updated to talk about integrating Vello?

Keavon avatar Nov 11 '23 11:11 Keavon

This is basically provided by the render node

TrueDoctor avatar Jan 10 '24 23:01 TrueDoctor

Except it's not currently actually coded to do that, right? I would suggest we use web-sys for the moment since that should just be a few lines of code and ensures consistent rendering results, until we can fully switch to Vello.

Keavon avatar Jan 10 '24 23:01 Keavon

The code exits, it is just not currently used but that can easily be changed when hooking it up to something. This is basically not a blocker

TrueDoctor avatar Jan 11 '24 10:01 TrueDoctor

The rasterize node currently takes Footprint -> GraphicElement data and returns a bitmap at the resolution of the footprint and thus, if manually hooked up, would be production-ready today? If so, what engine is it using to rasterize the content? I'm just clarifying since I recall hearing varying information about the readiness of that.

Keavon avatar Jan 11 '24 10:01 Keavon

I originally implemented this using the web-sys apis (that implementation is still available as comment in the node source code but can be made into a fallback based on the vello/resvg feature flags). I then started to adopt vello which is why the original code is currently commented out. For more info see wasm_application_io.rs

TrueDoctor avatar Jan 11 '24 10:01 TrueDoctor

Nice. And were you able to get working rasterized image output from the web-sys implementation? I'd suggest keeping your Vello port fully behind a feature flag so we can keep the web-sys version in the editor until the Vello integration is completed and robust enough to land. Once that's the case and this node is usable for users to hook up if they wanted, the PR achieving that can close this issue. Meanwhile, even though I'm quite glad to hear it sounds trivial to implement this, it'll still be useful to keep this issue open to track that.

Keavon avatar Jan 11 '24 11:01 Keavon

Yes, I was able to get proper images. iirc other issues are blocked on this one so keeping this open might not be the best approach

TrueDoctor avatar Jan 11 '24 12:01 TrueDoctor