Findus23 / BrachioGraph-Utils

A collection of random scripts for generating plots
14 stars 0 forks source link

Brachio Plots the file always mirrored #3

Open Trampf opened 4 years ago

Trampf commented 4 years ago

When I try to plot words it always plots them mirrored.

The same if I mirror it beforehand in Inkskape.

Any ideas?

Findus23 commented 4 years ago

Hi,

Hm, as said before my script just extracts the coordinates listed in the SVG file. But I think I remember that my outputs were mirrored too and I never got around to fixing it before I stopped working on it. Maybe BrachioGraph is mirroring the files internally or (more likely) I have a different corner defined as (0,0).

The same if I mirror it beforehand in Inkskape.

This is because if you mirror in Inkscape it won't change the paths. transform="matrix(-1,0,0,1,127.48464,0)">

If you have the following image consisting of one group of two lines

<svg xmlns="http://www.w3.org/2000/svg" width="210mm" height="297mm" viewBox="0 0 210 297">
  <g fill="none" stroke="#000" stroke-width="9.665">
    <path d="m 35.814116,18.505152 1.069078,38.486812 25.123335,-1.069078"/>
    <path d="m 74.639005,17.903582 1.069078,38.486811 25.123327,-1.069078"/>
  </g>
</svg>

and then you mirror the group in Inkscape, it does not modify the paths of the lines (my script only reads the m 35.814116,18.505152 1.069078,38.486812 25.123335,-1.069078), but just applies a transformation matrix to the whole group.

<svg xmlns="http://www.w3.org/2000/svg" width="210mm" height="297mm" viewBox="0 0 210 297">
  <g transform="matrix(-1,0,0,1,132.02034,0)" fill="none" stroke="#000" stroke-width="9.665">
    <path d="m 35.814116,18.505152 1.069078,38.486812 25.123335,-1.069078"/>
    <path d="m 74.639005,17.903582 1.069078,38.486811 25.123327,-1.069078"/>
  </g>
</svg>

So I think you can avoid this by ungrouping all elements in inkscape or running the file through svgo (for example with this amazing website: https://jakearchibald.github.io/svgomg/)

Findus23 commented 4 years ago

See also https://github.com/evildmp/BrachioGraph/pull/84 for someone mentioning the same.