codebase now lint free
This commit is contained in:
parent
2debc70e3f
commit
c6ddc833cb
22 changed files with 352 additions and 632 deletions
|
@ -52,7 +52,6 @@ module.exports = function(grunt) {
|
||||||
'<%= dirs.src %>/extras/Rope.js',
|
'<%= dirs.src %>/extras/Rope.js',
|
||||||
'<%= dirs.src %>/extras/TilingSprite.js',
|
'<%= dirs.src %>/extras/TilingSprite.js',
|
||||||
'<%= dirs.src %>/extras/Spine.js',
|
'<%= dirs.src %>/extras/Spine.js',
|
||||||
'<%= dirs.src %>/extras/CustomRenderable.js',
|
|
||||||
'<%= dirs.src %>/textures/BaseTexture.js',
|
'<%= dirs.src %>/textures/BaseTexture.js',
|
||||||
'<%= dirs.src %>/textures/Texture.js',
|
'<%= dirs.src %>/textures/Texture.js',
|
||||||
'<%= dirs.src %>/textures/RenderTexture.js',
|
'<%= dirs.src %>/textures/RenderTexture.js',
|
||||||
|
|
418
bin/pixi.dev.js
418
bin/pixi.dev.js
|
@ -1102,18 +1102,22 @@ PIXI.DisplayObject.prototype.updateTransform = function()
|
||||||
PIXI.DisplayObject.prototype.getBounds = function()
|
PIXI.DisplayObject.prototype.getBounds = function()
|
||||||
{
|
{
|
||||||
return PIXI.EmptyRectangle;
|
return PIXI.EmptyRectangle;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.DisplayObject.prototype._renderWebGL = function(renderSession)
|
PIXI.DisplayObject.prototype._renderWebGL = function(renderSession)
|
||||||
{
|
{
|
||||||
// OVERWRITE
|
// OVERWRITE;
|
||||||
}
|
// this line is just here to pass jshinting :)
|
||||||
|
renderSession = renderSession;
|
||||||
|
};
|
||||||
|
|
||||||
PIXI.DisplayObject.prototype._renderCanvas = function(renderSession)
|
PIXI.DisplayObject.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
// OVERWRITE
|
// OVERWRITE;
|
||||||
}
|
// this line is just here to pass jshinting :)
|
||||||
|
renderSession = renderSession;
|
||||||
|
};
|
||||||
|
|
||||||
PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0);
|
PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0);
|
||||||
|
|
||||||
|
@ -1207,7 +1211,7 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
|
||||||
|
|
||||||
// update the stage refference..
|
// update the stage refference..
|
||||||
|
|
||||||
if(this.stage)this.setStageReference(this.stage)
|
if(this.stage)this.setStageReference(this.stage);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1231,7 +1235,7 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
|
||||||
|
|
||||||
this.children.splice(index, 0, child);
|
this.children.splice(index, 0, child);
|
||||||
|
|
||||||
if(this.stage)this.setStageReference(this.stage)
|
if(this.stage)this.setStageReference(this.stage);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1261,7 +1265,7 @@ PIXI.DisplayObjectContainer.prototype.swapChildren = function(child, child2)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.children[index1] = child2;
|
this.children[index1] = child2;
|
||||||
this.children[index2] = child1;
|
this.children[index2] = child;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1372,7 +1376,7 @@ PIXI.DisplayObjectContainer.prototype.getBounds = function()
|
||||||
//this._currentBounds = bounds;
|
//this._currentBounds = bounds;
|
||||||
|
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage)
|
PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage)
|
||||||
{
|
{
|
||||||
|
@ -1384,7 +1388,7 @@ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage)
|
||||||
if(child.interactive)this.stage.dirty = true;
|
if(child.interactive)this.stage.dirty = true;
|
||||||
child.setStageReference(stage);
|
child.setStageReference(stage);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.DisplayObjectContainer.prototype.removeStageReference = function()
|
PIXI.DisplayObjectContainer.prototype.removeStageReference = function()
|
||||||
{
|
{
|
||||||
|
@ -1395,12 +1399,14 @@ PIXI.DisplayObjectContainer.prototype.removeStageReference = function()
|
||||||
child.removeStageReference();
|
child.removeStageReference();
|
||||||
child.stage = null;
|
child.stage = null;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
|
PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
|
||||||
{
|
{
|
||||||
if(this.visible === false || this.alpha === 0)return;
|
if(this.visible === false || this.alpha === 0)return;
|
||||||
|
|
||||||
|
var i,j;
|
||||||
|
|
||||||
if(this._mask || this._filters)
|
if(this._mask || this._filters)
|
||||||
{
|
{
|
||||||
if(this._mask)
|
if(this._mask)
|
||||||
|
@ -1417,10 +1423,9 @@ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
|
||||||
}
|
}
|
||||||
|
|
||||||
// simple render children!
|
// simple render children!
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSession.spriteBatch.stop();
|
renderSession.spriteBatch.stop();
|
||||||
|
@ -1433,13 +1438,12 @@ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// simple render children!
|
// simple render children!
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
|
PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -1460,7 +1464,7 @@ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
renderSession.maskManager.popMask(renderSession.context);
|
renderSession.maskManager.popMask(renderSession.context);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||||
|
@ -1701,7 +1705,7 @@ PIXI.Sprite.prototype.getBounds = function()
|
||||||
this._currentBounds = bounds;
|
this._currentBounds = bounds;
|
||||||
|
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.Sprite.prototype._renderWebGL = function(renderSession)
|
PIXI.Sprite.prototype._renderWebGL = function(renderSession)
|
||||||
|
@ -1709,6 +1713,8 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
|
||||||
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
||||||
if(this.visible === false || this.alpha === 0)return;
|
if(this.visible === false || this.alpha === 0)return;
|
||||||
|
|
||||||
|
var i,j;
|
||||||
|
|
||||||
// do a quick check to see if this element has a mask or a filter.
|
// do a quick check to see if this element has a mask or a filter.
|
||||||
if(this._mask || this._filters)
|
if(this._mask || this._filters)
|
||||||
{
|
{
|
||||||
|
@ -1731,10 +1737,9 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
|
||||||
spriteBatch.render(this);
|
spriteBatch.render(this);
|
||||||
|
|
||||||
// now loop through the children and make sure they get rendered
|
// now loop through the children and make sure they get rendered
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// time to stop the sprite batch as either a mask element or a filter draw will happen next
|
// time to stop the sprite batch as either a mask element or a filter draw will happen next
|
||||||
|
@ -1750,16 +1755,15 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
|
||||||
renderSession.spriteBatch.render(this);
|
renderSession.spriteBatch.render(this);
|
||||||
|
|
||||||
// simple render children!
|
// simple render children!
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO check culling
|
//TODO check culling
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.Sprite.prototype._renderCanvas = function(renderSession)
|
PIXI.Sprite.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -1869,7 +1873,7 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
renderSession.maskManager.popMask(renderSession.context);
|
renderSession.maskManager.popMask(renderSession.context);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// some helper functions..
|
// some helper functions..
|
||||||
|
|
||||||
|
@ -3474,11 +3478,11 @@ PIXI.AjaxRequest = function AjaxRequest()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
PIXI.packColorRGBA = function(r, g, b, a)//r, g, b, a)
|
PIXI.packColorRGBA = function(r, g, b, a)//r, g, b, a)
|
||||||
{
|
{
|
||||||
// console.log(r, b, c, d)
|
// console.log(r, b, c, d)
|
||||||
return (Math.floor((r)*63) << 18) | (Math.floor((g)*63) << 12) | (Math.floor((b)*63) << 6)// | (Math.floor((a)*63))
|
return (Math.floor((r)*63) << 18) | (Math.floor((g)*63) << 12) | (Math.floor((b)*63) << 6);// | (Math.floor((a)*63))
|
||||||
// i = i | (Math.floor((a)*63));
|
// i = i | (Math.floor((a)*63));
|
||||||
// return i;
|
// return i;
|
||||||
// var r = (i / 262144.0 ) / 64;
|
// var r = (i / 262144.0 ) / 64;
|
||||||
|
@ -3489,17 +3493,19 @@ PIXI.packColorRGBA = function(r, g, b, a)//r, g, b, a)
|
||||||
// console.log(r, g, b, a);
|
// console.log(r, g, b, a);
|
||||||
// return i;
|
// return i;
|
||||||
|
|
||||||
}
|
};
|
||||||
|
*/
|
||||||
|
/*
|
||||||
PIXI.packColorRGB = function(r, g, b)//r, g, b, a)
|
PIXI.packColorRGB = function(r, g, b)//r, g, b, a)
|
||||||
{
|
{
|
||||||
return (Math.floor((r)*255) << 16) | (Math.floor((g)*255) << 8) | (Math.floor((b)*255));
|
return (Math.floor((r)*255) << 16) | (Math.floor((g)*255) << 8) | (Math.floor((b)*255));
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.unpackColorRGB = function(r, g, b)//r, g, b, a)
|
PIXI.unpackColorRGB = function(r, g, b)//r, g, b, a)
|
||||||
{
|
{
|
||||||
return (Math.floor((r)*255) << 16) | (Math.floor((g)*255) << 8) | (Math.floor((b)*255));
|
return (Math.floor((r)*255) << 16) | (Math.floor((g)*255) << 8) | (Math.floor((b)*255));
|
||||||
}
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
PIXI.canUseNewCanvasBlendModes = function()
|
PIXI.canUseNewCanvasBlendModes = function()
|
||||||
{
|
{
|
||||||
|
@ -3513,39 +3519,10 @@ PIXI.canUseNewCanvasBlendModes = function()
|
||||||
context.fillStyle = '#fff';
|
context.fillStyle = '#fff';
|
||||||
context.fillRect(0,0,1,1);
|
context.fillRect(0,0,1,1);
|
||||||
return context.getImageData(0,0,1,1).data[0] === 0;
|
return context.getImageData(0,0,1,1).data[0] === 0;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DEBUGGING ONLY
|
|
||||||
*/
|
|
||||||
PIXI.runList = function(item)
|
|
||||||
{
|
|
||||||
window.console.log('>>>>>>>>>');
|
|
||||||
window.console.log('_');
|
|
||||||
var safe = 0;
|
|
||||||
var tmp = item.first;
|
|
||||||
window.console.log(tmp);
|
|
||||||
|
|
||||||
while(tmp._iNext)
|
|
||||||
{
|
|
||||||
safe++;
|
|
||||||
tmp = tmp._iNext;
|
|
||||||
window.console.log(tmp);
|
|
||||||
// console.log(tmp);
|
|
||||||
|
|
||||||
if(safe > 100)
|
|
||||||
{
|
|
||||||
window.console.log('BREAK');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/mrdoob/eventtarget.js/
|
* https://github.com/mrdoob/eventtarget.js/
|
||||||
* THankS mr DOob!
|
* THankS mr DOob!
|
||||||
|
@ -4029,7 +4006,7 @@ PIXI.PixiShader.prototype.init = function()
|
||||||
PIXI.PixiShader.prototype.initUniforms = function()
|
PIXI.PixiShader.prototype.initUniforms = function()
|
||||||
{
|
{
|
||||||
this.textureCount = 1;
|
this.textureCount = 1;
|
||||||
var gl = this.gl
|
var gl = this.gl;
|
||||||
var uniform;
|
var uniform;
|
||||||
|
|
||||||
for (var key in this.uniforms)
|
for (var key in this.uniforms)
|
||||||
|
@ -4409,7 +4386,7 @@ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projectio
|
||||||
{
|
{
|
||||||
var gl = renderSession.gl;
|
var gl = renderSession.gl;
|
||||||
var projection = renderSession.projection,
|
var projection = renderSession.projection,
|
||||||
offset = renderSession.offset;
|
offset = renderSession.offset,
|
||||||
shader = renderSession.shaderManager.primitiveShader;
|
shader = renderSession.shaderManager.primitiveShader;
|
||||||
|
|
||||||
if(!graphics._webGL)graphics._webGL = {points:[], indices:[], lastIndex:0,
|
if(!graphics._webGL)graphics._webGL = {points:[], indices:[], lastIndex:0,
|
||||||
|
@ -4975,7 +4952,7 @@ PIXI.WebGLRenderer = function(width, height, view, transparent, antialias)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//try 'webgl'
|
//try 'webgl'
|
||||||
try {
|
try {
|
||||||
this.gl = this.view.getContext('webgl', options);
|
this.gl = this.view.getContext('webgl', options);
|
||||||
} catch (e2) {
|
} catch (e2) {
|
||||||
// fail, not able to get a context
|
// fail, not able to get a context
|
||||||
throw new Error(' This browser does not support webGL. Try using the canvas renderer' + this);
|
throw new Error(' This browser does not support webGL. Try using the canvas renderer' + this);
|
||||||
|
@ -5131,7 +5108,7 @@ PIXI.WebGLRenderer.prototype.renderDisplayObject = function(displayObject, proje
|
||||||
|
|
||||||
// finish the sprite batch
|
// finish the sprite batch
|
||||||
this.spriteBatch.end();
|
this.spriteBatch.end();
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the textures loaded into this webgl renderer
|
* Updates the textures loaded into this webgl renderer
|
||||||
|
@ -5149,7 +5126,7 @@ PIXI.WebGLRenderer.updateTextures = function()
|
||||||
PIXI.WebGLRenderer.updateTexture(PIXI.texturesToUpdate[i]);
|
PIXI.WebGLRenderer.updateTexture(PIXI.texturesToUpdate[i]);
|
||||||
|
|
||||||
|
|
||||||
for (var i=0; i < PIXI.Texture.frameUpdates.length; i++)
|
for (i=0; i < PIXI.Texture.frameUpdates.length; i++)
|
||||||
PIXI.WebGLRenderer.updateTextureFrame(PIXI.Texture.frameUpdates[i]);
|
PIXI.WebGLRenderer.updateTextureFrame(PIXI.Texture.frameUpdates[i]);
|
||||||
|
|
||||||
for (i = 0; i < PIXI.texturesToDestroy.length; i++)
|
for (i = 0; i < PIXI.texturesToDestroy.length; i++)
|
||||||
|
@ -5308,7 +5285,7 @@ PIXI.WebGLMaskManager = function(gl)
|
||||||
this.gl = gl;
|
this.gl = gl;
|
||||||
this.maskStack = [];
|
this.maskStack = [];
|
||||||
this.maskPosition = 0;
|
this.maskPosition = 0;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession)
|
PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession)
|
||||||
{
|
{
|
||||||
|
@ -5332,7 +5309,7 @@ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession)
|
||||||
gl.colorMask(true, true, true, true);
|
gl.colorMask(true, true, true, true);
|
||||||
gl.stencilFunc(gl.NOTEQUAL,0, this.maskStack.length);
|
gl.stencilFunc(gl.NOTEQUAL,0, this.maskStack.length);
|
||||||
gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP);
|
gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLMaskManager.prototype.popMask = function(renderSession)
|
PIXI.WebGLMaskManager.prototype.popMask = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -5355,7 +5332,7 @@ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST);
|
if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST);
|
||||||
}
|
};
|
||||||
/**
|
/**
|
||||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||||
*/
|
*/
|
||||||
|
@ -5382,7 +5359,7 @@ PIXI.WebGLShaderManager = function(gl)
|
||||||
|
|
||||||
// the final one is used for the rendering strips
|
// the final one is used for the rendering strips
|
||||||
//this.stripShader = new PIXI.StripShader(gl);
|
//this.stripShader = new PIXI.StripShader(gl);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function()
|
PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function()
|
||||||
|
@ -5412,17 +5389,6 @@ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function()
|
||||||
gl.enableVertexAttribArray(this.defaultShader.colorAttribute);
|
gl.enableVertexAttribArray(this.defaultShader.colorAttribute);
|
||||||
gl.enableVertexAttribArray(this.defaultShader.aTextureCoord);
|
gl.enableVertexAttribArray(this.defaultShader.aTextureCoord);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.WebGLShaderManager.prototype.pushShader = function(maskData, renderSession)
|
|
||||||
{
|
|
||||||
// push a shader onto the stack..
|
|
||||||
}
|
|
||||||
|
|
||||||
PIXI.WebGLShaderManager.prototype.popShader = function(renderSession)
|
|
||||||
{
|
|
||||||
// push
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @author Mat Groves
|
* @author Mat Groves
|
||||||
*
|
*
|
||||||
|
@ -5468,7 +5434,7 @@ PIXI.WebGLSpriteBatch = function(gl)
|
||||||
this.indices[i + 3] = j + 0;
|
this.indices[i + 3] = j + 0;
|
||||||
this.indices[i + 4] = j + 2;
|
this.indices[i + 4] = j + 2;
|
||||||
this.indices[i + 5] = j + 3;
|
this.indices[i + 5] = j + 3;
|
||||||
};
|
}
|
||||||
|
|
||||||
//upload the index data
|
//upload the index data
|
||||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
||||||
|
@ -5479,8 +5445,8 @@ PIXI.WebGLSpriteBatch = function(gl)
|
||||||
|
|
||||||
this.drawing = false;
|
this.drawing = false;
|
||||||
this.currentBatchSize = 0;
|
this.currentBatchSize = 0;
|
||||||
this.currentBaseTexture;
|
this.currentBaseTexture = null;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession)
|
PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -5488,12 +5454,12 @@ PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession)
|
||||||
this.shader = this.renderSession.shaderManager.defaultShader;
|
this.shader = this.renderSession.shaderManager.defaultShader;
|
||||||
|
|
||||||
this.start();
|
this.start();
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.end = function()
|
PIXI.WebGLSpriteBatch.prototype.end = function()
|
||||||
{
|
{
|
||||||
this.flush();
|
this.flush();
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.render = function(sprite)
|
PIXI.WebGLSpriteBatch.prototype.render = function(sprite)
|
||||||
|
@ -5545,16 +5511,16 @@ PIXI.WebGLSpriteBatch.prototype.render = function(sprite)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var w0 = (width ) * (1-aX);
|
w0 = (width ) * (1-aX);
|
||||||
var w1 = (width ) * -aX;
|
w1 = (width ) * -aX;
|
||||||
|
|
||||||
var h0 = height * (1-aY);
|
h0 = height * (1-aY);
|
||||||
var h1 = height * -aY;
|
h1 = height * -aY;
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = this.currentBatchSize * 4 * this.vertSize;
|
var index = this.currentBatchSize * 4 * this.vertSize;
|
||||||
|
|
||||||
worldTransform = sprite.worldTransform;
|
var worldTransform = sprite.worldTransform;
|
||||||
|
|
||||||
var a = worldTransform[0];
|
var a = worldTransform[0];
|
||||||
var b = worldTransform[3];
|
var b = worldTransform[3];
|
||||||
|
@ -5607,7 +5573,7 @@ PIXI.WebGLSpriteBatch.prototype.render = function(sprite)
|
||||||
this.currentBatchSize++;
|
this.currentBatchSize++;
|
||||||
|
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
|
PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
|
||||||
{
|
{
|
||||||
|
@ -5627,7 +5593,6 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
|
||||||
|
|
||||||
// set the textures uvs temporarily
|
// set the textures uvs temporarily
|
||||||
// TODO create a seperate texture so that we can tile part of a texture
|
// TODO create a seperate texture so that we can tile part of a texture
|
||||||
var tempUvs = texture._uvs;
|
|
||||||
|
|
||||||
if(!tilingSprite._uvs)tilingSprite._uvs = new Float32Array(8);
|
if(!tilingSprite._uvs)tilingSprite._uvs = new Float32Array(8);
|
||||||
|
|
||||||
|
@ -5672,7 +5637,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
|
||||||
|
|
||||||
var index = this.currentBatchSize * 4 * this.vertSize;
|
var index = this.currentBatchSize * 4 * this.vertSize;
|
||||||
|
|
||||||
worldTransform = tilingSprite.worldTransform;
|
var worldTransform = tilingSprite.worldTransform;
|
||||||
|
|
||||||
var a = worldTransform[0];
|
var a = worldTransform[0];
|
||||||
var b = worldTransform[3];
|
var b = worldTransform[3];
|
||||||
|
@ -5723,7 +5688,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
|
||||||
|
|
||||||
// increment the batchs
|
// increment the batchs
|
||||||
this.currentBatchSize++;
|
this.currentBatchSize++;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.flush = function()
|
PIXI.WebGLSpriteBatch.prototype.flush = function()
|
||||||
{
|
{
|
||||||
|
@ -5747,12 +5712,12 @@ PIXI.WebGLSpriteBatch.prototype.flush = function()
|
||||||
|
|
||||||
// increment the draw count
|
// increment the draw count
|
||||||
this.renderSession.drawCount++;
|
this.renderSession.drawCount++;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.stop = function()
|
PIXI.WebGLSpriteBatch.prototype.stop = function()
|
||||||
{
|
{
|
||||||
this.flush();
|
this.flush();
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.start = function()
|
PIXI.WebGLSpriteBatch.prototype.start = function()
|
||||||
{
|
{
|
||||||
|
@ -5780,7 +5745,7 @@ PIXI.WebGLSpriteBatch.prototype.start = function()
|
||||||
{
|
{
|
||||||
this.setBlendMode(PIXI.blendModes.NORMAL);
|
this.setBlendMode(PIXI.blendModes.NORMAL);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode)
|
PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode)
|
||||||
{
|
{
|
||||||
|
@ -5790,7 +5755,7 @@ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode)
|
||||||
|
|
||||||
var blendModeWebGL = PIXI.blendModesWebGL[this.currentBlendMode];
|
var blendModeWebGL = PIXI.blendModesWebGL[this.currentBlendMode];
|
||||||
this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6176,7 +6141,6 @@ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function()
|
||||||
this.colorArray,
|
this.colorArray,
|
||||||
gl.STATIC_DRAW);
|
gl.STATIC_DRAW);
|
||||||
|
|
||||||
this.colorAttribute
|
|
||||||
// bind and upload the index
|
// bind and upload the index
|
||||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
||||||
gl.bufferData(
|
gl.bufferData(
|
||||||
|
@ -6331,7 +6295,7 @@ PIXI.FilterTexture.prototype.clear = function()
|
||||||
|
|
||||||
gl.clearColor(0,0,0, 0);
|
gl.clearColor(0,0,0, 0);
|
||||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.FilterTexture.prototype.resize = function(width, height)
|
PIXI.FilterTexture.prototype.resize = function(width, height)
|
||||||
{
|
{
|
||||||
|
@ -6356,7 +6320,7 @@ PIXI.FilterTexture.prototype.resize = function(width, height)
|
||||||
PIXI.CanvasMaskManager = function()
|
PIXI.CanvasMaskManager = function()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, context)
|
PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, context)
|
||||||
{
|
{
|
||||||
|
@ -6375,12 +6339,13 @@ PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, context)
|
||||||
context.clip();
|
context.clip();
|
||||||
|
|
||||||
maskData.worldAlpha = cacheAlpha;
|
maskData.worldAlpha = cacheAlpha;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasMaskManager.prototype.popMask = function(context)
|
PIXI.CanvasMaskManager.prototype.popMask = function(context)
|
||||||
{
|
{
|
||||||
context.restore();
|
context.restore();
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mat Groves
|
* @author Mat Groves
|
||||||
*
|
*
|
||||||
|
@ -6389,16 +6354,14 @@ PIXI.CanvasMaskManager.prototype.popMask = function(context)
|
||||||
|
|
||||||
PIXI.CanvasTinter = function()
|
PIXI.CanvasTinter = function()
|
||||||
{
|
{
|
||||||
/// this.textureCach
|
/// this.textureCach
|
||||||
}
|
};
|
||||||
|
|
||||||
//PIXI.CanvasTinter.cachTint = true;
|
//PIXI.CanvasTinter.cachTint = true;
|
||||||
|
|
||||||
|
|
||||||
PIXI.CanvasTinter.getTintedTexture = function(sprite, color, canvas)
|
PIXI.CanvasTinter.getTintedTexture = function(sprite, color)
|
||||||
{
|
{
|
||||||
var cacheMode = 0;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// cach on sprite
|
// cach on sprite
|
||||||
// cach on texture
|
// cach on texture
|
||||||
|
@ -6408,7 +6371,7 @@ PIXI.CanvasTinter.getTintedTexture = function(sprite, color, canvas)
|
||||||
|
|
||||||
color = PIXI.CanvasTinter.roundColor(color);
|
color = PIXI.CanvasTinter.roundColor(color);
|
||||||
|
|
||||||
var stringColor = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
|
var stringColor = "#" + ("00000" + ( color | 0).toString(16)).substr(-6);
|
||||||
|
|
||||||
texture.tintCache = texture.tintCache || {};
|
texture.tintCache = texture.tintCache || {};
|
||||||
|
|
||||||
|
@ -6424,38 +6387,38 @@ PIXI.CanvasTinter.getTintedTexture = function(sprite, color, canvas)
|
||||||
|
|
||||||
if(PIXI.CanvasTinter.convertTintToImage)
|
if(PIXI.CanvasTinter.convertTintToImage)
|
||||||
{
|
{
|
||||||
// is this better?
|
// is this better?
|
||||||
var tintImage = new Image();
|
var tintImage = new Image();
|
||||||
tintImage.src = canvas.toDataURL();
|
tintImage.src = canvas.toDataURL();
|
||||||
|
|
||||||
texture.tintCache[stringColor] = tintImage;
|
texture.tintCache[stringColor] = tintImage;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
texture.tintCache[stringColor] = canvas;
|
texture.tintCache[stringColor] = canvas;
|
||||||
// if we are not converting the texture to an image then we need to lose the refferance to the canvas
|
// if we are not converting the texture to an image then we need to lose the refferance to the canvas
|
||||||
PIXI.CanvasTinter.canvas = null;
|
PIXI.CanvasTinter.canvas = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas)
|
PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas)
|
||||||
{
|
{
|
||||||
var context = canvas.getContext( '2d' );
|
var context = canvas.getContext( "2d" );
|
||||||
|
|
||||||
var frame = texture.frame;
|
var frame = texture.frame;
|
||||||
|
|
||||||
canvas.width = frame.width;
|
canvas.width = frame.width;
|
||||||
canvas.height = frame.height;
|
canvas.height = frame.height;
|
||||||
|
|
||||||
context.fillStyle = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
|
context.fillStyle = "#" + ("00000" + ( color | 0).toString(16)).substr(-6);
|
||||||
|
|
||||||
context.fillRect(0, 0, frame.width, frame.height);
|
context.fillRect(0, 0, frame.width, frame.height);
|
||||||
|
|
||||||
context.globalCompositeOperation = 'multiply';
|
context.globalCompositeOperation = "multiply";
|
||||||
|
|
||||||
context.drawImage(texture.baseTexture.source,
|
context.drawImage(texture.baseTexture.source,
|
||||||
frame.x,
|
frame.x,
|
||||||
|
@ -6467,7 +6430,7 @@ PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas)
|
||||||
frame.width,
|
frame.width,
|
||||||
frame.height);
|
frame.height);
|
||||||
|
|
||||||
context.globalCompositeOperation = 'destination-atop';
|
context.globalCompositeOperation = "destination-atop";
|
||||||
|
|
||||||
context.drawImage(texture.baseTexture.source,
|
context.drawImage(texture.baseTexture.source,
|
||||||
frame.x,
|
frame.x,
|
||||||
|
@ -6478,11 +6441,11 @@ PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas)
|
||||||
0,
|
0,
|
||||||
frame.width,
|
frame.width,
|
||||||
frame.height);
|
frame.height);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
|
PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
|
||||||
{
|
{
|
||||||
var context = canvas.getContext( '2d' );
|
var context = canvas.getContext( "2d" );
|
||||||
|
|
||||||
var frame = texture.frame;
|
var frame = texture.frame;
|
||||||
|
|
||||||
|
@ -6491,11 +6454,11 @@ PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
context.globalCompositeOperation = 'copy';
|
context.globalCompositeOperation = "copy";
|
||||||
context.fillStyle = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
|
context.fillStyle = "#" + ("00000" + ( color | 0).toString(16)).substr(-6);
|
||||||
context.fillRect(0, 0, frame.width, frame.height);
|
context.fillRect(0, 0, frame.width, frame.height);
|
||||||
|
|
||||||
context.globalCompositeOperation = 'destination-atop';
|
context.globalCompositeOperation = "destination-atop";
|
||||||
context.drawImage(texture.baseTexture.source,
|
context.drawImage(texture.baseTexture.source,
|
||||||
frame.x,
|
frame.x,
|
||||||
frame.y,
|
frame.y,
|
||||||
|
@ -6507,21 +6470,21 @@ PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
|
||||||
frame.height);
|
frame.height);
|
||||||
|
|
||||||
|
|
||||||
//context.globalCompositeOperation = 'copy';
|
//context.globalCompositeOperation = "copy";
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.CanvasTinter.tintWithPerPixel = function(texture, color, canvas)
|
PIXI.CanvasTinter.tintWithPerPixel = function(texture, color, canvas)
|
||||||
{
|
{
|
||||||
var context = canvas.getContext( '2d' );
|
var context = canvas.getContext( "2d" );
|
||||||
|
|
||||||
var frame = texture.frame;
|
var frame = texture.frame;
|
||||||
|
|
||||||
canvas.width = frame.width;
|
canvas.width = frame.width;
|
||||||
canvas.height = frame.height;
|
canvas.height = frame.height;
|
||||||
|
|
||||||
context.globalCompositeOperation = 'copy';
|
context.globalCompositeOperation = "copy";
|
||||||
context.drawImage(texture.baseTexture.source,
|
context.drawImage(texture.baseTexture.source,
|
||||||
frame.x,
|
frame.x,
|
||||||
frame.y,
|
frame.y,
|
||||||
|
@ -6535,19 +6498,19 @@ PIXI.CanvasTinter.tintWithPerPixel = function(texture, color, canvas)
|
||||||
var rgbValues = PIXI.hex2rgb(color);
|
var rgbValues = PIXI.hex2rgb(color);
|
||||||
var r = rgbValues[0], g = rgbValues[1], b = rgbValues[2];
|
var r = rgbValues[0], g = rgbValues[1], b = rgbValues[2];
|
||||||
|
|
||||||
var pixelData = context.getImageData(0, 0, frame.width, frame.height)
|
var pixelData = context.getImageData(0, 0, frame.width, frame.height);
|
||||||
|
|
||||||
var pixels = pixelData.data;
|
var pixels = pixelData.data;
|
||||||
|
|
||||||
for (var i = 0; i < pixels.length; i += 4)
|
for (var i = 0; i < pixels.length; i += 4)
|
||||||
{
|
{
|
||||||
pixels[i+0] *= r;
|
pixels[i+0] *= r;
|
||||||
pixels[i+1] *= g;
|
pixels[i+1] *= g;
|
||||||
pixels[i+2] *= b;
|
pixels[i+2] *= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.putImageData(pixelData, 0, 0);
|
context.putImageData(pixelData, 0, 0);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasTinter.roundColor = function(color)
|
PIXI.CanvasTinter.roundColor = function(color)
|
||||||
{
|
{
|
||||||
|
@ -6559,52 +6522,8 @@ PIXI.CanvasTinter.roundColor = function(color)
|
||||||
rgbValues[1] = Math.round(rgbValues[1] * step) / step;
|
rgbValues[1] = Math.round(rgbValues[1] * step) / step;
|
||||||
rgbValues[2] = Math.round(rgbValues[2] * step) / step;
|
rgbValues[2] = Math.round(rgbValues[2] * step) / step;
|
||||||
|
|
||||||
return PIXI.rgb2hex(rgbValues)
|
return PIXI.rgb2hex(rgbValues);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasTinter._getTintedTextureFast = function(texture, color, canvas)
|
|
||||||
{
|
|
||||||
var stringColor = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
|
|
||||||
|
|
||||||
// clone texture..
|
|
||||||
var canvas = canvas || document.createElement("canvas");
|
|
||||||
var context = canvas.getContext( '2d' );
|
|
||||||
|
|
||||||
var frame = texture.frame;
|
|
||||||
|
|
||||||
context.width = frame.width;
|
|
||||||
context.height = frame.height;
|
|
||||||
|
|
||||||
context.fillStyle = stringColor;
|
|
||||||
|
|
||||||
context.fillRect(0, 0, frame.width, frame.height);
|
|
||||||
|
|
||||||
context.globalCompositeOperation = 'multiply';
|
|
||||||
|
|
||||||
context.drawImage(texture.baseTexture.source,
|
|
||||||
frame.x,
|
|
||||||
frame.y,
|
|
||||||
frame.width,
|
|
||||||
frame.height,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
frame.width,
|
|
||||||
frame.height);
|
|
||||||
|
|
||||||
context.globalCompositeOperation = 'destination-in';
|
|
||||||
|
|
||||||
context.drawImage(texture.baseTexture.source,
|
|
||||||
frame.x,
|
|
||||||
frame.y,
|
|
||||||
frame.width,
|
|
||||||
frame.height,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
frame.width,
|
|
||||||
frame.height);
|
|
||||||
|
|
||||||
return canvas;
|
|
||||||
}
|
|
||||||
|
|
||||||
PIXI.CanvasTinter.cacheStepsPerColorChannel = 8;
|
PIXI.CanvasTinter.cacheStepsPerColorChannel = 8;
|
||||||
PIXI.CanvasTinter.convertTintToImage = false;
|
PIXI.CanvasTinter.convertTintToImage = false;
|
||||||
|
@ -6683,26 +6602,26 @@ PIXI.CanvasRenderer = function(width, height, view, transparent)
|
||||||
* @property view
|
* @property view
|
||||||
* @type Canvas
|
* @type Canvas
|
||||||
*/
|
*/
|
||||||
this.view = view || document.createElement( 'canvas' );
|
this.view = view || document.createElement( "canvas" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The canvas context that the everything is drawn to
|
* The canvas context that the everything is drawn to
|
||||||
* @property context
|
* @property context
|
||||||
* @type Canvas 2d Context
|
* @type Canvas 2d Context
|
||||||
*/
|
*/
|
||||||
this.context = this.view.getContext( '2d' );
|
this.context = this.view.getContext( "2d" );
|
||||||
|
|
||||||
//some filter variables
|
//some filter variables
|
||||||
this.smoothProperty = null;
|
this.smoothProperty = null;
|
||||||
|
|
||||||
if('imageSmoothingEnabled' in this.context)
|
if("imageSmoothingEnabled" in this.context)
|
||||||
this.smoothProperty = 'imageSmoothingEnabled';
|
this.smoothProperty = "imageSmoothingEnabled";
|
||||||
else if('webkitImageSmoothingEnabled' in this.context)
|
else if("webkitImageSmoothingEnabled" in this.context)
|
||||||
this.smoothProperty = 'webkitImageSmoothingEnabled';
|
this.smoothProperty = "webkitImageSmoothingEnabled";
|
||||||
else if('mozImageSmoothingEnabled' in this.context)
|
else if("mozImageSmoothingEnabled" in this.context)
|
||||||
this.smoothProperty = 'mozImageSmoothingEnabled';
|
this.smoothProperty = "mozImageSmoothingEnabled";
|
||||||
else if('oImageSmoothingEnabled' in this.context)
|
else if("oImageSmoothingEnabled" in this.context)
|
||||||
this.smoothProperty = 'oImageSmoothingEnabled';
|
this.smoothProperty = "oImageSmoothingEnabled";
|
||||||
|
|
||||||
this.scaleMode = null;
|
this.scaleMode = null;
|
||||||
|
|
||||||
|
@ -6832,7 +6751,7 @@ PIXI.CanvasRenderer.prototype.renderStripFlat = function(strip)
|
||||||
context.lineTo(x2, y2);
|
context.lineTo(x2, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.fillStyle = '#FF0000';
|
context.fillStyle = "#FF0000";
|
||||||
context.fill();
|
context.fill();
|
||||||
context.closePath();
|
context.closePath();
|
||||||
};
|
};
|
||||||
|
@ -6898,24 +6817,24 @@ PIXI.CanvasBuffer = function(width, height)
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
|
||||||
this.canvas = document.createElement( 'canvas' );
|
this.canvas = document.createElement( "canvas" );
|
||||||
this.context = this.canvas.getContext( '2d' );
|
this.context = this.canvas.getContext( "2d" );
|
||||||
|
|
||||||
// this.context.f
|
// this.context.f
|
||||||
this.canvas.width = width;
|
this.canvas.width = width;
|
||||||
this.canvas.height = height;
|
this.canvas.height = height;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasBuffer.prototype.clear = function()
|
PIXI.CanvasBuffer.prototype.clear = function()
|
||||||
{
|
{
|
||||||
this.context.clearRect(0,0, this.width, this.height);
|
this.context.clearRect(0,0, this.width, this.height);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasBuffer.prototype.resize = function(width, height)
|
PIXI.CanvasBuffer.prototype.resize = function(width, height)
|
||||||
{
|
{
|
||||||
this.width = this.canvas.width = width;
|
this.width = this.canvas.width = width;
|
||||||
this.height = this.canvas.height = height;
|
this.height = this.canvas.height = height;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7209,7 +7128,7 @@ PIXI.Graphics = function()
|
||||||
*/
|
*/
|
||||||
this.graphicsData = [];
|
this.graphicsData = [];
|
||||||
|
|
||||||
this.tint = 0xFFFFFF// * Math.random();
|
this.tint = 0xFFFFFF;// * Math.random();
|
||||||
|
|
||||||
this.blendMode = PIXI.blendModes.NORMAL;
|
this.blendMode = PIXI.blendModes.NORMAL;
|
||||||
|
|
||||||
|
@ -7401,7 +7320,7 @@ PIXI.Graphics.prototype._renderWebGL = function(renderSession)
|
||||||
// check blend mode
|
// check blend mode
|
||||||
if(this.blendMode !== renderSession.spriteBatch.currentBlendMode)
|
if(this.blendMode !== renderSession.spriteBatch.currentBlendMode)
|
||||||
{
|
{
|
||||||
this.spriteBatch.currentBlendMode = sprite.blendMode;
|
this.spriteBatch.currentBlendMode = this.blendMode;
|
||||||
var blendModeWebGL = PIXI.blendModesWebGL[renderSession.spriteBatch.currentBlendMode];
|
var blendModeWebGL = PIXI.blendModesWebGL[renderSession.spriteBatch.currentBlendMode];
|
||||||
this.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
this.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
||||||
}
|
}
|
||||||
|
@ -7409,7 +7328,7 @@ PIXI.Graphics.prototype._renderWebGL = function(renderSession)
|
||||||
PIXI.WebGLGraphics.renderGraphics(this, renderSession);
|
PIXI.WebGLGraphics.renderGraphics(this, renderSession);
|
||||||
|
|
||||||
renderSession.spriteBatch.start();
|
renderSession.spriteBatch.start();
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.Graphics.prototype._renderCanvas = function(renderSession)
|
PIXI.Graphics.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -7427,7 +7346,7 @@ PIXI.Graphics.prototype._renderCanvas = function(renderSession)
|
||||||
|
|
||||||
context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]);
|
context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]);
|
||||||
PIXI.CanvasGraphics.renderGraphics(this, context);
|
PIXI.CanvasGraphics.renderGraphics(this, context);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.Graphics.prototype.getBounds = function()
|
PIXI.Graphics.prototype.getBounds = function()
|
||||||
{
|
{
|
||||||
|
@ -7495,7 +7414,7 @@ PIXI.Graphics.prototype.getBounds = function()
|
||||||
bounds.height = maxY - minY;
|
bounds.height = maxY - minY;
|
||||||
|
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.Graphics.prototype.updateBounds = function()
|
PIXI.Graphics.prototype.updateBounds = function()
|
||||||
{
|
{
|
||||||
|
@ -7884,7 +7803,7 @@ PIXI.TilingSprite.prototype.constructor = PIXI.TilingSprite;
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(PIXI.TilingSprite.prototype, 'width', {
|
Object.defineProperty(PIXI.TilingSprite.prototype, 'width', {
|
||||||
get: function() {
|
get: function() {
|
||||||
return this._width
|
return this._width;
|
||||||
},
|
},
|
||||||
set: function(value) {
|
set: function(value) {
|
||||||
|
|
||||||
|
@ -7900,7 +7819,7 @@ Object.defineProperty(PIXI.TilingSprite.prototype, 'width', {
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(PIXI.TilingSprite.prototype, 'height', {
|
Object.defineProperty(PIXI.TilingSprite.prototype, 'height', {
|
||||||
get: function() {
|
get: function() {
|
||||||
return this._height
|
return this._height;
|
||||||
},
|
},
|
||||||
set: function(value) {
|
set: function(value) {
|
||||||
this._height = value;
|
this._height = value;
|
||||||
|
@ -7921,6 +7840,8 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
|
||||||
|
|
||||||
if(this.visible === false || this.alpha === 0)return;
|
if(this.visible === false || this.alpha === 0)return;
|
||||||
|
|
||||||
|
var i,j;
|
||||||
|
|
||||||
if(this.mask || this.filters)
|
if(this.mask || this.filters)
|
||||||
{
|
{
|
||||||
if(this.mask)
|
if(this.mask)
|
||||||
|
@ -7940,10 +7861,9 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
|
||||||
renderSession.spriteBatch.renderTilingSprite(this);
|
renderSession.spriteBatch.renderTilingSprite(this);
|
||||||
|
|
||||||
// simple render children!
|
// simple render children!
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSession.spriteBatch.stop();
|
renderSession.spriteBatch.stop();
|
||||||
|
@ -7958,13 +7878,12 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
|
||||||
renderSession.spriteBatch.renderTilingSprite(this);
|
renderSession.spriteBatch.renderTilingSprite(this);
|
||||||
|
|
||||||
// simple render children!
|
// simple render children!
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
|
PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -8000,7 +7919,7 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
|
||||||
context.translate(-tilePosition.x, -tilePosition.y);
|
context.translate(-tilePosition.x, -tilePosition.y);
|
||||||
|
|
||||||
context.closePath();
|
context.closePath();
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||||
|
@ -9471,65 +9390,6 @@ PIXI.Spine.prototype.createSprite = function (slot, descriptor) {
|
||||||
return sprite;
|
return sprite;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This object is one that will allow you to specify custom rendering functions based on render type
|
|
||||||
*
|
|
||||||
* @class CustomRenderable
|
|
||||||
* @extends DisplayObject
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
PIXI.CustomRenderable = function()
|
|
||||||
{
|
|
||||||
PIXI.DisplayObject.call( this );
|
|
||||||
|
|
||||||
this.renderable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
PIXI.CustomRenderable.prototype = Object.create( PIXI.DisplayObject.prototype );
|
|
||||||
PIXI.CustomRenderable.prototype.constructor = PIXI.CustomRenderable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If this object is being rendered by a CanvasRenderer it will call this callback
|
|
||||||
*
|
|
||||||
* @method renderCanvas
|
|
||||||
* @param renderer {CanvasRenderer} The renderer instance
|
|
||||||
*/
|
|
||||||
PIXI.CustomRenderable.prototype.renderCanvas = function()
|
|
||||||
{
|
|
||||||
// override!
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If this object is being rendered by a WebGLRenderer it will call this callback to initialize
|
|
||||||
*
|
|
||||||
* @method initWebGL
|
|
||||||
* @param renderer {WebGLRenderer} The renderer instance
|
|
||||||
*/
|
|
||||||
PIXI.CustomRenderable.prototype.initWebGL = function()
|
|
||||||
{
|
|
||||||
// override!
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If this object is being rendered by a WebGLRenderer it will call this callback
|
|
||||||
*
|
|
||||||
* @method renderWebGL
|
|
||||||
* @param rendererGroup {WebGLRenderGroup} The renderer group instance
|
|
||||||
* @param projectionMatrix {Matrix} The object's projection matrix
|
|
||||||
*/
|
|
||||||
PIXI.CustomRenderable.prototype.renderWebGL = function()
|
|
||||||
{
|
|
||||||
// not sure if both needed? but ya have for now!
|
|
||||||
// override!
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||||
*/
|
*/
|
||||||
|
@ -9830,7 +9690,7 @@ PIXI.Texture.prototype.setFrame = function(frame)
|
||||||
|
|
||||||
PIXI.Texture.prototype._updateWebGLuvs = function()
|
PIXI.Texture.prototype._updateWebGLuvs = function()
|
||||||
{
|
{
|
||||||
if(!this._uvs)this._uvs = new Float32Array(8)
|
if(!this._uvs)this._uvs = new Float32Array(8);
|
||||||
|
|
||||||
var frame = this.frame;
|
var frame = this.frame;
|
||||||
var tw = this.baseTexture.width;
|
var tw = this.baseTexture.width;
|
||||||
|
@ -9847,7 +9707,7 @@ PIXI.Texture.prototype._updateWebGLuvs = function()
|
||||||
|
|
||||||
this._uvs[6] = frame.x / tw;
|
this._uvs[6] = frame.x / tw;
|
||||||
this._uvs[7] = (frame.y + frame.height) / th;
|
this._uvs[7] = (frame.y + frame.height) / th;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function that returns a texture based on an image url
|
* Helper function that returns a texture based on an image url
|
||||||
|
@ -10391,15 +10251,15 @@ PIXI.JsonLoader.prototype.onJSONLoaded = function () {
|
||||||
// check to see ifthe sprite ha been trimmed..
|
// check to see ifthe sprite ha been trimmed..
|
||||||
if (frameData[i].trimmed) {
|
if (frameData[i].trimmed) {
|
||||||
|
|
||||||
var texture = PIXI.TextureCache[i]
|
var texture = PIXI.TextureCache[i];
|
||||||
|
|
||||||
texture.trimmed = true;
|
texture.trimmed = true;
|
||||||
|
|
||||||
var actualSize = frameData[i].sourceSize;
|
var actualSize = frameData[i].sourceSize;
|
||||||
var realSize = frameData[i].spriteSourceSize;
|
var realSize = frameData[i].spriteSourceSize;
|
||||||
|
|
||||||
texture.trim.x = realSize.x
|
texture.trim.x = realSize.x;
|
||||||
texture.trim.y = realSize.y
|
texture.trim.y = realSize.y;
|
||||||
texture.trim.realWidth = actualSize.w;
|
texture.trim.realWidth = actualSize.w;
|
||||||
texture.trim.realHeight = actualSize.h;
|
texture.trim.realHeight = actualSize.h;
|
||||||
}
|
}
|
||||||
|
|
12
bin/pixi.js
12
bin/pixi.js
File diff suppressed because one or more lines are too long
|
@ -405,18 +405,22 @@ PIXI.DisplayObject.prototype.updateTransform = function()
|
||||||
PIXI.DisplayObject.prototype.getBounds = function()
|
PIXI.DisplayObject.prototype.getBounds = function()
|
||||||
{
|
{
|
||||||
return PIXI.EmptyRectangle;
|
return PIXI.EmptyRectangle;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.DisplayObject.prototype._renderWebGL = function(renderSession)
|
PIXI.DisplayObject.prototype._renderWebGL = function(renderSession)
|
||||||
{
|
{
|
||||||
// OVERWRITE
|
// OVERWRITE;
|
||||||
}
|
// this line is just here to pass jshinting :)
|
||||||
|
renderSession = renderSession;
|
||||||
|
};
|
||||||
|
|
||||||
PIXI.DisplayObject.prototype._renderCanvas = function(renderSession)
|
PIXI.DisplayObject.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
// OVERWRITE
|
// OVERWRITE;
|
||||||
}
|
// this line is just here to pass jshinting :)
|
||||||
|
renderSession = renderSession;
|
||||||
|
};
|
||||||
|
|
||||||
PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0);
|
PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0);
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
|
||||||
|
|
||||||
// update the stage refference..
|
// update the stage refference..
|
||||||
|
|
||||||
if(this.stage)this.setStageReference(this.stage)
|
if(this.stage)this.setStageReference(this.stage);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
|
||||||
|
|
||||||
this.children.splice(index, 0, child);
|
this.children.splice(index, 0, child);
|
||||||
|
|
||||||
if(this.stage)this.setStageReference(this.stage)
|
if(this.stage)this.setStageReference(this.stage);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -141,7 +141,7 @@ PIXI.DisplayObjectContainer.prototype.swapChildren = function(child, child2)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.children[index1] = child2;
|
this.children[index1] = child2;
|
||||||
this.children[index2] = child1;
|
this.children[index2] = child;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ PIXI.DisplayObjectContainer.prototype.getBounds = function()
|
||||||
//this._currentBounds = bounds;
|
//this._currentBounds = bounds;
|
||||||
|
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage)
|
PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage)
|
||||||
{
|
{
|
||||||
|
@ -264,7 +264,7 @@ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage)
|
||||||
if(child.interactive)this.stage.dirty = true;
|
if(child.interactive)this.stage.dirty = true;
|
||||||
child.setStageReference(stage);
|
child.setStageReference(stage);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.DisplayObjectContainer.prototype.removeStageReference = function()
|
PIXI.DisplayObjectContainer.prototype.removeStageReference = function()
|
||||||
{
|
{
|
||||||
|
@ -275,12 +275,14 @@ PIXI.DisplayObjectContainer.prototype.removeStageReference = function()
|
||||||
child.removeStageReference();
|
child.removeStageReference();
|
||||||
child.stage = null;
|
child.stage = null;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
|
PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
|
||||||
{
|
{
|
||||||
if(this.visible === false || this.alpha === 0)return;
|
if(this.visible === false || this.alpha === 0)return;
|
||||||
|
|
||||||
|
var i,j;
|
||||||
|
|
||||||
if(this._mask || this._filters)
|
if(this._mask || this._filters)
|
||||||
{
|
{
|
||||||
if(this._mask)
|
if(this._mask)
|
||||||
|
@ -297,10 +299,9 @@ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
|
||||||
}
|
}
|
||||||
|
|
||||||
// simple render children!
|
// simple render children!
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSession.spriteBatch.stop();
|
renderSession.spriteBatch.stop();
|
||||||
|
@ -313,13 +314,12 @@ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// simple render children!
|
// simple render children!
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
|
PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -340,4 +340,4 @@ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
renderSession.maskManager.popMask(renderSession.context);
|
renderSession.maskManager.popMask(renderSession.context);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -237,7 +237,7 @@ PIXI.Sprite.prototype.getBounds = function()
|
||||||
this._currentBounds = bounds;
|
this._currentBounds = bounds;
|
||||||
|
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.Sprite.prototype._renderWebGL = function(renderSession)
|
PIXI.Sprite.prototype._renderWebGL = function(renderSession)
|
||||||
|
@ -245,6 +245,8 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
|
||||||
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
||||||
if(this.visible === false || this.alpha === 0)return;
|
if(this.visible === false || this.alpha === 0)return;
|
||||||
|
|
||||||
|
var i,j;
|
||||||
|
|
||||||
// do a quick check to see if this element has a mask or a filter.
|
// do a quick check to see if this element has a mask or a filter.
|
||||||
if(this._mask || this._filters)
|
if(this._mask || this._filters)
|
||||||
{
|
{
|
||||||
|
@ -267,10 +269,9 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
|
||||||
spriteBatch.render(this);
|
spriteBatch.render(this);
|
||||||
|
|
||||||
// now loop through the children and make sure they get rendered
|
// now loop through the children and make sure they get rendered
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// time to stop the sprite batch as either a mask element or a filter draw will happen next
|
// time to stop the sprite batch as either a mask element or a filter draw will happen next
|
||||||
|
@ -286,16 +287,15 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
|
||||||
renderSession.spriteBatch.render(this);
|
renderSession.spriteBatch.render(this);
|
||||||
|
|
||||||
// simple render children!
|
// simple render children!
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO check culling
|
//TODO check culling
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.Sprite.prototype._renderCanvas = function(renderSession)
|
PIXI.Sprite.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -405,7 +405,7 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
renderSession.maskManager.popMask(renderSession.context);
|
renderSession.maskManager.popMask(renderSession.context);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// some helper functions..
|
// some helper functions..
|
||||||
|
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This object is one that will allow you to specify custom rendering functions based on render type
|
|
||||||
*
|
|
||||||
* @class CustomRenderable
|
|
||||||
* @extends DisplayObject
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
PIXI.CustomRenderable = function()
|
|
||||||
{
|
|
||||||
PIXI.DisplayObject.call( this );
|
|
||||||
|
|
||||||
this.renderable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
PIXI.CustomRenderable.prototype = Object.create( PIXI.DisplayObject.prototype );
|
|
||||||
PIXI.CustomRenderable.prototype.constructor = PIXI.CustomRenderable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If this object is being rendered by a CanvasRenderer it will call this callback
|
|
||||||
*
|
|
||||||
* @method renderCanvas
|
|
||||||
* @param renderer {CanvasRenderer} The renderer instance
|
|
||||||
*/
|
|
||||||
PIXI.CustomRenderable.prototype.renderCanvas = function()
|
|
||||||
{
|
|
||||||
// override!
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If this object is being rendered by a WebGLRenderer it will call this callback to initialize
|
|
||||||
*
|
|
||||||
* @method initWebGL
|
|
||||||
* @param renderer {WebGLRenderer} The renderer instance
|
|
||||||
*/
|
|
||||||
PIXI.CustomRenderable.prototype.initWebGL = function()
|
|
||||||
{
|
|
||||||
// override!
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If this object is being rendered by a WebGLRenderer it will call this callback
|
|
||||||
*
|
|
||||||
* @method renderWebGL
|
|
||||||
* @param rendererGroup {WebGLRenderGroup} The renderer group instance
|
|
||||||
* @param projectionMatrix {Matrix} The object's projection matrix
|
|
||||||
*/
|
|
||||||
PIXI.CustomRenderable.prototype.renderWebGL = function()
|
|
||||||
{
|
|
||||||
// not sure if both needed? but ya have for now!
|
|
||||||
// override!
|
|
||||||
};
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ PIXI.TilingSprite.prototype.constructor = PIXI.TilingSprite;
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(PIXI.TilingSprite.prototype, 'width', {
|
Object.defineProperty(PIXI.TilingSprite.prototype, 'width', {
|
||||||
get: function() {
|
get: function() {
|
||||||
return this._width
|
return this._width;
|
||||||
},
|
},
|
||||||
set: function(value) {
|
set: function(value) {
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ Object.defineProperty(PIXI.TilingSprite.prototype, 'width', {
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(PIXI.TilingSprite.prototype, 'height', {
|
Object.defineProperty(PIXI.TilingSprite.prototype, 'height', {
|
||||||
get: function() {
|
get: function() {
|
||||||
return this._height
|
return this._height;
|
||||||
},
|
},
|
||||||
set: function(value) {
|
set: function(value) {
|
||||||
this._height = value;
|
this._height = value;
|
||||||
|
@ -93,6 +93,8 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
|
||||||
|
|
||||||
if(this.visible === false || this.alpha === 0)return;
|
if(this.visible === false || this.alpha === 0)return;
|
||||||
|
|
||||||
|
var i,j;
|
||||||
|
|
||||||
if(this.mask || this.filters)
|
if(this.mask || this.filters)
|
||||||
{
|
{
|
||||||
if(this.mask)
|
if(this.mask)
|
||||||
|
@ -112,10 +114,9 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
|
||||||
renderSession.spriteBatch.renderTilingSprite(this);
|
renderSession.spriteBatch.renderTilingSprite(this);
|
||||||
|
|
||||||
// simple render children!
|
// simple render children!
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSession.spriteBatch.stop();
|
renderSession.spriteBatch.stop();
|
||||||
|
@ -130,13 +131,12 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
|
||||||
renderSession.spriteBatch.renderTilingSprite(this);
|
renderSession.spriteBatch.renderTilingSprite(this);
|
||||||
|
|
||||||
// simple render children!
|
// simple render children!
|
||||||
for(var i=0,j=this.children.length; i<j; i++)
|
for(i=0,j=this.children.length; i<j; i++)
|
||||||
{
|
{
|
||||||
var child = this.children[i];
|
this.children[i]._renderWebGL(renderSession);
|
||||||
child._renderWebGL(renderSession);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
|
PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -172,4 +172,4 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
|
||||||
context.translate(-tilePosition.x, -tilePosition.y);
|
context.translate(-tilePosition.x, -tilePosition.y);
|
||||||
|
|
||||||
context.closePath();
|
context.closePath();
|
||||||
}
|
};
|
||||||
|
|
|
@ -109,15 +109,15 @@ PIXI.JsonLoader.prototype.onJSONLoaded = function () {
|
||||||
// check to see ifthe sprite ha been trimmed..
|
// check to see ifthe sprite ha been trimmed..
|
||||||
if (frameData[i].trimmed) {
|
if (frameData[i].trimmed) {
|
||||||
|
|
||||||
var texture = PIXI.TextureCache[i]
|
var texture = PIXI.TextureCache[i];
|
||||||
|
|
||||||
texture.trimmed = true;
|
texture.trimmed = true;
|
||||||
|
|
||||||
var actualSize = frameData[i].sourceSize;
|
var actualSize = frameData[i].sourceSize;
|
||||||
var realSize = frameData[i].spriteSourceSize;
|
var realSize = frameData[i].spriteSourceSize;
|
||||||
|
|
||||||
texture.trim.x = realSize.x
|
texture.trim.x = realSize.x;
|
||||||
texture.trim.y = realSize.y
|
texture.trim.y = realSize.y;
|
||||||
texture.trim.realWidth = actualSize.w;
|
texture.trim.realWidth = actualSize.w;
|
||||||
texture.trim.realHeight = actualSize.h;
|
texture.trim.realHeight = actualSize.h;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ PIXI.Graphics = function()
|
||||||
*/
|
*/
|
||||||
this.graphicsData = [];
|
this.graphicsData = [];
|
||||||
|
|
||||||
this.tint = 0xFFFFFF// * Math.random();
|
this.tint = 0xFFFFFF;// * Math.random();
|
||||||
|
|
||||||
this.blendMode = PIXI.blendModes.NORMAL;
|
this.blendMode = PIXI.blendModes.NORMAL;
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ PIXI.Graphics.prototype._renderWebGL = function(renderSession)
|
||||||
// check blend mode
|
// check blend mode
|
||||||
if(this.blendMode !== renderSession.spriteBatch.currentBlendMode)
|
if(this.blendMode !== renderSession.spriteBatch.currentBlendMode)
|
||||||
{
|
{
|
||||||
this.spriteBatch.currentBlendMode = sprite.blendMode;
|
this.spriteBatch.currentBlendMode = this.blendMode;
|
||||||
var blendModeWebGL = PIXI.blendModesWebGL[renderSession.spriteBatch.currentBlendMode];
|
var blendModeWebGL = PIXI.blendModesWebGL[renderSession.spriteBatch.currentBlendMode];
|
||||||
this.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
this.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ PIXI.Graphics.prototype._renderWebGL = function(renderSession)
|
||||||
PIXI.WebGLGraphics.renderGraphics(this, renderSession);
|
PIXI.WebGLGraphics.renderGraphics(this, renderSession);
|
||||||
|
|
||||||
renderSession.spriteBatch.start();
|
renderSession.spriteBatch.start();
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.Graphics.prototype._renderCanvas = function(renderSession)
|
PIXI.Graphics.prototype._renderCanvas = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -269,7 +269,7 @@ PIXI.Graphics.prototype._renderCanvas = function(renderSession)
|
||||||
|
|
||||||
context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]);
|
context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]);
|
||||||
PIXI.CanvasGraphics.renderGraphics(this, context);
|
PIXI.CanvasGraphics.renderGraphics(this, context);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.Graphics.prototype.getBounds = function()
|
PIXI.Graphics.prototype.getBounds = function()
|
||||||
{
|
{
|
||||||
|
@ -337,7 +337,7 @@ PIXI.Graphics.prototype.getBounds = function()
|
||||||
bounds.height = maxY - minY;
|
bounds.height = maxY - minY;
|
||||||
|
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.Graphics.prototype.updateBounds = function()
|
PIXI.Graphics.prototype.updateBounds = function()
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,26 +66,26 @@ PIXI.CanvasRenderer = function(width, height, view, transparent)
|
||||||
* @property view
|
* @property view
|
||||||
* @type Canvas
|
* @type Canvas
|
||||||
*/
|
*/
|
||||||
this.view = view || document.createElement( 'canvas' );
|
this.view = view || document.createElement( "canvas" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The canvas context that the everything is drawn to
|
* The canvas context that the everything is drawn to
|
||||||
* @property context
|
* @property context
|
||||||
* @type Canvas 2d Context
|
* @type Canvas 2d Context
|
||||||
*/
|
*/
|
||||||
this.context = this.view.getContext( '2d' );
|
this.context = this.view.getContext( "2d" );
|
||||||
|
|
||||||
//some filter variables
|
//some filter variables
|
||||||
this.smoothProperty = null;
|
this.smoothProperty = null;
|
||||||
|
|
||||||
if('imageSmoothingEnabled' in this.context)
|
if("imageSmoothingEnabled" in this.context)
|
||||||
this.smoothProperty = 'imageSmoothingEnabled';
|
this.smoothProperty = "imageSmoothingEnabled";
|
||||||
else if('webkitImageSmoothingEnabled' in this.context)
|
else if("webkitImageSmoothingEnabled" in this.context)
|
||||||
this.smoothProperty = 'webkitImageSmoothingEnabled';
|
this.smoothProperty = "webkitImageSmoothingEnabled";
|
||||||
else if('mozImageSmoothingEnabled' in this.context)
|
else if("mozImageSmoothingEnabled" in this.context)
|
||||||
this.smoothProperty = 'mozImageSmoothingEnabled';
|
this.smoothProperty = "mozImageSmoothingEnabled";
|
||||||
else if('oImageSmoothingEnabled' in this.context)
|
else if("oImageSmoothingEnabled" in this.context)
|
||||||
this.smoothProperty = 'oImageSmoothingEnabled';
|
this.smoothProperty = "oImageSmoothingEnabled";
|
||||||
|
|
||||||
this.scaleMode = null;
|
this.scaleMode = null;
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ PIXI.CanvasRenderer.prototype.renderStripFlat = function(strip)
|
||||||
context.lineTo(x2, y2);
|
context.lineTo(x2, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.fillStyle = '#FF0000';
|
context.fillStyle = "#FF0000";
|
||||||
context.fill();
|
context.fill();
|
||||||
context.closePath();
|
context.closePath();
|
||||||
};
|
};
|
||||||
|
@ -281,22 +281,22 @@ PIXI.CanvasBuffer = function(width, height)
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
|
||||||
this.canvas = document.createElement( 'canvas' );
|
this.canvas = document.createElement( "canvas" );
|
||||||
this.context = this.canvas.getContext( '2d' );
|
this.context = this.canvas.getContext( "2d" );
|
||||||
|
|
||||||
// this.context.f
|
// this.context.f
|
||||||
this.canvas.width = width;
|
this.canvas.width = width;
|
||||||
this.canvas.height = height;
|
this.canvas.height = height;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasBuffer.prototype.clear = function()
|
PIXI.CanvasBuffer.prototype.clear = function()
|
||||||
{
|
{
|
||||||
this.context.clearRect(0,0, this.width, this.height);
|
this.context.clearRect(0,0, this.width, this.height);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasBuffer.prototype.resize = function(width, height)
|
PIXI.CanvasBuffer.prototype.resize = function(width, height)
|
||||||
{
|
{
|
||||||
this.width = this.canvas.width = width;
|
this.width = this.canvas.width = width;
|
||||||
this.height = this.canvas.height = height;
|
this.height = this.canvas.height = height;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
PIXI.CanvasMaskManager = function()
|
PIXI.CanvasMaskManager = function()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, context)
|
PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, context)
|
||||||
{
|
{
|
||||||
|
@ -26,9 +26,9 @@ PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, context)
|
||||||
context.clip();
|
context.clip();
|
||||||
|
|
||||||
maskData.worldAlpha = cacheAlpha;
|
maskData.worldAlpha = cacheAlpha;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasMaskManager.prototype.popMask = function(context)
|
PIXI.CanvasMaskManager.prototype.popMask = function(context)
|
||||||
{
|
{
|
||||||
context.restore();
|
context.restore();
|
||||||
}
|
};
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mat Groves
|
* @author Mat Groves
|
||||||
*
|
*
|
||||||
|
@ -6,16 +7,14 @@
|
||||||
|
|
||||||
PIXI.CanvasTinter = function()
|
PIXI.CanvasTinter = function()
|
||||||
{
|
{
|
||||||
/// this.textureCach
|
/// this.textureCach
|
||||||
}
|
};
|
||||||
|
|
||||||
//PIXI.CanvasTinter.cachTint = true;
|
//PIXI.CanvasTinter.cachTint = true;
|
||||||
|
|
||||||
|
|
||||||
PIXI.CanvasTinter.getTintedTexture = function(sprite, color, canvas)
|
PIXI.CanvasTinter.getTintedTexture = function(sprite, color)
|
||||||
{
|
{
|
||||||
var cacheMode = 0;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// cach on sprite
|
// cach on sprite
|
||||||
// cach on texture
|
// cach on texture
|
||||||
|
@ -25,7 +24,7 @@ PIXI.CanvasTinter.getTintedTexture = function(sprite, color, canvas)
|
||||||
|
|
||||||
color = PIXI.CanvasTinter.roundColor(color);
|
color = PIXI.CanvasTinter.roundColor(color);
|
||||||
|
|
||||||
var stringColor = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
|
var stringColor = "#" + ("00000" + ( color | 0).toString(16)).substr(-6);
|
||||||
|
|
||||||
texture.tintCache = texture.tintCache || {};
|
texture.tintCache = texture.tintCache || {};
|
||||||
|
|
||||||
|
@ -41,38 +40,38 @@ PIXI.CanvasTinter.getTintedTexture = function(sprite, color, canvas)
|
||||||
|
|
||||||
if(PIXI.CanvasTinter.convertTintToImage)
|
if(PIXI.CanvasTinter.convertTintToImage)
|
||||||
{
|
{
|
||||||
// is this better?
|
// is this better?
|
||||||
var tintImage = new Image();
|
var tintImage = new Image();
|
||||||
tintImage.src = canvas.toDataURL();
|
tintImage.src = canvas.toDataURL();
|
||||||
|
|
||||||
texture.tintCache[stringColor] = tintImage;
|
texture.tintCache[stringColor] = tintImage;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
texture.tintCache[stringColor] = canvas;
|
texture.tintCache[stringColor] = canvas;
|
||||||
// if we are not converting the texture to an image then we need to lose the refferance to the canvas
|
// if we are not converting the texture to an image then we need to lose the refferance to the canvas
|
||||||
PIXI.CanvasTinter.canvas = null;
|
PIXI.CanvasTinter.canvas = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas)
|
PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas)
|
||||||
{
|
{
|
||||||
var context = canvas.getContext( '2d' );
|
var context = canvas.getContext( "2d" );
|
||||||
|
|
||||||
var frame = texture.frame;
|
var frame = texture.frame;
|
||||||
|
|
||||||
canvas.width = frame.width;
|
canvas.width = frame.width;
|
||||||
canvas.height = frame.height;
|
canvas.height = frame.height;
|
||||||
|
|
||||||
context.fillStyle = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
|
context.fillStyle = "#" + ("00000" + ( color | 0).toString(16)).substr(-6);
|
||||||
|
|
||||||
context.fillRect(0, 0, frame.width, frame.height);
|
context.fillRect(0, 0, frame.width, frame.height);
|
||||||
|
|
||||||
context.globalCompositeOperation = 'multiply';
|
context.globalCompositeOperation = "multiply";
|
||||||
|
|
||||||
context.drawImage(texture.baseTexture.source,
|
context.drawImage(texture.baseTexture.source,
|
||||||
frame.x,
|
frame.x,
|
||||||
|
@ -84,7 +83,7 @@ PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas)
|
||||||
frame.width,
|
frame.width,
|
||||||
frame.height);
|
frame.height);
|
||||||
|
|
||||||
context.globalCompositeOperation = 'destination-atop';
|
context.globalCompositeOperation = "destination-atop";
|
||||||
|
|
||||||
context.drawImage(texture.baseTexture.source,
|
context.drawImage(texture.baseTexture.source,
|
||||||
frame.x,
|
frame.x,
|
||||||
|
@ -95,11 +94,11 @@ PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas)
|
||||||
0,
|
0,
|
||||||
frame.width,
|
frame.width,
|
||||||
frame.height);
|
frame.height);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
|
PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
|
||||||
{
|
{
|
||||||
var context = canvas.getContext( '2d' );
|
var context = canvas.getContext( "2d" );
|
||||||
|
|
||||||
var frame = texture.frame;
|
var frame = texture.frame;
|
||||||
|
|
||||||
|
@ -108,11 +107,11 @@ PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
context.globalCompositeOperation = 'copy';
|
context.globalCompositeOperation = "copy";
|
||||||
context.fillStyle = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
|
context.fillStyle = "#" + ("00000" + ( color | 0).toString(16)).substr(-6);
|
||||||
context.fillRect(0, 0, frame.width, frame.height);
|
context.fillRect(0, 0, frame.width, frame.height);
|
||||||
|
|
||||||
context.globalCompositeOperation = 'destination-atop';
|
context.globalCompositeOperation = "destination-atop";
|
||||||
context.drawImage(texture.baseTexture.source,
|
context.drawImage(texture.baseTexture.source,
|
||||||
frame.x,
|
frame.x,
|
||||||
frame.y,
|
frame.y,
|
||||||
|
@ -124,21 +123,21 @@ PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
|
||||||
frame.height);
|
frame.height);
|
||||||
|
|
||||||
|
|
||||||
//context.globalCompositeOperation = 'copy';
|
//context.globalCompositeOperation = "copy";
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.CanvasTinter.tintWithPerPixel = function(texture, color, canvas)
|
PIXI.CanvasTinter.tintWithPerPixel = function(texture, color, canvas)
|
||||||
{
|
{
|
||||||
var context = canvas.getContext( '2d' );
|
var context = canvas.getContext( "2d" );
|
||||||
|
|
||||||
var frame = texture.frame;
|
var frame = texture.frame;
|
||||||
|
|
||||||
canvas.width = frame.width;
|
canvas.width = frame.width;
|
||||||
canvas.height = frame.height;
|
canvas.height = frame.height;
|
||||||
|
|
||||||
context.globalCompositeOperation = 'copy';
|
context.globalCompositeOperation = "copy";
|
||||||
context.drawImage(texture.baseTexture.source,
|
context.drawImage(texture.baseTexture.source,
|
||||||
frame.x,
|
frame.x,
|
||||||
frame.y,
|
frame.y,
|
||||||
|
@ -152,19 +151,19 @@ PIXI.CanvasTinter.tintWithPerPixel = function(texture, color, canvas)
|
||||||
var rgbValues = PIXI.hex2rgb(color);
|
var rgbValues = PIXI.hex2rgb(color);
|
||||||
var r = rgbValues[0], g = rgbValues[1], b = rgbValues[2];
|
var r = rgbValues[0], g = rgbValues[1], b = rgbValues[2];
|
||||||
|
|
||||||
var pixelData = context.getImageData(0, 0, frame.width, frame.height)
|
var pixelData = context.getImageData(0, 0, frame.width, frame.height);
|
||||||
|
|
||||||
var pixels = pixelData.data;
|
var pixels = pixelData.data;
|
||||||
|
|
||||||
for (var i = 0; i < pixels.length; i += 4)
|
for (var i = 0; i < pixels.length; i += 4)
|
||||||
{
|
{
|
||||||
pixels[i+0] *= r;
|
pixels[i+0] *= r;
|
||||||
pixels[i+1] *= g;
|
pixels[i+1] *= g;
|
||||||
pixels[i+2] *= b;
|
pixels[i+2] *= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.putImageData(pixelData, 0, 0);
|
context.putImageData(pixelData, 0, 0);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasTinter.roundColor = function(color)
|
PIXI.CanvasTinter.roundColor = function(color)
|
||||||
{
|
{
|
||||||
|
@ -176,52 +175,8 @@ PIXI.CanvasTinter.roundColor = function(color)
|
||||||
rgbValues[1] = Math.round(rgbValues[1] * step) / step;
|
rgbValues[1] = Math.round(rgbValues[1] * step) / step;
|
||||||
rgbValues[2] = Math.round(rgbValues[2] * step) / step;
|
rgbValues[2] = Math.round(rgbValues[2] * step) / step;
|
||||||
|
|
||||||
return PIXI.rgb2hex(rgbValues)
|
return PIXI.rgb2hex(rgbValues);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.CanvasTinter._getTintedTextureFast = function(texture, color, canvas)
|
|
||||||
{
|
|
||||||
var stringColor = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
|
|
||||||
|
|
||||||
// clone texture..
|
|
||||||
var canvas = canvas || document.createElement("canvas");
|
|
||||||
var context = canvas.getContext( '2d' );
|
|
||||||
|
|
||||||
var frame = texture.frame;
|
|
||||||
|
|
||||||
context.width = frame.width;
|
|
||||||
context.height = frame.height;
|
|
||||||
|
|
||||||
context.fillStyle = stringColor;
|
|
||||||
|
|
||||||
context.fillRect(0, 0, frame.width, frame.height);
|
|
||||||
|
|
||||||
context.globalCompositeOperation = 'multiply';
|
|
||||||
|
|
||||||
context.drawImage(texture.baseTexture.source,
|
|
||||||
frame.x,
|
|
||||||
frame.y,
|
|
||||||
frame.width,
|
|
||||||
frame.height,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
frame.width,
|
|
||||||
frame.height);
|
|
||||||
|
|
||||||
context.globalCompositeOperation = 'destination-in';
|
|
||||||
|
|
||||||
context.drawImage(texture.baseTexture.source,
|
|
||||||
frame.x,
|
|
||||||
frame.y,
|
|
||||||
frame.width,
|
|
||||||
frame.height,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
frame.width,
|
|
||||||
frame.height);
|
|
||||||
|
|
||||||
return canvas;
|
|
||||||
}
|
|
||||||
|
|
||||||
PIXI.CanvasTinter.cacheStepsPerColorChannel = 8;
|
PIXI.CanvasTinter.cacheStepsPerColorChannel = 8;
|
||||||
PIXI.CanvasTinter.convertTintToImage = false;
|
PIXI.CanvasTinter.convertTintToImage = false;
|
||||||
|
|
|
@ -84,7 +84,7 @@ PIXI.PixiShader.prototype.init = function()
|
||||||
PIXI.PixiShader.prototype.initUniforms = function()
|
PIXI.PixiShader.prototype.initUniforms = function()
|
||||||
{
|
{
|
||||||
this.textureCount = 1;
|
this.textureCount = 1;
|
||||||
var gl = this.gl
|
var gl = this.gl;
|
||||||
var uniform;
|
var uniform;
|
||||||
|
|
||||||
for (var key in this.uniforms)
|
for (var key in this.uniforms)
|
||||||
|
|
|
@ -61,7 +61,7 @@ PIXI.WebGLRenderer = function(width, height, view, transparent, antialias)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//try 'webgl'
|
//try 'webgl'
|
||||||
try {
|
try {
|
||||||
this.gl = this.view.getContext('webgl', options);
|
this.gl = this.view.getContext('webgl', options);
|
||||||
} catch (e2) {
|
} catch (e2) {
|
||||||
// fail, not able to get a context
|
// fail, not able to get a context
|
||||||
throw new Error(' This browser does not support webGL. Try using the canvas renderer' + this);
|
throw new Error(' This browser does not support webGL. Try using the canvas renderer' + this);
|
||||||
|
@ -217,7 +217,7 @@ PIXI.WebGLRenderer.prototype.renderDisplayObject = function(displayObject, proje
|
||||||
|
|
||||||
// finish the sprite batch
|
// finish the sprite batch
|
||||||
this.spriteBatch.end();
|
this.spriteBatch.end();
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the textures loaded into this webgl renderer
|
* Updates the textures loaded into this webgl renderer
|
||||||
|
@ -235,7 +235,7 @@ PIXI.WebGLRenderer.updateTextures = function()
|
||||||
PIXI.WebGLRenderer.updateTexture(PIXI.texturesToUpdate[i]);
|
PIXI.WebGLRenderer.updateTexture(PIXI.texturesToUpdate[i]);
|
||||||
|
|
||||||
|
|
||||||
for (var i=0; i < PIXI.Texture.frameUpdates.length; i++)
|
for (i=0; i < PIXI.Texture.frameUpdates.length; i++)
|
||||||
PIXI.WebGLRenderer.updateTextureFrame(PIXI.Texture.frameUpdates[i]);
|
PIXI.WebGLRenderer.updateTextureFrame(PIXI.Texture.frameUpdates[i]);
|
||||||
|
|
||||||
for (i = 0; i < PIXI.texturesToDestroy.length; i++)
|
for (i = 0; i < PIXI.texturesToDestroy.length; i++)
|
||||||
|
|
|
@ -380,7 +380,6 @@ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function()
|
||||||
this.colorArray,
|
this.colorArray,
|
||||||
gl.STATIC_DRAW);
|
gl.STATIC_DRAW);
|
||||||
|
|
||||||
this.colorAttribute
|
|
||||||
// bind and upload the index
|
// bind and upload the index
|
||||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
||||||
gl.bufferData(
|
gl.bufferData(
|
||||||
|
@ -535,7 +534,7 @@ PIXI.FilterTexture.prototype.clear = function()
|
||||||
|
|
||||||
gl.clearColor(0,0,0, 0);
|
gl.clearColor(0,0,0, 0);
|
||||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.FilterTexture.prototype.resize = function(width, height)
|
PIXI.FilterTexture.prototype.resize = function(width, height)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projectio
|
||||||
{
|
{
|
||||||
var gl = renderSession.gl;
|
var gl = renderSession.gl;
|
||||||
var projection = renderSession.projection,
|
var projection = renderSession.projection,
|
||||||
offset = renderSession.offset;
|
offset = renderSession.offset,
|
||||||
shader = renderSession.shaderManager.primitiveShader;
|
shader = renderSession.shaderManager.primitiveShader;
|
||||||
|
|
||||||
if(!graphics._webGL)graphics._webGL = {points:[], indices:[], lastIndex:0,
|
if(!graphics._webGL)graphics._webGL = {points:[], indices:[], lastIndex:0,
|
||||||
|
|
|
@ -7,7 +7,7 @@ PIXI.WebGLMaskManager = function(gl)
|
||||||
this.gl = gl;
|
this.gl = gl;
|
||||||
this.maskStack = [];
|
this.maskStack = [];
|
||||||
this.maskPosition = 0;
|
this.maskPosition = 0;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession)
|
PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession)
|
||||||
gl.colorMask(true, true, true, true);
|
gl.colorMask(true, true, true, true);
|
||||||
gl.stencilFunc(gl.NOTEQUAL,0, this.maskStack.length);
|
gl.stencilFunc(gl.NOTEQUAL,0, this.maskStack.length);
|
||||||
gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP);
|
gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP);
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLMaskManager.prototype.popMask = function(renderSession)
|
PIXI.WebGLMaskManager.prototype.popMask = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -54,4 +54,4 @@ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST);
|
if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST);
|
||||||
}
|
};
|
|
@ -24,7 +24,7 @@ PIXI.WebGLShaderManager = function(gl)
|
||||||
|
|
||||||
// the final one is used for the rendering strips
|
// the final one is used for the rendering strips
|
||||||
//this.stripShader = new PIXI.StripShader(gl);
|
//this.stripShader = new PIXI.StripShader(gl);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function()
|
PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function()
|
||||||
|
@ -54,14 +54,3 @@ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function()
|
||||||
gl.enableVertexAttribArray(this.defaultShader.colorAttribute);
|
gl.enableVertexAttribArray(this.defaultShader.colorAttribute);
|
||||||
gl.enableVertexAttribArray(this.defaultShader.aTextureCoord);
|
gl.enableVertexAttribArray(this.defaultShader.aTextureCoord);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.WebGLShaderManager.prototype.pushShader = function(maskData, renderSession)
|
|
||||||
{
|
|
||||||
// push a shader onto the stack..
|
|
||||||
}
|
|
||||||
|
|
||||||
PIXI.WebGLShaderManager.prototype.popShader = function(renderSession)
|
|
||||||
{
|
|
||||||
// push
|
|
||||||
}
|
|
|
@ -43,7 +43,7 @@ PIXI.WebGLSpriteBatch = function(gl)
|
||||||
this.indices[i + 3] = j + 0;
|
this.indices[i + 3] = j + 0;
|
||||||
this.indices[i + 4] = j + 2;
|
this.indices[i + 4] = j + 2;
|
||||||
this.indices[i + 5] = j + 3;
|
this.indices[i + 5] = j + 3;
|
||||||
};
|
}
|
||||||
|
|
||||||
//upload the index data
|
//upload the index data
|
||||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
||||||
|
@ -54,8 +54,8 @@ PIXI.WebGLSpriteBatch = function(gl)
|
||||||
|
|
||||||
this.drawing = false;
|
this.drawing = false;
|
||||||
this.currentBatchSize = 0;
|
this.currentBatchSize = 0;
|
||||||
this.currentBaseTexture;
|
this.currentBaseTexture = null;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession)
|
PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession)
|
||||||
{
|
{
|
||||||
|
@ -63,12 +63,12 @@ PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession)
|
||||||
this.shader = this.renderSession.shaderManager.defaultShader;
|
this.shader = this.renderSession.shaderManager.defaultShader;
|
||||||
|
|
||||||
this.start();
|
this.start();
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.end = function()
|
PIXI.WebGLSpriteBatch.prototype.end = function()
|
||||||
{
|
{
|
||||||
this.flush();
|
this.flush();
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.render = function(sprite)
|
PIXI.WebGLSpriteBatch.prototype.render = function(sprite)
|
||||||
|
@ -120,16 +120,16 @@ PIXI.WebGLSpriteBatch.prototype.render = function(sprite)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var w0 = (width ) * (1-aX);
|
w0 = (width ) * (1-aX);
|
||||||
var w1 = (width ) * -aX;
|
w1 = (width ) * -aX;
|
||||||
|
|
||||||
var h0 = height * (1-aY);
|
h0 = height * (1-aY);
|
||||||
var h1 = height * -aY;
|
h1 = height * -aY;
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = this.currentBatchSize * 4 * this.vertSize;
|
var index = this.currentBatchSize * 4 * this.vertSize;
|
||||||
|
|
||||||
worldTransform = sprite.worldTransform;
|
var worldTransform = sprite.worldTransform;
|
||||||
|
|
||||||
var a = worldTransform[0];
|
var a = worldTransform[0];
|
||||||
var b = worldTransform[3];
|
var b = worldTransform[3];
|
||||||
|
@ -182,7 +182,7 @@ PIXI.WebGLSpriteBatch.prototype.render = function(sprite)
|
||||||
this.currentBatchSize++;
|
this.currentBatchSize++;
|
||||||
|
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
|
PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
|
||||||
{
|
{
|
||||||
|
@ -202,7 +202,6 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
|
||||||
|
|
||||||
// set the textures uvs temporarily
|
// set the textures uvs temporarily
|
||||||
// TODO create a seperate texture so that we can tile part of a texture
|
// TODO create a seperate texture so that we can tile part of a texture
|
||||||
var tempUvs = texture._uvs;
|
|
||||||
|
|
||||||
if(!tilingSprite._uvs)tilingSprite._uvs = new Float32Array(8);
|
if(!tilingSprite._uvs)tilingSprite._uvs = new Float32Array(8);
|
||||||
|
|
||||||
|
@ -247,7 +246,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
|
||||||
|
|
||||||
var index = this.currentBatchSize * 4 * this.vertSize;
|
var index = this.currentBatchSize * 4 * this.vertSize;
|
||||||
|
|
||||||
worldTransform = tilingSprite.worldTransform;
|
var worldTransform = tilingSprite.worldTransform;
|
||||||
|
|
||||||
var a = worldTransform[0];
|
var a = worldTransform[0];
|
||||||
var b = worldTransform[3];
|
var b = worldTransform[3];
|
||||||
|
@ -298,7 +297,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
|
||||||
|
|
||||||
// increment the batchs
|
// increment the batchs
|
||||||
this.currentBatchSize++;
|
this.currentBatchSize++;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.flush = function()
|
PIXI.WebGLSpriteBatch.prototype.flush = function()
|
||||||
{
|
{
|
||||||
|
@ -322,12 +321,12 @@ PIXI.WebGLSpriteBatch.prototype.flush = function()
|
||||||
|
|
||||||
// increment the draw count
|
// increment the draw count
|
||||||
this.renderSession.drawCount++;
|
this.renderSession.drawCount++;
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.stop = function()
|
PIXI.WebGLSpriteBatch.prototype.stop = function()
|
||||||
{
|
{
|
||||||
this.flush();
|
this.flush();
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.start = function()
|
PIXI.WebGLSpriteBatch.prototype.start = function()
|
||||||
{
|
{
|
||||||
|
@ -355,7 +354,7 @@ PIXI.WebGLSpriteBatch.prototype.start = function()
|
||||||
{
|
{
|
||||||
this.setBlendMode(PIXI.blendModes.NORMAL);
|
this.setBlendMode(PIXI.blendModes.NORMAL);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode)
|
PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode)
|
||||||
{
|
{
|
||||||
|
@ -365,6 +364,6 @@ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode)
|
||||||
|
|
||||||
var blendModeWebGL = PIXI.blendModesWebGL[this.currentBlendMode];
|
var blendModeWebGL = PIXI.blendModesWebGL[this.currentBlendMode];
|
||||||
this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ PIXI.Texture.prototype.setFrame = function(frame)
|
||||||
|
|
||||||
PIXI.Texture.prototype._updateWebGLuvs = function()
|
PIXI.Texture.prototype._updateWebGLuvs = function()
|
||||||
{
|
{
|
||||||
if(!this._uvs)this._uvs = new Float32Array(8)
|
if(!this._uvs)this._uvs = new Float32Array(8);
|
||||||
|
|
||||||
var frame = this.frame;
|
var frame = this.frame;
|
||||||
var tw = this.baseTexture.width;
|
var tw = this.baseTexture.width;
|
||||||
|
@ -142,7 +142,7 @@ PIXI.Texture.prototype._updateWebGLuvs = function()
|
||||||
|
|
||||||
this._uvs[6] = frame.x / tw;
|
this._uvs[6] = frame.x / tw;
|
||||||
this._uvs[7] = (frame.y + frame.height) / th;
|
this._uvs[7] = (frame.y + frame.height) / th;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function that returns a texture based on an image url
|
* Helper function that returns a texture based on an image url
|
||||||
|
|
|
@ -116,11 +116,11 @@ PIXI.AjaxRequest = function AjaxRequest()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
PIXI.packColorRGBA = function(r, g, b, a)//r, g, b, a)
|
PIXI.packColorRGBA = function(r, g, b, a)//r, g, b, a)
|
||||||
{
|
{
|
||||||
// console.log(r, b, c, d)
|
// console.log(r, b, c, d)
|
||||||
return (Math.floor((r)*63) << 18) | (Math.floor((g)*63) << 12) | (Math.floor((b)*63) << 6)// | (Math.floor((a)*63))
|
return (Math.floor((r)*63) << 18) | (Math.floor((g)*63) << 12) | (Math.floor((b)*63) << 6);// | (Math.floor((a)*63))
|
||||||
// i = i | (Math.floor((a)*63));
|
// i = i | (Math.floor((a)*63));
|
||||||
// return i;
|
// return i;
|
||||||
// var r = (i / 262144.0 ) / 64;
|
// var r = (i / 262144.0 ) / 64;
|
||||||
|
@ -131,17 +131,19 @@ PIXI.packColorRGBA = function(r, g, b, a)//r, g, b, a)
|
||||||
// console.log(r, g, b, a);
|
// console.log(r, g, b, a);
|
||||||
// return i;
|
// return i;
|
||||||
|
|
||||||
}
|
};
|
||||||
|
*/
|
||||||
|
/*
|
||||||
PIXI.packColorRGB = function(r, g, b)//r, g, b, a)
|
PIXI.packColorRGB = function(r, g, b)//r, g, b, a)
|
||||||
{
|
{
|
||||||
return (Math.floor((r)*255) << 16) | (Math.floor((g)*255) << 8) | (Math.floor((b)*255));
|
return (Math.floor((r)*255) << 16) | (Math.floor((g)*255) << 8) | (Math.floor((b)*255));
|
||||||
}
|
};
|
||||||
|
|
||||||
PIXI.unpackColorRGB = function(r, g, b)//r, g, b, a)
|
PIXI.unpackColorRGB = function(r, g, b)//r, g, b, a)
|
||||||
{
|
{
|
||||||
return (Math.floor((r)*255) << 16) | (Math.floor((g)*255) << 8) | (Math.floor((b)*255));
|
return (Math.floor((r)*255) << 16) | (Math.floor((g)*255) << 8) | (Math.floor((b)*255));
|
||||||
}
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
PIXI.canUseNewCanvasBlendModes = function()
|
PIXI.canUseNewCanvasBlendModes = function()
|
||||||
{
|
{
|
||||||
|
@ -155,35 +157,6 @@ PIXI.canUseNewCanvasBlendModes = function()
|
||||||
context.fillStyle = '#fff';
|
context.fillStyle = '#fff';
|
||||||
context.fillRect(0,0,1,1);
|
context.fillRect(0,0,1,1);
|
||||||
return context.getImageData(0,0,1,1).data[0] === 0;
|
return context.getImageData(0,0,1,1).data[0] === 0;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DEBUGGING ONLY
|
|
||||||
*/
|
|
||||||
PIXI.runList = function(item)
|
|
||||||
{
|
|
||||||
window.console.log('>>>>>>>>>');
|
|
||||||
window.console.log('_');
|
|
||||||
var safe = 0;
|
|
||||||
var tmp = item.first;
|
|
||||||
window.console.log(tmp);
|
|
||||||
|
|
||||||
while(tmp._iNext)
|
|
||||||
{
|
|
||||||
safe++;
|
|
||||||
tmp = tmp._iNext;
|
|
||||||
window.console.log(tmp);
|
|
||||||
// console.log(tmp);
|
|
||||||
|
|
||||||
if(safe > 100)
|
|
||||||
{
|
|
||||||
window.console.log('BREAK');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue