diff --git a/src/pixi/renderers/canvas/CanvasGraphics.js b/src/pixi/renderers/canvas/CanvasGraphics.js index 9fe4194..5dacf25 100644 --- a/src/pixi/renderers/canvas/CanvasGraphics.js +++ b/src/pixi/renderers/canvas/CanvasGraphics.js @@ -10,15 +10,12 @@ */ PIXI.CanvasGraphics = function() { - }; - /* - * Renders the graphics object + * Renders a PIXI.Graphics object to a canvas. * * @static - * @private * @method renderGraphics * @param graphics {Graphics} the actual graphics object to render * @param context {CanvasRenderingContext2D} the 2d drawing method of the canvas @@ -88,7 +85,6 @@ context.globalAlpha = data.lineAlpha * worldAlpha; context.strokeRect(shape.x, shape.y, shape.width, shape.height); } - } else if(data.type === PIXI.Graphics.CIRC) { @@ -111,7 +107,6 @@ } else if(data.type === PIXI.Graphics.ELIP) { - // ellipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas var w = shape.width * 2; diff --git a/src/pixi/renderers/canvas/CanvasGraphics.js b/src/pixi/renderers/canvas/CanvasGraphics.js index 9fe4194..5dacf25 100644 --- a/src/pixi/renderers/canvas/CanvasGraphics.js +++ b/src/pixi/renderers/canvas/CanvasGraphics.js @@ -10,15 +10,12 @@ */ PIXI.CanvasGraphics = function() { - }; - /* - * Renders the graphics object + * Renders a PIXI.Graphics object to a canvas. * * @static - * @private * @method renderGraphics * @param graphics {Graphics} the actual graphics object to render * @param context {CanvasRenderingContext2D} the 2d drawing method of the canvas @@ -88,7 +85,6 @@ context.globalAlpha = data.lineAlpha * worldAlpha; context.strokeRect(shape.x, shape.y, shape.width, shape.height); } - } else if(data.type === PIXI.Graphics.CIRC) { @@ -111,7 +107,6 @@ } else if(data.type === PIXI.Graphics.ELIP) { - // ellipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas var w = shape.width * 2; diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index aa998c1..c3fabda 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -3,14 +3,13 @@ */ /** - * the CanvasRenderer draws the stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. - * Dont forget to add the view to your DOM or you will not see anything :) + * The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. + * Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :) * * @class CanvasRenderer * @constructor * @param [width=800] {Number} the width of the canvas view * @param [height=600] {Number} the height of the canvas view - * @param [options] {Object} The optional renderer parameters * @param [options.view] {HTMLCanvasElement} the canvas to use as a view, optional * @param [options.transparent=false] {Boolean} If the render view is transparent, default false @@ -37,8 +36,20 @@ PIXI.defaultRenderer = this; } + /** + * The renderer type. + * + * @property type + * @type Number + */ this.type = PIXI.CANVAS_RENDERER; + /** + * The resolution of the canvas. + * + * @property resolution + * @type Number + */ this.resolution = options.resolution; /** @@ -60,7 +71,6 @@ * @type Boolean */ this.transparent = options.transparent; - /** * The width of the canvas view @@ -84,7 +94,7 @@ this.height *= this.resolution; /** - * The canvas element that everything is drawn to + * The canvas element that everything is drawn to. * * @property view * @type HTMLCanvasElement @@ -98,12 +108,23 @@ */ this.context = this.view.getContext( "2d", { alpha: this.transparent } ); + /** + * Boolean flag controlling canvas refresh. + * + * @property refresh + * @type Boolean + */ this.refresh = true; - // hack to enable some hardware acceleration! - //this.view.style["transform"] = "translatez(0)"; this.view.width = this.width * this.resolution; this.view.height = this.height * this.resolution; + + /** + * Internal var. + * + * @property count + * @type Number + */ this.count = 0; /** @@ -151,7 +172,7 @@ PIXI.CanvasRenderer.prototype.constructor = PIXI.CanvasRenderer; /** - * Renders the stage to its canvas view + * Renders the Stage to this canvas view * * @method render * @param stage {Stage} the Stage element to be rendered @@ -233,8 +254,12 @@ displayObject._renderCanvas(this.renderSession); }; - - +/** + * Maps Pixi blend modes to canvas blend modes. + * + * @method mapBlendModes + * @private + */ PIXI.CanvasRenderer.prototype.mapBlendModes = function() { if(!PIXI.blendModesCanvas) diff --git a/src/pixi/renderers/canvas/CanvasGraphics.js b/src/pixi/renderers/canvas/CanvasGraphics.js index 9fe4194..5dacf25 100644 --- a/src/pixi/renderers/canvas/CanvasGraphics.js +++ b/src/pixi/renderers/canvas/CanvasGraphics.js @@ -10,15 +10,12 @@ */ PIXI.CanvasGraphics = function() { - }; - /* - * Renders the graphics object + * Renders a PIXI.Graphics object to a canvas. * * @static - * @private * @method renderGraphics * @param graphics {Graphics} the actual graphics object to render * @param context {CanvasRenderingContext2D} the 2d drawing method of the canvas @@ -88,7 +85,6 @@ context.globalAlpha = data.lineAlpha * worldAlpha; context.strokeRect(shape.x, shape.y, shape.width, shape.height); } - } else if(data.type === PIXI.Graphics.CIRC) { @@ -111,7 +107,6 @@ } else if(data.type === PIXI.Graphics.ELIP) { - // ellipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas var w = shape.width * 2; diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index aa998c1..c3fabda 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -3,14 +3,13 @@ */ /** - * the CanvasRenderer draws the stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. - * Dont forget to add the view to your DOM or you will not see anything :) + * The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. + * Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :) * * @class CanvasRenderer * @constructor * @param [width=800] {Number} the width of the canvas view * @param [height=600] {Number} the height of the canvas view - * @param [options] {Object} The optional renderer parameters * @param [options.view] {HTMLCanvasElement} the canvas to use as a view, optional * @param [options.transparent=false] {Boolean} If the render view is transparent, default false @@ -37,8 +36,20 @@ PIXI.defaultRenderer = this; } + /** + * The renderer type. + * + * @property type + * @type Number + */ this.type = PIXI.CANVAS_RENDERER; + /** + * The resolution of the canvas. + * + * @property resolution + * @type Number + */ this.resolution = options.resolution; /** @@ -60,7 +71,6 @@ * @type Boolean */ this.transparent = options.transparent; - /** * The width of the canvas view @@ -84,7 +94,7 @@ this.height *= this.resolution; /** - * The canvas element that everything is drawn to + * The canvas element that everything is drawn to. * * @property view * @type HTMLCanvasElement @@ -98,12 +108,23 @@ */ this.context = this.view.getContext( "2d", { alpha: this.transparent } ); + /** + * Boolean flag controlling canvas refresh. + * + * @property refresh + * @type Boolean + */ this.refresh = true; - // hack to enable some hardware acceleration! - //this.view.style["transform"] = "translatez(0)"; this.view.width = this.width * this.resolution; this.view.height = this.height * this.resolution; + + /** + * Internal var. + * + * @property count + * @type Number + */ this.count = 0; /** @@ -151,7 +172,7 @@ PIXI.CanvasRenderer.prototype.constructor = PIXI.CanvasRenderer; /** - * Renders the stage to its canvas view + * Renders the Stage to this canvas view * * @method render * @param stage {Stage} the Stage element to be rendered @@ -233,8 +254,12 @@ displayObject._renderCanvas(this.renderSession); }; - - +/** + * Maps Pixi blend modes to canvas blend modes. + * + * @method mapBlendModes + * @private + */ PIXI.CanvasRenderer.prototype.mapBlendModes = function() { if(!PIXI.blendModesCanvas) diff --git a/src/pixi/renderers/canvas/utils/CanvasBuffer.js b/src/pixi/renderers/canvas/utils/CanvasBuffer.js index f559383..6b7653a 100644 --- a/src/pixi/renderers/canvas/utils/CanvasBuffer.js +++ b/src/pixi/renderers/canvas/utils/CanvasBuffer.js @@ -1,32 +1,56 @@ /** - * @author Mat Groves - * - * + * @author Mat Groves http://matgroves.com/ @Doormat23 */ /** - * Creates a Canvas element of the given size + * 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) { + /** + * The width of the Canvas in pixels. + * + * @property width + * @type Number + */ this.width = width; + + /** + * The height of the Canvas in pixels. + * + * @property height + * @type Number + */ this.height = height; - this.canvas = document.createElement( "canvas" ); - this.context = this.canvas.getContext( "2d" ); + /** + * The Canvas object that belongs to this CanvasBuffer. + * + * @property canvas + * @type HTMLCanvasElement + */ + this.canvas = document.createElement("canvas"); + + /** + * A CanvasRenderingContext2D object representing a two-dimensional rendering context. + * + * @property context + * @type CanvasRenderingContext2D + */ + this.context = this.canvas.getContext("2d"); this.canvas.width = width; this.canvas.height = height; }; +PIXI.CanvasBuffer.prototype.constructor = PIXI.CanvasBuffer; + /** - * Clears the canvas that was created by the CanvasBuffer class + * Clears the canvas that was created by the CanvasBuffer class. * * @method clear * @private @@ -37,17 +61,14 @@ }; /** - * Resizes the canvas that was created by the CanvasBuffer class to the specified width and height + * Resizes the canvas 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; this.height = this.canvas.height = height; }; - diff --git a/src/pixi/renderers/canvas/CanvasGraphics.js b/src/pixi/renderers/canvas/CanvasGraphics.js index 9fe4194..5dacf25 100644 --- a/src/pixi/renderers/canvas/CanvasGraphics.js +++ b/src/pixi/renderers/canvas/CanvasGraphics.js @@ -10,15 +10,12 @@ */ PIXI.CanvasGraphics = function() { - }; - /* - * Renders the graphics object + * Renders a PIXI.Graphics object to a canvas. * * @static - * @private * @method renderGraphics * @param graphics {Graphics} the actual graphics object to render * @param context {CanvasRenderingContext2D} the 2d drawing method of the canvas @@ -88,7 +85,6 @@ context.globalAlpha = data.lineAlpha * worldAlpha; context.strokeRect(shape.x, shape.y, shape.width, shape.height); } - } else if(data.type === PIXI.Graphics.CIRC) { @@ -111,7 +107,6 @@ } else if(data.type === PIXI.Graphics.ELIP) { - // ellipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas var w = shape.width * 2; diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index aa998c1..c3fabda 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -3,14 +3,13 @@ */ /** - * the CanvasRenderer draws the stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. - * Dont forget to add the view to your DOM or you will not see anything :) + * The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. + * Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :) * * @class CanvasRenderer * @constructor * @param [width=800] {Number} the width of the canvas view * @param [height=600] {Number} the height of the canvas view - * @param [options] {Object} The optional renderer parameters * @param [options.view] {HTMLCanvasElement} the canvas to use as a view, optional * @param [options.transparent=false] {Boolean} If the render view is transparent, default false @@ -37,8 +36,20 @@ PIXI.defaultRenderer = this; } + /** + * The renderer type. + * + * @property type + * @type Number + */ this.type = PIXI.CANVAS_RENDERER; + /** + * The resolution of the canvas. + * + * @property resolution + * @type Number + */ this.resolution = options.resolution; /** @@ -60,7 +71,6 @@ * @type Boolean */ this.transparent = options.transparent; - /** * The width of the canvas view @@ -84,7 +94,7 @@ this.height *= this.resolution; /** - * The canvas element that everything is drawn to + * The canvas element that everything is drawn to. * * @property view * @type HTMLCanvasElement @@ -98,12 +108,23 @@ */ this.context = this.view.getContext( "2d", { alpha: this.transparent } ); + /** + * Boolean flag controlling canvas refresh. + * + * @property refresh + * @type Boolean + */ this.refresh = true; - // hack to enable some hardware acceleration! - //this.view.style["transform"] = "translatez(0)"; this.view.width = this.width * this.resolution; this.view.height = this.height * this.resolution; + + /** + * Internal var. + * + * @property count + * @type Number + */ this.count = 0; /** @@ -151,7 +172,7 @@ PIXI.CanvasRenderer.prototype.constructor = PIXI.CanvasRenderer; /** - * Renders the stage to its canvas view + * Renders the Stage to this canvas view * * @method render * @param stage {Stage} the Stage element to be rendered @@ -233,8 +254,12 @@ displayObject._renderCanvas(this.renderSession); }; - - +/** + * Maps Pixi blend modes to canvas blend modes. + * + * @method mapBlendModes + * @private + */ PIXI.CanvasRenderer.prototype.mapBlendModes = function() { if(!PIXI.blendModesCanvas) diff --git a/src/pixi/renderers/canvas/utils/CanvasBuffer.js b/src/pixi/renderers/canvas/utils/CanvasBuffer.js index f559383..6b7653a 100644 --- a/src/pixi/renderers/canvas/utils/CanvasBuffer.js +++ b/src/pixi/renderers/canvas/utils/CanvasBuffer.js @@ -1,32 +1,56 @@ /** - * @author Mat Groves - * - * + * @author Mat Groves http://matgroves.com/ @Doormat23 */ /** - * Creates a Canvas element of the given size + * 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) { + /** + * The width of the Canvas in pixels. + * + * @property width + * @type Number + */ this.width = width; + + /** + * The height of the Canvas in pixels. + * + * @property height + * @type Number + */ this.height = height; - this.canvas = document.createElement( "canvas" ); - this.context = this.canvas.getContext( "2d" ); + /** + * The Canvas object that belongs to this CanvasBuffer. + * + * @property canvas + * @type HTMLCanvasElement + */ + this.canvas = document.createElement("canvas"); + + /** + * A CanvasRenderingContext2D object representing a two-dimensional rendering context. + * + * @property context + * @type CanvasRenderingContext2D + */ + this.context = this.canvas.getContext("2d"); this.canvas.width = width; this.canvas.height = height; }; +PIXI.CanvasBuffer.prototype.constructor = PIXI.CanvasBuffer; + /** - * Clears the canvas that was created by the CanvasBuffer class + * Clears the canvas that was created by the CanvasBuffer class. * * @method clear * @private @@ -37,17 +61,14 @@ }; /** - * Resizes the canvas that was created by the CanvasBuffer class to the specified width and height + * Resizes the canvas 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; this.height = this.canvas.height = height; }; - diff --git a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js index 0c0d5bc..cd3f205 100644 --- a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js +++ b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js @@ -9,15 +9,14 @@ */ PIXI.CanvasMaskManager = function() { - }; /** - * This method adds it to the current stack of masks + * This method adds it to the current stack of masks. * * @method pushMask - * @param maskData the maskData that will be pushed - * @param context {CanvasRenderingContext2D} the 2d drawing method of the canvas + * @param maskData {Object} the maskData that will be pushed + * @param renderSession {Object} The renderSession whose context will be used for this mask manager. */ PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, renderSession) { @@ -45,12 +44,12 @@ }; /** - * Restores the current drawing context to the state it was before the mask was applied + * Restores the current drawing context to the state it was before the mask was applied. * * @method popMask - * @param context {CanvasRenderingContext2D} the 2d drawing method of the canvas + * @param renderSession {Object} The renderSession whose context will be used for this mask manager. */ PIXI.CanvasMaskManager.prototype.popMask = function(renderSession) { renderSession.context.restore(); -}; \ No newline at end of file +}; diff --git a/src/pixi/renderers/canvas/CanvasGraphics.js b/src/pixi/renderers/canvas/CanvasGraphics.js index 9fe4194..5dacf25 100644 --- a/src/pixi/renderers/canvas/CanvasGraphics.js +++ b/src/pixi/renderers/canvas/CanvasGraphics.js @@ -10,15 +10,12 @@ */ PIXI.CanvasGraphics = function() { - }; - /* - * Renders the graphics object + * Renders a PIXI.Graphics object to a canvas. * * @static - * @private * @method renderGraphics * @param graphics {Graphics} the actual graphics object to render * @param context {CanvasRenderingContext2D} the 2d drawing method of the canvas @@ -88,7 +85,6 @@ context.globalAlpha = data.lineAlpha * worldAlpha; context.strokeRect(shape.x, shape.y, shape.width, shape.height); } - } else if(data.type === PIXI.Graphics.CIRC) { @@ -111,7 +107,6 @@ } else if(data.type === PIXI.Graphics.ELIP) { - // ellipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas var w = shape.width * 2; diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index aa998c1..c3fabda 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -3,14 +3,13 @@ */ /** - * the CanvasRenderer draws the stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. - * Dont forget to add the view to your DOM or you will not see anything :) + * The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. + * Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :) * * @class CanvasRenderer * @constructor * @param [width=800] {Number} the width of the canvas view * @param [height=600] {Number} the height of the canvas view - * @param [options] {Object} The optional renderer parameters * @param [options.view] {HTMLCanvasElement} the canvas to use as a view, optional * @param [options.transparent=false] {Boolean} If the render view is transparent, default false @@ -37,8 +36,20 @@ PIXI.defaultRenderer = this; } + /** + * The renderer type. + * + * @property type + * @type Number + */ this.type = PIXI.CANVAS_RENDERER; + /** + * The resolution of the canvas. + * + * @property resolution + * @type Number + */ this.resolution = options.resolution; /** @@ -60,7 +71,6 @@ * @type Boolean */ this.transparent = options.transparent; - /** * The width of the canvas view @@ -84,7 +94,7 @@ this.height *= this.resolution; /** - * The canvas element that everything is drawn to + * The canvas element that everything is drawn to. * * @property view * @type HTMLCanvasElement @@ -98,12 +108,23 @@ */ this.context = this.view.getContext( "2d", { alpha: this.transparent } ); + /** + * Boolean flag controlling canvas refresh. + * + * @property refresh + * @type Boolean + */ this.refresh = true; - // hack to enable some hardware acceleration! - //this.view.style["transform"] = "translatez(0)"; this.view.width = this.width * this.resolution; this.view.height = this.height * this.resolution; + + /** + * Internal var. + * + * @property count + * @type Number + */ this.count = 0; /** @@ -151,7 +172,7 @@ PIXI.CanvasRenderer.prototype.constructor = PIXI.CanvasRenderer; /** - * Renders the stage to its canvas view + * Renders the Stage to this canvas view * * @method render * @param stage {Stage} the Stage element to be rendered @@ -233,8 +254,12 @@ displayObject._renderCanvas(this.renderSession); }; - - +/** + * Maps Pixi blend modes to canvas blend modes. + * + * @method mapBlendModes + * @private + */ PIXI.CanvasRenderer.prototype.mapBlendModes = function() { if(!PIXI.blendModesCanvas) diff --git a/src/pixi/renderers/canvas/utils/CanvasBuffer.js b/src/pixi/renderers/canvas/utils/CanvasBuffer.js index f559383..6b7653a 100644 --- a/src/pixi/renderers/canvas/utils/CanvasBuffer.js +++ b/src/pixi/renderers/canvas/utils/CanvasBuffer.js @@ -1,32 +1,56 @@ /** - * @author Mat Groves - * - * + * @author Mat Groves http://matgroves.com/ @Doormat23 */ /** - * Creates a Canvas element of the given size + * 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) { + /** + * The width of the Canvas in pixels. + * + * @property width + * @type Number + */ this.width = width; + + /** + * The height of the Canvas in pixels. + * + * @property height + * @type Number + */ this.height = height; - this.canvas = document.createElement( "canvas" ); - this.context = this.canvas.getContext( "2d" ); + /** + * The Canvas object that belongs to this CanvasBuffer. + * + * @property canvas + * @type HTMLCanvasElement + */ + this.canvas = document.createElement("canvas"); + + /** + * A CanvasRenderingContext2D object representing a two-dimensional rendering context. + * + * @property context + * @type CanvasRenderingContext2D + */ + this.context = this.canvas.getContext("2d"); this.canvas.width = width; this.canvas.height = height; }; +PIXI.CanvasBuffer.prototype.constructor = PIXI.CanvasBuffer; + /** - * Clears the canvas that was created by the CanvasBuffer class + * Clears the canvas that was created by the CanvasBuffer class. * * @method clear * @private @@ -37,17 +61,14 @@ }; /** - * Resizes the canvas that was created by the CanvasBuffer class to the specified width and height + * Resizes the canvas 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; this.height = this.canvas.height = height; }; - diff --git a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js index 0c0d5bc..cd3f205 100644 --- a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js +++ b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js @@ -9,15 +9,14 @@ */ PIXI.CanvasMaskManager = function() { - }; /** - * This method adds it to the current stack of masks + * This method adds it to the current stack of masks. * * @method pushMask - * @param maskData the maskData that will be pushed - * @param context {CanvasRenderingContext2D} the 2d drawing method of the canvas + * @param maskData {Object} the maskData that will be pushed + * @param renderSession {Object} The renderSession whose context will be used for this mask manager. */ PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, renderSession) { @@ -45,12 +44,12 @@ }; /** - * Restores the current drawing context to the state it was before the mask was applied + * Restores the current drawing context to the state it was before the mask was applied. * * @method popMask - * @param context {CanvasRenderingContext2D} the 2d drawing method of the canvas + * @param renderSession {Object} The renderSession whose context will be used for this mask manager. */ PIXI.CanvasMaskManager.prototype.popMask = function(renderSession) { renderSession.context.restore(); -}; \ No newline at end of file +}; diff --git a/src/pixi/renderers/canvas/utils/CanvasTinter.js b/src/pixi/renderers/canvas/utils/CanvasTinter.js index b98aea1..76084ff 100644 --- a/src/pixi/renderers/canvas/utils/CanvasTinter.js +++ b/src/pixi/renderers/canvas/utils/CanvasTinter.js @@ -1,7 +1,5 @@ /** - * @author Mat Groves - * - * + * @author Mat Groves http://matgroves.com/ @Doormat23 */ /** @@ -11,23 +9,18 @@ */ PIXI.CanvasTinter = function() { - /// this.textureCach }; -//PIXI.CanvasTinter.cachTint = true; - - /** - * Basically this method just needs a sprite and a color and tints the sprite - * with the given color + * Basically this method just needs a sprite and a color and tints the sprite with the given color. * * @method getTintedTexture * @param sprite {Sprite} the sprite to tint * @param color {Number} the color to use to tint the sprite with + * @return {HTMLCanvasElement} The tinted canvas */ PIXI.CanvasTinter.getTintedTexture = function(sprite, color) { - var texture = sprite.texture; color = PIXI.CanvasTinter.roundColor(color); @@ -42,8 +35,6 @@ var canvas = PIXI.CanvasTinter.canvas || document.createElement("canvas"); //PIXI.CanvasTinter.tintWithPerPixel(texture, stringColor, canvas); - - PIXI.CanvasTinter.tintMethod(texture, color, canvas); if(PIXI.CanvasTinter.convertTintToImage) @@ -56,20 +47,19 @@ } else { - texture.tintCache[stringColor] = canvas; // if we are not converting the texture to an image then we need to lose the reference to the canvas PIXI.CanvasTinter.canvas = null; - } return canvas; }; /** - * Tint a texture using the "multiply" operation + * Tint a texture using the "multiply" operation. + * * @method tintWithMultiply - * @param texture {texture} the texture to tint + * @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 */ @@ -112,7 +102,8 @@ }; /** - * Tint a texture using the "overlay" operation + * 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 @@ -126,8 +117,6 @@ canvas.width = crop.width; canvas.height = crop.height; - - context.globalCompositeOperation = "copy"; context.fillStyle = "#" + ("00000" + ( color | 0).toString(16)).substr(-6); @@ -143,14 +132,13 @@ 0, crop.width, crop.height); - //context.globalCompositeOperation = "copy"; - }; /** - * Tint a texture pixel per pixel + * 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 @@ -194,7 +182,8 @@ }; /** - * Rounds the specified color according to the PIXI.CanvasTinter.cacheStepsPerColorChannel + * Rounds the specified color according to the PIXI.CanvasTinter.cacheStepsPerColorChannel. + * * @method roundColor * @param color {number} the color to round, should be a hex color */ @@ -212,16 +201,15 @@ }; /** - * - * Number of steps which will be used as a cap when rounding colors + * 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 + * Tint cache boolean flag. * * @property convertTintToImage * @type Boolean @@ -229,12 +217,16 @@ PIXI.CanvasTinter.convertTintToImage = false; /** - * Whether or not the Canvas BlendModes are supported, consequently the ability to tint using the multiply method + * 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(); +/** + * The tinting method that will be used. + * + * @method tintMethod + */ PIXI.CanvasTinter.tintMethod = PIXI.CanvasTinter.canUseMultiply ? PIXI.CanvasTinter.tintWithMultiply : PIXI.CanvasTinter.tintWithPerPixel; -