diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index e7e18c5..2c1ca72 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -2,6 +2,16 @@ * @author Mat Groves http://matgroves.com/ */ + /** + * + * @class Strip + * @constructor + * @param texture {Texture} TODO-Alvin + * @param width {Number} the width of the TODO-Alvin + * @param height {Number} the height of the TODO-Alvin + * + */ + PIXI.Strip = function(texture, width, height) { PIXI.DisplayObjectContainer.call( this ); @@ -69,6 +79,14 @@ PIXI.Strip.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Strip.prototype.constructor = PIXI.Strip; +/* + * Sets the texture that the Strip will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + * @private + */ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES @@ -81,6 +99,13 @@ this.updateFrame = true; }; +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.Strip.prototype.onTextureUpdate = function() { this.updateFrame = true; diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index e7e18c5..2c1ca72 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -2,6 +2,16 @@ * @author Mat Groves http://matgroves.com/ */ + /** + * + * @class Strip + * @constructor + * @param texture {Texture} TODO-Alvin + * @param width {Number} the width of the TODO-Alvin + * @param height {Number} the height of the TODO-Alvin + * + */ + PIXI.Strip = function(texture, width, height) { PIXI.DisplayObjectContainer.call( this ); @@ -69,6 +79,14 @@ PIXI.Strip.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Strip.prototype.constructor = PIXI.Strip; +/* + * Sets the texture that the Strip will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + * @private + */ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES @@ -81,6 +99,13 @@ this.updateFrame = true; }; +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.Strip.prototype.onTextureUpdate = function() { this.updateFrame = true; diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index a3a86ca..59a1ad1 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -16,7 +16,19 @@ { PIXI.Sprite.call( this, texture); + /** + * The with of the tiling sprite + * + * @property width + * @type Number + */ this.width = width || 100; + /** + * The height of the tiling sprite + * + * @property height + * @type Number + */ this.height = height || 100; /** @@ -27,7 +39,12 @@ */ this.tileScale = new PIXI.Point(1,1); - + /** + * + * + * @property tileScaleOffset + * @type Point + */ this.tileScaleOffset = new PIXI.Point(1,1); /** @@ -40,7 +57,22 @@ this.renderable = true; + /** + * The tint applied to the sprite. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ this.tint = 0xFFFFFF; + + /** + * The blend mode to be applied to the sprite + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; }; @@ -80,6 +112,13 @@ } }); +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.TilingSprite.prototype.onTextureUpdate = function() { // so if _width is 0 then width was not set.. diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index e7e18c5..2c1ca72 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -2,6 +2,16 @@ * @author Mat Groves http://matgroves.com/ */ + /** + * + * @class Strip + * @constructor + * @param texture {Texture} TODO-Alvin + * @param width {Number} the width of the TODO-Alvin + * @param height {Number} the height of the TODO-Alvin + * + */ + PIXI.Strip = function(texture, width, height) { PIXI.DisplayObjectContainer.call( this ); @@ -69,6 +79,14 @@ PIXI.Strip.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Strip.prototype.constructor = PIXI.Strip; +/* + * Sets the texture that the Strip will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + * @private + */ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES @@ -81,6 +99,13 @@ this.updateFrame = true; }; +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.Strip.prototype.onTextureUpdate = function() { this.updateFrame = true; diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index a3a86ca..59a1ad1 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -16,7 +16,19 @@ { PIXI.Sprite.call( this, texture); + /** + * The with of the tiling sprite + * + * @property width + * @type Number + */ this.width = width || 100; + /** + * The height of the tiling sprite + * + * @property height + * @type Number + */ this.height = height || 100; /** @@ -27,7 +39,12 @@ */ this.tileScale = new PIXI.Point(1,1); - + /** + * + * + * @property tileScaleOffset + * @type Point + */ this.tileScaleOffset = new PIXI.Point(1,1); /** @@ -40,7 +57,22 @@ this.renderable = true; + /** + * The tint applied to the sprite. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ this.tint = 0xFFFFFF; + + /** + * The blend mode to be applied to the sprite + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; }; @@ -80,6 +112,13 @@ } }); +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.TilingSprite.prototype.onTextureUpdate = function() { // so if _width is 0 then width was not set.. diff --git a/src/pixi/filters/AbstractFilter.js b/src/pixi/filters/AbstractFilter.js index 94b895b..f9ca0b3 100644 --- a/src/pixi/filters/AbstractFilter.js +++ b/src/pixi/filters/AbstractFilter.js @@ -21,16 +21,26 @@ */ this.passes = [this]; + /** + * @property shaders + * @type Array an array of shaders + * @private + */ this.shaders = []; this.dirty = true; this.padding = 0; /** - @property uniforms - @private + * @property uniforms + * @type object + * @private */ this.uniforms = uniforms || {}; - + /** + * @property fragmentSrc + * @type Array + * @private + */ this.fragmentSrc = fragmentSrc || []; }; diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index e7e18c5..2c1ca72 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -2,6 +2,16 @@ * @author Mat Groves http://matgroves.com/ */ + /** + * + * @class Strip + * @constructor + * @param texture {Texture} TODO-Alvin + * @param width {Number} the width of the TODO-Alvin + * @param height {Number} the height of the TODO-Alvin + * + */ + PIXI.Strip = function(texture, width, height) { PIXI.DisplayObjectContainer.call( this ); @@ -69,6 +79,14 @@ PIXI.Strip.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Strip.prototype.constructor = PIXI.Strip; +/* + * Sets the texture that the Strip will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + * @private + */ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES @@ -81,6 +99,13 @@ this.updateFrame = true; }; +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.Strip.prototype.onTextureUpdate = function() { this.updateFrame = true; diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index a3a86ca..59a1ad1 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -16,7 +16,19 @@ { PIXI.Sprite.call( this, texture); + /** + * The with of the tiling sprite + * + * @property width + * @type Number + */ this.width = width || 100; + /** + * The height of the tiling sprite + * + * @property height + * @type Number + */ this.height = height || 100; /** @@ -27,7 +39,12 @@ */ this.tileScale = new PIXI.Point(1,1); - + /** + * + * + * @property tileScaleOffset + * @type Point + */ this.tileScaleOffset = new PIXI.Point(1,1); /** @@ -40,7 +57,22 @@ this.renderable = true; + /** + * The tint applied to the sprite. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ this.tint = 0xFFFFFF; + + /** + * The blend mode to be applied to the sprite + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; }; @@ -80,6 +112,13 @@ } }); +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.TilingSprite.prototype.onTextureUpdate = function() { // so if _width is 0 then width was not set.. diff --git a/src/pixi/filters/AbstractFilter.js b/src/pixi/filters/AbstractFilter.js index 94b895b..f9ca0b3 100644 --- a/src/pixi/filters/AbstractFilter.js +++ b/src/pixi/filters/AbstractFilter.js @@ -21,16 +21,26 @@ */ this.passes = [this]; + /** + * @property shaders + * @type Array an array of shaders + * @private + */ this.shaders = []; this.dirty = true; this.padding = 0; /** - @property uniforms - @private + * @property uniforms + * @type object + * @private */ this.uniforms = uniforms || {}; - + /** + * @property fragmentSrc + * @type Array + * @private + */ this.fragmentSrc = fragmentSrc || []; }; diff --git a/src/pixi/filters/AlphaMaskFilter.js b/src/pixi/filters/AlphaMaskFilter.js index cd1dff9..5d69412 100644 --- a/src/pixi/filters/AlphaMaskFilter.js +++ b/src/pixi/filters/AlphaMaskFilter.js @@ -6,7 +6,7 @@ * * The AlphaMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used offset the x and the g propery of the texture is used to offset the y. + * Currently the r property of the texture is used to offset the x and the g propery of the texture is used to offset the y. * @class AlphaMaskFilter * @contructor * @param texture {Texture} The texture used for the displacemtent map * must be power of 2 texture at the moment diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index e7e18c5..2c1ca72 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -2,6 +2,16 @@ * @author Mat Groves http://matgroves.com/ */ + /** + * + * @class Strip + * @constructor + * @param texture {Texture} TODO-Alvin + * @param width {Number} the width of the TODO-Alvin + * @param height {Number} the height of the TODO-Alvin + * + */ + PIXI.Strip = function(texture, width, height) { PIXI.DisplayObjectContainer.call( this ); @@ -69,6 +79,14 @@ PIXI.Strip.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Strip.prototype.constructor = PIXI.Strip; +/* + * Sets the texture that the Strip will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + * @private + */ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES @@ -81,6 +99,13 @@ this.updateFrame = true; }; +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.Strip.prototype.onTextureUpdate = function() { this.updateFrame = true; diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index a3a86ca..59a1ad1 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -16,7 +16,19 @@ { PIXI.Sprite.call( this, texture); + /** + * The with of the tiling sprite + * + * @property width + * @type Number + */ this.width = width || 100; + /** + * The height of the tiling sprite + * + * @property height + * @type Number + */ this.height = height || 100; /** @@ -27,7 +39,12 @@ */ this.tileScale = new PIXI.Point(1,1); - + /** + * + * + * @property tileScaleOffset + * @type Point + */ this.tileScaleOffset = new PIXI.Point(1,1); /** @@ -40,7 +57,22 @@ this.renderable = true; + /** + * The tint applied to the sprite. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ this.tint = 0xFFFFFF; + + /** + * The blend mode to be applied to the sprite + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; }; @@ -80,6 +112,13 @@ } }); +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.TilingSprite.prototype.onTextureUpdate = function() { // so if _width is 0 then width was not set.. diff --git a/src/pixi/filters/AbstractFilter.js b/src/pixi/filters/AbstractFilter.js index 94b895b..f9ca0b3 100644 --- a/src/pixi/filters/AbstractFilter.js +++ b/src/pixi/filters/AbstractFilter.js @@ -21,16 +21,26 @@ */ this.passes = [this]; + /** + * @property shaders + * @type Array an array of shaders + * @private + */ this.shaders = []; this.dirty = true; this.padding = 0; /** - @property uniforms - @private + * @property uniforms + * @type object + * @private */ this.uniforms = uniforms || {}; - + /** + * @property fragmentSrc + * @type Array + * @private + */ this.fragmentSrc = fragmentSrc || []; }; diff --git a/src/pixi/filters/AlphaMaskFilter.js b/src/pixi/filters/AlphaMaskFilter.js index cd1dff9..5d69412 100644 --- a/src/pixi/filters/AlphaMaskFilter.js +++ b/src/pixi/filters/AlphaMaskFilter.js @@ -6,7 +6,7 @@ * * The AlphaMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used offset the x and the g propery of the texture is used to offset the y. + * Currently the r property of the texture is used to offset the x and the g propery of the texture is used to offset the y. * @class AlphaMaskFilter * @contructor * @param texture {Texture} The texture used for the displacemtent map * must be power of 2 texture at the moment diff --git a/src/pixi/loaders/AssetLoader.js b/src/pixi/loaders/AssetLoader.js index c2e8ef1..0dda750 100644 --- a/src/pixi/loaders/AssetLoader.js +++ b/src/pixi/loaders/AssetLoader.js @@ -70,7 +70,12 @@ // constructor PIXI.AssetLoader.prototype.constructor = PIXI.AssetLoader; - +/** + * Given a filename, returns its extension, wil + * + * @method _getDataType + * @param str {String} the name of the asset + */ PIXI.AssetLoader.prototype._getDataType = function(str) { var test = 'data:'; diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index e7e18c5..2c1ca72 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -2,6 +2,16 @@ * @author Mat Groves http://matgroves.com/ */ + /** + * + * @class Strip + * @constructor + * @param texture {Texture} TODO-Alvin + * @param width {Number} the width of the TODO-Alvin + * @param height {Number} the height of the TODO-Alvin + * + */ + PIXI.Strip = function(texture, width, height) { PIXI.DisplayObjectContainer.call( this ); @@ -69,6 +79,14 @@ PIXI.Strip.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Strip.prototype.constructor = PIXI.Strip; +/* + * Sets the texture that the Strip will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + * @private + */ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES @@ -81,6 +99,13 @@ this.updateFrame = true; }; +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.Strip.prototype.onTextureUpdate = function() { this.updateFrame = true; diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index a3a86ca..59a1ad1 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -16,7 +16,19 @@ { PIXI.Sprite.call( this, texture); + /** + * The with of the tiling sprite + * + * @property width + * @type Number + */ this.width = width || 100; + /** + * The height of the tiling sprite + * + * @property height + * @type Number + */ this.height = height || 100; /** @@ -27,7 +39,12 @@ */ this.tileScale = new PIXI.Point(1,1); - + /** + * + * + * @property tileScaleOffset + * @type Point + */ this.tileScaleOffset = new PIXI.Point(1,1); /** @@ -40,7 +57,22 @@ this.renderable = true; + /** + * The tint applied to the sprite. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ this.tint = 0xFFFFFF; + + /** + * The blend mode to be applied to the sprite + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; }; @@ -80,6 +112,13 @@ } }); +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.TilingSprite.prototype.onTextureUpdate = function() { // so if _width is 0 then width was not set.. diff --git a/src/pixi/filters/AbstractFilter.js b/src/pixi/filters/AbstractFilter.js index 94b895b..f9ca0b3 100644 --- a/src/pixi/filters/AbstractFilter.js +++ b/src/pixi/filters/AbstractFilter.js @@ -21,16 +21,26 @@ */ this.passes = [this]; + /** + * @property shaders + * @type Array an array of shaders + * @private + */ this.shaders = []; this.dirty = true; this.padding = 0; /** - @property uniforms - @private + * @property uniforms + * @type object + * @private */ this.uniforms = uniforms || {}; - + /** + * @property fragmentSrc + * @type Array + * @private + */ this.fragmentSrc = fragmentSrc || []; }; diff --git a/src/pixi/filters/AlphaMaskFilter.js b/src/pixi/filters/AlphaMaskFilter.js index cd1dff9..5d69412 100644 --- a/src/pixi/filters/AlphaMaskFilter.js +++ b/src/pixi/filters/AlphaMaskFilter.js @@ -6,7 +6,7 @@ * * The AlphaMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used offset the x and the g propery of the texture is used to offset the y. + * Currently the r property of the texture is used to offset the x and the g propery of the texture is used to offset the y. * @class AlphaMaskFilter * @contructor * @param texture {Texture} The texture used for the displacemtent map * must be power of 2 texture at the moment diff --git a/src/pixi/loaders/AssetLoader.js b/src/pixi/loaders/AssetLoader.js index c2e8ef1..0dda750 100644 --- a/src/pixi/loaders/AssetLoader.js +++ b/src/pixi/loaders/AssetLoader.js @@ -70,7 +70,12 @@ // constructor PIXI.AssetLoader.prototype.constructor = PIXI.AssetLoader; - +/** + * Given a filename, returns its extension, wil + * + * @method _getDataType + * @param str {String} the name of the asset + */ PIXI.AssetLoader.prototype._getDataType = function(str) { var test = 'data:'; diff --git a/src/pixi/loaders/AtlasLoader.js b/src/pixi/loaders/AtlasLoader.js index 2288e81..98e32c9 100644 --- a/src/pixi/loaders/AtlasLoader.js +++ b/src/pixi/loaders/AtlasLoader.js @@ -25,8 +25,11 @@ // constructor PIXI.AtlasLoader.constructor = PIXI.AtlasLoader; -/** - * This will begin loading the JSON file + + /** + * Starts loading the JSON file + * + * @method load */ PIXI.AtlasLoader.prototype.load = function () { this.ajaxRequest = new PIXI.AjaxRequest(); @@ -39,6 +42,7 @@ /** * Invoke when JSON file is loaded + * @method onAtlasLoaded * @private */ PIXI.AtlasLoader.prototype.onAtlasLoaded = function () { @@ -156,7 +160,8 @@ }; /** - * Invoke when json file loaded + * Invoke when json file has loaded + * @method onLoaded * @private */ PIXI.AtlasLoader.prototype.onLoaded = function () { @@ -174,6 +179,7 @@ /** * Invoke when error occured + * @method onError * @private */ PIXI.AtlasLoader.prototype.onError = function () { diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index e7e18c5..2c1ca72 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -2,6 +2,16 @@ * @author Mat Groves http://matgroves.com/ */ + /** + * + * @class Strip + * @constructor + * @param texture {Texture} TODO-Alvin + * @param width {Number} the width of the TODO-Alvin + * @param height {Number} the height of the TODO-Alvin + * + */ + PIXI.Strip = function(texture, width, height) { PIXI.DisplayObjectContainer.call( this ); @@ -69,6 +79,14 @@ PIXI.Strip.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Strip.prototype.constructor = PIXI.Strip; +/* + * Sets the texture that the Strip will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + * @private + */ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES @@ -81,6 +99,13 @@ this.updateFrame = true; }; +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.Strip.prototype.onTextureUpdate = function() { this.updateFrame = true; diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index a3a86ca..59a1ad1 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -16,7 +16,19 @@ { PIXI.Sprite.call( this, texture); + /** + * The with of the tiling sprite + * + * @property width + * @type Number + */ this.width = width || 100; + /** + * The height of the tiling sprite + * + * @property height + * @type Number + */ this.height = height || 100; /** @@ -27,7 +39,12 @@ */ this.tileScale = new PIXI.Point(1,1); - + /** + * + * + * @property tileScaleOffset + * @type Point + */ this.tileScaleOffset = new PIXI.Point(1,1); /** @@ -40,7 +57,22 @@ this.renderable = true; + /** + * The tint applied to the sprite. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ this.tint = 0xFFFFFF; + + /** + * The blend mode to be applied to the sprite + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; }; @@ -80,6 +112,13 @@ } }); +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.TilingSprite.prototype.onTextureUpdate = function() { // so if _width is 0 then width was not set.. diff --git a/src/pixi/filters/AbstractFilter.js b/src/pixi/filters/AbstractFilter.js index 94b895b..f9ca0b3 100644 --- a/src/pixi/filters/AbstractFilter.js +++ b/src/pixi/filters/AbstractFilter.js @@ -21,16 +21,26 @@ */ this.passes = [this]; + /** + * @property shaders + * @type Array an array of shaders + * @private + */ this.shaders = []; this.dirty = true; this.padding = 0; /** - @property uniforms - @private + * @property uniforms + * @type object + * @private */ this.uniforms = uniforms || {}; - + /** + * @property fragmentSrc + * @type Array + * @private + */ this.fragmentSrc = fragmentSrc || []; }; diff --git a/src/pixi/filters/AlphaMaskFilter.js b/src/pixi/filters/AlphaMaskFilter.js index cd1dff9..5d69412 100644 --- a/src/pixi/filters/AlphaMaskFilter.js +++ b/src/pixi/filters/AlphaMaskFilter.js @@ -6,7 +6,7 @@ * * The AlphaMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used offset the x and the g propery of the texture is used to offset the y. + * Currently the r property of the texture is used to offset the x and the g propery of the texture is used to offset the y. * @class AlphaMaskFilter * @contructor * @param texture {Texture} The texture used for the displacemtent map * must be power of 2 texture at the moment diff --git a/src/pixi/loaders/AssetLoader.js b/src/pixi/loaders/AssetLoader.js index c2e8ef1..0dda750 100644 --- a/src/pixi/loaders/AssetLoader.js +++ b/src/pixi/loaders/AssetLoader.js @@ -70,7 +70,12 @@ // constructor PIXI.AssetLoader.prototype.constructor = PIXI.AssetLoader; - +/** + * Given a filename, returns its extension, wil + * + * @method _getDataType + * @param str {String} the name of the asset + */ PIXI.AssetLoader.prototype._getDataType = function(str) { var test = 'data:'; diff --git a/src/pixi/loaders/AtlasLoader.js b/src/pixi/loaders/AtlasLoader.js index 2288e81..98e32c9 100644 --- a/src/pixi/loaders/AtlasLoader.js +++ b/src/pixi/loaders/AtlasLoader.js @@ -25,8 +25,11 @@ // constructor PIXI.AtlasLoader.constructor = PIXI.AtlasLoader; -/** - * This will begin loading the JSON file + + /** + * Starts loading the JSON file + * + * @method load */ PIXI.AtlasLoader.prototype.load = function () { this.ajaxRequest = new PIXI.AjaxRequest(); @@ -39,6 +42,7 @@ /** * Invoke when JSON file is loaded + * @method onAtlasLoaded * @private */ PIXI.AtlasLoader.prototype.onAtlasLoaded = function () { @@ -156,7 +160,8 @@ }; /** - * Invoke when json file loaded + * Invoke when json file has loaded + * @method onLoaded * @private */ PIXI.AtlasLoader.prototype.onLoaded = function () { @@ -174,6 +179,7 @@ /** * Invoke when error occured + * @method onError * @private */ PIXI.AtlasLoader.prototype.onError = function () { diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index d00a494..4fa32d5 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -17,7 +17,7 @@ PIXI.BitmapFontLoader = function(url, crossorigin) { /* - * i use texture packer to load the assets.. + * I use texture packer to load the assets.. * http://www.codeandweb.com/texturepacker * make sure to set the format as 'JSON' */ diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index e7e18c5..2c1ca72 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -2,6 +2,16 @@ * @author Mat Groves http://matgroves.com/ */ + /** + * + * @class Strip + * @constructor + * @param texture {Texture} TODO-Alvin + * @param width {Number} the width of the TODO-Alvin + * @param height {Number} the height of the TODO-Alvin + * + */ + PIXI.Strip = function(texture, width, height) { PIXI.DisplayObjectContainer.call( this ); @@ -69,6 +79,14 @@ PIXI.Strip.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Strip.prototype.constructor = PIXI.Strip; +/* + * Sets the texture that the Strip will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + * @private + */ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES @@ -81,6 +99,13 @@ this.updateFrame = true; }; +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.Strip.prototype.onTextureUpdate = function() { this.updateFrame = true; diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index a3a86ca..59a1ad1 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -16,7 +16,19 @@ { PIXI.Sprite.call( this, texture); + /** + * The with of the tiling sprite + * + * @property width + * @type Number + */ this.width = width || 100; + /** + * The height of the tiling sprite + * + * @property height + * @type Number + */ this.height = height || 100; /** @@ -27,7 +39,12 @@ */ this.tileScale = new PIXI.Point(1,1); - + /** + * + * + * @property tileScaleOffset + * @type Point + */ this.tileScaleOffset = new PIXI.Point(1,1); /** @@ -40,7 +57,22 @@ this.renderable = true; + /** + * The tint applied to the sprite. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ this.tint = 0xFFFFFF; + + /** + * The blend mode to be applied to the sprite + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; }; @@ -80,6 +112,13 @@ } }); +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.TilingSprite.prototype.onTextureUpdate = function() { // so if _width is 0 then width was not set.. diff --git a/src/pixi/filters/AbstractFilter.js b/src/pixi/filters/AbstractFilter.js index 94b895b..f9ca0b3 100644 --- a/src/pixi/filters/AbstractFilter.js +++ b/src/pixi/filters/AbstractFilter.js @@ -21,16 +21,26 @@ */ this.passes = [this]; + /** + * @property shaders + * @type Array an array of shaders + * @private + */ this.shaders = []; this.dirty = true; this.padding = 0; /** - @property uniforms - @private + * @property uniforms + * @type object + * @private */ this.uniforms = uniforms || {}; - + /** + * @property fragmentSrc + * @type Array + * @private + */ this.fragmentSrc = fragmentSrc || []; }; diff --git a/src/pixi/filters/AlphaMaskFilter.js b/src/pixi/filters/AlphaMaskFilter.js index cd1dff9..5d69412 100644 --- a/src/pixi/filters/AlphaMaskFilter.js +++ b/src/pixi/filters/AlphaMaskFilter.js @@ -6,7 +6,7 @@ * * The AlphaMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used offset the x and the g propery of the texture is used to offset the y. + * Currently the r property of the texture is used to offset the x and the g propery of the texture is used to offset the y. * @class AlphaMaskFilter * @contructor * @param texture {Texture} The texture used for the displacemtent map * must be power of 2 texture at the moment diff --git a/src/pixi/loaders/AssetLoader.js b/src/pixi/loaders/AssetLoader.js index c2e8ef1..0dda750 100644 --- a/src/pixi/loaders/AssetLoader.js +++ b/src/pixi/loaders/AssetLoader.js @@ -70,7 +70,12 @@ // constructor PIXI.AssetLoader.prototype.constructor = PIXI.AssetLoader; - +/** + * Given a filename, returns its extension, wil + * + * @method _getDataType + * @param str {String} the name of the asset + */ PIXI.AssetLoader.prototype._getDataType = function(str) { var test = 'data:'; diff --git a/src/pixi/loaders/AtlasLoader.js b/src/pixi/loaders/AtlasLoader.js index 2288e81..98e32c9 100644 --- a/src/pixi/loaders/AtlasLoader.js +++ b/src/pixi/loaders/AtlasLoader.js @@ -25,8 +25,11 @@ // constructor PIXI.AtlasLoader.constructor = PIXI.AtlasLoader; -/** - * This will begin loading the JSON file + + /** + * Starts loading the JSON file + * + * @method load */ PIXI.AtlasLoader.prototype.load = function () { this.ajaxRequest = new PIXI.AjaxRequest(); @@ -39,6 +42,7 @@ /** * Invoke when JSON file is loaded + * @method onAtlasLoaded * @private */ PIXI.AtlasLoader.prototype.onAtlasLoaded = function () { @@ -156,7 +160,8 @@ }; /** - * Invoke when json file loaded + * Invoke when json file has loaded + * @method onLoaded * @private */ PIXI.AtlasLoader.prototype.onLoaded = function () { @@ -174,6 +179,7 @@ /** * Invoke when error occured + * @method onError * @private */ PIXI.AtlasLoader.prototype.onError = function () { diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index d00a494..4fa32d5 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -17,7 +17,7 @@ PIXI.BitmapFontLoader = function(url, crossorigin) { /* - * i use texture packer to load the assets.. + * I use texture packer to load the assets.. * http://www.codeandweb.com/texturepacker * make sure to set the format as 'JSON' */ diff --git a/src/pixi/primitives/Graphics.js b/src/pixi/primitives/Graphics.js index 3a18769..b057305 100644 --- a/src/pixi/primitives/Graphics.js +++ b/src/pixi/primitives/Graphics.js @@ -5,8 +5,8 @@ /** * The Graphics class contains a set of methods that you can use to create primitive shapes and lines. - * It is important to know that with the webGL renderer only simple polys can be filled at this stage - * Complex polys will not be filled. Heres an example of a complex poly: http://www.goodboydigital.com/wp-content/uploads/2013/06/complexPolygon.png + * It is important to know that with the webGL renderer only simple polygons can be filled at this stage + * Complex polygons will not be filled. Heres an example of a complex polygon: http://www.goodboydigital.com/wp-content/uploads/2013/06/complexPolygon.png * * @class Graphics * @extends DisplayObjectContainer @@ -51,8 +51,23 @@ */ this.graphicsData = []; - this.tint = 0xFFFFFF;// * Math.random(); + /** + * The tint applied to the graphic shape. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ + this.tint = 0xFFFFFF;// * Math.random(); + + /** + * The blend mode to be applied to the graphic shape + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; /** @@ -64,12 +79,37 @@ */ this.currentPath = {points:[]}; + /** + * WebGL lines ? TODO-Alvin + * + * @property _webGL + * @type Array + * @private + */ this._webGL = []; + /** + * Whether this shape is used as a mask + * + * @property isMask + * @type isMask + */ this.isMask = false; + /** + * The bounds of the graphic shape as rectangle object + * + * @property bounds + * @type Rectangle + */ this.bounds = null; + /** + * the bound padding TODO-Alvin + * + * @property bounds + * @type Number + */ this.boundsPadding = 10; }; @@ -110,7 +150,7 @@ /** - * Specifies a line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. + * Specifies the line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. * * @method lineStyle * @param lineWidth {Number} width of the line to draw, will update the object's stored style @@ -135,8 +175,8 @@ * Moves the current drawing position to (x, y). * * @method moveTo - * @param x {Number} the X coord to move to - * @param y {Number} the Y coord to move to + * @param x {Number} the X coordinate to move to + * @param y {Number} the Y coordinate to move to */ PIXI.Graphics.prototype.moveTo = function(x, y) { @@ -155,8 +195,8 @@ * the current drawing position is then set to (x, y). * * @method lineTo - * @param x {Number} the X coord to draw to - * @param y {Number} the Y coord to draw to + * @param x {Number} the X coordinate to draw to + * @param y {Number} the Y coordinate to draw to */ PIXI.Graphics.prototype.lineTo = function(x, y) { @@ -169,8 +209,8 @@ * (such as lineTo() or drawCircle()) use when drawing. * * @method beginFill - * @param color {uint} the color of the fill - * @param alpha {Number} the alpha + * @param color {Number} the color of the fill + * @param alpha {Number} the alpha of the fill */ PIXI.Graphics.prototype.beginFill = function(color, alpha) { @@ -216,8 +256,8 @@ * Draws a circle. * * @method drawCircle - * @param x {Number} The X coord of the center of the circle - * @param y {Number} The Y coord of the center of the circle + * @param x {Number} The X coordinate of the center of the circle + * @param y {Number} The Y coordinate of the center of the circle * @param radius {Number} The radius of the circle */ PIXI.Graphics.prototype.drawCircle = function( x, y, radius) @@ -237,10 +277,10 @@ * Draws an ellipse. * * @method drawEllipse - * @param x {Number} - * @param y {Number} - * @param width {Number} - * @param height {Number} + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param width {Number} The width of the ellipse + * @param height {Number} The height of the ellipse */ PIXI.Graphics.prototype.drawEllipse = function( x, y, width, height) { @@ -293,6 +333,13 @@ return texture; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Graphics.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -354,6 +401,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Graphics.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -378,6 +432,12 @@ } }; +/** + * Retrieves the bounds of the graphic shape as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Graphics.prototype.getBounds = function() { if(!this.bounds)this.updateBounds(); @@ -446,6 +506,11 @@ return bounds; }; +/** + * Update the bounds of the object + * + * @method updateBounds + */ PIXI.Graphics.prototype.updateBounds = function() { @@ -510,6 +575,13 @@ this.bounds = new PIXI.Rectangle(minX - padding, minY - padding, (maxX - minX) + padding * 2, (maxY - minY) + padding * 2); }; + +/** + * Generates the cached sprite that was made using the generate TODO-Alvin + * + * @method _generateCachedSprite + * @private + */ PIXI.Graphics.prototype._generateCachedSprite = function() { var bounds = this.getBounds(); @@ -555,5 +627,3 @@ PIXI.Graphics.RECT = 1; PIXI.Graphics.CIRC = 2; PIXI.Graphics.ELIP = 3; - -PIXI.tempMatrix = PIXI.mat3.create(); diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index e7e18c5..2c1ca72 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -2,6 +2,16 @@ * @author Mat Groves http://matgroves.com/ */ + /** + * + * @class Strip + * @constructor + * @param texture {Texture} TODO-Alvin + * @param width {Number} the width of the TODO-Alvin + * @param height {Number} the height of the TODO-Alvin + * + */ + PIXI.Strip = function(texture, width, height) { PIXI.DisplayObjectContainer.call( this ); @@ -69,6 +79,14 @@ PIXI.Strip.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Strip.prototype.constructor = PIXI.Strip; +/* + * Sets the texture that the Strip will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + * @private + */ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES @@ -81,6 +99,13 @@ this.updateFrame = true; }; +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.Strip.prototype.onTextureUpdate = function() { this.updateFrame = true; diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index a3a86ca..59a1ad1 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -16,7 +16,19 @@ { PIXI.Sprite.call( this, texture); + /** + * The with of the tiling sprite + * + * @property width + * @type Number + */ this.width = width || 100; + /** + * The height of the tiling sprite + * + * @property height + * @type Number + */ this.height = height || 100; /** @@ -27,7 +39,12 @@ */ this.tileScale = new PIXI.Point(1,1); - + /** + * + * + * @property tileScaleOffset + * @type Point + */ this.tileScaleOffset = new PIXI.Point(1,1); /** @@ -40,7 +57,22 @@ this.renderable = true; + /** + * The tint applied to the sprite. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ this.tint = 0xFFFFFF; + + /** + * The blend mode to be applied to the sprite + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; }; @@ -80,6 +112,13 @@ } }); +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.TilingSprite.prototype.onTextureUpdate = function() { // so if _width is 0 then width was not set.. diff --git a/src/pixi/filters/AbstractFilter.js b/src/pixi/filters/AbstractFilter.js index 94b895b..f9ca0b3 100644 --- a/src/pixi/filters/AbstractFilter.js +++ b/src/pixi/filters/AbstractFilter.js @@ -21,16 +21,26 @@ */ this.passes = [this]; + /** + * @property shaders + * @type Array an array of shaders + * @private + */ this.shaders = []; this.dirty = true; this.padding = 0; /** - @property uniforms - @private + * @property uniforms + * @type object + * @private */ this.uniforms = uniforms || {}; - + /** + * @property fragmentSrc + * @type Array + * @private + */ this.fragmentSrc = fragmentSrc || []; }; diff --git a/src/pixi/filters/AlphaMaskFilter.js b/src/pixi/filters/AlphaMaskFilter.js index cd1dff9..5d69412 100644 --- a/src/pixi/filters/AlphaMaskFilter.js +++ b/src/pixi/filters/AlphaMaskFilter.js @@ -6,7 +6,7 @@ * * The AlphaMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used offset the x and the g propery of the texture is used to offset the y. + * Currently the r property of the texture is used to offset the x and the g propery of the texture is used to offset the y. * @class AlphaMaskFilter * @contructor * @param texture {Texture} The texture used for the displacemtent map * must be power of 2 texture at the moment diff --git a/src/pixi/loaders/AssetLoader.js b/src/pixi/loaders/AssetLoader.js index c2e8ef1..0dda750 100644 --- a/src/pixi/loaders/AssetLoader.js +++ b/src/pixi/loaders/AssetLoader.js @@ -70,7 +70,12 @@ // constructor PIXI.AssetLoader.prototype.constructor = PIXI.AssetLoader; - +/** + * Given a filename, returns its extension, wil + * + * @method _getDataType + * @param str {String} the name of the asset + */ PIXI.AssetLoader.prototype._getDataType = function(str) { var test = 'data:'; diff --git a/src/pixi/loaders/AtlasLoader.js b/src/pixi/loaders/AtlasLoader.js index 2288e81..98e32c9 100644 --- a/src/pixi/loaders/AtlasLoader.js +++ b/src/pixi/loaders/AtlasLoader.js @@ -25,8 +25,11 @@ // constructor PIXI.AtlasLoader.constructor = PIXI.AtlasLoader; -/** - * This will begin loading the JSON file + + /** + * Starts loading the JSON file + * + * @method load */ PIXI.AtlasLoader.prototype.load = function () { this.ajaxRequest = new PIXI.AjaxRequest(); @@ -39,6 +42,7 @@ /** * Invoke when JSON file is loaded + * @method onAtlasLoaded * @private */ PIXI.AtlasLoader.prototype.onAtlasLoaded = function () { @@ -156,7 +160,8 @@ }; /** - * Invoke when json file loaded + * Invoke when json file has loaded + * @method onLoaded * @private */ PIXI.AtlasLoader.prototype.onLoaded = function () { @@ -174,6 +179,7 @@ /** * Invoke when error occured + * @method onError * @private */ PIXI.AtlasLoader.prototype.onError = function () { diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index d00a494..4fa32d5 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -17,7 +17,7 @@ PIXI.BitmapFontLoader = function(url, crossorigin) { /* - * i use texture packer to load the assets.. + * I use texture packer to load the assets.. * http://www.codeandweb.com/texturepacker * make sure to set the format as 'JSON' */ diff --git a/src/pixi/primitives/Graphics.js b/src/pixi/primitives/Graphics.js index 3a18769..b057305 100644 --- a/src/pixi/primitives/Graphics.js +++ b/src/pixi/primitives/Graphics.js @@ -5,8 +5,8 @@ /** * The Graphics class contains a set of methods that you can use to create primitive shapes and lines. - * It is important to know that with the webGL renderer only simple polys can be filled at this stage - * Complex polys will not be filled. Heres an example of a complex poly: http://www.goodboydigital.com/wp-content/uploads/2013/06/complexPolygon.png + * It is important to know that with the webGL renderer only simple polygons can be filled at this stage + * Complex polygons will not be filled. Heres an example of a complex polygon: http://www.goodboydigital.com/wp-content/uploads/2013/06/complexPolygon.png * * @class Graphics * @extends DisplayObjectContainer @@ -51,8 +51,23 @@ */ this.graphicsData = []; - this.tint = 0xFFFFFF;// * Math.random(); + /** + * The tint applied to the graphic shape. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ + this.tint = 0xFFFFFF;// * Math.random(); + + /** + * The blend mode to be applied to the graphic shape + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; /** @@ -64,12 +79,37 @@ */ this.currentPath = {points:[]}; + /** + * WebGL lines ? TODO-Alvin + * + * @property _webGL + * @type Array + * @private + */ this._webGL = []; + /** + * Whether this shape is used as a mask + * + * @property isMask + * @type isMask + */ this.isMask = false; + /** + * The bounds of the graphic shape as rectangle object + * + * @property bounds + * @type Rectangle + */ this.bounds = null; + /** + * the bound padding TODO-Alvin + * + * @property bounds + * @type Number + */ this.boundsPadding = 10; }; @@ -110,7 +150,7 @@ /** - * Specifies a line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. + * Specifies the line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. * * @method lineStyle * @param lineWidth {Number} width of the line to draw, will update the object's stored style @@ -135,8 +175,8 @@ * Moves the current drawing position to (x, y). * * @method moveTo - * @param x {Number} the X coord to move to - * @param y {Number} the Y coord to move to + * @param x {Number} the X coordinate to move to + * @param y {Number} the Y coordinate to move to */ PIXI.Graphics.prototype.moveTo = function(x, y) { @@ -155,8 +195,8 @@ * the current drawing position is then set to (x, y). * * @method lineTo - * @param x {Number} the X coord to draw to - * @param y {Number} the Y coord to draw to + * @param x {Number} the X coordinate to draw to + * @param y {Number} the Y coordinate to draw to */ PIXI.Graphics.prototype.lineTo = function(x, y) { @@ -169,8 +209,8 @@ * (such as lineTo() or drawCircle()) use when drawing. * * @method beginFill - * @param color {uint} the color of the fill - * @param alpha {Number} the alpha + * @param color {Number} the color of the fill + * @param alpha {Number} the alpha of the fill */ PIXI.Graphics.prototype.beginFill = function(color, alpha) { @@ -216,8 +256,8 @@ * Draws a circle. * * @method drawCircle - * @param x {Number} The X coord of the center of the circle - * @param y {Number} The Y coord of the center of the circle + * @param x {Number} The X coordinate of the center of the circle + * @param y {Number} The Y coordinate of the center of the circle * @param radius {Number} The radius of the circle */ PIXI.Graphics.prototype.drawCircle = function( x, y, radius) @@ -237,10 +277,10 @@ * Draws an ellipse. * * @method drawEllipse - * @param x {Number} - * @param y {Number} - * @param width {Number} - * @param height {Number} + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param width {Number} The width of the ellipse + * @param height {Number} The height of the ellipse */ PIXI.Graphics.prototype.drawEllipse = function( x, y, width, height) { @@ -293,6 +333,13 @@ return texture; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Graphics.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -354,6 +401,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Graphics.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -378,6 +432,12 @@ } }; +/** + * Retrieves the bounds of the graphic shape as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Graphics.prototype.getBounds = function() { if(!this.bounds)this.updateBounds(); @@ -446,6 +506,11 @@ return bounds; }; +/** + * Update the bounds of the object + * + * @method updateBounds + */ PIXI.Graphics.prototype.updateBounds = function() { @@ -510,6 +575,13 @@ this.bounds = new PIXI.Rectangle(minX - padding, minY - padding, (maxX - minX) + padding * 2, (maxY - minY) + padding * 2); }; + +/** + * Generates the cached sprite that was made using the generate TODO-Alvin + * + * @method _generateCachedSprite + * @private + */ PIXI.Graphics.prototype._generateCachedSprite = function() { var bounds = this.getBounds(); @@ -555,5 +627,3 @@ PIXI.Graphics.RECT = 1; PIXI.Graphics.CIRC = 2; PIXI.Graphics.ELIP = 3; - -PIXI.tempMatrix = PIXI.mat3.create(); diff --git a/src/pixi/utils/Detector.js b/src/pixi/utils/Detector.js index afe931e..cf4896b 100644 --- a/src/pixi/utils/Detector.js +++ b/src/pixi/utils/Detector.js @@ -7,13 +7,11 @@ * WebGL is the preferred renderer as it is a lot faster. If webGL is not supported by * the browser then this function will return a canvas renderer * - * @method autoDetectRenderer - * @static - * @param width {Number} the width of the renderers view - * @param height {Number} the height of the renderers view - * @param view {Canvas} the canvas to use as a view, optional - * @param transparent=false {Boolean} the transparency of the render view, default false - * @param antialias=false {Boolean} sets antialias (only applicable in webGL chrome at the moment) + * @param width=800 {Number} the width of the renderers view + * @param height=600 {Number} the height of the renderers view + * @param [view] {Canvas} the canvas to use as a view, optional + * @param [transparent=false] {Boolean} the transparency of the render view, default false + * @param [antialias=false] {Boolean} sets antialias (only applicable in webGL chrome at the moment) * * antialias */ diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index e7e18c5..2c1ca72 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -2,6 +2,16 @@ * @author Mat Groves http://matgroves.com/ */ + /** + * + * @class Strip + * @constructor + * @param texture {Texture} TODO-Alvin + * @param width {Number} the width of the TODO-Alvin + * @param height {Number} the height of the TODO-Alvin + * + */ + PIXI.Strip = function(texture, width, height) { PIXI.DisplayObjectContainer.call( this ); @@ -69,6 +79,14 @@ PIXI.Strip.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Strip.prototype.constructor = PIXI.Strip; +/* + * Sets the texture that the Strip will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + * @private + */ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES @@ -81,6 +99,13 @@ this.updateFrame = true; }; +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.Strip.prototype.onTextureUpdate = function() { this.updateFrame = true; diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index a3a86ca..59a1ad1 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -16,7 +16,19 @@ { PIXI.Sprite.call( this, texture); + /** + * The with of the tiling sprite + * + * @property width + * @type Number + */ this.width = width || 100; + /** + * The height of the tiling sprite + * + * @property height + * @type Number + */ this.height = height || 100; /** @@ -27,7 +39,12 @@ */ this.tileScale = new PIXI.Point(1,1); - + /** + * + * + * @property tileScaleOffset + * @type Point + */ this.tileScaleOffset = new PIXI.Point(1,1); /** @@ -40,7 +57,22 @@ this.renderable = true; + /** + * The tint applied to the sprite. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ this.tint = 0xFFFFFF; + + /** + * The blend mode to be applied to the sprite + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; }; @@ -80,6 +112,13 @@ } }); +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.TilingSprite.prototype.onTextureUpdate = function() { // so if _width is 0 then width was not set.. diff --git a/src/pixi/filters/AbstractFilter.js b/src/pixi/filters/AbstractFilter.js index 94b895b..f9ca0b3 100644 --- a/src/pixi/filters/AbstractFilter.js +++ b/src/pixi/filters/AbstractFilter.js @@ -21,16 +21,26 @@ */ this.passes = [this]; + /** + * @property shaders + * @type Array an array of shaders + * @private + */ this.shaders = []; this.dirty = true; this.padding = 0; /** - @property uniforms - @private + * @property uniforms + * @type object + * @private */ this.uniforms = uniforms || {}; - + /** + * @property fragmentSrc + * @type Array + * @private + */ this.fragmentSrc = fragmentSrc || []; }; diff --git a/src/pixi/filters/AlphaMaskFilter.js b/src/pixi/filters/AlphaMaskFilter.js index cd1dff9..5d69412 100644 --- a/src/pixi/filters/AlphaMaskFilter.js +++ b/src/pixi/filters/AlphaMaskFilter.js @@ -6,7 +6,7 @@ * * The AlphaMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used offset the x and the g propery of the texture is used to offset the y. + * Currently the r property of the texture is used to offset the x and the g propery of the texture is used to offset the y. * @class AlphaMaskFilter * @contructor * @param texture {Texture} The texture used for the displacemtent map * must be power of 2 texture at the moment diff --git a/src/pixi/loaders/AssetLoader.js b/src/pixi/loaders/AssetLoader.js index c2e8ef1..0dda750 100644 --- a/src/pixi/loaders/AssetLoader.js +++ b/src/pixi/loaders/AssetLoader.js @@ -70,7 +70,12 @@ // constructor PIXI.AssetLoader.prototype.constructor = PIXI.AssetLoader; - +/** + * Given a filename, returns its extension, wil + * + * @method _getDataType + * @param str {String} the name of the asset + */ PIXI.AssetLoader.prototype._getDataType = function(str) { var test = 'data:'; diff --git a/src/pixi/loaders/AtlasLoader.js b/src/pixi/loaders/AtlasLoader.js index 2288e81..98e32c9 100644 --- a/src/pixi/loaders/AtlasLoader.js +++ b/src/pixi/loaders/AtlasLoader.js @@ -25,8 +25,11 @@ // constructor PIXI.AtlasLoader.constructor = PIXI.AtlasLoader; -/** - * This will begin loading the JSON file + + /** + * Starts loading the JSON file + * + * @method load */ PIXI.AtlasLoader.prototype.load = function () { this.ajaxRequest = new PIXI.AjaxRequest(); @@ -39,6 +42,7 @@ /** * Invoke when JSON file is loaded + * @method onAtlasLoaded * @private */ PIXI.AtlasLoader.prototype.onAtlasLoaded = function () { @@ -156,7 +160,8 @@ }; /** - * Invoke when json file loaded + * Invoke when json file has loaded + * @method onLoaded * @private */ PIXI.AtlasLoader.prototype.onLoaded = function () { @@ -174,6 +179,7 @@ /** * Invoke when error occured + * @method onError * @private */ PIXI.AtlasLoader.prototype.onError = function () { diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index d00a494..4fa32d5 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -17,7 +17,7 @@ PIXI.BitmapFontLoader = function(url, crossorigin) { /* - * i use texture packer to load the assets.. + * I use texture packer to load the assets.. * http://www.codeandweb.com/texturepacker * make sure to set the format as 'JSON' */ diff --git a/src/pixi/primitives/Graphics.js b/src/pixi/primitives/Graphics.js index 3a18769..b057305 100644 --- a/src/pixi/primitives/Graphics.js +++ b/src/pixi/primitives/Graphics.js @@ -5,8 +5,8 @@ /** * The Graphics class contains a set of methods that you can use to create primitive shapes and lines. - * It is important to know that with the webGL renderer only simple polys can be filled at this stage - * Complex polys will not be filled. Heres an example of a complex poly: http://www.goodboydigital.com/wp-content/uploads/2013/06/complexPolygon.png + * It is important to know that with the webGL renderer only simple polygons can be filled at this stage + * Complex polygons will not be filled. Heres an example of a complex polygon: http://www.goodboydigital.com/wp-content/uploads/2013/06/complexPolygon.png * * @class Graphics * @extends DisplayObjectContainer @@ -51,8 +51,23 @@ */ this.graphicsData = []; - this.tint = 0xFFFFFF;// * Math.random(); + /** + * The tint applied to the graphic shape. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ + this.tint = 0xFFFFFF;// * Math.random(); + + /** + * The blend mode to be applied to the graphic shape + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; /** @@ -64,12 +79,37 @@ */ this.currentPath = {points:[]}; + /** + * WebGL lines ? TODO-Alvin + * + * @property _webGL + * @type Array + * @private + */ this._webGL = []; + /** + * Whether this shape is used as a mask + * + * @property isMask + * @type isMask + */ this.isMask = false; + /** + * The bounds of the graphic shape as rectangle object + * + * @property bounds + * @type Rectangle + */ this.bounds = null; + /** + * the bound padding TODO-Alvin + * + * @property bounds + * @type Number + */ this.boundsPadding = 10; }; @@ -110,7 +150,7 @@ /** - * Specifies a line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. + * Specifies the line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. * * @method lineStyle * @param lineWidth {Number} width of the line to draw, will update the object's stored style @@ -135,8 +175,8 @@ * Moves the current drawing position to (x, y). * * @method moveTo - * @param x {Number} the X coord to move to - * @param y {Number} the Y coord to move to + * @param x {Number} the X coordinate to move to + * @param y {Number} the Y coordinate to move to */ PIXI.Graphics.prototype.moveTo = function(x, y) { @@ -155,8 +195,8 @@ * the current drawing position is then set to (x, y). * * @method lineTo - * @param x {Number} the X coord to draw to - * @param y {Number} the Y coord to draw to + * @param x {Number} the X coordinate to draw to + * @param y {Number} the Y coordinate to draw to */ PIXI.Graphics.prototype.lineTo = function(x, y) { @@ -169,8 +209,8 @@ * (such as lineTo() or drawCircle()) use when drawing. * * @method beginFill - * @param color {uint} the color of the fill - * @param alpha {Number} the alpha + * @param color {Number} the color of the fill + * @param alpha {Number} the alpha of the fill */ PIXI.Graphics.prototype.beginFill = function(color, alpha) { @@ -216,8 +256,8 @@ * Draws a circle. * * @method drawCircle - * @param x {Number} The X coord of the center of the circle - * @param y {Number} The Y coord of the center of the circle + * @param x {Number} The X coordinate of the center of the circle + * @param y {Number} The Y coordinate of the center of the circle * @param radius {Number} The radius of the circle */ PIXI.Graphics.prototype.drawCircle = function( x, y, radius) @@ -237,10 +277,10 @@ * Draws an ellipse. * * @method drawEllipse - * @param x {Number} - * @param y {Number} - * @param width {Number} - * @param height {Number} + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param width {Number} The width of the ellipse + * @param height {Number} The height of the ellipse */ PIXI.Graphics.prototype.drawEllipse = function( x, y, width, height) { @@ -293,6 +333,13 @@ return texture; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Graphics.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -354,6 +401,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Graphics.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -378,6 +432,12 @@ } }; +/** + * Retrieves the bounds of the graphic shape as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Graphics.prototype.getBounds = function() { if(!this.bounds)this.updateBounds(); @@ -446,6 +506,11 @@ return bounds; }; +/** + * Update the bounds of the object + * + * @method updateBounds + */ PIXI.Graphics.prototype.updateBounds = function() { @@ -510,6 +575,13 @@ this.bounds = new PIXI.Rectangle(minX - padding, minY - padding, (maxX - minX) + padding * 2, (maxY - minY) + padding * 2); }; + +/** + * Generates the cached sprite that was made using the generate TODO-Alvin + * + * @method _generateCachedSprite + * @private + */ PIXI.Graphics.prototype._generateCachedSprite = function() { var bounds = this.getBounds(); @@ -555,5 +627,3 @@ PIXI.Graphics.RECT = 1; PIXI.Graphics.CIRC = 2; PIXI.Graphics.ELIP = 3; - -PIXI.tempMatrix = PIXI.mat3.create(); diff --git a/src/pixi/utils/Detector.js b/src/pixi/utils/Detector.js index afe931e..cf4896b 100644 --- a/src/pixi/utils/Detector.js +++ b/src/pixi/utils/Detector.js @@ -7,13 +7,11 @@ * WebGL is the preferred renderer as it is a lot faster. If webGL is not supported by * the browser then this function will return a canvas renderer * - * @method autoDetectRenderer - * @static - * @param width {Number} the width of the renderers view - * @param height {Number} the height of the renderers view - * @param view {Canvas} the canvas to use as a view, optional - * @param transparent=false {Boolean} the transparency of the render view, default false - * @param antialias=false {Boolean} sets antialias (only applicable in webGL chrome at the moment) + * @param width=800 {Number} the width of the renderers view + * @param height=600 {Number} the height of the renderers view + * @param [view] {Canvas} the canvas to use as a view, optional + * @param [transparent=false] {Boolean} the transparency of the render view, default false + * @param [antialias=false] {Boolean} sets antialias (only applicable in webGL chrome at the moment) * * antialias */ diff --git a/src/pixi/utils/EventTarget.js b/src/pixi/utils/EventTarget.js index ce7d7a2..92dca1f 100644 --- a/src/pixi/utils/EventTarget.js +++ b/src/pixi/utils/EventTarget.js @@ -1,4 +1,8 @@ /** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** * https://github.com/mrdoob/eventtarget.js/ * THankS mr DOob! */ diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js new file mode 100644 index 0000000..4eb2d78 --- /dev/null +++ b/src/pixi/InteractionData.js @@ -0,0 +1,63 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * Holds all information related to an Interaction event + * + * @class InteractionData + * @constructor + */ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + // this is here for legacy... but will remove + this.local = new PIXI.Point(); + + /** + * The target Sprite that was interacted with + * + * @property target + * @type Sprite + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @property originalEvent + * @type Event + */ + this.originalEvent = null; +}; + +/** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @method getLocalPosition + * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off + * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject + */ +PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) +{ + var worldTransform = displayObject.worldTransform; + var global = this.global; + + // do a cheeky transform to get the mouse coords; + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + // set the mouse coords... + return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, + a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); +}; + +// constructor +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index efddfdd..16052ec 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -4,6 +4,7 @@ /** * The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive + * if its interactive parameter is set to true * This manager also supports multitouch. * * @class InteractionManager @@ -129,12 +130,12 @@ /** - * Sets the dom element which will receive mouse/touch events. This is useful for when you have other DOM - * elements ontop of the renderers Canvas element. With this you'll be able to delegate another dom element + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM + * elements on top of the renderers Canvas element. With this you'll be able to delegate another DOM element * to receive those events * * @method setTargetDomElement - * @param domElement {DOMElement} the dom element which will receive mouse and touch events + * @param domElement {DOMElement} the DOM element which will receive mouse and touch events * @private */ PIXI.InteractionManager.prototype.setTargetDomElement = function(domElement) @@ -315,7 +316,7 @@ { this.mouse.originalEvent = event || window.event; //IE uses window.event - if(PIXI.AUTO_PREVENT_DEFULT)this.mouse.originalEvent.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault(); // loop through interaction tree... // hit test each item! -> @@ -347,7 +348,13 @@ } }; - +/** + * Is called when the mouse button is moved out of the renderer element + * + * @method onMouseDown + * @param event {Event} The DOM event of a mouse button being moved out + * @private + */ PIXI.InteractionManager.prototype.onMouseOut = function() { var length = this.interactiveItems.length; @@ -418,11 +425,11 @@ }; /** - * Tests if the current mouse coords hit a sprite + * Tests if the current mouse coordinates hit a sprite * * @method hitTest * @param item {DisplayObject} The displayObject to test for a hit - * @param interactionData {InteractionData} The interactionData object to update in the case of a hit + * @param interactionData {InteractionData} The interactionData object to update in the case there is a hit * @private */ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) @@ -541,7 +548,7 @@ { var rect = this.interactionDOMElement.getBoundingClientRect(); - if(PIXI.AUTO_PREVENT_DEFULT)event.preventDefault(); + if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) @@ -660,64 +667,4 @@ this.pool.push(touchData); this.touchs[touchEvent.identifier] = null; } -}; - -/** - * Holds all information related to an Interaction event - * - * @class InteractionData - * @constructor - */ -PIXI.InteractionData = function() -{ - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @property global - * @type Point - */ - this.global = new PIXI.Point(); - - // this is here for legacy... but will remove - this.local = new PIXI.Point(); - - /** - * The target Sprite that was interacted with - * - * @property target - * @type Sprite - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @property originalEvent - * @type Event - */ - this.originalEvent = null; -}; - -/** - * This will return the local coords of the specified displayObject for this InteractionData - * - * @method getLocalPosition - * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off - * @return {Point} A point containing the coords of the InteractionData position relative to the DisplayObject - */ -PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) -{ - var worldTransform = displayObject.worldTransform; - var global = this.global; - - // do a cheeky transform to get the mouse coords; - var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], - a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], - id = 1 / (a00 * a11 + a01 * -a10); - // set the mouse coords... - return new PIXI.Point(a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id, - a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id); -}; - -// constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; +}; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 09ab87d..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,6 +41,6 @@ NEAREST:1 }; -// interaction frequancy +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; -PIXI.AUTO_PREVENT_DEFULT = true; \ No newline at end of file +PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 43ec63b..114b498 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -7,8 +7,8 @@ * * @class Circle * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this circle - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this circle + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle * @param radius {Number} The radius of the circle */ PIXI.Circle = function(x, y, radius) @@ -47,12 +47,12 @@ }; /** - * Checks if the x, and y coords passed to this function are contained within this circle + * Checks whether the x, and y coordinates passed to this function are contained within this circle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Circle.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Ellipse.js b/src/pixi/core/Ellipse.js index 4a4cf86..e65313a 100644 --- a/src/pixi/core/Ellipse.js +++ b/src/pixi/core/Ellipse.js @@ -7,8 +7,8 @@ * * @class Ellipse * @constructor - * @param x {Number} The X coord of the upper-left corner of the framing rectangle of this ellipse - * @param y {Number} The Y coord of the upper-left corner of the framing rectangle of this ellipse + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse * @param width {Number} The overall width of this ellipse * @param height {Number} The overall height of this ellipse */ @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this ellipse + * Checks whether the x and y coordinates passed to this function are contained within this ellipse * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this ellipse + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this ellipse */ PIXI.Ellipse.prototype.contains = function(x, y) { @@ -78,6 +78,12 @@ return (normx + normy < 0.25); }; +/** +* Returns the framing rectangle of the ellipse as a PIXI.Rectangle object +* +* @method getBounds +* @return {Rectangle} the framing rectangle +*/ PIXI.Ellipse.prototype.getBounds = function() { return new PIXI.Rectangle(this.x, this.y, this.width, this.height); diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 5414ca7..414cdec 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -1,19 +1,36 @@ - - -/* - * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV - * you both rock! +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 */ -function determineMatrixArrayType() { - PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array; - return PIXI.Matrix; +/* +* @class Matrix +* The Matrix class will choose the best type of array to use between +* a regular javascript Array and a Float32Array if the latter is available +* +*/ +PIXI.determineMatrixArrayType = function() { + return (typeof Float32Array !== 'undefined') ? Float32Array : Array; } -determineMatrixArrayType(); +PIXI.Matrix = PIXI.determineMatrixArrayType(); + + +/** + * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV + * you both rock! + * + * @class mat3 + * @static +*/ PIXI.mat3 = {}; +/* +* Creates a mat3 object +* +* @method mat3.create +* @static +*/ PIXI.mat3.create = function() { var matrix = new PIXI.Matrix(9); @@ -31,7 +48,14 @@ return matrix; }; - +/* +* Creates a mat3 identity matrix +* +* @method mat3.indentity +* @static +* @param matrix {Array|Float32Array} +* +*/ PIXI.mat3.identity = function(matrix) { matrix[0] = 1; @@ -47,33 +71,15 @@ return matrix; }; - -PIXI.mat4 = {}; - -PIXI.mat4.create = function() -{ - var matrix = new PIXI.Matrix(16); - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - - return matrix; -}; - +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat3.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -102,6 +108,14 @@ return dest; }; +/* +* Makes a copy of the matrix given in parameter +* +* @method mat3.clone +* @static +* @param mat {Array|Float32Array} +* +*/ PIXI.mat3.clone = function(mat) { var matrix = new PIXI.Matrix(9); @@ -119,6 +133,14 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* @method mat3.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -147,6 +169,17 @@ return dest; }; +PIXI.mat4 = {}; + +/* +* Appends the mat3 into a mat4, therefore making it a regular mat4 object +* +* @method mat3.toMat4 +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } @@ -175,9 +208,13 @@ }; -///// - - +/* +* Creates a new mat4 matrix +* +* @method mat4.create +* @static +* +*/ PIXI.mat4.create = function() { var matrix = new PIXI.Matrix(16); @@ -202,6 +239,16 @@ return matrix; }; +/* +* Re-arranges the matrix +* +* +* @method mat4.transpose +* @static +* @param mat {Array|Float32Array} +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +* +*/ PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -245,6 +292,15 @@ return dest; }; +/* +* Multiplies the matrices given as parameters by themselves +* +* @method mat4.multiply +* @static +* @param mat {Array|Float32Array} the first operand (matrix) +* @param mat2 {Array|Float32Array} the second operand (matrix) +* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix +*/ PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } @@ -293,3 +349,4 @@ }; PIXI.identityMatrix = PIXI.mat3.create(); +PIXI.tempMatrix = PIXI.mat3.create(); \ No newline at end of file diff --git a/src/pixi/core/Point.js b/src/pixi/core/Point.js index 9a6c3c3..a3c8e5e 100644 --- a/src/pixi/core/Point.js +++ b/src/pixi/core/Point.js @@ -7,8 +7,8 @@ * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {Number} position of the point on the x axis + * @param y {Number} position of the point on the y axis */ PIXI.Point = function(x, y) { diff --git a/src/pixi/core/Polygon.js b/src/pixi/core/Polygon.js index fe37d45..b118818 100644 --- a/src/pixi/core/Polygon.js +++ b/src/pixi/core/Polygon.js @@ -49,12 +49,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this polygon + * Checks whether the x and y coordinates passed to this function are contained within this polygon * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this polygon + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coordinates are within this polygon */ PIXI.Polygon.prototype.contains = function(x, y) { diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index 56047e8..b8edfcc 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -55,12 +55,12 @@ }; /** - * Checks if the x and y coords passed to this function are contained within this Rectangle + * Checks whether the x and y coordinates passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test - * @return {Boolean} if the x/y coords are within this Rectangle + * @param x {Number} The X coordinate of the point to test + * @param y {Number} The Y coordinate of the point to test + * @return {Boolean} Whether the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) { @@ -84,3 +84,4 @@ // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 20808d2..fb247d3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -173,12 +173,37 @@ this._sr = 0; this._cr = 1; - + /** + * The area the filter is applied to + * + * @property filterArea + * @type Rectangle + */ this.filterArea = new PIXI.Rectangle(0,0,1,1); - + /** + * The original, cached bounds of the object + * + * @property _bounds + * @type Rectangle + * @private + */ this._bounds = new PIXI.Rectangle(0, 0, 1, 1); + /** + * The most up-to-date bounds of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._currentBounds = null; + /** + * The original, cached mask of the object + * + * @property _currentBounds + * @type Rectangle + * @private + */ this._mask = null; /* @@ -419,11 +444,23 @@ this.worldAlpha = this.alpha * this.parent.worldAlpha; }; +/** + * Retrieves the bounds of the displayObject as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getBounds = function() { return PIXI.EmptyRectangle; }; +/** + * Retrieves the local bounds of the displayObject as a rectangle object + * + * @method getLocalBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObject.prototype.getLocalBounds = function() { var matrixCache = this.worldTransform; @@ -439,12 +476,25 @@ return bounds; }; +/** + * Sets the object's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the object will have as its current stage reference + */ PIXI.DisplayObject.prototype.setStageReference = function(stage) { this.stage = stage; if(this._interactive)this.stage.dirty = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) { // OVERWRITE; @@ -452,12 +502,16 @@ renderSession = renderSession; }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) { // OVERWRITE; // this line is just here to pass jshinting :) renderSession = renderSession; -}; - -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); - +}; \ No newline at end of file diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 435de83..9984b78 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -193,6 +193,12 @@ } }; +/** + * Retrieves the bounds of the displayObjectContainer as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.DisplayObjectContainer.prototype.getBounds = function() { if(this.children.length === 0)return PIXI.EmptyRectangle; @@ -241,6 +247,12 @@ return bounds; }; +/** + * Sets the container's stage reference, the stage this object is connected to + * + * @method setStageReference + * @param stage {Stage} the stage that the container will have as its current stage reference + */ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage) { this.stage = stage; @@ -253,6 +265,11 @@ } }; +/** + * removes the current stage reference of the container + * + * @method removeStageReference + */ PIXI.DisplayObjectContainer.prototype.removeStageReference = function() { @@ -267,6 +284,13 @@ this.stage = null; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0)return; @@ -311,6 +335,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession) { if(this.visible === false || this.alpha === 0)return; @@ -332,4 +363,3 @@ } }; - diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index c344265..9bc9cec 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -1,4 +1,6 @@ - +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -7,7 +9,11 @@ * @extends DisplayObjectContainer * @constructor * @param texture {Texture} The texture for this sprite - * @type String + * + * A sprite can be created directly from an image like this : + * var sprite = nex PIXI.Sprite.FromImage('assets/image.png'); + * yourStage.addChild(sprite); + * then obviously don't forget to add it to the stage you have already created */ PIXI.Sprite = function(texture) { @@ -15,9 +21,9 @@ /** * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * The default is 0,0 this means the texture's origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centred + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner * * @property anchor * @type Point @@ -158,6 +164,12 @@ this.updateFrame = true; }; +/** + * Retrieves the bounds of the sprite as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Sprite.prototype.getBounds = function() { @@ -231,7 +243,13 @@ return bounds; }; - +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -289,6 +307,13 @@ //TODO check culling }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Sprite.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index fb099af..a6ab59c 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -1,5 +1,14 @@ +/** + * @author Mat Groves http://matgroves.com/ + */ - +/** + * TODO-Alvin + * + * @class SpriteBatch + * @constructor + * @param texture {Texture} + */ PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -22,6 +31,12 @@ // alert("!") }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.SpriteBatch.prototype.updateTransform = function() { // dont need to! @@ -29,6 +44,13 @@ // PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession) { if(!this.visible || this.alpha <= 0 || !this.children.length)return; @@ -48,6 +70,13 @@ }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 0e63015..04f8050 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -8,8 +8,15 @@ * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white + * + * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * var stage = new PIXI.Stage(0xFFFFFF); + * where the parameter given is the background colour of the stage, in hex + * you will use this stage instance to add your sprites to it and therefore to the renderer + * Here is how to add a sprite to the stage : + * stage.addChild(sprite); */ PIXI.Stage = function(backgroundColor) { diff --git a/src/pixi/extras/Rope.js b/src/pixi/extras/Rope.js index 3cb9c25..24adfd6 100644 --- a/src/pixi/extras/Rope.js +++ b/src/pixi/extras/Rope.js @@ -1,7 +1,14 @@ -/** - * @author Mat Groves http://matgroves.com/ +/* @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** + * + * @class Rope + * @constructor + * @param texture {Texture} TODO-Alvin + * @param y {Array} TODO-Alvin + * + */ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); @@ -30,6 +37,11 @@ PIXI.Rope.prototype = Object.create( PIXI.Strip.prototype ); PIXI.Rope.prototype.constructor = PIXI.Rope; +/* + * Refreshes TODO-Alvin + * + * @method refresh + */ PIXI.Rope.prototype.refresh = function() { var points = this.points; @@ -96,6 +108,12 @@ } }; +/* + * Updates the object transform for rendering + * + * @method updateTransform + * @private + */ PIXI.Rope.prototype.updateTransform = function() { @@ -157,7 +175,13 @@ PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); }; - +/* + * Sets the texture that the Rope will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + */ PIXI.Rope.prototype.setTexture = function(texture) { // stop current texture diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index e7e18c5..2c1ca72 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -2,6 +2,16 @@ * @author Mat Groves http://matgroves.com/ */ + /** + * + * @class Strip + * @constructor + * @param texture {Texture} TODO-Alvin + * @param width {Number} the width of the TODO-Alvin + * @param height {Number} the height of the TODO-Alvin + * + */ + PIXI.Strip = function(texture, width, height) { PIXI.DisplayObjectContainer.call( this ); @@ -69,6 +79,14 @@ PIXI.Strip.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Strip.prototype.constructor = PIXI.Strip; +/* + * Sets the texture that the Strip will use + * TODO-Alvin + * + * @method setTexture + * @param texture {Texture} the texture that will be used + * @private + */ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES @@ -81,6 +99,13 @@ this.updateFrame = true; }; +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.Strip.prototype.onTextureUpdate = function() { this.updateFrame = true; diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index a3a86ca..59a1ad1 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -16,7 +16,19 @@ { PIXI.Sprite.call( this, texture); + /** + * The with of the tiling sprite + * + * @property width + * @type Number + */ this.width = width || 100; + /** + * The height of the tiling sprite + * + * @property height + * @type Number + */ this.height = height || 100; /** @@ -27,7 +39,12 @@ */ this.tileScale = new PIXI.Point(1,1); - + /** + * + * + * @property tileScaleOffset + * @type Point + */ this.tileScaleOffset = new PIXI.Point(1,1); /** @@ -40,7 +57,22 @@ this.renderable = true; + /** + * The tint applied to the sprite. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ this.tint = 0xFFFFFF; + + /** + * The blend mode to be applied to the sprite + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; }; @@ -80,6 +112,13 @@ } }); +/** + * When the texture is updated, this event will fire to update the scale and frame + * + * @method onTextureUpdate + * @param event + * @private + */ PIXI.TilingSprite.prototype.onTextureUpdate = function() { // so if _width is 0 then width was not set.. diff --git a/src/pixi/filters/AbstractFilter.js b/src/pixi/filters/AbstractFilter.js index 94b895b..f9ca0b3 100644 --- a/src/pixi/filters/AbstractFilter.js +++ b/src/pixi/filters/AbstractFilter.js @@ -21,16 +21,26 @@ */ this.passes = [this]; + /** + * @property shaders + * @type Array an array of shaders + * @private + */ this.shaders = []; this.dirty = true; this.padding = 0; /** - @property uniforms - @private + * @property uniforms + * @type object + * @private */ this.uniforms = uniforms || {}; - + /** + * @property fragmentSrc + * @type Array + * @private + */ this.fragmentSrc = fragmentSrc || []; }; diff --git a/src/pixi/filters/AlphaMaskFilter.js b/src/pixi/filters/AlphaMaskFilter.js index cd1dff9..5d69412 100644 --- a/src/pixi/filters/AlphaMaskFilter.js +++ b/src/pixi/filters/AlphaMaskFilter.js @@ -6,7 +6,7 @@ * * The AlphaMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used offset the x and the g propery of the texture is used to offset the y. + * Currently the r property of the texture is used to offset the x and the g propery of the texture is used to offset the y. * @class AlphaMaskFilter * @contructor * @param texture {Texture} The texture used for the displacemtent map * must be power of 2 texture at the moment diff --git a/src/pixi/loaders/AssetLoader.js b/src/pixi/loaders/AssetLoader.js index c2e8ef1..0dda750 100644 --- a/src/pixi/loaders/AssetLoader.js +++ b/src/pixi/loaders/AssetLoader.js @@ -70,7 +70,12 @@ // constructor PIXI.AssetLoader.prototype.constructor = PIXI.AssetLoader; - +/** + * Given a filename, returns its extension, wil + * + * @method _getDataType + * @param str {String} the name of the asset + */ PIXI.AssetLoader.prototype._getDataType = function(str) { var test = 'data:'; diff --git a/src/pixi/loaders/AtlasLoader.js b/src/pixi/loaders/AtlasLoader.js index 2288e81..98e32c9 100644 --- a/src/pixi/loaders/AtlasLoader.js +++ b/src/pixi/loaders/AtlasLoader.js @@ -25,8 +25,11 @@ // constructor PIXI.AtlasLoader.constructor = PIXI.AtlasLoader; -/** - * This will begin loading the JSON file + + /** + * Starts loading the JSON file + * + * @method load */ PIXI.AtlasLoader.prototype.load = function () { this.ajaxRequest = new PIXI.AjaxRequest(); @@ -39,6 +42,7 @@ /** * Invoke when JSON file is loaded + * @method onAtlasLoaded * @private */ PIXI.AtlasLoader.prototype.onAtlasLoaded = function () { @@ -156,7 +160,8 @@ }; /** - * Invoke when json file loaded + * Invoke when json file has loaded + * @method onLoaded * @private */ PIXI.AtlasLoader.prototype.onLoaded = function () { @@ -174,6 +179,7 @@ /** * Invoke when error occured + * @method onError * @private */ PIXI.AtlasLoader.prototype.onError = function () { diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index d00a494..4fa32d5 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -17,7 +17,7 @@ PIXI.BitmapFontLoader = function(url, crossorigin) { /* - * i use texture packer to load the assets.. + * I use texture packer to load the assets.. * http://www.codeandweb.com/texturepacker * make sure to set the format as 'JSON' */ diff --git a/src/pixi/primitives/Graphics.js b/src/pixi/primitives/Graphics.js index 3a18769..b057305 100644 --- a/src/pixi/primitives/Graphics.js +++ b/src/pixi/primitives/Graphics.js @@ -5,8 +5,8 @@ /** * The Graphics class contains a set of methods that you can use to create primitive shapes and lines. - * It is important to know that with the webGL renderer only simple polys can be filled at this stage - * Complex polys will not be filled. Heres an example of a complex poly: http://www.goodboydigital.com/wp-content/uploads/2013/06/complexPolygon.png + * It is important to know that with the webGL renderer only simple polygons can be filled at this stage + * Complex polygons will not be filled. Heres an example of a complex polygon: http://www.goodboydigital.com/wp-content/uploads/2013/06/complexPolygon.png * * @class Graphics * @extends DisplayObjectContainer @@ -51,8 +51,23 @@ */ this.graphicsData = []; - this.tint = 0xFFFFFF;// * Math.random(); + /** + * The tint applied to the graphic shape. This is a hex value + * + * @property tint + * @type Number + * @default 0xFFFFFF + */ + this.tint = 0xFFFFFF;// * Math.random(); + + /** + * The blend mode to be applied to the graphic shape + * + * @property blendMode + * @type Number + * @default PIXI.blendModes.NORMAL; + */ this.blendMode = PIXI.blendModes.NORMAL; /** @@ -64,12 +79,37 @@ */ this.currentPath = {points:[]}; + /** + * WebGL lines ? TODO-Alvin + * + * @property _webGL + * @type Array + * @private + */ this._webGL = []; + /** + * Whether this shape is used as a mask + * + * @property isMask + * @type isMask + */ this.isMask = false; + /** + * The bounds of the graphic shape as rectangle object + * + * @property bounds + * @type Rectangle + */ this.bounds = null; + /** + * the bound padding TODO-Alvin + * + * @property bounds + * @type Number + */ this.boundsPadding = 10; }; @@ -110,7 +150,7 @@ /** - * Specifies a line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. + * Specifies the line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. * * @method lineStyle * @param lineWidth {Number} width of the line to draw, will update the object's stored style @@ -135,8 +175,8 @@ * Moves the current drawing position to (x, y). * * @method moveTo - * @param x {Number} the X coord to move to - * @param y {Number} the Y coord to move to + * @param x {Number} the X coordinate to move to + * @param y {Number} the Y coordinate to move to */ PIXI.Graphics.prototype.moveTo = function(x, y) { @@ -155,8 +195,8 @@ * the current drawing position is then set to (x, y). * * @method lineTo - * @param x {Number} the X coord to draw to - * @param y {Number} the Y coord to draw to + * @param x {Number} the X coordinate to draw to + * @param y {Number} the Y coordinate to draw to */ PIXI.Graphics.prototype.lineTo = function(x, y) { @@ -169,8 +209,8 @@ * (such as lineTo() or drawCircle()) use when drawing. * * @method beginFill - * @param color {uint} the color of the fill - * @param alpha {Number} the alpha + * @param color {Number} the color of the fill + * @param alpha {Number} the alpha of the fill */ PIXI.Graphics.prototype.beginFill = function(color, alpha) { @@ -216,8 +256,8 @@ * Draws a circle. * * @method drawCircle - * @param x {Number} The X coord of the center of the circle - * @param y {Number} The Y coord of the center of the circle + * @param x {Number} The X coordinate of the center of the circle + * @param y {Number} The Y coordinate of the center of the circle * @param radius {Number} The radius of the circle */ PIXI.Graphics.prototype.drawCircle = function( x, y, radius) @@ -237,10 +277,10 @@ * Draws an ellipse. * * @method drawEllipse - * @param x {Number} - * @param y {Number} - * @param width {Number} - * @param height {Number} + * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse + * @param width {Number} The width of the ellipse + * @param height {Number} The height of the ellipse */ PIXI.Graphics.prototype.drawEllipse = function( x, y, width, height) { @@ -293,6 +333,13 @@ return texture; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Graphics.prototype._renderWebGL = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -354,6 +401,13 @@ } }; +/** +* Renders the object using the Canvas renderer +* +* @method _renderCanvas +* @param renderSession {RenderSession} +* @private +*/ PIXI.Graphics.prototype._renderCanvas = function(renderSession) { // if the sprite is not visible or the alpha is 0 then no need to render this element @@ -378,6 +432,12 @@ } }; +/** + * Retrieves the bounds of the graphic shape as a rectangle object + * + * @method getBounds + * @return {Rectangle} the rectangular bounding area + */ PIXI.Graphics.prototype.getBounds = function() { if(!this.bounds)this.updateBounds(); @@ -446,6 +506,11 @@ return bounds; }; +/** + * Update the bounds of the object + * + * @method updateBounds + */ PIXI.Graphics.prototype.updateBounds = function() { @@ -510,6 +575,13 @@ this.bounds = new PIXI.Rectangle(minX - padding, minY - padding, (maxX - minX) + padding * 2, (maxY - minY) + padding * 2); }; + +/** + * Generates the cached sprite that was made using the generate TODO-Alvin + * + * @method _generateCachedSprite + * @private + */ PIXI.Graphics.prototype._generateCachedSprite = function() { var bounds = this.getBounds(); @@ -555,5 +627,3 @@ PIXI.Graphics.RECT = 1; PIXI.Graphics.CIRC = 2; PIXI.Graphics.ELIP = 3; - -PIXI.tempMatrix = PIXI.mat3.create(); diff --git a/src/pixi/utils/Detector.js b/src/pixi/utils/Detector.js index afe931e..cf4896b 100644 --- a/src/pixi/utils/Detector.js +++ b/src/pixi/utils/Detector.js @@ -7,13 +7,11 @@ * WebGL is the preferred renderer as it is a lot faster. If webGL is not supported by * the browser then this function will return a canvas renderer * - * @method autoDetectRenderer - * @static - * @param width {Number} the width of the renderers view - * @param height {Number} the height of the renderers view - * @param view {Canvas} the canvas to use as a view, optional - * @param transparent=false {Boolean} the transparency of the render view, default false - * @param antialias=false {Boolean} sets antialias (only applicable in webGL chrome at the moment) + * @param width=800 {Number} the width of the renderers view + * @param height=600 {Number} the height of the renderers view + * @param [view] {Canvas} the canvas to use as a view, optional + * @param [transparent=false] {Boolean} the transparency of the render view, default false + * @param [antialias=false] {Boolean} sets antialias (only applicable in webGL chrome at the moment) * * antialias */ diff --git a/src/pixi/utils/EventTarget.js b/src/pixi/utils/EventTarget.js index ce7d7a2..92dca1f 100644 --- a/src/pixi/utils/EventTarget.js +++ b/src/pixi/utils/EventTarget.js @@ -1,4 +1,8 @@ /** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** * https://github.com/mrdoob/eventtarget.js/ * THankS mr DOob! */ diff --git a/src/pixi/utils/Utils.js b/src/pixi/utils/Utils.js index 90fd759..7328b18 100644 --- a/src/pixi/utils/Utils.js +++ b/src/pixi/utils/Utils.js @@ -1,3 +1,7 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating @@ -7,6 +11,8 @@ /** * A polyfill for requestAnimationFrame + * You can actually use both requestAnimationFrame and requestAnimFrame, + * you will still benefit from the polyfill * * @method requestAnimationFrame */ @@ -52,7 +58,12 @@ return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255]; }; - +/** + * Converts a color as an [R, G, B] array to a hex number + * + * @method rgb2hex + * @param rgb {Array} + */ PIXI.rgb2hex = function(rgb) { return ((rgb[0]*255 << 16) + (rgb[1]*255 << 8) + rgb[2]*255); }; @@ -145,6 +156,12 @@ }; */ +/** + * Checks whether the Canvas BlendModes are supported by the current browser + * + * @method canUseNewCanvasBlendModes + * @return {Boolean} whether they are supported + */ PIXI.canUseNewCanvasBlendModes = function() { var canvas = document.createElement('canvas'); @@ -159,7 +176,14 @@ return context.getImageData(0,0,1,1).data[0] === 0; }; -// this function is taken from Starling Framework as its pretty neat ;) +/** + * Given a number, this function returns the closest number that is a power of two + * this function is taken from Starling Framework as its pretty neat ;) + * + * @method getNextPowerOfTwo + * @param number {Number} + * @return {Number} the closest number that is a power of two + */ PIXI.getNextPowerOfTwo = function(number) { if (number > 0 && (number & (number - 1)) === 0) // see: http://goo.gl/D9kPj @@ -171,5 +195,3 @@ return result; } }; - -