TinyVG / specification

The specification for TinyVG. This is the central authority for the file system
https://tinyvg.tech/
MIT License
239 stars 6 forks source link

[Proposal] Templates / Repeated elements #8

Open rsheeter opened 2 years ago

rsheeter commented 2 years ago

QQ, from a quick skim it seems to me that repeated identical shapes must be fully reproduced? - apologies if I simply misunderstood.

If you provide the ability to reuse parts you may more significantly outperform svg on size in some cases. For example, in COLRv1 we allow reuse with a new fill and a transform applied.

ikskuh commented 2 years ago

Yes, this is something i'm still considering as it can make repetetive graphics a lot smaller. SVG can do that as well

ikskuh commented 2 years ago

I think this can be implemented reasonably easily by calling the parser/interpreter recursively. As it also reduces the file size, we can load complexer graphics in less memory, so seeking shouldn't be a huge problem.

My current idea would be two new commands:

neinseg commented 2 years ago

My current idea would be two new commands:

something like setRotation(angle, center_x, center_y) would be useful here.

ikskuh commented 2 years ago

Oh yeah, that's a good idea. This would allow a lot of stuff to be made. I'll think a bit about precise semantics, but i'm already happy with the idea. With offset and rotation around point you can probably duplicate any part of the image into another position. Not sure if we should support scale/shearing, as those usually are more abused than used

rsheeter commented 2 years ago

Reuse scaled is definitely useful. Shear ... I'm not sure how often it's used but IMO it's odd to have everything except shear. Maybe just off a setTransform that takes a full affine matrix as a fallback?

ikskuh commented 2 years ago

Maybe just off a setTransform that takes a full affine matrix as a fallback?

This is something i wanna prevent, but maybe it's the smarter idea. Encoding-wise it would be better to have offset, rotate, scale tho