RazrFalcon / resvg

An SVG rendering library.
Mozilla Public License 2.0
2.63k stars 216 forks source link

Make a way to create usvg::Fill and usvg::Stroke #731

Closed woodroof closed 3 months ago

woodroof commented 3 months ago

I'm playing with usvg::Tree binary serialization and deserialization, so I can avoid using XML. Currently I can serialize, but I have problems with deserialization — I can't create usvg::Fill and usvg::Stroke cause they don't have any public functions for creation and their fields marked as public only inside a crate. Can you provide some way for creating objects of these types from an external library?

LaurenzV commented 3 months ago

This used to be possible, but this was changed recently (and for the better), because it made things much harder for rendering. It's on purpose that you can't create your own fill/strokes. usvg is supposed to be a read-only representation of an SVG which can then be used to build a rendering library on top of it. But it's not supposed to be editable.

See also: https://github.com/RazrFalcon/resvg/issues/710

woodroof commented 3 months ago

Oh, ok. Thank you for the explanation.

RazrFalcon commented 3 months ago

You're not suppose to create usvg::Tree yourself. If you want to render some stuff - just use tiny-skia directly. You don't need resvg.