diff --git a/src/path/Curve.js b/src/path/Curve.js index be30826c..38405343 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -522,8 +522,8 @@ var Curve = Base.extend(/** @lends Curve# */{ * * @return {Curve} a reversed version of the curve */ - reverse: function() { - return new Curve(this._segment2.reverse(), this._segment1.reverse()); + reversed: function() { + return new Curve(this._segment2.reversed(), this._segment1.reversed()); }, /** diff --git a/src/path/Segment.js b/src/path/Segment.js index 14cd1aa6..61b7d610 100644 --- a/src/path/Segment.js +++ b/src/path/Segment.js @@ -393,10 +393,24 @@ var Segment = Base.extend(/** @lends Segment# */{ }, /** - * Returns the reversed the segment, without modifying the segment itself. + * Reverses the {@link #handleIn} and {@link #handleOut} vectors of this + * segment. Note: the actual segment is modified, no copy is created. * @return {Segment} the reversed segment */ reverse: function() { + var handleIn = this._handleIn, + handleOut = this._handleOut, + inX = handleIn._x, + inY = handleIn._y; + handleIn.set(handleOut._x, handleOut._y); + handleOut.set(inX, inY); + }, + + /** + * Returns the reversed the segment, without modifying the segment itself. + * @return {Segment} the reversed segment + */ + reversed: function() { return new Segment(this._point, this._handleOut, this._handleIn); }, diff --git a/test/tests/Segment.js b/test/tests/Segment.js index 3c8eb957..b28de7b7 100644 --- a/test/tests/Segment.js +++ b/test/tests/Segment.js @@ -43,7 +43,7 @@ test('new Segment(size)', function() { test('segment.reverse()', function() { var segment = new Segment(new Point(10, 10), new Point(5, 5), new Point(15, 15)); - segment = segment.reverse(); + segment.reverse(); equals(segment.toString(), '{ point: { x: 10, y: 10 }, handleIn: { x: 15, y: 15 }, handleOut: { x: 5, y: 5 } }'); });