memononen / nanosvg

Simple stupid SVG parser
zlib License
1.71k stars 363 forks source link

Push/pop attributes for SVG element. Add support for x and y attributes. #131

Open mindbrix opened 6 years ago

mindbrix commented 6 years ago

Hi. This fixes the attached SVG.

material_design_icons.svg.zip

FitzerIRL commented 6 years ago

This is nice !

mindbrix commented 6 years ago

On closer inspection, attribute parsing needs to be element specific is some cases, e.g. x and y for concatenates a translation matrix, but sets the lower point for the rect element

Also, transforms attributes need priority for (and possible others), but they are currently parsed in the order they are found. The attached file illustrates this issue.

Accordion.svg.zip

SergeySlice commented 6 years ago

Such picture? 2018-08-15 19 24 52 :)

mindbrix commented 6 years ago

Yes. Fixed, but it needs more work.

image
mindbrix commented 6 years ago

https://github.com/memononen/nanosvg/pull/131/commits/f8d80bc7c5554b535f30ea03faeee6cc843892fe fixes rects while still supporting x and y attributes for the svg element

SergeySlice commented 6 years ago

OK. One moment else. Should we perform parsing "transform" after parsing "x" and "y" in nsvg__parseAttr? The order is significant.

SergeySlice commented 6 years ago

O, I see you already said this "Also, transforms attributes need priority for (and possible others), but they are currently parsed in the order they are found." Somehow reorder attributes?

SergeySlice commented 6 years ago

Or just don't multiply matrices until parseAttr will finish.

mindbrix commented 6 years ago

@SergeySlice my analysis was incorrect. The problem was that for rects the x and y attributes were being consumed twice and concatenating an unnecessary translation. This is now fixed.

SergeySlice commented 6 years ago

All is good now. 2018-08-16 19 16 23