Closed abusedmedia closed 7 years ago
Thanks for the demonstration case! I think what's going on here is that maxSegmentLength
is 10 by default and it's in pixel space, so these paths are so short that not enough points are getting added (this only affects path string inputs, not array inputs).
For an immediate fix you can specify a maxSegmentLength
that's less than 1/3 the total length:
https://runkit.com/590ff00e90d6f10011380a19/593ebcea407b44001216b817
In the short term I'll fix so that it always polygonizes a path string into a minimum of three points. Longer term I'm planning to turn maxSegmentLength
into a relative value anyway (e.g. 0.1
means no segment can be longer than 10% of the whole perimeter), which should help.
Thanks so much for Flubber! I'm really excited to use it. I'm running into a similar problem that I'm not able to fix with the maxSegmentLength
solution you have here. I've added a sample path to runkit here: https://runkit.com/ejfox/594bd75bc5101e00118c0f5a
I've uploaded a snapshot of my project in case that helps as well: http://stenographer-access-43136.netlify.com/
Appreciate any help you can offer!
Will look into it - I notice that your runkit sample is using an old version (0.2.2), and your app bundle might be also. This was patched in 0.2.6, so try installing the latest?
Strangely, I'm not able to reproduce this even with 0.2.2 in Node or in browser. Let me know if you're still getting it with a 0.2.6+ version?
Thanks Noah,
I've been playing around with things for the last few days after updating to 0.3.0 and going through the demos to figure out my bug a little better. I've made some progress but still encountering some paths that return errors.
I've made a new runkit with a problematic path using 0.3.0 https://runkit.com/ejfox/flubber-error
So your example path string has two individual rings. By default, flubber will only use the first ring, which in this case is:
M673.504130256738,582.2362322253204
L673.4952926184682,582.137462231841
L673.504130256738,582.2362322253204Z
The first and third points are identical, so it's really only a two-point line segment rather than a polygon with any interior area, which is why it fails the test.
I'm still undecided on how to handle cases like this, but in the meantime if you want to avoid this error you could take the second ring from the path string instead, which seems like the important shape anyway:
var interpolate = f.toCircle(f.splitPathString(a)[1], 0, 0, 8);
Hi there Nice lib!
I'm getting this error while using normalised coordinates: TypeError: Polygons must have at least three points.
Here the live test: https://runkit.com/abusedmedia/593e75ced98c590011feaed9
Keep it up!