linebender / vello_svg Goto Github PK
View Code? Open in Web Editor NEWAn integration to render SVG files with Vello.
Home Page: http://linebender.org/vello_svg/
License: Apache License 2.0
An integration to render SVG files with Vello.
Home Page: http://linebender.org/vello_svg/
License: Apache License 2.0
Lines 217 to 237 in cf6fe55
Is there a way to set a color/brush override?
If not, would a PR for that be accepted?
I do this a lot in bevy_vello - It feels very verbose!
// SVG -> Scene
let svg_tree = bevy_vello::vello_svg::usvg::Tree::from_str(
&svg_contents,
&Default::default(),
&Default::default(),
)
.unwrap();
let mut scene = bevy_vello::vello::Scene::new();
bevy_vello::vello_svg::render_tree(&mut scene, &svg_tree);
This is pretty much the requirement for every SVG load, which feels pretty dumb.
We can surely do better, can't we? e.g. vello_svg::render_str(&str) -> Scene
.
Proposal:
usvg
cargo feature.
vello_svg::render_tree
behind this feature.vello_svg::render_tree_with
behind this feature.vello_svg::usvg
behind this feature.vello_svg::render_str(&str) -> Scene
method (uses default usvg opts)vello_svg::render_str_to(&str, &mut Scene)
method (uses default usvg opts)Thoughts, @DJMcNab ?
Right now, a lot of the useful functions in vello_svg is locked up inside a private util mod:
pub fn to_affine(ts: &usvg::Transform) -> Affine
pub fn to_stroke(stroke: &usvg::Stroke) -> Stroke
pub fn to_bez_path(path: &usvg::Path) -> BezPath
pub fn into_image(image: image::ImageBuffer<image::Rgba<u8>, Vec<u8>>) -> Image
pub fn to_brush(paint: &usvg::Paint, opacity: usvg::Opacity) -> Option<(Brush, Affine)>
pub fn decode_raw_raster_image(
img: &usvg::ImageKind,
) -> Result<image::RgbaImage, image::ImageError>
As a user from the outside, it would be nice if I can access these functions and use it to transform an Svg into custom data struct that uses Vello
types other than just Scene
(maybe a collection of BezPath
s).
Lines 262 to 264 in cf6fe55
Similarly as:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.