inloop / svg2android

SVG to Android VectorDrawable XML resource file
http://inloop.github.io/svg2android
Apache License 2.0
1.71k stars 357 forks source link

transform baking not working #98

Open OleksandrKucherenko opened 6 years ago

OleksandrKucherenko commented 6 years ago
Before:
        <path fill="#fff" id="a" d="M1007.195 733.064l-73.56-56.43-73.542 56.457 28.313-90.994-73.795-56.092 91.06.193 27.934-91.123 27.964 91.113 91.06-.226-73.777 56.119 28.343 90.983z"/>
        <use xlink:href="#a" transform="translate(577.189)"/>
        <use xlink:href="#a" transform="translate(288.889 -214.211)"/>
        <use xlink:href="#a" transform="translate(108 342.749)"/>
        <use xlink:href="#a" transform="translate(469.189 342.749)"/>

Produced:

    <path
        android:fillColor="#fff"
        android:pathData="M1007.2,733.064 L933.635,676.634 L860.093,733.091 L888.406,642.097 L814.611,586.005 L905.671,586.198 L933.605,495.075 L961.569,586.188 L1052.63,585.962 L978.853,642.081 L1007.2,733.064 Z" />
    <path
        android:fillColor="#fff"
        android:pathData="M1007.2,733.064 L933.635,676.634 L860.093,733.091 L888.406,642.097 L814.611,586.005 L905.671,586.198 L933.605,495.075 L961.569,586.188 L1052.63,585.962 L978.853,642.081 L1007.2,733.064 Z" />
    <path
        android:fillColor="#fff"
        android:pathData="M1007.2,733.064 L933.635,676.634 L860.093,733.091 L888.406,642.097 L814.611,586.005 L905.671,586.198 L933.605,495.075 L961.569,586.188 L1052.63,585.962 L978.853,642.081 L1007.2,733.064 Z" />
    <path
        android:fillColor="#fff"
        android:pathData="M1007.2,733.064 L933.635,676.634 L860.093,733.091 L888.406,642.097 L814.611,586.005 L905.671,586.198 L933.605,495.075 L961.569,586.188 L1052.63,585.962 L978.853,642.081 L1007.2,733.064 Z" />
    <path
        android:fillColor="#fff"
        android:pathData="M1007.2,733.064 L933.635,676.634 L860.093,733.091 L888.406,642.097 L814.611,586.005 L905.671,586.198 L933.605,495.075 L961.569,586.188 L1052.63,585.962 L978.853,642.081 L1007.2,733.064 Z" />

Correct After:

        <path d="M1007.2,733.06l-73.56-56.43-73.54,56.46,28.31-91L814.61,586l91.06.19,27.93-91.12,28,91.11,91.06-.23-73.78,56.12Z" fill="#fff"/>
        <path d="M1584.38,733.06l-73.56-56.43-73.54,56.46,28.31-91L1391.8,586l91.06.19,27.93-91.12,28,91.11,91.06-.23L1556,642.08Z" fill="#fff"/>
        <path d="M1296.08,518.85l-73.56-56.43L1149,518.88l28.31-91-73.79-56.09,91.06.19,27.93-91.12,28,91.11,91.06-.23-73.78,56.12Z" fill="#fff"/>
        <path d="M1115.19,1075.81l-73.56-56.43-73.54,56.46,28.31-91-73.79-56.09,91.06.19,27.93-91.12,28,91.11,91.06-.23-73.78,56.12Z" fill="#fff"/>
        <path d="M1476.38,1075.81l-73.56-56.43-73.54,56.46,28.31-91-73.79-56.09,91.06.19,27.93-91.12,28,91.11,91.06-.23L1448,984.83Z" fill="#fff"/>

what is wrong:

OleksandrKucherenko commented 6 years ago

https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform

translate(x [y]) This transform definition specifies a translation by x and y. This is equivalent to matrix(1 0 0 1 x y). If y is not provided, it is assumed to be zero.

OleksandrKucherenko commented 6 years ago

https://www.w3.org/TR/SVG/coords.html#__svg__SVGTransformList__consolidate

method that can convert all transformation into matrix

OleksandrKucherenko commented 6 years ago

http://phrogz.net/SVG/transform_to_path.xhtml

looks like a solution: http://phrogz.net/SVG/transformations.js

OleksandrKucherenko commented 6 years ago

Another solution: http://petercollingridge.appspot.com/svg-transforms