jzbrooks / vgo

vector graphic optimization
MIT License
43 stars 2 forks source link

Reland collapse multiple curves into arcs #32

Closed jzbrooks closed 3 years ago

jzbrooks commented 4 years ago

The code in collapseMultipleCurves stands to gain a lot from a rework. Ideally, this would help address #31.

jzbrooks commented 3 years ago

It appears that the shorthand fixup isn't working. Using the offending subset of the commands in the linked issue, the shorthand (s) command persists even after its preceding command has been swapped for an arc.

===Before===
M13.932,8.63
c-0.215,-1.348-0.918,-2.533-1.924,-3.367
c0.122,-1.822 1.638,-3.263 3.492,-3.263
c1.933,0 3.5,1.567 3.5,3.5
s-1.567,3.5-3.5,3.5
c-0.564,0-1.097,-0.133-1.568,-0.37
Z
m3.068,9.37
v-0.328

===Multi Pass===
M13.932,8.63
a5.499,5.499,0,0,0,-1.924,-3.367
a3.5,3.5,0,0,1,6.992,0.237
s-1.567,3.5-3.5,3.5
a3.479,3.479,0,0,1,-1.568,-0.37
Z
m3.068,9.37
v-0.328

===Single Pass===
M13.932,8.63
a5.499,5.499,0,0,0,-1.924,-3.367
a3.5,3.5,0,0,1,6.992,0.237
s-1.567,3.5-3.5,3.5
a3.479,3.479,0,0,1,-1.568,-0.37
Z
m3.068,9.37
v-0.328

Size before: 426 B
Size after: 380 B
Percent saved: 10.7981220657277
jzbrooks commented 3 years ago

Removing the shorthand curve manually addresses the deformation.