From c7d8aebb9ebb9d6cbaba30a560764cf0b1096d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 28 Jan 2013 16:32:04 -0800 Subject: [PATCH] Swap Curve's bounds scope with point evaluation scope, for proximity to bounds related methods in scope before. --- src/path/Curve.js | 110 +++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index b7e154cb..46690646 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -688,7 +688,61 @@ statics: { } return locations; } -}}, Base.each(['getPoint', 'getTangent', 'getNormal'], +}}, Base.each(['getBounds', 'getStrokeBounds', 'getHandleBounds', 'getRoughBounds'], + // Note: Although Curve.getBounds() exists, we are using Path.getBounds() to + // determine the bounds of Curve objects with defined segment1 and segment2 + // values Curve.getBounds() can be used directly on curve arrays, without + // the need to create a Curve object first, as required by the code that + // finds path interesections. + function(name) { + this[name] = function() { + if (!this._bounds) + this._bounds = {}; + var bounds = this._bounds[name]; + if (!bounds) { + // Calculate the curve bounds by passing a segment list for the + // curve to the static Path.get*Boudns methods. + bounds = this._bounds[name] = Path[name]( + [this._segment1, this._segment2], false, this._path._style); + } + return bounds.clone(); + }; + }, +/** @lends Curve# */{ + /** + * The bounding rectangle of the curve excluding stroke width. + * + * @name Curve#getBounds + * @type Rectangle + * @bean + */ + + /** + * The bounding rectangle of the curve including stroke width. + * + * @name Curve#getStrokeBounds + * @type Rectangle + * @bean + */ + + /** + * The bounding rectangle of the curve including handles. + * + * @name Curve#getHandleBounds + * @type Rectangle + * @bean + */ + + /** + * The rough bounding rectangle of the curve that is shure to include all of + * the drawing, including stroke width. + * + * @name Curve#getRoughBounds + * @type Rectangle + * @bean + * @ignore + */ +}), Base.each(['getPoint', 'getTangent', 'getNormal'], // Note: Although Curve.getBounds() exists, we are using Path.getBounds() to // determine the bounds of Curve objects with defined segment1 and segment2 // values Curve.getBounds() can be used directly on curve arrays, without @@ -766,60 +820,6 @@ statics: { * @param {Number} parameter the position at which to find the normal * point as a value between {@code 0} and {@code 1}. */ -}), Base.each(['getBounds', 'getStrokeBounds', 'getHandleBounds', 'getRoughBounds'], - // Note: Although Curve.getBounds() exists, we are using Path.getBounds() to - // determine the bounds of Curve objects with defined segment1 and segment2 - // values Curve.getBounds() can be used directly on curve arrays, without - // the need to create a Curve object first, as required by the code that - // finds path interesections. - function(name) { - this[name] = function() { - if (!this._bounds) - this._bounds = {}; - var bounds = this._bounds[name]; - if (!bounds) { - // Calculate the curve bounds by passing a segment list for the - // curve to the static Path.get*Boudns methods. - bounds = this._bounds[name] = Path[name]( - [this._segment1, this._segment2], false, this._path._style); - } - return bounds.clone(); - }; - }, -/** @lends Curve# */{ - /** - * The bounding rectangle of the curve excluding stroke width. - * - * @name Curve#getBounds - * @type Rectangle - * @bean - */ - - /** - * The bounding rectangle of the curve including stroke width. - * - * @name Curve#getStrokeBounds - * @type Rectangle - * @bean - */ - - /** - * The bounding rectangle of the curve including handles. - * - * @name Curve#getHandleBounds - * @type Rectangle - * @bean - */ - - /** - * The rough bounding rectangle of the curve that is shure to include all of - * the drawing, including stroke width. - * - * @name Curve#getRoughBounds - * @type Rectangle - * @bean - * @ignore - */ }), new function() { // Scope for methods that require numerical integration