[Request] Support rendering existing `usvg::Tree`
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
Support loading SVG images directly from `usvg::Tree` that is already in memory.
**Is your feature request related to a problem? Please describe.**
I cannot render SVG images in egui with an already existing `usvg::Tree`.
**Describe the solution you'd like**
Some additional method on the svg_loader in `egui_extras` named something like `from_tree()` that would accept a `usvg::Tree`. Not quite sure how this would work, as I am not familiar with the internals of the library. Would be nice to not have to specify a URI in this function as it already knows what datatype is incoming.
**Describe alternatives you've considered**
My current solution is to use `egui::widgets::Image::from_bytes()` and convert the tree to a bytes array using `tree.to_string().into_bytes()` which introduces several additional conversion steps.
**Additional context**
I am building a library that uses `usvg::Tree` internally to parse custom data out of SVGs. As I already have the SVG parsed into a `tree`, it would be ideal to pass that directly to rendering code without having to go through converting to string, then bytes, then reparsing the SVG.
This is partially related to #7797.
Contributor guide
Research direction
Start with the SVG loader in egui_extras and review the related discussion in issue #7797. Determine how an existing usvg::Tree could enter the rendering path without a URI or serialization step; done means an additional loader method can render the in-memory tree directly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100