diff --git a/src/basic/Matrix.js b/src/basic/Matrix.js index a231d281..375bbbbc 100644 --- a/src/basic/Matrix.js +++ b/src/basic/Matrix.js @@ -43,19 +43,19 @@ var Matrix = Base.extend(/** @lends Matrix# */{ /** * Creates a 2D affine transform. * - * @param {Number} a The scaleX coordinate of the transform - * @param {Number} c The shearY coordinate of the transform - * @param {Number} b The shearX coordinate of the transform - * @param {Number} d The scaleY coordinate of the transform - * @param {Number} tx The translateX coordinate of the transform - * @param {Number} ty The translateY coordinate of the transform + * @param {Number} a the scaleX coordinate of the transform + * @param {Number} c the shearY coordinate of the transform + * @param {Number} b the shearX coordinate of the transform + * @param {Number} d the scaleY coordinate of the transform + * @param {Number} tx the translateX coordinate of the transform + * @param {Number} ty the translateY coordinate of the transform */ initialize: function Matrix(arg) { var count = arguments.length, ok = true; - if (count == 6) { + if (count === 6) { this.set.apply(this, arguments); - } else if (count == 1) { + } else if (count === 1) { if (arg instanceof Matrix) { this.set(arg._a, arg._c, arg._b, arg._d, arg._tx, arg._ty); } else if (Array.isArray(arg)) { @@ -63,7 +63,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{ } else { ok = false; } - } else if (count == 0) { + } else if (count === 0) { this.reset(); } else { ok = false; @@ -75,13 +75,13 @@ var Matrix = Base.extend(/** @lends Matrix# */{ /** * Sets this transform to the matrix specified by the 6 values. * - * @param {Number} a The scaleX coordinate of the transform - * @param {Number} c The shearY coordinate of the transform - * @param {Number} b The shearX coordinate of the transform - * @param {Number} d The scaleY coordinate of the transform - * @param {Number} tx The translateX coordinate of the transform - * @param {Number} ty The translateY coordinate of the transform - * @return {Matrix} This affine transform + * @param {Number} a the scaleX coordinate of the transform + * @param {Number} c the shearY coordinate of the transform + * @param {Number} b the shearX coordinate of the transform + * @param {Number} d the scaleY coordinate of the transform + * @param {Number} tx the translateX coordinate of the transform + * @param {Number} ty the translateY coordinate of the transform + * @return {Matrix} this affine transform */ set: function(a, c, b, d, tx, ty) { this._a = a; @@ -98,7 +98,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{ }, /** - * @return {Matrix} A copy of this transform. + * @return {Matrix} a copy of this transform */ clone: function() { return new Matrix(this._a, this._c, this._b, this._d, @@ -119,7 +119,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{ }, /** - * @return {String} A string representation of this transform. + * @return {String} a string representation of this transform */ toString: function() { var f = Formatter.instance; @@ -144,19 +144,19 @@ var Matrix = Base.extend(/** @lends Matrix# */{ * * @name Matrix#scale * @function - * @param {Number} scale The scaling factor - * @param {Point} [center] The center for the scaling transformation - * @return {Matrix} This affine transform + * @param {Number} scale the scaling factor + * @param {Point} [center] the center for the scaling transformation + * @return {Matrix} this affine transform */ /** * Concatenates this transform with a scaling transformation. * * @name Matrix#scale * @function - * @param {Number} hor The horizontal scaling factor - * @param {Number} ver The vertical scaling factor - * @param {Point} [center] The center for the scaling transformation - * @return {Matrix} This affine transform + * @param {Number} hor the horizontal scaling factor + * @param {Number} ver the vertical scaling factor + * @param {Point} [center] the center for the scaling transformation + * @return {Matrix} this affine transform */ scale: function(/* scale, center */) { // Do not modify scale, center, since that would arguments of which @@ -179,17 +179,17 @@ var Matrix = Base.extend(/** @lends Matrix# */{ * * @name Matrix#translate * @function - * @param {Point} point The vector to translate by - * @return {Matrix} This affine transform + * @param {Point} point the vector to translate by + * @return {Matrix} this affine transform */ /** * Concatenates this transform with a translate transformation. * * @name Matrix#translate * @function - * @param {Number} dx The distance to translate in the x direction - * @param {Number} dy The distance to translate in the y direction - * @return {Matrix} This affine transform + * @param {Number} dx the distance to translate in the x direction + * @param {Number} dy the distance to translate in the y direction + * @return {Matrix} this affine transform */ translate: function(point) { point = Point.read(arguments); @@ -206,9 +206,9 @@ var Matrix = Base.extend(/** @lends Matrix# */{ * * @name Matrix#rotate * @function - * @param {Number} angle The angle of rotation measured in degrees - * @param {Point} center The anchor point to rotate around - * @return {Matrix} This affine transform + * @param {Number} angle the angle of rotation measured in degrees + * @param {Point} center the anchor point to rotate around + * @return {Matrix} this affine transform */ /** * Concatenates this transform with a rotation transformation around an @@ -216,10 +216,10 @@ var Matrix = Base.extend(/** @lends Matrix# */{ * * @name Matrix#rotate * @function - * @param {Number} angle The angle of rotation measured in degrees - * @param {Number} x The x coordinate of the anchor point - * @param {Number} y The y coordinate of the anchor point - * @return {Matrix} This affine transform + * @param {Number} angle the angle of rotation measured in degrees + * @param {Number} x the x coordinate of the anchor point + * @param {Number} y the y coordinate of the anchor point + * @return {Matrix} this affine transform */ rotate: function(angle, center) { center = Point.read(arguments, 1); @@ -249,19 +249,19 @@ var Matrix = Base.extend(/** @lends Matrix# */{ * * @name Matrix#shear * @function - * @param {Point} point The shear factor in x and y direction - * @param {Point} [center] The center for the shear transformation - * @return {Matrix} This affine transform + * @param {Point} point the shear factor in x and y direction + * @param {Point} [center] the center for the shear transformation + * @return {Matrix} this affine transform */ /** * Concatenates this transform with a shear transformation. * * @name Matrix#shear * @function - * @param {Number} hor The horizontal shear factor - * @param {Number} ver The vertical shear factor - * @param {Point} [center] The center for the shear transformation - * @return {Matrix} This affine transform + * @param {Number} hor the horizontal shear factor + * @param {Number} ver the vertical shear factor + * @param {Point} [center] the center for the shear transformation + * @return {Matrix} this affine transform */ shear: function(/* point, center */) { // Do not modify point, center, since that would arguments of which @@ -281,39 +281,11 @@ var Matrix = Base.extend(/** @lends Matrix# */{ return this; }, - /** - * @return {Boolean} Whether this transform is the identity transform - */ - isIdentity: function() { - return this._a == 1 && this._c == 0 && this._b == 0 && this._d == 1 - && this._tx == 0 && this._ty == 0; - }, - - /** - * Returns whether the transform is invertible. A transform is not - * invertible if the determinant is 0 or any value is non-finite or NaN. - * - * @return {Boolean} Whether the transform is invertible - */ - isInvertible: function() { - return !!this._getDeterminant(); - }, - - /** - * Checks whether the matrix is singular or not. Singular matrices cannot be - * inverted. - * - * @return {Boolean} Whether the matrix is singular - */ - isSingular: function() { - return !this._getDeterminant(); - }, - /** * Concatenates an affine transform to this transform. * - * @param {Matrix} mx The transform to concatenate - * @return {Matrix} This affine transform + * @param {Matrix} mx the transform to concatenate + * @return {Matrix} this affine transform */ concatenate: function(mx) { var a = this._a, @@ -332,8 +304,8 @@ var Matrix = Base.extend(/** @lends Matrix# */{ /** * Pre-concatenates an affine transform to this transform. * - * @param {Matrix} mx The transform to preconcatenate - * @return {Matrix} This affine transform + * @param {Matrix} mx the transform to preconcatenate + * @return {Matrix} this affine transform */ preConcatenate: function(mx) { var a = this._a, @@ -351,13 +323,41 @@ var Matrix = Base.extend(/** @lends Matrix# */{ return this; }, + /** + * @return {Boolean} whether this transform is the identity transform + */ + isIdentity: function() { + return this._a == 1 && this._c == 0 && this._b == 0 && this._d == 1 + && this._tx == 0 && this._ty == 0; + }, + + /** + * Returns whether the transform is invertible. A transform is not + * invertible if the determinant is 0 or any value is non-finite or NaN. + * + * @return {Boolean} whether the transform is invertible + */ + isInvertible: function() { + return !!this._getDeterminant(); + }, + + /** + * Checks whether the matrix is singular or not. Singular matrices cannot be + * inverted. + * + * @return {Boolean} whether the matrix is singular + */ + isSingular: function() { + return !this._getDeterminant(); + }, + /** * Transforms a point and returns the result. * * @name Matrix#transform * @function - * @param {Point} point The point to be transformed - * @return {Point} The transformed point + * @param {Point} point the point to be transformed + * @return {Point} the transformed point */ /** * Transforms an array of coordinates by this matrix and stores the results @@ -365,15 +365,15 @@ var Matrix = Base.extend(/** @lends Matrix# */{ * * @name Matrix#transform * @function - * @param {Number[]} src The array containing the source points + * @param {Number[]} src the array containing the source points * as x, y value pairs - * @param {Number} srcOff The offset to the first point to be transformed - * @param {Number[]} dst The array into which to store the transformed + * @param {Number} srcOff the offset to the first point to be transformed + * @param {Number[]} dst the array into which to store the transformed * point pairs - * @param {Number} dstOff The offset of the location of the first + * @param {Number} dstOff the offset of the location of the first * transformed point in the destination array - * @param {Number} numPts The number of points to tranform - * @return {Number[]} The dst array, containing the transformed coordinates. + * @param {Number} numPts the number of points to tranform + * @return {Number[]} the dst array, containing the transformed coordinates. */ transform: function(/* point | */ src, srcOff, dst, dstOff, numPts) { return arguments.length < 5 @@ -445,7 +445,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{ /** * Inverse transforms a point and returns the result. * - * @param {Point} point The point to be transformed + * @param {Point} point the point to be transformed */ inverseTransform: function(/* point */) { return this._inverseTransform(Point.read(arguments)); @@ -541,14 +541,14 @@ var Matrix = Base.extend(/** @lends Matrix# */{ */ /** - * @return {Number} The shear factor in the x-direction ({@code b}). + * The shear factor in the x-direction ({@code b}). * * @name Matrix#shearX * @type Number */ /** - * @return {Number} The shear factor in the y-direction ({@code c}). + * The shear factor in the y-direction ({@code c}). * * @name Matrix#shearY * @type Number @@ -617,7 +617,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{ * (in which case {@link #isSingular()} returns true), {@code null } is * returned. * - * @return {Matrix} The inverted matrix, or {@code null }, if the matrix is + * @return {Matrix} the inverted matrix, or {@code null }, if the matrix is * singular */ inverted: function() { diff --git a/src/basic/Point.js b/src/basic/Point.js index 261551e8..1d2b6d22 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -223,7 +223,7 @@ var Point = Base.extend(/** @lends Point# */{ }, /** - * @return {String} A string representation of the point. + * @return {String} a string representation of the point */ toString: function() { var f = Formatter.instance; @@ -434,7 +434,7 @@ var Point = Base.extend(/** @lends Point# */{ * is not modified! * * @param {Matrix} matrix - * @return {Point} The transformed point + * @return {Point} the transformed point */ transform: function(matrix) { return matrix ? matrix._transformPoint(this) : this; @@ -505,8 +505,8 @@ var Point = Base.extend(/** @lends Point# */{ * The object itself is not modified! * * @param {Number} [length=1] The length of the normalized vector - * @return {Point} The normalized vector of the vector that is represented - * by this point's coordinates. + * @return {Point} the normalized vector of the vector that is represented + * by this point's coordinates */ normalize: function(length) { if (length === undefined) @@ -853,7 +853,7 @@ var Point = Base.extend(/** @lends Point# */{ * @static * @param {Point} point1 * @param {Point} point2 - * @returns {Point} The newly created point object + * @returns {Point} the newly created point object * * @example * var point1 = new Point(10, 100); @@ -877,7 +877,7 @@ var Point = Base.extend(/** @lends Point# */{ * @static * @param {Point} point1 * @param {Point} point2 - * @returns {Point} The newly created point object + * @returns {Point} the newly created point object * * @example * var point1 = new Point(10, 100); @@ -898,7 +898,7 @@ var Point = Base.extend(/** @lends Point# */{ * Returns a point object with random {@link #x} and {@link #y} values * between {@code 0} and {@code 1}. * - * @returns {Point} The newly created point object + * @returns {Point} the newly created point object * @static * * @example diff --git a/src/basic/Rectangle.js b/src/basic/Rectangle.js index 88639753..6c00d89b 100644 --- a/src/basic/Rectangle.js +++ b/src/basic/Rectangle.js @@ -210,7 +210,7 @@ var Rectangle = Base.extend(/** @lends Rectangle# */{ }, /** - * @return {String} A string representation of this rectangle. + * @return {String} a string representation of this rectangle */ toString: function() { var f = Formatter.instance; @@ -647,8 +647,8 @@ var Rectangle = Base.extend(/** @lends Rectangle# */{ * * @param {Rectangle} rect The rectangle to be intersected with this * rectangle - * @return {Rectangle} The largest rectangle contained in both the specified - * rectangle and in this rectangle. + * @return {Rectangle} the largest rectangle contained in both the specified + * rectangle and in this rectangle * * @example {@paperscript} * // Intersecting two rectangles and visualizing the result using rectangle diff --git a/src/basic/Size.js b/src/basic/Size.js index 4ce1f81e..75ec4dc6 100644 --- a/src/basic/Size.js +++ b/src/basic/Size.js @@ -172,7 +172,7 @@ var Size = Base.extend(/** @lends Size# */{ }, /** - * @return {String} A string representation of the size. + * @return {String} a string representation of the size */ toString: function() { var f = Formatter.instance; @@ -459,7 +459,7 @@ var Size = Base.extend(/** @lends Size# */{ * @static * @param {Size} size1 * @param {Size} size2 - * @returns {Size} The newly created size object + * @returns {Size} the newly created size object * * @example * var size1 = new Size(10, 100); @@ -480,7 +480,7 @@ var Size = Base.extend(/** @lends Size# */{ * @static * @param {Size} size1 * @param {Size} size2 - * @returns {Size} The newly created size object + * @returns {Size} the newly created size object * * @example * var size1 = new Size(10, 100); @@ -498,7 +498,7 @@ var Size = Base.extend(/** @lends Size# */{ * Returns a size object with random {@link #width} and {@link #height} * values between {@code 0} and {@code 1}. * - * @returns {Size} The newly created size object + * @returns {Size} the newly created size object * @static * * @example diff --git a/src/core/PaperScript.js b/src/core/PaperScript.js index f16b5632..c26f100b 100644 --- a/src/core/PaperScript.js +++ b/src/core/PaperScript.js @@ -108,8 +108,8 @@ paper.PaperScope.prototype.PaperScript = (function(root) { * * @name PaperScript.compile * @function - * @param {String} code The PaperScript code. - * @return {String} The compiled PaperScript as JavaScript code. + * @param {String} code The PaperScript code + * @return {String} the compiled PaperScript as JavaScript code */ function compile(code) { // Use Acorn or Esprima to translate the code into an AST structure @@ -238,9 +238,9 @@ paper.PaperScope.prototype.PaperScript = (function(root) { * * @name PaperScript.evaluate * @function - * @param {String} code The PaperScript code. - * @param {PaperScript} scope The scope in which the code is executed. - * @return {Object} The result of the code evaluation. + * @param {String} code The PaperScript code + * @param {PaperScript} scope The scope in which the code is executed + * @return {Object} the result of the code evaluation */ function evaluate(code, scope) { // Set currently active scope. diff --git a/src/item/Item.js b/src/item/Item.js index 3579f74c..ff4cc614 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -749,8 +749,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{ }, /** - * The item's transformation matrix, defining position and dimensions in the - * document. + * The item's transformation matrix, defining position and dimensions in + * relation to its parent item in which it is contained. * * @type Matrix * @bean @@ -1400,9 +1400,9 @@ var Item = Base.extend(Callback, /** @lends Item# */{ * @param {Point} point The point where the hit test should be performed * @param {Object} [options={ fill: true, stroke: true, segments: true, * tolerance: 2 }] - * @return {HitResult} A hit result object that contains more + * @return {HitResult} a hit result object that contains more * information about what exactly was hit or {@code null} if nothing was - * hit. + * hit */ hitTest: function(point, options) { point = Point.read(arguments); diff --git a/src/path/Curve.js b/src/path/Curve.js index f7fb1891..705195d1 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -405,7 +405,7 @@ var Curve = Base.extend(/** @lends Curve# */{ * or the curve time parameter if {@code isParameter} is {@code true} * @param {Boolean} [isParameter=false] pass {@code true} if {@code offset} * is a curve time parameter. - * @return {Path} The newly created path after splitting, if any + * @return {Path} the newly created path after splitting, if any * @see Path#split(index, parameter) */ // TODO: Rename to splitAt()? @@ -426,7 +426,7 @@ var Curve = Base.extend(/** @lends Curve# */{ }, /** - * @return {String} A string representation of the curve. + * @return {String} a string representation of the curve */ toString: function() { var parts = [ 'point1: ' + this._segment1._point ]; diff --git a/src/path/CurveLocation.js b/src/path/CurveLocation.js index 532cffd7..b4ade4db 100644 --- a/src/path/CurveLocation.js +++ b/src/path/CurveLocation.js @@ -247,7 +247,7 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{ }, /** - * @return {String} A string representation of the curve location. + * @return {String} a string representation of the curve location */ toString: function() { var parts = [], diff --git a/src/path/Path.js b/src/path/Path.js index 62af2f92..0af045f6 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -918,7 +918,7 @@ var Path = PathItem.extend(/** @lends Path# */{ * @function * @param {Number} offset the offset at which to split the path * as a number between 0 and {@link Path#length} - * @return {Path} The newly created path after splitting, if any + * @return {Path} the newly created path after splitting, if any * * @example {@paperscript} // Splitting an open path * var path = new Path(); @@ -961,7 +961,7 @@ var Path = PathItem.extend(/** @lends Path# */{ * @function * @param {CurveLocation} location the curve location at which to split * the path - * @return {Path} The newly created path after splitting, if any + * @return {Path} the newly created path after splitting, if any * * @example {@paperscript} * var path = new Path.Circle({ @@ -1018,7 +1018,7 @@ var Path = PathItem.extend(/** @lends Path# */{ * @param {Number} index the index of the curve in the {@link Path#curves} * array at which to split * @param {Number} parameter the parameter at which the curve will be split - * @return {Path} The newly created path after splitting, if any + * @return {Path} the newly created path after splitting, if any */ split: function(index, parameter) { if (parameter === null) @@ -1540,8 +1540,8 @@ var Path = PathItem.extend(/** @lends Path# */{ * Returns the nearest location on the path to the specified point. * * @function - * @param point {Point} The point for which we search the nearest location - * @return {CurveLocation} The location on the path that's the closest to + * @param point {Point} the point for which we search the nearest location + * @return {CurveLocation} the location on the path that's the closest to * the specified point */ getNearestLocation: function(point) { @@ -1563,8 +1563,8 @@ var Path = PathItem.extend(/** @lends Path# */{ * Returns the nearest point on the path to the specified point. * * @function - * @param point {Point} The point for which we search the nearest point - * @return {Point} The point on the path that's the closest to the specified + * @param point {Point} the point for which we search the nearest point + * @return {Point} the point on the path that's the closest to the specified * point * * @example {@paperscript height=200} diff --git a/src/path/Segment.js b/src/path/Segment.js index eddea247..722c2ebb 100644 --- a/src/path/Segment.js +++ b/src/path/Segment.js @@ -437,7 +437,7 @@ var Segment = Base.extend(/** @lends Segment# */{ }, /** - * @return {String} A string representation of the segment. + * @return {String} a string representation of the segment */ toString: function() { var parts = [ 'point: ' + this._point ]; diff --git a/src/project/Project.js b/src/project/Project.js index 4e027167..6a1ac062 100644 --- a/src/project/Project.js +++ b/src/project/Project.js @@ -247,9 +247,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{ * @param {Point} point The point where the hit test should be performed * @param {Object} [options={ fill: true, stroke: true, segments: true, * tolerance: true }] - * @return {HitResult} A hit result object that contains more + * @return {HitResult} a hit result object that contains more * information about what exactly was hit or {@code null} if nothing was - * hit. + * hit */ hitTest: function(point, options) { // We don't need to do this here, but it speeds up things since we won't @@ -334,6 +334,8 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{ */ draw: function(ctx, matrix) { + // Increase the drawCount before the draw-loop. After that, items that + // are visible will have their drawCount set to the new value. this._drawCount++; ctx.save(); matrix.applyToContext(ctx); diff --git a/src/style/Color.js b/src/style/Color.js index 00f7aef1..263b179d 100644 --- a/src/style/Color.js +++ b/src/style/Color.js @@ -748,7 +748,7 @@ var Color = Base.extend(new function() { /** * {@grouptitle String Representations} - * @return {String} A string representation of the color. + * @return {String} a string representation of the color */ toString: function() { var properties = this._properties, @@ -767,7 +767,7 @@ var Color = Base.extend(new function() { }, /** - * @return {String} A css string representation of the color. + * @return {String} a css string representation of the color */ toCSS: function(noAlpha) { var components = this._convert('rgb'), diff --git a/src/tool/ToolEvent.js b/src/tool/ToolEvent.js index 5cb7eee3..c1450020 100644 --- a/src/tool/ToolEvent.js +++ b/src/tool/ToolEvent.js @@ -199,7 +199,7 @@ var ToolEvent = Event.extend(/** @lends ToolEvent# */{ }, /** - * @return {String} A string representation of the tool event. + * @return {String} a string representation of the tool event */ toString: function() { return '{ type: ' + this.type diff --git a/src/ui/KeyEvent.js b/src/ui/KeyEvent.js index 82f1e88a..0dc13c32 100644 --- a/src/ui/KeyEvent.js +++ b/src/ui/KeyEvent.js @@ -52,7 +52,7 @@ var KeyEvent = Event.extend(/** @lends KeyEvent# */{ */ /** - * @return {String} A string representation of the key event. + * @return {String} a string representation of the key event */ toString: function() { return "{ type: '" + this.type diff --git a/src/ui/MouseEvent.js b/src/ui/MouseEvent.js index 9c810991..d780ae3d 100644 --- a/src/ui/MouseEvent.js +++ b/src/ui/MouseEvent.js @@ -62,7 +62,7 @@ var MouseEvent = Event.extend(/** @lends MouseEvent# */{ */ /** - * @return {String} A string representation of the mouse event. + * @return {String} a string representation of the mouse event */ toString: function() { return "{ type: '" + this.type diff --git a/src/ui/View.js b/src/ui/View.js index f60df560..f43ff225 100644 --- a/src/ui/View.js +++ b/src/ui/View.js @@ -359,7 +359,7 @@ var View = Base.extend(Callback, /** @lends View# */{ * Checks whether the view is currently visible within the current browser * viewport. * - * @return {Boolean} Whether the view is visible. + * @return {Boolean} whether the view is visible. */ isVisible: function() { return DomElement.isInView(this._element); @@ -392,6 +392,7 @@ var View = Base.extend(Callback, /** @lends View# */{ // TODO: getMousePoint // TODO: projectToView(rect) + // DOCS: projectToView(point), viewToProject(point) projectToView: function(/* point */) { return this._matrix._transformPoint(Point.read(arguments)); },