Skip to content

Precomputing group transformation #1

@drewnoakes

Description

@drewnoakes

Firstly, nice work on this tool. It's really great.

I often make logos using SVG in Inkscape and end up putting them online. Normally I create it in the middle of the artboard, and when done, trim the board to fit the content. Inkscape achieves this by translating the content to the origin, and reducing the viewbox dimensions.

This ends up with something like:

<g transform="translate(-11.118166,-287.17383)">
  <path d="m 11.118166,339.05194 c 0,-13.80712 11.2085,-25 25.01562,-25 1.25365,1.25192 15.21962,15.21745 17,17 l -17.05273,0 -0.0215,0 c -4.41828,0 -8,3.58173 -8,8 0,4.41828 3.58172,8 8,8 l 0.0215,-0.002 0,0.002 0.0371,0 12.6914,0 10.96875,0 c 0,0 0,0.002 0,0.002 l 9.36524,0.002 16.996104,16.996 -26.369144,0 -10.96094,0 -12.6914,0 -0.0371,0 -0.0215,0 c -4.41828,0 -8,3.58173 -8,8 0,4.41828 3.58172,8 8,8 l 0.0215,-0.002 0,0.002 0.0527,0 23.64453,0 c -1.9e-4,5.8e-4 2e-4,10e-4 0,0.002 l 42.357434,0.002 16.99611,16.996 -82.998054,0 c -0.005,10e-6 -0.0104,-10e-6 -0.0156,0 -13.80712,0 -25,-11.19288 -25,-25 0.008,-6.08001 2.23126,-11.94875 6.2539,-16.50781 -4.0191,-4.55502 -6.2422,-10.41756 -6.25392,-16.49219 z" />

Within the path data, the positional values could all be adjusted so that the translation wasn't needed. This would remove the transform attribute, but for complex geometry the larger saving would likely be due to values requiring fewer digits (eg. 0 instead of 11.118166).

Would it be possible to pre multiply position values by the parent group's transformation matrix?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions