From 85de8a0b7d1b00059f0b9f9ba8d13aed1b48523c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Fri, 3 May 2013 21:00:46 -0700 Subject: [PATCH] Clean up Curve#divide() code. --- src/path/Curve.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index 329476c6..1d8eaebe 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -393,26 +393,24 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{ var parts = Curve.subdivide(this.getValues(), parameter), isLinear = this.isLinear(), left = parts[0], - right = parts[1], - point1 = this._segment1._point, - point2 = this._segment2._point; + right = parts[1]; // Write back the results: if (!isLinear) { - this._segment1._handleOut.set(left[2] - point1._x, - left[3] - point1._y); + this._segment1._handleOut.set(left[2] - left[0], + left[3] - left[1]); // segment2 is the end segment. By inserting newSegment // between segment1 and 2, 2 becomes the end segment. // Convert absolute -> relative - this._segment2._handleIn.set(right[4] - point2._x, - right[5] - point2._y); + this._segment2._handleIn.set(right[4] - right[6], + right[5] - right[7]); } // Create the new segment, convert absolute -> relative: var x = left[6], y = left[7], segment = new Segment(Point.create(x, y), - isLinear ? null : Point.create(left[4] - x, left[5] - y), - isLinear ? null : Point.create(right[2] - x, right[3] - y)); + !isLinear && Point.create(left[4] - x, left[5] - y), + !isLinear && Point.create(right[2] - x, right[3] - y)); // Insert it in the segments list, if needed: if (this._path) { @@ -427,8 +425,8 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{ // become the owner of the newly inserted segment. // TODO: I expect this.getNext() to produce the correct result, // but since we're inserting differently in _add (something - // linked with CurveLocation#dividie()), this is not the case... - res = this; + // linked with CurveLocation#divide()), this is not the case... + res = this; // this.getNext(); } else { // otherwise create it from the result of split var end = this._segment2;