diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index 8e79054..f46d1c0 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -27,14 +27,14 @@ // set up the main bits.. this.uvs = new PIXI.Float32Array([0, 1, - 1, 1, - 1, 0, - 0,1]); + 1, 1, + 1, 0, + 0, 1]); this.verticies = new PIXI.Float32Array([0, 0, - 100,0, - 100,100, - 0, 100]); + 100, 0, + 100, 100, + 0, 100]); this.colors = new PIXI.Float32Array([1, 1, 1, 1]); @@ -194,6 +194,8 @@ }; + + PIXI.Strip.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; @@ -225,10 +227,8 @@ var x0 = verticies[index], x1 = verticies[index+2], x2 = verticies[index+4]; var y0 = verticies[index+1], y1 = verticies[index+3], y2 = verticies[index+5]; - if(this.padding === 0) + if(this.padding > 0) { - - //expand(); var centerX = (x0 + x1 + x2)/3; var centerY = (y0 + y1 + y2)/3; @@ -254,7 +254,6 @@ dist = Math.sqrt( normX * normX + normY * normY ); x2 = centerX + (normX / dist) * (dist + 3); y2 = centerY + (normY / dist) * (dist + 3); - } var u0 = uvs[index] * strip.texture.width, u1 = uvs[index+2] * strip.texture.width, u2 = uvs[index+4]* strip.texture.width; @@ -290,13 +289,40 @@ } }; -/* - * Sets the texture that the Strip will use + +/** + * Renders a flat strip * - * @method setTexture - * @param texture {Texture} the texture that will be used + * @method renderStripFlat + * @param strip {Strip} The Strip to render * @private */ +PIXI.Strip.prototype.renderStripFlat = function(strip) +{ + var context = this.context; + var verticies = strip.verticies; + + var length = verticies.length/2; + this.count++; + + context.beginPath(); + for (var i=1; i < length-2; i++) + { + // draw some triangles! + var index = i*2; + + var x0 = verticies[index], x1 = verticies[index+2], x2 = verticies[index+4]; + var y0 = verticies[index+1], y1 = verticies[index+3], y2 = verticies[index+5]; + + context.moveTo(x0, y0); + context.lineTo(x1, y1); + context.lineTo(x2, y2); + } + + context.fillStyle = "#FF0000"; + context.fill(); + context.closePath(); +}; /* PIXI.Strip.prototype.setTexture = function(texture) diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index 8e79054..f46d1c0 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -27,14 +27,14 @@ // set up the main bits.. this.uvs = new PIXI.Float32Array([0, 1, - 1, 1, - 1, 0, - 0,1]); + 1, 1, + 1, 0, + 0, 1]); this.verticies = new PIXI.Float32Array([0, 0, - 100,0, - 100,100, - 0, 100]); + 100, 0, + 100, 100, + 0, 100]); this.colors = new PIXI.Float32Array([1, 1, 1, 1]); @@ -194,6 +194,8 @@ }; + + PIXI.Strip.prototype._renderCanvas = function(renderSession) { var context = renderSession.context; @@ -225,10 +227,8 @@ var x0 = verticies[index], x1 = verticies[index+2], x2 = verticies[index+4]; var y0 = verticies[index+1], y1 = verticies[index+3], y2 = verticies[index+5]; - if(this.padding === 0) + if(this.padding > 0) { - - //expand(); var centerX = (x0 + x1 + x2)/3; var centerY = (y0 + y1 + y2)/3; @@ -254,7 +254,6 @@ dist = Math.sqrt( normX * normX + normY * normY ); x2 = centerX + (normX / dist) * (dist + 3); y2 = centerY + (normY / dist) * (dist + 3); - } var u0 = uvs[index] * strip.texture.width, u1 = uvs[index+2] * strip.texture.width, u2 = uvs[index+4]* strip.texture.width; @@ -290,13 +289,40 @@ } }; -/* - * Sets the texture that the Strip will use + +/** + * Renders a flat strip * - * @method setTexture - * @param texture {Texture} the texture that will be used + * @method renderStripFlat + * @param strip {Strip} The Strip to render * @private */ +PIXI.Strip.prototype.renderStripFlat = function(strip) +{ + var context = this.context; + var verticies = strip.verticies; + + var length = verticies.length/2; + this.count++; + + context.beginPath(); + for (var i=1; i < length-2; i++) + { + // draw some triangles! + var index = i*2; + + var x0 = verticies[index], x1 = verticies[index+2], x2 = verticies[index+4]; + var y0 = verticies[index+1], y1 = verticies[index+3], y2 = verticies[index+5]; + + context.moveTo(x0, y0); + context.lineTo(x1, y1); + context.lineTo(x2, y2); + } + + context.fillStyle = "#FF0000"; + context.fill(); + context.closePath(); +}; /* PIXI.Strip.prototype.setTexture = function(texture) diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 8971d16..77b3166 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -232,95 +232,7 @@ displayObject._renderCanvas(this.renderSession); }; -/** - * Renders a flat strip - * - * @method renderStripFlat - * @param strip {Strip} The Strip to render - * @private - */ -PIXI.CanvasRenderer.prototype.renderStripFlat = function(strip) -{ - var context = this.context; - var verticies = strip.verticies; - var length = verticies.length/2; - this.count++; - - context.beginPath(); - for (var i=1; i < length-2; i++) - { - // draw some triangles! - var index = i*2; - - var x0 = verticies[index], x1 = verticies[index+2], x2 = verticies[index+4]; - var y0 = verticies[index+1], y1 = verticies[index+3], y2 = verticies[index+5]; - - context.moveTo(x0, y0); - context.lineTo(x1, y1); - context.lineTo(x2, y2); - } - - context.fillStyle = "#FF0000"; - context.fill(); - context.closePath(); -}; - -/** - * Renders a strip - * - * @method renderStrip - * @param strip {Strip} The Strip to render - * @private - */ -PIXI.CanvasRenderer.prototype.renderStrip = function(strip) -{ - var context = this.context; - - // draw triangles!! - var verticies = strip.verticies; - var uvs = strip.uvs; - - var length = verticies.length/2; - this.count++; - - for (var i = 1; i < length-2; i++) - { - // draw some triangles! - var index = i*2; - - var x0 = verticies[index], x1 = verticies[index+2], x2 = verticies[index+4]; - var y0 = verticies[index+1], y1 = verticies[index+3], y2 = verticies[index+5]; - - var u0 = uvs[index] * strip.texture.width, u1 = uvs[index+2] * strip.texture.width, u2 = uvs[index+4]* strip.texture.width; - var v0 = uvs[index+1]* strip.texture.height, v1 = uvs[index+3] * strip.texture.height, v2 = uvs[index+5]* strip.texture.height; - - context.save(); - context.beginPath(); - context.moveTo(x0, y0); - context.lineTo(x1, y1); - context.lineTo(x2, y2); - context.closePath(); - - context.clip(); - - // Compute matrix transform - var delta = u0*v1 + v0*u2 + u1*v2 - v1*u2 - v0*u1 - u0*v2; - var deltaA = x0*v1 + v0*x2 + x1*v2 - v1*x2 - v0*x1 - x0*v2; - var deltaB = u0*x1 + x0*u2 + u1*x2 - x1*u2 - x0*u1 - u0*x2; - var deltaC = u0*v1*x2 + v0*x1*u2 + x0*u1*v2 - x0*v1*u2 - v0*u1*x2 - u0*x1*v2; - var deltaD = y0*v1 + v0*y2 + y1*v2 - v1*y2 - v0*y1 - y0*v2; - var deltaE = u0*y1 + y0*u2 + u1*y2 - y1*u2 - y0*u1 - u0*y2; - var deltaF = u0*v1*y2 + v0*y1*u2 + y0*u1*v2 - y0*v1*u2 - v0*u1*y2 - u0*y1*v2; - - context.transform(deltaA / delta, deltaD / delta, - deltaB / delta, deltaE / delta, - deltaC / delta, deltaF / delta); - - context.drawImage(strip.texture.baseTexture.source, 0, 0); - context.restore(); - } -}; PIXI.CanvasRenderer.prototype.mapBlendModes = function() {