Open ikskuh opened 2 years ago
Hi! I wrote an initial prototype that converts SVG to tvg-text (text, not bin) and it works mostly fine. Need some additional tweaks. And I have some questions:
Hi! I wrote an initial prototype that converts SVG to tvg-text (text, not bin) and it works mostly fine.
Very nice!
How can I render tvg/tvgt to png?
You can download the SDK on the website and use tvg-text
to convert the text format to binary, then use tvg-render
to create a .tga
file. I didn't implement any PNG writer as we don't have a pure Zig implementation right now and i would've needed that to ship the code without libc. I usually use convert
from ImageMagick for the .tga
to .png
conversion.
Currently, resvg/usvg doesn't preserve original shapes, meaning svg2tvgt will produce only paths. No lines and rectangles. But we could try autodetecting those.
I am fine with this for now, this is something that can be improved upon later.
Do I understand correctly that Y axis is flipped in TinyVG? At least compared to SVG.
It should not? :thinking: Both use a X-right, Y-down coordinate system. See also the original converter
TinyVG doesn't support a lot. Like a lot. How we should handle unsupported features?
For most of them, i would provide a --sloppy
mode that will just convert what is possible and try best effort while --strict
will just reject the conversion and tell you that the file uses a non-supported feature.
Group opacity might come into TinyVG, but i have to figure out what the implications of adding it are.
I will think about each of these points if it would be reasonable to add them to TinyVG or not.
But many thanks for implementing this! Can i see the source somewhere? Do we want to integrate that into this repository so i can link the Rust and Zig code together?
It should not? 🤔 Both use a X-right, Y-down coordinate system.
My bad. I was confused.
Group opacity might come into TinyVG, but I have to figure out what the implications of adding it are.
The easiest one is https://github.com/RazrFalcon/resvg-test-suite/blob/master/svg/a-opacity-001.svg This is currently impossible to implement.
while --strict will just reject the conversion and tell you that the file uses a non-supported feature.
It would reject 99% of the files... Will take a look.
Can i see the source somewhere?
I will plan to send you a pull request today.
The easiest one is https://github.com/RazrFalcon/resvg-test-suite/blob/master/svg/a-opacity-001.svg This is currently impossible to implement.
Ah, i see. Yes, right now, such an example would require performing some kind of CSG on the paths. I have to think about that.
I will plan to send you a pull request today.
Very sweet!
The author of https://github.com/RazrFalcon/resvg said it might be easier to use resvg as a code base for the SVG converter:
https://news.ycombinator.com/item?id=29637778
This is something that would allow
tvg-text
to also implement the svg => tvg conversion by linking the Rust code as an object file