diff --git a/src/basic/Line.js b/src/basic/Line.js index 9282feb4..d055d7e0 100644 --- a/src/basic/Line.js +++ b/src/basic/Line.js @@ -1,22 +1,25 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ -var Line = this.Line = Base.extend({ - /** @lends Line# */ - +/** + * @name Line + * + * @class The Line object represents.. + */ +var Line = this.Line = Base.extend(/** @lends Line# */{ // DOCS: document Line class and constructor /** * Creates a Line object. @@ -24,9 +27,6 @@ var Line = this.Line = Base.extend({ * @param {Point} point1 * @param {Point} point2 * @param {Boolean} [infinite=true] - * - * @class The Line object represents.. - * @constructs Line */ initialize: function(point1, point2, infinite) { // Convention: With 3 parameters, both points are absolute, and infinite diff --git a/src/basic/Matrix.js b/src/basic/Matrix.js index 1e335653..f1d508f1 100644 --- a/src/basic/Matrix.js +++ b/src/basic/Matrix.js @@ -1,16 +1,16 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ @@ -19,38 +19,38 @@ // // Licensed under the Apache License, Version 2.0 (the "License"); -var Matrix = this.Matrix = Base.extend({ - /** @lends Matrix# */ - +/** + * @name Matrix + * + * @class An affine transform performs a linear mapping from 2D coordinates + * to other 2D coordinates that preserves the "straightness" and + * "parallelness" of lines. + * + * Such a coordinate transformation can be represented by a 3 row by 3 + * column matrix with an implied last row of [ 0 0 1 ]. This matrix + * transforms source coordinates (x,y) into destination coordinates (x',y') + * by considering them to be a column vector and multiplying the coordinate + * vector by the matrix according to the following process: + *
+ * [ x'] [ m00 m01 m02 ] [ x ] [ m00x + m01y + m02 ] + * [ y'] = [ m10 m11 m12 ] [ y ] = [ m10x + m11y + m12 ] + * [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ] + *+ * + * This class is optimized for speed and minimizes calculations based on its + * knowledge of the underlying matrix (as opposed to say simply performing + * matrix multiplication). + */ +var Matrix = this.Matrix = Base.extend(/** @lends Matrix# */{ /** * Creates a 2D affine transform. * - * @constructs Matrix * @param {Number} m00 The m00 coordinate of the transform. * @param {Number} m10 The m10 coordinate of the transform. * @param {Number} m01 The m01 coordinate of the transform. * @param {Number} m11 The m11 coordinate of the transform. * @param {Number} m02 The m02 coordinate of the transform. * @param {Number} m12 The m12 coordinate of the transform. - * - * @class An affine transform performs a linear mapping from 2D coordinates - * to other 2D coordinates that preserves the "straightness" and - * "parallelness" of lines. - * - * Such a coordinate transformation can be represented by a 3 row by 3 - * column matrix with an implied last row of [ 0 0 1 ]. This matrix - * transforms source coordinates (x,y) into destination coordinates (x',y') - * by considering them to be a column vector and multiplying the coordinate - * vector by the matrix according to the following process: - *
- * [ x'] [ m00 m01 m02 ] [ x ] [ m00x + m01y + m02 ] - * [ y'] = [ m10 m11 m12 ] [ y ] = [ m10x + m11y + m12 ] - * [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ] - *- * - * This class is optimized for speed and minimizes calculations based on its - * knowledge of the underlying matrix (as opposed to say simply performing - * matrix multiplication). */ initialize: function(m00, m10, m01, m11, m02, m12) { var ok = true; diff --git a/src/basic/Point.js b/src/basic/Point.js index 9f5cfcfe..87f69ba8 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -1,28 +1,37 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ -var Point = this.Point = Base.extend({ - /** @lends Point# */ - +/** + * @name Point + * + * @class The Point object represents a point in the two dimensional space + * of the Paper.js project. It is also used to represent two dimensional + * vector objects. + * + * @classexample + * // Create a point at x: 10, y: 5 + * var point = new Point(10, 5); + * console.log(point.x); // 10 + * console.log(point.y); // 5 + */ +var Point = this.Point = Base.extend(/** @lends Point# */{ /** * Creates a Point object with the given x and y coordinates. * - * @name Point - * @constructor - * + * @name Point#initialize * @param {Number} x the x coordinate * @param {Number} y the y coordinate * @@ -31,16 +40,6 @@ var Point = this.Point = Base.extend({ * var point = new Point(10, 5); * console.log(point.x); // 10 * console.log(point.y); // 5 - * - * @class The Point object represents a point in the two dimensional space - * of the Paper.js project. It is also used to represent two dimensional - * vector objects. - * - * @classexample - * // Create a point at x: 10, y: 5 - * var point = new Point(10, 5); - * console.log(point.x); // 10 - * console.log(point.y); // 5 */ /** * Creates a Point object using the numbers in the given array as @@ -909,11 +908,13 @@ var Point = this.Point = Base.extend({ }); /** - * An internal version of Point that notifies its owner of each change through - * setting itself again on the setter that corresponds to the getter that - * produced this LinkedPoint. See uses of LinkedPoint.create() + * @name LinkedPoint + * + * @class An internal version of Point that notifies its owner of each change + * through setting itself again on the setter that corresponds to the getter + * that produced this LinkedPoint. See uses of LinkedPoint.create() * Note: This prototype is not exported. - * + * * @ignore */ var LinkedPoint = Point.extend({ diff --git a/src/basic/Rectangle.js b/src/basic/Rectangle.js index bbb2d3db..5b71c0ad 100644 --- a/src/basic/Rectangle.js +++ b/src/basic/Rectangle.js @@ -1,34 +1,33 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ -var Rectangle = this.Rectangle = Base.extend({ - /** @lends Rectangle# */ - +/** + * @name Rectangle + * + * @class A Rectangle specifies an area that is enclosed by it's top-left + * point (x, y), its width, and its height. It should not be confused with a + * rectangular path, it is not an item. + */ +var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{ /** * Creates a Rectangle object. * - * @name Rectangle - * @constructor - * + * @name Rectangle#initialize * @param {Point} point the top-left point of the rectangle * @param {Size} size the size of the rectangle - * - * @class A Rectangle specifies an area that is enclosed by it's top-left - * point (x, y), its width, and its height. It should not be confused with a - * rectangular path, it is not an item. */ /** * Creates a rectangle object. @@ -651,12 +650,15 @@ var Rectangle = this.Rectangle = Base.extend({ }); /** - * An internal version of Rectangle that notifies its owner of each change - * through setting itself again on the setter that corresponds to the getter - * that produced this LinkedRectangle. See uses of LinkedRectangle.create() + * @name LinkedRectangle + * + * @class An internal version of Rectangle that notifies its owner of each + * change through setting itself again on the setter that corresponds to the + * getter that produced this LinkedRectangle. + * See uses of LinkedRectangle.create() * Note: This prototype is not exported. - * - * @ignore + * + * @private */ var LinkedRectangle = Rectangle.extend({ set: function(x, y, width, height, dontNotify) { diff --git a/src/basic/Size.js b/src/basic/Size.js index 816a84b7..a2b39d5e 100644 --- a/src/basic/Size.js +++ b/src/basic/Size.js @@ -1,29 +1,37 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ -var Size = this.Size = Base.extend({ - /** @lends Size# */ - +/** + * @name Size + * + * @class The Size object is used to describe the size of something, through + * its {@link #width} and {@link #height} properties. + * + * @classexample + * // Create a size that is 10pt wide and 5pt high + * var size = new Size(10, 5); + * console.log(size.width); // 10 + * console.log(size.height); // 5 + */ +var Size = this.Size = Base.extend(/** @lends Size# */{ // DOCS: improve Size class description /** * Creates a Size object with the given width and height values. * - * @name Size - * @constructor - * + * @name Size#initialize * @param {Number} width the width * @param {Number} height the height * @@ -33,15 +41,6 @@ var Size = this.Size = Base.extend({ * console.log(size.width); // 10 * console.log(size.height); // 5 * - * @class The Size object is used to describe the size of something, through - * its {@link #width} and {@link #height} properties. - * - * @classexample - * // Create a size that is 10pt wide and 5pt high - * var size = new Size(10, 5); - * console.log(size.width); // 10 - * console.log(size.height); // 5 - */ /** * Creates a Size object using the numbers in the given array as * dimensions. @@ -494,12 +493,14 @@ var Size = this.Size = Base.extend({ }); /** - * An internal version of Size that notifies its owner of each change through - * setting itself again on the setter that corresponds to the getter that - * produced this LinkedSize. See uses of LinkedSize.create() + * @name LinkedSize + * + * @class An internal version of Size that notifies its owner of each change + * through setting itself again on the setter that corresponds to the getter + * that produced this LinkedSize. See uses of LinkedSize.create() * Note: This prototype is not exported. - * - * @ignore + * + * @private */ var LinkedSize = Size.extend({ set: function(width, height, dontNotify) { diff --git a/src/browser/DomElement.js b/src/browser/DomElement.js index 975c5598..cdc49146 100644 --- a/src/browser/DomElement.js +++ b/src/browser/DomElement.js @@ -1,16 +1,16 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ diff --git a/src/browser/DomEvent.js b/src/browser/DomEvent.js index c21078ab..f5c74b7d 100644 --- a/src/browser/DomEvent.js +++ b/src/browser/DomEvent.js @@ -1,16 +1,16 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ diff --git a/src/color/Color.js b/src/color/Color.js index c5e537a0..3a0ba523 100644 --- a/src/color/Color.js +++ b/src/color/Color.js @@ -1,19 +1,51 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ +// DOCS: write Color class documentation. +/** + * @name Color + * + * @class All properties and functions that expect color values accept + * instances of the different color classes such as {@link RGBColor}, + * {@link HSBColor} and {@link GrayColor}, and also accept named colors + * and hex values as strings which are then converted to instances of + * {@link RGBColor} internally. + * + * @classexample {@paperscript} + * // Named color values: + * + * // Create a circle shaped path at {x: 80, y: 50} + * // with a radius of 30. + * var circle = new Path.Circle(new Point(80, 50), 30); + * + * // Pass a color name to the fillColor property, which is internally + * // converted to an RGBColor. + * circle.fillColor = 'green'; + * + * @classexample {@paperscript} + * // Hex color values: + * + * // Create a circle shaped path at {x: 80, y: 50} + * // with a radius of 30. + * var circle = new Path.Circle(new Point(80, 50), 30); + * + * // Pass a hex string to the fillColor property, which is internally + * // converted to an RGBColor. + * circle.fillColor = '#ff0000'; + */ var Color = this.Color = Base.extend(new function() { var components = { @@ -135,42 +167,9 @@ var Color = this.Color = Base.extend(new function() { } }; - var fields = { - /** @lends Color# */ - + var fields = /** @lends Color# */{ _readNull: true, - // DOCS: write Color constructor and class documentation. - /** - * @constructs Color - * @class All properties and functions that expect color values accept - * instances of the different color classes such as {@link RGBColor}, - * {@link HSBColor} and {@link GrayColor}, and also accept named colors - * and hex values as strings which are then converted to instances of - * {@link RGBColor} internally. - * - * @classexample {@paperscript} - * // Named color values: - * - * // Create a circle shaped path at {x: 80, y: 50} - * // with a radius of 30. - * var circle = new Path.Circle(new Point(80, 50), 30); - * - * // Pass a color name to the fillColor property, which is internally - * // converted to an RGBColor. - * circle.fillColor = 'green'; - * - * @classexample {@paperscript} - * // Hex color values: - * - * // Create a circle shaped path at {x: 80, y: 50} - * // with a radius of 30. - * var circle = new Path.Circle(new Point(80, 50), 30); - * - * // Pass a hex string to the fillColor property, which is internally - * // converted to an RGBColor. - * circle.fillColor = '#ff0000'; - */ initialize: function(arg) { var isArray = Array.isArray(arg), type = this._colorType; @@ -244,7 +243,7 @@ var Color = this.Color = Base.extend(new function() { : converters[this._colorType + '-' + type](this); }, - statics: { + statics: /** @lends Color */{ /** * Override Color.extend() to produce getters and setters based * on the component types defined in _components. @@ -303,8 +302,7 @@ var Color = this.Color = Base.extend(new function() { }); return fields; -}, { - /** @lends Color# */ +}, /** @lends Color# */{ /** * Called by various setters whenever a color value changes @@ -345,14 +343,12 @@ var Color = this.Color = Base.extend(new function() { /** * Returns the type of the color as a string. * - * Example: - *
- * var color = new RGBColor(1, 0, 0);
- * console.log(color.type); // 'rgb'
- *
- *
* @type String('rgb', 'hsb', 'gray')
* @bean
+ *
+ * @example
+ * var color = new RGBColor(1, 0, 0);
+ * console.log(color.type); // 'rgb'
*/
getType: function() {
return this._colorType;
@@ -579,21 +575,21 @@ var Color = this.Color = Base.extend(new function() {
});
-var GrayColor = this.GrayColor = Color.extend(/** @scope GrayColor */{
+/**
+ * @name GrayColor
+ * @class A GrayColor object is used to represent any gray color value.
+ * @extends Color
+ */
+var GrayColor = this.GrayColor = Color.extend(/** @lends GrayColor# */{
/**
* Creates a GrayColor object
*
- * @name GrayColor
- * @constructor
- *
+ * @name GrayColor#initialize
* @param {Number} gray the amount of gray in the color as a value
* between {@code 0} and {@code 1}
* @param {Number} [alpha] the alpha of the color as a value between
* {@code 0} and {@code 1}
*
- * @class A GrayColor object is used to represent any gray color value.
- * @extends Color
- *
* @example {@paperscript}
* // Creating a GrayColor:
*
@@ -608,13 +604,16 @@ var GrayColor = this.GrayColor = Color.extend(/** @scope GrayColor */{
_colorType: 'gray'
});
-var RGBColor = this.RGBColor = Color.extend(/** @scope RGBColor */{
+/**
+ * @name RGBColor
+ * @class An RGBColor object is used to represent any RGB color value.
+ * @extends Color
+ */
+var RGBColor = this.RGBColor = Color.extend(/** @lends RGBColor# */{
/**
* Creates an RGBColor object
*
- * @name RGBColor
- * @constructor
- *
+ * @name RGBColor#initialize
* @param {Number} red the amount of red in the color as a value
* between {@code 0} and {@code 1}
* @param {Number} green the amount of green in the color as a value
@@ -624,9 +623,6 @@ var RGBColor = this.RGBColor = Color.extend(/** @scope RGBColor */{
* @param {Number} [alpha] the alpha of the color as a value between
* {@code 0} and {@code 1}
*
- * @class An RGBColor object is used to represent any RGB color value.
- * @extends Color
- *
* @example {@paperscript}
* // Creating an RGBColor:
*
@@ -641,13 +637,16 @@ var RGBColor = this.RGBColor = Color.extend(/** @scope RGBColor */{
_colorType: 'rgb'
});
-var HSBColor = this.HSBColor = Color.extend(/** @scope HSBColor */{
+/**
+ * @name HSBColor
+ * @class An HSBColor object is used to represent any HSB color value.
+ * @extends Color
+ */
+var HSBColor = this.HSBColor = Color.extend(/** @lends HSBColor# */{
/**
* Creates an HSBColor object
*
- * @name HSBColor
- * @constructor
- *
+ * @name HSBColor#initialize
* @param {Number} hue the hue of the color as a value in degrees between
* {@code 0} and {@code 360}.
* @param {Number} saturation the saturation of the color as a value
@@ -657,9 +656,6 @@ var HSBColor = this.HSBColor = Color.extend(/** @scope HSBColor */{
* @param {Number} [alpha] the alpha of the color as a value between
* {@code 0} and {@code 1}
*
- * @class An HSBColor object is used to represent any HSB color value.
- * @extends Color
- *
* @example {@paperscript}
* // Creating an HSBColor:
*
diff --git a/src/color/Gradient.js b/src/color/Gradient.js
index f91d99b0..dee111be 100644
--- a/src/color/Gradient.js
+++ b/src/color/Gradient.js
@@ -1,22 +1,25 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
-var Gradient = this.Gradient = Base.extend({
- /** @lends Gradient# */
-
+/**
+ * @name Gradient
+ *
+ * @class The Gradient object.
+ */
+var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{
// TODO: Should type here be called 'radial' and have it receive a
// boolean value?
/**
@@ -24,9 +27,6 @@ var Gradient = this.Gradient = Base.extend({
*
* @param {GradientStop[]} stops
* @param {String} [type='linear'] 'linear' or 'radial'
- * @constructs Gradient
- *
- * @class The Gradient object.
*/
initialize: function(stops, type) {
this.setStops(stops || ['white', 'black']);
diff --git a/src/color/GradientColor.js b/src/color/GradientColor.js
index 4d5a3f02..71c48885 100644
--- a/src/color/GradientColor.js
+++ b/src/color/GradientColor.js
@@ -1,21 +1,25 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
-var GradientColor = this.GradientColor = Color.extend({
- /** @lends GradientColor# */
+/**
+ * @name GradientColor
+ *
+ * @class The GradientColor object.
+ */
+var GradientColor = this.GradientColor = Color.extend(/** @lends GradientColor# */{
/**
* Creates a gradient color object.
@@ -24,7 +28,6 @@ var GradientColor = this.GradientColor = Color.extend({
* @param {Point} origin
* @param {Point} destination
* @param {Point} [hilite]
- * @constructs GradientColor
*
* @example {@paperscript height=200}
* // Applying a linear gradient color containing evenly distributed
@@ -78,8 +81,6 @@ var GradientColor = this.GradientColor = Color.extend({
*
* // Set the fill color of the path to the gradient color:
* path.fillColor = gradientColor;
- *
- * @class The GradientColor object.
*/
initialize: function(gradient, origin, destination, hilite) {
this.gradient = gradient || new Gradient();
diff --git a/src/color/GradientStop.js b/src/color/GradientStop.js
index 83d2c9ad..c91738da 100644
--- a/src/color/GradientStop.js
+++ b/src/color/GradientStop.js
@@ -1,32 +1,32 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
// TODO: Support midPoint? (initial tests didn't look nice)
-var GradientStop = this.GradientStop = Base.extend({
- /** @lends GradientStop# */
-
+/**
+ * @name GradientStop
+ *
+ * @class The GradientStop object.
+ */
+var GradientStop = this.GradientStop = Base.extend(/** @lends GradientStop# */{
/**
* Creates a GradientStop object.
*
* @param {Color} [color=new RGBColor(0, 0, 0)] the color of the stop
* @param {Number} [rampPoint=0] the position of the stop on the gradient
* ramp {@default 0}
- * @constructs GradientStop
- *
- * @class The GradientStop object.
*/
initialize: function(arg0, arg1) {
if (arg1 === undefined && Array.isArray(arg0)) {
diff --git a/src/core/Base.js b/src/core/Base.js
index e6cb57ef..4862c6a8 100644
--- a/src/core/Base.js
+++ b/src/core/Base.js
@@ -1,22 +1,27 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
// Extend Base with utility functions used across the library. Also set
-// this.Base, since bootstrap.js ommits that.
-this.Base = Base.inject({
+// this.Base on the injection scope, since bootstrap.js ommits that.
+/**
+ * @name Base
+ * @class
+ * @private
+ */
+this.Base = Base.inject(/** @lends Base# */{
/**
* General purpose clone function that delegates cloning to the constructor
* that receives the object to be cloned as the first argument.
@@ -27,7 +32,7 @@ this.Base = Base.inject({
return new this.constructor(this);
},
- statics: {
+ statics: /** @lends Base */{
/**
* Reads arguments of the type of the class on which it is called on
* from the passed arguments list or array, at the given index, up to
@@ -68,8 +73,6 @@ this.Base = Base.inject({
* Utility function for adding and removing items from a list of which
* each entry keeps a reference to its index in the list in the private
* _index property. Used for PaperScope#projects and Item#children.
- *
- * @ignore
*/
splice: function(list, items, index, remove) {
var amount = items && items.length,
@@ -128,8 +131,6 @@ this.Base = Base.inject({
/**
* Utility function for rendering numbers to strings at a precision of
* up to 5 fractional digits.
- *
- * @ignore
*/
formatNumber: function(num) {
return (Math.round(num * 100000) / 100000).toString();
@@ -138,8 +139,6 @@ this.Base = Base.inject({
/**
* Utility function for rendering objects to strings, in object literal
* notation.
- *
- * @ignore
*/
formatObject: function(obj) {
return '{ ' + Base.each(obj, function(value, key) {
diff --git a/src/core/PaperScope.js b/src/core/PaperScope.js
index 7fdc2307..f4a56b87 100644
--- a/src/core/PaperScope.js
+++ b/src/core/PaperScope.js
@@ -1,28 +1,31 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
/**
- * Define internal PaperScope class that handles all the fields available on the
+ * @name PaperScope
+ *
+ * @class Internal PaperScope class that handles all the fields available on the
* global paper object, which simply is a pointer to the currently active scope.
- * @ignore
+ *
+ * @private
*/
var PaperScope = this.PaperScope = Base.extend(/** @scope _global_ */{
/**
* The version of Paper.js, as a float number.
- *
+ *
* @type Number
*/
version: 0.1,
@@ -181,6 +184,13 @@ var PaperScope = this.PaperScope = Base.extend(/** @scope _global_ */{
statics: {
_scopes: {},
+ /**
+ * Retrieves a PaperScope object with the given id or associated with
+ * the passed canvas element.
+ *
+ * @param id
+ * @ignore
+ */
get: function(id) {
// If a script tag is passed, get the id from it.
if (typeof id === 'object')
@@ -190,6 +200,9 @@ var PaperScope = this.PaperScope = Base.extend(/** @scope _global_ */{
/**
* A way to iterate over all active scopes without accessing _scopes
+ *
+ * @param iter
+ * @ignore
*/
each: function(iter) {
Base.each(this._scopes, iter);
diff --git a/src/core/PaperScript.js b/src/core/PaperScript.js
index f78fd88f..1ddd340c 100644
--- a/src/core/PaperScript.js
+++ b/src/core/PaperScript.js
@@ -1,16 +1,16 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
diff --git a/src/item/ChangeFlag.js b/src/item/ChangeFlag.js
index 986b2db5..c344bab9 100644
--- a/src/item/ChangeFlag.js
+++ b/src/item/ChangeFlag.js
@@ -1,16 +1,16 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
diff --git a/src/item/Group.js b/src/item/Group.js
index 937f2c0d..520f6726 100644
--- a/src/item/Group.js
+++ b/src/item/Group.js
@@ -1,22 +1,29 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
-var Group = this.Group = Item.extend({
- /** @lends Group# */
-
+/**
+ * @name Group
+ *
+ * @class A Group is a collection of items. When you transform a Group, its
+ * children are treated as a single unit without changing their relative
+ * positions.
+ *
+ * @extends Item
+ */
+var Group = this.Group = Item.extend(/** @lends Group# */{
// DOCS: document new Group(item, item...);
/**
* Creates a new Group item and places it at the top of the active layer.
@@ -58,12 +65,6 @@ var Group = this.Group = Item.extend({
* // the centerpoint of the view:
* group.rotate(1, view.center);
* }
- *
- * @class A Group is a collection of items. When you transform a Group, its
- * children are treated as a single unit without changing their relative
- * positions.
- * @extends Item
- * @constructs Group
*/
initialize: function(items) {
this.base();
diff --git a/src/item/Item.js b/src/item/Item.js
index 6f1b65ce..f9e742be 100644
--- a/src/item/Item.js
+++ b/src/item/Item.js
@@ -1,31 +1,30 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
-var Item = this.Item = Base.extend({
- /** @lends Item# */
-
- /**
- * @name Item
- * @class The Item type allows you to access and modify the items in
- * Paper.js projects. Its functionality is inherited by different project
- * item types such as {@link Path}, {@link CompoundPath}, {@link Group},
- * {@link Layer} and {@link Raster}. They each add a layer of functionality that
- * is unique to their type, but share the underlying properties and functions
- * that they inherit from Item.
- */
+/**
+ * @name Item
+ *
+ * @class The Item type allows you to access and modify the items in
+ * Paper.js projects. Its functionality is inherited by different project
+ * item types such as {@link Path}, {@link CompoundPath}, {@link Group},
+ * {@link Layer} and {@link Raster}. They each add a layer of functionality that
+ * is unique to their type, but share the underlying properties and functions
+ * that they inherit from Item.
+ */
+var Item = this.Item = Base.extend(/** @lends Item# */{
initialize: function() {
// If _project is already set, the item was already moved into the DOM
// hierarchy. Used by Layer, where it's added to project.layers instead
@@ -219,9 +218,7 @@ var Item = this.Item = Base.extend({
}
};
}, {});
-}, {
- /** @lends Item# */
-
+}, /** @lends Item# */{
// Note: These properties have their getter / setters produced in the
// injection scope above.
@@ -940,7 +937,7 @@ var Item = this.Item = Base.extend({
/**
* {@grouptitle Hierarchy Tests}
- *
+ *
* Checks if the item contains any children items.
*
* @return {Boolean} {@true it has one or more children}
diff --git a/src/item/Layer.js b/src/item/Layer.js
index e5cbe39c..e7115cf5 100644
--- a/src/item/Layer.js
+++ b/src/item/Layer.js
@@ -1,22 +1,32 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
-var Layer = this.Layer = Group.extend({
- /** @lends Layer# */
-
+/**
+ * @name Layer
+ *
+ * @class The Layer item represents a layer in a Paper.js project.
+ *
+ * The layer which is currently active can be accessed through
+ * {@link Project#activeLayer}.
+ * An array of all layers in a project can be accessed through
+ * {@link Project#layers}.
+ *
+ * @extends Group
+ */
+var Layer = this.Layer = Group.extend(/** @lends Layer# */{
// DOCS: improve constructor code example.
/**
* Creates a new Layer item and places it at the end of the
@@ -28,16 +38,6 @@ var Layer = this.Layer = Group.extend({
*
* @example
* var layer = new Layer();
- *
- * @class The Layer item represents a layer in a Paper.js project.
- *
- * The layer which is currently active can be accessed through
- * {@link Project#activeLayer}.
- * An array of all layers in a project can be accessed through
- * {@link Project#layers}.
- *
- * @extends Group
- * @constructs Layer
*/
initialize: function(items) {
this._project = paper.project;
diff --git a/src/item/PlacedSymbol.js b/src/item/PlacedSymbol.js
index 43ae21c5..a6b987c1 100644
--- a/src/item/PlacedSymbol.js
+++ b/src/item/PlacedSymbol.js
@@ -1,22 +1,28 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
-var PlacedSymbol = this.PlacedSymbol = Item.extend({
- /** @lends PlacedSymbol# */
-
+/**
+ * @name PlacedSymbol
+ *
+ * @class A PlacedSymbol represents an instance of a symbol which has been
+ * placed in a Paper.js project.
+ *
+ * @extends Item
+ */
+var PlacedSymbol = this.PlacedSymbol = Item.extend(/** @lends PlacedSymbol# */{
/**
* Creates a new PlacedSymbol Item.
*
@@ -54,12 +60,6 @@ var PlacedSymbol = this.PlacedSymbol = Item.extend({
* // Scale the instance between 0.25 and 1:
* instance.scale(0.25 + Math.random() * 0.75);
* }
- *
- * @class A PlacedSymbol represents an instance of a symbol which has been
- * placed in a Paper.js project.
- *
- * @extends Item
- * @constructs PlacedSymbol
*/
initialize: function(symbol, matrixOrOffset) {
this.base();
diff --git a/src/item/Raster.js b/src/item/Raster.js
index 9ea55228..89c99891 100644
--- a/src/item/Raster.js
+++ b/src/item/Raster.js
@@ -1,34 +1,32 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
-var Raster = this.Raster = Item.extend({
- /** @lends Raster# */
-
+/**
+ * @name Raster
+ * @class The Raster item represents an image in a Paper.js project.
+ * @extends Item
+ */
+var Raster = this.Raster = Item.extend(/** @lends Raster# */{
// TODO: Implement url / type, width, height.
// TODO: Have PlacedSymbol & Raster inherit from a shared class?
// DOCS: Document Raster constructor.
/**
* Creates a new raster item and places it in the active layer.
*
- * @constructs Raster
* @param {HTMLImageElement|Canvas|string} [object]
- *
- * @class The Raster item represents an image in a Paper.js project.
- *
- * @extends Item
*/
initialize: function(object) {
this.base();
@@ -286,7 +284,7 @@ var Raster = this.Raster = Item.extend({
*/
/**
* Gets the color of a pixel in the raster.
- *
+ *
* @name Raster#getPixel
* @function
* @param point the offset of the pixel as a point in pixel coordinates
@@ -312,7 +310,7 @@ var Raster = this.Raster = Item.extend({
*/
/**
* Sets the color of the specified pixel to the specified color.
- *
+ *
* @name Raster#setPixel
* @function
* @param point the offset of the pixel as a point in pixel coordinates
diff --git a/src/load.js b/src/load.js
index c9173e6d..5ca1850d 100644
--- a/src/load.js
+++ b/src/load.js
@@ -1,16 +1,16 @@
/*
* Paper.js
- *
+ *
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
*/
diff --git a/src/paper.js b/src/paper.js
index 45230142..e006ab03 100644
--- a/src/paper.js
+++ b/src/paper.js
@@ -1,41 +1,43 @@
/***
- *
+*
* Paper.js
- *
+ *
* A JavaScript Vector Graphics Library, based on Scriptographer.org and
* designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
- *
+ *
* Distributed under the MIT license. See LICENSE file for details.
- *
+ *
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
- *
+ *
* All rights reserved.
- *
+ *
***
- *
+ *
* Bootstrap.js JavaScript Framework.
* http://bootstrapjs.org/
- *
+ *
* Distributed under the MIT license.
- *
+ *
* Copyright (c) 2006 - 2011 Juerg Lehni
* http://lehni.org/
- *
+ *
***
- *
+ *
* Parse-JS, A JavaScript tokenizer / parser / generator.
- *
+ *
* Distributed under the BSD license.
- *
+ *
* Copyright (c) 2010, Mihai Bazon - * var path; - * - * // Only execute onMouseDrag when the mouse - * // has moved at least 10 points: - * tool.distanceThreshold = 10; - * - * function onMouseDown(event) { - * // Create a new path every time the mouse is clicked - * path = new Path(); - * path.add(event.point); - * path.strokeColor = 'black'; - * } - * - * function onMouseDrag(event) { - * // Add a point to the path every time the mouse is dragged - * path.add(event.point); - * } - **/ initialize: function(handlers, scope) { this._scope = scope; diff --git a/src/tool/ToolEvent.js b/src/tool/ToolEvent.js index e5c3521e..d1abaf8e 100644 --- a/src/tool/ToolEvent.js +++ b/src/tool/ToolEvent.js @@ -1,32 +1,31 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ -var ToolEvent = this.ToolEvent = Event.extend({ - /** @lends ToolEvent# */ - - /** - * @name ToolEvent - * @constructor - * - * @class ToolEvent The ToolEvent object is received by the {@link Tool}'s mouse event handlers - * {@link Tool#onMouseDown}, {@link Tool#onMouseDrag}, - * {@link Tool#onMouseMove} and {@link Tool#onMouseUp}. The ToolEvent - * object is the only parameter passed to these functions and contains - * information about the mouse event. - */ +/** + * @name ToolEvent + * + * @class ToolEvent The ToolEvent object is received by the {@link Tool}'s mouse + * event handlers {@link Tool#onMouseDown}, {@link Tool#onMouseDrag}, + * {@link Tool#onMouseMove} and {@link Tool#onMouseUp}. The ToolEvent + * object is the only parameter passed to these functions and contains + * information about the mouse event. + * + * @extends Event + */ +var ToolEvent = this.ToolEvent = Event.extend(/** @lends ToolEvent# */{ initialize: function(tool, type, event) { this.tool = tool; this.type = type; diff --git a/src/ui/Event.js b/src/ui/Event.js index a1a45075..819946eb 100644 --- a/src/ui/Event.js +++ b/src/ui/Event.js @@ -1,20 +1,24 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ -var Event = this.Event = Base.extend({ +/** + * @name Event + * @class + */ +var Event = this.Event = Base.extend(/** @lends Event# */{ initialize: function(event) { this.event = event; }, diff --git a/src/ui/Key.js b/src/ui/Key.js index 213f3e32..96aa0117 100644 --- a/src/ui/Key.js +++ b/src/ui/Key.js @@ -1,22 +1,22 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ /** - * @namespace * @name Key + * @namespace */ var Key = this.Key = new function() { // TODO: Make sure the keys are called the same as in Scriptographer diff --git a/src/ui/KeyEvent.js b/src/ui/KeyEvent.js index 5dfc0979..704f7ec0 100644 --- a/src/ui/KeyEvent.js +++ b/src/ui/KeyEvent.js @@ -1,32 +1,31 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ +/** + * @name KeyEvent + * + * @class KeyEvent The KeyEvent object is received by the {@link Tool}'s + * keyboard handlers {@link Tool#onKeyDown}, {@link Tool#onKeyUp}, + * The KeyEvent object is the only parameter passed to these functions + * and contains information about the keyboard event. + * + * @extends Event + */ var KeyEvent = this.KeyEvent = Event.extend(new function() { - return { - /** @lends KeyEvent# */ - - /** - * @name KeyEvent - * @constructor - * - * @class KeyEvent The KeyEvent object is received by the {@link Tool}'s - * keyboard handlers {@link Tool#onKeyDown}, {@link Tool#onKeyUp}, - * The KeyEvent object is the only parameter passed to these functions - * and contains information about the keyboard event. - */ + return /** @lends KeyEvent# */{ initialize: function(down, key, character, event) { this.base(event); this.type = down ? 'keydown' : 'keyup'; diff --git a/src/ui/View.js b/src/ui/View.js index e3cff6cd..fd0bb28b 100644 --- a/src/ui/View.js +++ b/src/ui/View.js @@ -1,32 +1,28 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ -var View = this.View = Base.extend({ - /** @lends View# */ - - // DOCS: View: there is alot left to document - // TODO: Add bounds parameter that defines position within canvas? - // Find a good name for these bounds, since #bounds is already the artboard - // bounds of the visible area. +// DOCS: View: there is alot left to document +/** + * @name View + * @class The View object.. + */ +var View = this.View = Base.extend(/** @lends View# */{ /** * Creates a view object * @param {Canvas} canvas - * @constructs View - * - * @class The View object.. */ initialize: function(canvas) { // Associate this view with the active paper scope. diff --git a/src/util/BlendMode.js b/src/util/BlendMode.js index 5f4b7e3c..04def925 100644 --- a/src/util/BlendMode.js +++ b/src/util/BlendMode.js @@ -1,16 +1,16 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ diff --git a/src/util/CanvasProvider.js b/src/util/CanvasProvider.js index 59ecc83f..eaf17c6a 100644 --- a/src/util/CanvasProvider.js +++ b/src/util/CanvasProvider.js @@ -1,16 +1,16 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */ diff --git a/src/util/Numerical.js b/src/util/Numerical.js index c8476495..f14be9c0 100644 --- a/src/util/Numerical.js +++ b/src/util/Numerical.js @@ -1,16 +1,16 @@ /* * Paper.js - * + * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ - * + * * Distributed under the MIT license. See LICENSE file for details. - * + * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ - * + * * All rights reserved. */