diff --git a/src/pixi/renderers/canvas/CanvasGraphics.js b/src/pixi/renderers/canvas/CanvasGraphics.js index a34c400..cdb4b87 100644 --- a/src/pixi/renderers/canvas/CanvasGraphics.js +++ b/src/pixi/renderers/canvas/CanvasGraphics.js @@ -20,8 +20,8 @@ * @static * @private * @method renderGraphics - * @param graphics {Graphics} - * @param context {Context2D} + * @param graphics {Graphics} the actual graphics object to render + * @param context {Context2D} the 2d drawing method of the canvas */ PIXI.CanvasGraphics.renderGraphics = function(graphics, context) { @@ -154,8 +154,8 @@ * @static * @private * @method renderGraphicsMask - * @param graphics {Graphics} - * @param context {Context2D} + * @param graphics {Graphics} the graphics which will be used as a mask + * @param context {Context2D} the context 2d method of the canvas */ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context) { diff --git a/src/pixi/renderers/canvas/CanvasGraphics.js b/src/pixi/renderers/canvas/CanvasGraphics.js index a34c400..cdb4b87 100644 --- a/src/pixi/renderers/canvas/CanvasGraphics.js +++ b/src/pixi/renderers/canvas/CanvasGraphics.js @@ -20,8 +20,8 @@ * @static * @private * @method renderGraphics - * @param graphics {Graphics} - * @param context {Context2D} + * @param graphics {Graphics} the actual graphics object to render + * @param context {Context2D} the 2d drawing method of the canvas */ PIXI.CanvasGraphics.renderGraphics = function(graphics, context) { @@ -154,8 +154,8 @@ * @static * @private * @method renderGraphicsMask - * @param graphics {Graphics} - * @param context {Context2D} + * @param graphics {Graphics} the graphics which will be used as a mask + * @param context {Context2D} the context 2d method of the canvas */ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context) { diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index fb2c16e..4203ab1 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -8,9 +8,9 @@ * * @class CanvasRenderer * @constructor - * @param width=0 {Number} the width of the canvas view - * @param height=0 {Number} the height of the canvas view - * @param view {Canvas} the canvas to use as a view, optional + * @param width=800 {Number} the width of the canvas view + * @param height=600 {Number} the height of the canvas view + * @param view {{HTMLCanvasElement}} the canvas to use as a view, optional * @param transparent=false {Boolean} the transparency of the render view, default false */ PIXI.CanvasRenderer = function(width, height, view, transparent) @@ -19,6 +19,13 @@ this.type = PIXI.CANVAS_RENDERER; + + /** + * Whether the render view is transparent + * + * @property transparent + * @type Boolean + */ this.transparent = !!transparent; if(!PIXI.blendModesCanvas) @@ -87,17 +94,17 @@ this.height = height || 600; /** - * The canvas element that the everything is drawn to + * The canvas element that everything is drawn to * * @property view - * @type Canvas + * @type {HTMLCanvasElement} */ this.view = view || document.createElement( "canvas" ); /** - * The canvas context that the everything is drawn to + * The canvas 2d context that everything is drawn to * @property context - * @type Canvas 2d Context + * @type HTMLCanvasElement 2d Context */ this.context = this.view.getContext( "2d", { alpha: this.transparent } ); @@ -109,6 +116,11 @@ this.view.height = this.height; this.count = 0; + /** + * Instance of a PIXI.CanvasMaskManager, handles masking when using the canvas renderer + * @property CanvasMaskManager + * @type CanvasMaskManager + */ this.maskManager = new PIXI.CanvasMaskManager(); this.renderSession = { @@ -190,7 +202,7 @@ }; /** - * resizes the canvas view to the specified width and height + * Resizes the canvas view to the specified width and height * * @method resize * @param width {Number} the new width of the canvas view @@ -210,11 +222,12 @@ * * @method renderDisplayObject * @param displayObject {DisplayObject} The displayObject to render + * @param context {Context2D} the context 2d method of the canvas * @private */ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject, context) { - // no longer recurrsive! + // no longer recursive! //var transform; //var context = this.context; @@ -312,6 +325,15 @@ } }; +/** + * Creates a Canvas element of the given size + * + * @method CanvasBuffer + * @param width {Number} the width for the newly created canvas + * @param height {Number} the height for the newly created canvas + * @static + * @private + */ PIXI.CanvasBuffer = function(width, height) { this.width = width; @@ -324,11 +346,26 @@ this.canvas.height = height; }; +/** + * Clears the canvas that was created by the CanvasBuffer class + * + * @method clear + * @private + */ PIXI.CanvasBuffer.prototype.clear = function() { this.context.clearRect(0,0, this.width, this.height); }; +/** + * Resizes the canvas that was created by the CanvasBuffer class to the specified width and height + * + * @method resize + * @param width {Number} the new width of the canvas + * @param height {Number} the new height of the canvas + * @private + */ + PIXI.CanvasBuffer.prototype.resize = function(width, height) { this.width = this.canvas.width = width; diff --git a/src/pixi/renderers/canvas/CanvasGraphics.js b/src/pixi/renderers/canvas/CanvasGraphics.js index a34c400..cdb4b87 100644 --- a/src/pixi/renderers/canvas/CanvasGraphics.js +++ b/src/pixi/renderers/canvas/CanvasGraphics.js @@ -20,8 +20,8 @@ * @static * @private * @method renderGraphics - * @param graphics {Graphics} - * @param context {Context2D} + * @param graphics {Graphics} the actual graphics object to render + * @param context {Context2D} the 2d drawing method of the canvas */ PIXI.CanvasGraphics.renderGraphics = function(graphics, context) { @@ -154,8 +154,8 @@ * @static * @private * @method renderGraphicsMask - * @param graphics {Graphics} - * @param context {Context2D} + * @param graphics {Graphics} the graphics which will be used as a mask + * @param context {Context2D} the context 2d method of the canvas */ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context) { diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index fb2c16e..4203ab1 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -8,9 +8,9 @@ * * @class CanvasRenderer * @constructor - * @param width=0 {Number} the width of the canvas view - * @param height=0 {Number} the height of the canvas view - * @param view {Canvas} the canvas to use as a view, optional + * @param width=800 {Number} the width of the canvas view + * @param height=600 {Number} the height of the canvas view + * @param view {{HTMLCanvasElement}} the canvas to use as a view, optional * @param transparent=false {Boolean} the transparency of the render view, default false */ PIXI.CanvasRenderer = function(width, height, view, transparent) @@ -19,6 +19,13 @@ this.type = PIXI.CANVAS_RENDERER; + + /** + * Whether the render view is transparent + * + * @property transparent + * @type Boolean + */ this.transparent = !!transparent; if(!PIXI.blendModesCanvas) @@ -87,17 +94,17 @@ this.height = height || 600; /** - * The canvas element that the everything is drawn to + * The canvas element that everything is drawn to * * @property view - * @type Canvas + * @type {HTMLCanvasElement} */ this.view = view || document.createElement( "canvas" ); /** - * The canvas context that the everything is drawn to + * The canvas 2d context that everything is drawn to * @property context - * @type Canvas 2d Context + * @type HTMLCanvasElement 2d Context */ this.context = this.view.getContext( "2d", { alpha: this.transparent } ); @@ -109,6 +116,11 @@ this.view.height = this.height; this.count = 0; + /** + * Instance of a PIXI.CanvasMaskManager, handles masking when using the canvas renderer + * @property CanvasMaskManager + * @type CanvasMaskManager + */ this.maskManager = new PIXI.CanvasMaskManager(); this.renderSession = { @@ -190,7 +202,7 @@ }; /** - * resizes the canvas view to the specified width and height + * Resizes the canvas view to the specified width and height * * @method resize * @param width {Number} the new width of the canvas view @@ -210,11 +222,12 @@ * * @method renderDisplayObject * @param displayObject {DisplayObject} The displayObject to render + * @param context {Context2D} the context 2d method of the canvas * @private */ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject, context) { - // no longer recurrsive! + // no longer recursive! //var transform; //var context = this.context; @@ -312,6 +325,15 @@ } }; +/** + * Creates a Canvas element of the given size + * + * @method CanvasBuffer + * @param width {Number} the width for the newly created canvas + * @param height {Number} the height for the newly created canvas + * @static + * @private + */ PIXI.CanvasBuffer = function(width, height) { this.width = width; @@ -324,11 +346,26 @@ this.canvas.height = height; }; +/** + * Clears the canvas that was created by the CanvasBuffer class + * + * @method clear + * @private + */ PIXI.CanvasBuffer.prototype.clear = function() { this.context.clearRect(0,0, this.width, this.height); }; +/** + * Resizes the canvas that was created by the CanvasBuffer class to the specified width and height + * + * @method resize + * @param width {Number} the new width of the canvas + * @param height {Number} the new height of the canvas + * @private + */ + PIXI.CanvasBuffer.prototype.resize = function(width, height) { this.width = this.canvas.width = width; diff --git a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js index e27902a..3bbca21 100644 --- a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js +++ b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js @@ -3,12 +3,23 @@ * * */ - +/** + * A set of functions used to handle masking + * + * @class CanvasMaskManager + */ PIXI.CanvasMaskManager = function() { }; +/** + * TODO-Alvin + * + * @method pushMask + * @param maskData TODO-Alvin + * @param context {Context2D} the 2d drawing method of the canvas + */ PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, context) { context.save(); @@ -28,6 +39,12 @@ maskData.worldAlpha = cacheAlpha; }; +/** + * Restores the current drawing context to the state it was before the mask was applied + * + * @method popMask + * @param context {Context2D} the 2d drawing method of the canvas + */ PIXI.CanvasMaskManager.prototype.popMask = function(context) { context.restore(); diff --git a/src/pixi/renderers/canvas/CanvasGraphics.js b/src/pixi/renderers/canvas/CanvasGraphics.js index a34c400..cdb4b87 100644 --- a/src/pixi/renderers/canvas/CanvasGraphics.js +++ b/src/pixi/renderers/canvas/CanvasGraphics.js @@ -20,8 +20,8 @@ * @static * @private * @method renderGraphics - * @param graphics {Graphics} - * @param context {Context2D} + * @param graphics {Graphics} the actual graphics object to render + * @param context {Context2D} the 2d drawing method of the canvas */ PIXI.CanvasGraphics.renderGraphics = function(graphics, context) { @@ -154,8 +154,8 @@ * @static * @private * @method renderGraphicsMask - * @param graphics {Graphics} - * @param context {Context2D} + * @param graphics {Graphics} the graphics which will be used as a mask + * @param context {Context2D} the context 2d method of the canvas */ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context) { diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index fb2c16e..4203ab1 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -8,9 +8,9 @@ * * @class CanvasRenderer * @constructor - * @param width=0 {Number} the width of the canvas view - * @param height=0 {Number} the height of the canvas view - * @param view {Canvas} the canvas to use as a view, optional + * @param width=800 {Number} the width of the canvas view + * @param height=600 {Number} the height of the canvas view + * @param view {{HTMLCanvasElement}} the canvas to use as a view, optional * @param transparent=false {Boolean} the transparency of the render view, default false */ PIXI.CanvasRenderer = function(width, height, view, transparent) @@ -19,6 +19,13 @@ this.type = PIXI.CANVAS_RENDERER; + + /** + * Whether the render view is transparent + * + * @property transparent + * @type Boolean + */ this.transparent = !!transparent; if(!PIXI.blendModesCanvas) @@ -87,17 +94,17 @@ this.height = height || 600; /** - * The canvas element that the everything is drawn to + * The canvas element that everything is drawn to * * @property view - * @type Canvas + * @type {HTMLCanvasElement} */ this.view = view || document.createElement( "canvas" ); /** - * The canvas context that the everything is drawn to + * The canvas 2d context that everything is drawn to * @property context - * @type Canvas 2d Context + * @type HTMLCanvasElement 2d Context */ this.context = this.view.getContext( "2d", { alpha: this.transparent } ); @@ -109,6 +116,11 @@ this.view.height = this.height; this.count = 0; + /** + * Instance of a PIXI.CanvasMaskManager, handles masking when using the canvas renderer + * @property CanvasMaskManager + * @type CanvasMaskManager + */ this.maskManager = new PIXI.CanvasMaskManager(); this.renderSession = { @@ -190,7 +202,7 @@ }; /** - * resizes the canvas view to the specified width and height + * Resizes the canvas view to the specified width and height * * @method resize * @param width {Number} the new width of the canvas view @@ -210,11 +222,12 @@ * * @method renderDisplayObject * @param displayObject {DisplayObject} The displayObject to render + * @param context {Context2D} the context 2d method of the canvas * @private */ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject, context) { - // no longer recurrsive! + // no longer recursive! //var transform; //var context = this.context; @@ -312,6 +325,15 @@ } }; +/** + * Creates a Canvas element of the given size + * + * @method CanvasBuffer + * @param width {Number} the width for the newly created canvas + * @param height {Number} the height for the newly created canvas + * @static + * @private + */ PIXI.CanvasBuffer = function(width, height) { this.width = width; @@ -324,11 +346,26 @@ this.canvas.height = height; }; +/** + * Clears the canvas that was created by the CanvasBuffer class + * + * @method clear + * @private + */ PIXI.CanvasBuffer.prototype.clear = function() { this.context.clearRect(0,0, this.width, this.height); }; +/** + * Resizes the canvas that was created by the CanvasBuffer class to the specified width and height + * + * @method resize + * @param width {Number} the new width of the canvas + * @param height {Number} the new height of the canvas + * @private + */ + PIXI.CanvasBuffer.prototype.resize = function(width, height) { this.width = this.canvas.width = width; diff --git a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js index e27902a..3bbca21 100644 --- a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js +++ b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js @@ -3,12 +3,23 @@ * * */ - +/** + * A set of functions used to handle masking + * + * @class CanvasMaskManager + */ PIXI.CanvasMaskManager = function() { }; +/** + * TODO-Alvin + * + * @method pushMask + * @param maskData TODO-Alvin + * @param context {Context2D} the 2d drawing method of the canvas + */ PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, context) { context.save(); @@ -28,6 +39,12 @@ maskData.worldAlpha = cacheAlpha; }; +/** + * Restores the current drawing context to the state it was before the mask was applied + * + * @method popMask + * @param context {Context2D} the 2d drawing method of the canvas + */ PIXI.CanvasMaskManager.prototype.popMask = function(context) { context.restore(); diff --git a/src/pixi/renderers/canvas/utils/CanvasTinter.js b/src/pixi/renderers/canvas/utils/CanvasTinter.js index 046809f..5bb4e3e 100644 --- a/src/pixi/renderers/canvas/utils/CanvasTinter.js +++ b/src/pixi/renderers/canvas/utils/CanvasTinter.js @@ -5,6 +5,11 @@ * */ +/** + * @class CanvasTinter + * @constructor + * @static + */ PIXI.CanvasTinter = function() { /// this.textureCach @@ -13,6 +18,12 @@ //PIXI.CanvasTinter.cachTint = true; +/** + * TODO-Alvin + * @method getTintedTexture + * @param sprite {Sprite} the sprite to tint + * @param color {Number} the color to use to tint the sprite with + */ PIXI.CanvasTinter.getTintedTexture = function(sprite, color) { // @@ -58,6 +69,13 @@ return canvas; }; +/** + * Tint a texture using the "multiply" operation + * @method tintWithMultiply + * @param texture {texture} the texture to tint + * @param color {Number} the color to use to tint the sprite with + * @param canvas {HTMLCanvasElement} the current canvas + */ PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas) { var context = canvas.getContext( "2d" ); @@ -96,6 +114,13 @@ frame.height); }; +/** + * Tint a texture using the "overlay" operation + * @method tintWithOverlay + * @param texture {texture} the texture to tint + * @param color {Number} the color to use to tint the sprite with + * @param canvas {HTMLCanvasElement} the current canvas + */ PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas) { var context = canvas.getContext( "2d" ); @@ -127,7 +152,13 @@ }; - +/** + * Tint a texture pixel per pixel + * @method tintPerPixel + * @param texture {texture} the texture to tint + * @param color {Number} the color to use to tint the sprite with + * @param canvas {HTMLCanvasElement} the current canvas + */ PIXI.CanvasTinter.tintWithPerPixel = function(texture, color, canvas) { var context = canvas.getContext( "2d" ); @@ -165,6 +196,11 @@ context.putImageData(pixelData, 0, 0); }; +/** + * Rounds the specified color according to the PIXI.CanvasTinter.cacheStepsPerColorChannel + * @method roundColor + * @param color {number} the color to round, should be a hex color + */ PIXI.CanvasTinter.roundColor = function(color) { var step = PIXI.CanvasTinter.cacheStepsPerColorChannel; @@ -178,11 +214,30 @@ return PIXI.rgb2hex(rgbValues); }; +/** + * + * Number of steps which will be used as a cap when rounding colors + * + * @property cacheStepsPerColorChannel + * @type Number + */ PIXI.CanvasTinter.cacheStepsPerColorChannel = 8; +/** + * + * Number of steps which will be used as a cap when rounding colors + * + * @property convertTintToImage + * @type Boolean + */ PIXI.CanvasTinter.convertTintToImage = false; +/** + * Whether or not the Canvas BlendModes are supported, consequently the ability to tint using the multiply method + * + * @property canUseMultiply + * @type Boolean + */ PIXI.CanvasTinter.canUseMultiply = PIXI.canUseNewCanvasBlendModes(); PIXI.CanvasTinter.tintMethod = PIXI.CanvasTinter.canUseMultiply ? PIXI.CanvasTinter.tintWithMultiply : PIXI.CanvasTinter.tintWithPerPixel; -