From d4d6d652ecdee8282e0ef33033f6d73cfb54a688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 3 Mar 2011 12:51:47 +0000 Subject: [PATCH] Rename Path#addSegment() to #_add(), to make sure it's supposed to be a private method. --- src/path/Path.Constructors.js | 10 +++++----- src/path/Path.js | 18 +++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/path/Path.Constructors.js b/src/path/Path.Constructors.js index 05532baa..2b11b23a 100644 --- a/src/path/Path.Constructors.js +++ b/src/path/Path.Constructors.js @@ -12,11 +12,11 @@ Path.inject({ statics: new function() { Line: function() { var path = new Path(); if (arguments.length == 2) { - path.addSegment(new Segment(arguments[0])); - path.addSegment(new Segment(arguments[1])); + path._add(new Segment(arguments[0])); + path._add(new Segment(arguments[1])); } else if (arguments.length == 4) { - path.addSegment(Segment.read(arguments[0], arguments[1])); - path.addSegment(Segment.read(arguments[2], arguments[3])); + path._add(Segment.read(arguments[0], arguments[1])); + path._add(Segment.read(arguments[2], arguments[3])); } return path; }, @@ -74,7 +74,7 @@ Path.inject({ statics: new function() { var size = new Size(rect.width, rect.height); for (var i = 0; i < 4; i++) { var segment = ovalSegments[i]; - path.addSegment(new Segment( + path._add(new Segment( segment.point.multiply(size).add(topLeft), segment.handleIn.multiply(size), segment.handleOut.multiply(size) diff --git a/src/path/Path.js b/src/path/Path.js index e3432972..00d644fc 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -13,7 +13,7 @@ Path = PathItem.extend({ || typeof segments[0] != 'object') segments = arguments; for (var i = 0, l = segments.length; i < l; i++) - this.addSegment(new Segment(segments[i])); + this._add(new Segment(segments[i])); }, /** @@ -113,7 +113,11 @@ Path = PathItem.extend({ } }, - addSegment: function(segment) { + /** + * Private method that adds a segment to the segment list. It assumes that + * the passed object is a segment already and does not perform any checks. + */ + _add: function(segment) { segment.path = this; this._segments.push(segment); }, @@ -121,7 +125,7 @@ Path = PathItem.extend({ add: function() { var segment = Segment.read(arguments); if (segment) - this.addSegment(segment); + this._add(segment); return segment; }, @@ -148,13 +152,13 @@ Path = PathItem.extend({ moveTo: function() { var segment = Segment.read(arguments); if (segment && !this._segments.length) - this.addSegment(segment); + this._add(segment); }, lineTo: function() { var segment = Segment.read(arguments); if (segment) - this.addSegment(segment); + this._add(segment); }, /** @@ -169,7 +173,7 @@ Path = PathItem.extend({ handle1.x - current.point.x, handle1.y - current.point.y); // And add the new segment, with handleIn set to c2 - this.addSegment( + this._add( new Segment(to, handle2.subtract(to), new Point()) ); }, @@ -297,7 +301,7 @@ Path = PathItem.extend({ var inPoint = new Point( centerX + (relx + z * rely) * radius - pt.x, centerY + (rely - z * relx) * radius - pt.y); - this.addSegment(new Segment(pt, inPoint, out)); + this._add(new Segment(pt, inPoint, out)); } angle += inc; }