Comments (14)
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.
Looks like missed sign somewhere.
@kpym probably your fork has the same bug - flipping can trash arcs.
from svgpath.
@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.
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.
@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.
@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.
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.
https://github.com/fontello/svgpath/blob/master/lib/matrix.js#L47
sx * sy < 0
?
from svgpath.
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
b50ec17As 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.
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.
@kpym is my answer correct #23 (comment) ?
[ sx, *, *, sy, *, * ]
=> need to check if sx*sy is negative or not?
from svgpath.
@puzrin No. This is only valid for diagonal matrix. For general matrix you have to use the determinant.
from svgpath.
The determinant is m[0]×m[3]-m[1]×m[2]
.
from svgpath.
Seems to work now.
@kpym big thanks for your help!
from svgpath.
Related Issues (20)
- For in-browser use, do we have a bundled JS file served anywhere? HOT 5
- feature request: non-scaling-stroke HOT 4
- Shorthand notation ends up in missing parameters HOT 8
- Is is possible to split segments HOT 1
- Support for calculating bounding boxes HOT 1
- Support for reversing the path HOT 23
- Support for open/closed path HOT 1
- Support for more modular structure using ES6 modules HOT 2
- [QUESTION] apply 3d transform to svg path commands possible? HOT 1
- Update index.d.ts to include export SvgPath interface and type declarations for from() HOT 1
- Differentiate between relative chained and isolated command in parser HOT 1
- rel method Supports Typescript HOT 1
- Instructions for running locally HOT 5
- How I can create path for mltline text? HOT 1
- Transform origin and transform box are not centered HOT 1
- very high cpu usage HOT 2
- Run in Browser. No Node HOT 2
- Support for setting the origin of the transformation HOT 1
- Support transformation units HOT 1
- Is it possible to have the pair of transformed coordinates returned as a dataset HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svgpath.