diff --git a/src/path/Path.js b/src/path/Path.js index 394bbfa9..b3bc085d 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -248,8 +248,8 @@ var Path = this.Path = PathItem.extend({ } else { if (clockwise === null) clockwise = true; - var middle = current._point.add(to).divide(2); - var step = middle.subtract(current._point); + var middle = current._point.add(to).divide(2), + step = middle.subtract(current._point); through = clockwise ? middle.subtract(-step.y, step.x) : middle.add(-step.y, step.x); @@ -360,18 +360,17 @@ var Path = this.Path = PathItem.extend({ ctx.beginPath(); var segments = this._segments, length = segments.length, - outX, outY; + handleOut, outX, outY; for (var i = 0; i < length; i++) { var segment = segments[i], point = segment._point, x = point.x, y = point.y, - handleIn = segment._handleIn, - handleOut = segment._handleOut; + handleIn = segment._handleIn; if (i == 0) { ctx.moveTo(x, y); } else { - if (handleOut.isZero() && handleIn.isZero()) { + if (handleIn.isZero() && handleOut.isZero()) { ctx.lineTo(x, y); } else { ctx.bezierCurveTo( @@ -381,6 +380,7 @@ var Path = this.Path = PathItem.extend({ ); } } + handleOut = segment._handleOut; outX = handleOut.x + x; outY = handleOut.y + y; } diff --git a/src/path/Segment.js b/src/path/Segment.js index 2bd1abd4..f6d7a364 100644 --- a/src/path/Segment.js +++ b/src/path/Segment.js @@ -48,24 +48,19 @@ var Segment = this.Segment = Base.extend({ return this._handleIn; }, - getHandleInIfSet: function() { - return this._handleIn.x == this._handleIn.y == 0 - ? null : this._handleIn; - }, - setHandleIn: function() { this._handleIn = Point.read(arguments); // Update corner accordingly // this.corner = !this._handleIn.isParallel(this._handleOut); }, - getHandleOut: function() { - return this._handleOut; + getHandleInIfSet: function() { + return this._handleIn.x == 0 && this._handleIn.y == 0 + ? null : this._handleIn; }, - getHandleOutIfSet: function() { - return this._handleOut.x == this._handleOut.y == 0 - ? null : this._handleOut; + getHandleOut: function() { + return this._handleOut; }, setHandleOut: function() { @@ -74,6 +69,11 @@ var Segment = this.Segment = Base.extend({ // this.corner = !this._handleIn.isParallel(this._handleOut); }, + getHandleOutIfSet: function() { + return this._handleOut.x == 0 && this._handleOut.y == 0 + ? null : this._handleOut; + }, + getIndex: function() { // TODO: Cache and update indices instead of searching? return this.path ? this.path._segments.indexOf(this) : -1;