Git Product home page Git Product logo

Comments (14)

rlidwka avatar rlidwka commented on July 30, 2024

Here is the exact way to reproduce this one:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1000 1000">
<path d="M148.7 277.9A228.7 113.2 90 1 0 159.3 734.8L837.5 734.8A228.5 113 90 1 0 837.5 277.9L159.3 277.9A228.5 113 90 0 0 148.7 277.9Z" />
</svg>
var s = 'M148.7 277.9A228.7 113.2 90 1 0 159.3 734.8L837.5 734.8A228.5 113 90 1 0 837.5 277.9L159.3 277.9A228.5 113 90 0 0 148.7 277.9Z'

console.log(new SvgPath(s).scale(1, -1).translate(0, 850).abs().round(1).toString())
// M148.7 572.1A228.7 113.2 18.383 1 0 159.3 115.2L837.5 115.2A113 228.5 0 1 0 837.5 572.1L159.3 572.1A113 228.5 0 0 0 148.7 572.1Z
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1000 1000">
<path d="M148.7 572.1A228.7 113.2 18.383 1 0 159.3 115.2L837.5 115.2A113 228.5 0 1 0 837.5 572.1L159.3 572.1A113 228.5 0 0 0 148.7 572.1Z" />
</svg>

from svgpath.

puzrin avatar puzrin commented on July 30, 2024

Looks like missed sign somewhere.

@kpym probably your fork has the same bug - flipping can trash arcs.

from svgpath.

kpym avatar kpym commented on July 30, 2024

@puzrin Probably, if the problem is in a2c (I have not changed a2c), but it looks like the problem is in the way the transform works with arc. I'll check this ...

from svgpath.

puzrin avatar puzrin commented on July 30, 2024

100% not in a2c. See #23 (comment). There are 2 problems:

  • use improper part of esllipsis
  • distortion due presition loss (in internal division 0 / 0)

@rlidwka is investigating too.

from svgpath.

kpym avatar kpym commented on July 30, 2024

@puzrin I have not checked, but if I remember well the sweep-flag is not changed by the transform. But it should be, because if the transformation is orientetion reversing (like scale(1,-1)) the positif direction change and the sweep-flag should be reversed ... to be checked.

from svgpath.

rlidwka avatar rlidwka commented on July 30, 2024

@kpym, I believe the first issue I found is here:
https://github.com/fontello/svgpath/blob/master/lib/ellipse.js#L70-L77

L is -2.41e-12, l1 is 52303.68999999999, K is 52303.689999999995, and so it divides numbers both very close to zero.

If you add rotate(0.00001), this issue goes away.

But there is a second issue somewhere, because arc does not actually flip. Maybe it has something to do with sweep-flag, thanks for the suggestion.

from svgpath.

rlidwka avatar rlidwka commented on July 30, 2024

Here is the attempt to fix precision error (is there a better way?):
b50ec17

As for sweep-flag, you're right, it needs to be flipped when one axis is flipped (e.g. scale(1, -1), but not scale(-1, -1)). Trying to figure out the exact conditions now.

from svgpath.

puzrin avatar puzrin commented on July 30, 2024

https://github.com/fontello/svgpath/blob/master/lib/matrix.js#L47

sx * sy < 0 ?

from svgpath.

kpym avatar kpym commented on July 30, 2024

The exact condition is what I said: if the transform is orientation
preserving. This is equivalent to the determinant of the linear part is
positif.
Le 9 mars 2016 15:40, "Alex Kocharin" [email protected] a écrit :

Here is the attempt to fix precision error (is there a better way?):
b50ec17
b50ec17

As for sweep-flag, you're right, it needs to be flipped when one axis is
flipped (e.g. scale(1, -1), but not scale(-1, -1)). Trying to figure out
the exact conditions now.


Reply to this email directly or view it on GitHub
#23 (comment).

from svgpath.

kpym avatar kpym commented on July 30, 2024

Sorry I'm answering from my phone and I'm not very concentrated... I'll try to be more clear: if the determinant is negative, the seep-flag should be reversed.

from svgpath.

puzrin avatar puzrin commented on July 30, 2024

@kpym is my answer correct #23 (comment) ?

[ sx, *, *, sy, *, * ] => need to check if sx*sy is negative or not?

from svgpath.

kpym avatar kpym commented on July 30, 2024

@puzrin No. This is only valid for diagonal matrix. For general matrix you have to use the determinant.

from svgpath.

kpym avatar kpym commented on July 30, 2024

The determinant is m[0]×m[3]-m[1]×m[2].

from svgpath.

puzrin avatar puzrin commented on July 30, 2024

Seems to work now.

@kpym big thanks for your help!

from svgpath.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.