Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove transforms, apply transform="translate(...)" to x and y coordinates #428

Open
milahu opened this issue Oct 7, 2023 · 0 comments
Open

Comments

@milahu
Copy link

milahu commented Oct 7, 2023

input

<svg version="1.1" viewBox="0 0 33.951 42.07" xmlns="http://www.w3.org/2000/svg">
  <g transform="translate(-.5821)" font-family="sans-serif" font-size="3.5278px">
    <g transform="translate(-18.031 -47.378)" fill="none" stroke="#000" stroke-width=".26458px">
      <path d="m35.631 55.041 0 26.779"/>
      <path d="m28.936 75.125 13.389 0"/>
    </g>
    <text x="16.597956" y="5.1086421">2</text>
    <text x="16.81669" y="39.515091">1</text>
    <text x="3.0625346" y="29.008286">401</text>
    <text x="26.690271" y="29.008286">301</text>
  </g>
</svg>

actual output

the transform="translate(...)" is moved from <g> to child elements

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 42.1">
  <g font-family="sans-serif" font-size="3.5">
    <path fill="none" stroke="#000" stroke-width=".3" d="M17 7.7v26.7m-6.7-6.7h13.4"/>
    <text x="16.6" y="5.1" transform="translate(-.6)">2</text>
    <text x="16.8" y="39.5" transform="translate(-.6)">1</text>
    <text x="3.1" y="29" transform="translate(-.6)">401</text>
    <text x="26.7" y="29" transform="translate(-.6)">301</text>
  </g>
</svg>

expected diff

the transform="translate(...)" should be removed
and the translate should be applied to the x and y coordinates

 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 42.1">
   <g font-family="sans-serif" font-size="3.5">
     <path fill="none" stroke="#000" stroke-width=".3" d="M17 7.7v26.7m-6.7-6.7h13.4"/>
-    <text x="16.6" y="5.1" transform="translate(-.6)">2</text>
+    <text x="16" y="5.1">2</text>
-    <text x="16.8" y="39.5" transform="translate(-.6)">1</text>
+    <text x="16.2" y="39.5">1</text>
-    <text x="3.1" y="29" transform="translate(-.6)">401</text>
+    <text x="2.5" y="29">401</text>
-    <text x="26.7" y="29" transform="translate(-.6)">301</text>
+    <text x="26.1" y="29">301</text>
   </g>
 </svg>

the option round/rewrite transforms is enabled

related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant