bezierjs icon indicating copy to clipboard operation
bezierjs copied to clipboard

outline() fails miserably when reduce() returns empy list because it cannot form a reduction

Open chuckhacker opened this issue 8 years ago • 5 comments
trafficstars

Shouldn't reduce() in the "cannot reduce" case return the original unreduced curve? Y so destructive?

we can never form a reduction  bezier.js:1152:13
TypeError: fcurves[0] is undefined[Learn More]  bezier.js:1273:7
	Bezier.prototype.outline file:///home/chuck/curve_test_js/bezier.js:1273:7
	Bezier.prototype.outlineshapes file:///home/chuck/curve_test_js/bezier.js:1286:17
	<anonymous> file:///home/chuck/curve_test_js/outlines.html:375:40
	r.Callbacks/i file:///home/chuck/curve_test_js/jquery-3.1.1.min.js:2:27978
	r.Callbacks/j.fireWith file:///home/chuck/curve_test_js/jquery-3.1.1.min.js:2:28749
	A file:///home/chuck/curve_test_js/jquery-3.1.1.min.js:4:14201
	.send/c/< file:///home/chuck/curve_test_js/jquery-3.1.1.min.js:4:16491

chuckhacker avatar Dec 02 '16 02:12 chuckhacker

Here is a repro quadratic curve:

start: (193.15625, 203.84375)
control point: (193.15625, 203.84375)
end: (213.125, 209.46875)

Hope that helps!

chuckhacker avatar Dec 02 '16 02:12 chuckhacker

hm, probably a good idea, marking as enhancement.

Pomax avatar Dec 02 '16 17:12 Pomax

Thank you! It's also a bug because outline() (which calls reduce() in its own internal implementation) doesn't work at all with this curve (it crashes with the aforementioned stack trace instead of returning an outline for the original curve).

chuckhacker avatar Dec 02 '16 21:12 chuckhacker

Note to anyone else running into this: I'm terribly unavailable atm, so if anyone wants to file a PR: you'd be a hero

Pomax avatar Jan 11 '18 19:01 Pomax

test:

b = new Bezier(0,0,  0,0,  1,1);
r = b.reduce();

r will be an empty array. Note that this is a degenerate curve, and there are no degeneracy checks at the moment, which there really should be..

Pomax avatar Jul 05 '18 23:07 Pomax