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
No room for floating point error in Path.closePath (when merging last point). #1045
Comments
I had the same experience before. This problem is a combination of lack of precision in the SVG file and the IMHO weird decision to use relative coordinates for path descriptions in SVG (they probably wanted to reduce the file size by getting smaller corrdinate values). Another approach could be to make Inkscape use higher precision for SVG export, but I am not sure if there is a setting for this. Anyway, I think you are correct that |
Yes, I've actually lowered my precision in Inkscape previously to 4 or something (was debugging the path and all those decimals were driving me mad). I hadn't noticed the absolute setting though. I'll give that a go. It's unfortunate that my workflow might be tied into Inkscape configuration, but nevermind I suppose. I shall play with Inkscape's settings next time I'm working on this project. Yes I suppose it's fundamentally a downfall of the syntax. Or the format as a whole for not having object-based nodes. Reductions in precision will always cause issues. In my case it probably is low-quality path data.
So perhaps a patch isn't neccessary. Will experiment more soon.
|
I just checked if Paper.js supports absolute coordinates at all. For import absolute coordinates should work, but export is always with relative coordinates. |
Here the example as a sketch, with added logging of the distance. |
You see that the logged distance is I'm thinking that we should maybe |
I have an SVG path from Inkscape which creates a closed loop (at least it does in inkscape). When loading this path the last points don't get merged together (I end up with 1 too many points). This is a no-go for me because I'm implementing blend-shape style animation, so the paths must have an equal number of points.
Here is a JS fiddle which demonstrates my problem and monkey-patch fix using
paper.Numerical.GEOMETRIC_EPSILON
: https://jsfiddle.net/willstott101/fouvx8y4/3/A more sensible fix would use
GEOMETRIC_EPSILON
andPoint.isClose()
instead ofPoint.equals()
all throughoutPath.join()
.While this is arguably an Inkscape problem with precision. It seems to me this is exactly what
paper.Numerical.GEOMETRIC_EPSILON
andisClose
should be used for.The text was updated successfully, but these errors were encountered: