Comments (5)
No, there isn't currently.
This crate essentially exposes one method to translate an SVG into a Vello 'Scene'.
I think of a Scene as "write-only". There's no way to go back and recolor it.
I'm not sure what API would be suitable, how would you go about it?
from vello_svg.
let brush_present = brush.is_some();
let mut scene = Scene::new();
if let Some(brush) = brush {
let rect = Rect::from_origin_size(
(0., 0.),
(svg_size.width() as f64, svg_size.height() as f64),
);
scene.fill(Fill::NonZero, Affine::IDENTITY, brush, None, &rect);
scene.push_layer(
vello::peniko::BlendMode {
mix: Mix::Multiply,
compose: Compose::SrcOver,
},
1.,
Affine::IDENTITY,
&rect,
);
}
vello_svg::render_tree(&mut scene, svg.tree);
if brush_present {
scene.pop_layer();
}
I am trying to come up with a way to do this by drawing the override brush color to the background and then using the svg layer as an alpha mask for the background. But I can't figure it out / don't know if it is possible by using a layer with a blend mode.
from vello_svg.
if let Some(brush) = brush {
scene.push_layer(
vello::peniko::BlendMode {
mix: Mix::Normal,
compose: Compose::SrcOver,
},
1.0,
Affine::IDENTITY,
&Rect::from_origin_size(
(0., 0.),
(svg_size.width() as f64, svg_size.height() as f64),
),
);
vello_svg::render_tree(&mut scene, svg.tree);
scene.push_layer(
vello::peniko::BlendMode {
mix: Mix::Clip,
compose: Compose::SrcIn,
},
1.0,
Affine::IDENTITY,
&Rect::from_origin_size(
(0., 0.),
(svg_size.width() as f64, svg_size.height() as f64),
),
);
scene.fill(Fill::NonZero, Affine::IDENTITY, brush.into(), None, &rect);
scene.pop_layer();
scene.pop_layer();
} else {
vello_svg::render_tree(&mut scene, svg.tree);
}
![Screenshot 2024-06-26 at 10 26 41 PM](https://private-user-images.githubusercontent.com/13090441/343631681-cf1cdc87-c179-42b0-9f3a-d57662c1d867.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIwMDUwMDYsIm5iZiI6MTcyMjAwNDcwNiwicGF0aCI6Ii8xMzA5MDQ0MS8zNDM2MzE2ODEtY2YxY2RjODctYzE3OS00MmIwLTlmM2EtZDU3NjYyYzFkODY3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI2VDE0MzgyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRlMTk1NzM3YTc4OGQ3ZmM3NWEyOTZhZTA0MTg1ZWU4ZjZiY2Y5Nzk0NzY1MGY4MTY0Y2Q1MTYzYjBiYmQ2MGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vdhqPYvGj4Cwcxh5NrunyrCFhLG9KmrOzXr_P7uOMQg)
I was finally able to figure it out. This will override the svg color, essentially using the svg as an alpha mask
from vello_svg.
Great! Does this need to be an addition to vello_svg then? You seem to have a workaround that uses vello_svg as intended.
from vello_svg.
Probably doesn't need to be an addition to vello_svg. I think this is better solved by adding some docs on how to create an alpha mask with Vello. I'll look into adding that
from vello_svg.
Related Issues (5)
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 vello_svg.