icculus / ControllerImage

A library for producing images of SDL controllers.
zlib License
107 stars 2 forks source link

tinyvg #16

Open IcedQuinn opened 7 months ago

IcedQuinn commented 7 months ago

Probably a good time to mention TinyVG, which is a project to store vector graphics in a greatly simplified format. It's basically meant to cut out the majority of SVG down to the basic shapes used on production.

https://tinyvg.tech/

Relying on SVG support at runtime would be quite onerous as its a massive spec to support.

icculus commented 7 months ago

The TinyVG SDK is written in Zig, so that's a non-starter.

icculus commented 7 months ago

So I'm still thinking about this.

I think it makes sense to stay in SVG in revision control for various reasons: easy tooling, browsers can show individual images, GitHub can show you interactive diffs between revisions (which blew my mind), etc.

But it might make a lot of sense to have the final database pack down to TinyVG: we already have a step where we have to process the data into a single binary file, and we want it to be as small as possible, and it doesn't matter a lot what format it is in at that point, so smaller is better.

We did have a request in #1 to get SVG data at runtime, but we could generate that on the fly trivially from the TinyVG data.

I'm not deeply worried about the complexity of the SVG format, as we control the data and the parser (nanosvg), so if it doesn't work there, we'd just not ship it without modifications. I'm sure nanosvg has gaps in spec compliance, but we're probably only using the subset of SVG that TinyVG cares about anyhow.

So I might write a simple TinyVG parser in C, and have it output the data structure that nanosvg's parser spits out, so I can continue to use nanosvg's rasterizer, just without SVG data.

Then I can also convert that data structure down to TinyVG data, so cooking the database will parse the SVGs, then generate and pack TinyVG into the output instead of the SVG. Since the spec is pretty simple, this could be doable without having to use the existing Zig code.

This will take some work, but I think it's doable, and make this a better project if it works out.