Published files

This commit is contained in:
Mat Groves 2014-02-04 09:01:11 +00:00
parent e78a82fa34
commit 597e2b129e
2 changed files with 157 additions and 139 deletions

View file

@ -1,14 +1,14 @@
/**
* @license
* pixi.js - v1.4.3
* Copyright (c) 2012-2014, Mat Groves
* http://goodboydigital.com/
*
* Compiled: 2014-02-02
*
* pixi.js is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license.php
*/
/**
* @license
* pixi.js - v1.4.3
* Copyright (c) 2012-2014, Mat Groves
* http://goodboydigital.com/
*
* Compiled: 2014-02-04
*
* pixi.js is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license.php
*/
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -16,7 +16,7 @@
(function(){
var root = this;
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -62,7 +62,7 @@ PIXI.scaleModes = {
// interaction frequency
PIXI.INTERACTION_FREQUENCY = 30;
PIXI.AUTO_PREVENT_DEFAULT = true;
PIXI.AUTO_PREVENT_DEFAULT = true;
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -112,7 +112,7 @@ PIXI.Point.prototype.set = function(x, y)
this.y = y || ( (y !== 0) ? this.x : 0 ) ;
};
/**
* @author Mat Groves http://matgroves.com/
*/
@ -199,7 +199,7 @@ PIXI.Rectangle.prototype.contains = function(x, y)
// constructor
PIXI.Rectangle.prototype.constructor = PIXI.Rectangle;
PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0);
PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0);
/**
* @author Adrien Brault <adrien.brault@gmail.com>
*/
@ -277,7 +277,7 @@ PIXI.Polygon.prototype.contains = function(x, y)
// constructor
PIXI.Polygon.prototype.constructor = PIXI.Polygon;
/**
* @author Chad Engler <chad@pantherdev.com>
*/
@ -352,7 +352,7 @@ PIXI.Circle.prototype.contains = function(x, y)
// constructor
PIXI.Circle.prototype.constructor = PIXI.Circle;
/**
* @author Chad Engler <chad@pantherdev.com>
*/
@ -446,7 +446,7 @@ PIXI.Ellipse.prototype.getBounds = function()
// constructor
PIXI.Ellipse.prototype.constructor = PIXI.Ellipse;
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -516,7 +516,7 @@ PIXI.Matrix.prototype.toArray = function(transpose)
return array;//[this.a, this.b, this.tx, this.c, this.d, this.ty, 0, 0, 1];
};
PIXI.identityMatrix = new PIXI.Matrix();
PIXI.identityMatrix = new PIXI.Matrix();
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -911,6 +911,9 @@ PIXI.DisplayObject.prototype.updateTransform = function()
// TODO OPTIMIZE THIS!! with dirty
if(this.rotation !== this.rotationCache)
{
if(isNaN(parseFloat(this.rotation)))
throw new Error('DisplayObject rotation values must be numeric.');
this.rotationCache = this.rotation;
this._sr = Math.sin(this.rotation);
this._cr = Math.cos(this.rotation);
@ -1043,7 +1046,8 @@ Object.defineProperty(PIXI.DisplayObject.prototype, 'y', {
set: function(value) {
this.position.y = value;
}
});
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -1416,7 +1420,7 @@ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
}
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -1880,7 +1884,7 @@ PIXI.Sprite.fromImage = function(imageId)
var texture = PIXI.Texture.fromImage(imageId);
return new PIXI.Sprite(texture);
};
/**
* @author Mat Groves http://matgroves.com/
*/
@ -2037,7 +2041,7 @@ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession)
context.restore();
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -2204,7 +2208,7 @@ PIXI.MovieClip.prototype.updateTransform = function()
}
}
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -2216,7 +2220,7 @@ PIXI.FilterBlock = function()
this.visible = true;
this.renderable = true;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -2527,7 +2531,7 @@ PIXI.Text.prototype.destroy = function(destroyTexture)
};
PIXI.Text.heightCache = {};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -2550,6 +2554,8 @@ PIXI.BitmapText = function(text, style)
{
PIXI.DisplayObjectContainer.call(this);
this._pool = [];
this.setText(text);
this.setStyle(style);
this.updateText();
@ -2655,13 +2661,28 @@ PIXI.BitmapText.prototype.updateText = function()
lineAlignOffsets.push(alignOffset);
}
for(i = 0; i < chars.length; i++)
var lenChildren = this.children.length;
var lenChars = chars.length;
for(i = 0; i < lenChars; i++)
{
var c = new PIXI.Sprite(chars[i].texture); //PIXI.Sprite.fromFrame(chars[i].charCode);
var c = i < lenChildren ? this.children[i] : this._pool.pop(); // get old child if have. if not - take from pool.
if (c) c.setTexture(chars[i].texture); // check if got one before.
else c = new PIXI.Sprite(chars[i].texture); // if no create new one.
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
c.position.y = chars[i].position.y * scale;
c.scale.x = c.scale.y = scale;
this.addChild(c);
if (!c.parent) this.addChild(c);
}
// remove unnecessary children.
// and put their into the pool.
while(this.children.length > lenChars)
{
var child = this.getChildAt(this.children.length - 1);
this._pool.push(child);
this.removeChild(child);
}
this.width = maxLineWidth * scale;
@ -2678,12 +2699,7 @@ PIXI.BitmapText.prototype.updateTransform = function()
{
if(this.dirty)
{
while(this.children.length > 0)
{
this.removeChild(this.getChildAt(0));
}
this.updateText();
this.dirty = false;
}
@ -2691,7 +2707,7 @@ PIXI.BitmapText.prototype.updateTransform = function()
};
PIXI.BitmapText.fonts = {};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -2754,7 +2770,7 @@ PIXI.InteractionData.prototype.getLocalPosition = function(displayObject)
};
// constructor
PIXI.InteractionData.prototype.constructor = PIXI.InteractionData;
PIXI.InteractionData.prototype.constructor = PIXI.InteractionData;
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -2817,6 +2833,8 @@ PIXI.InteractionManager = function(stage)
this.last = 0;
this.currentCursorStyle = 'inherit';
this.mouseOut = false;
};
// constructor
@ -3142,7 +3160,6 @@ PIXI.InteractionManager.prototype.onMouseOut = function()
for (var i = 0; i < length; i++)
{
var item = this.interactiveItems[i];
if(item.__isOver)
{
this.mouse.target = item;
@ -3150,6 +3167,12 @@ PIXI.InteractionManager.prototype.onMouseOut = function()
item.__isOver = false;
}
}
this.mouseOut = true;
// move the mouse to an impossible position
this.mouse.global.x = -10000;
this.mouse.global.y = -10000;
};
/**
@ -3445,7 +3468,7 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
this.pool.push(touchData);
this.touchs[touchEvent.identifier] = null;
}
};
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -3581,7 +3604,7 @@ PIXI.Stage.prototype.getMousePosition = function()
{
return this.interactionManager.mouse.global;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -3779,7 +3802,7 @@ PIXI.getNextPowerOfTwo = function(number)
return result;
}
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -3887,7 +3910,7 @@ PIXI.EventTarget = function () {
a.length = 0;
};
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -3936,7 +3959,7 @@ PIXI.autoDetectRenderer = function(width, height, view, transparent, antialias)
return new PIXI.CanvasRenderer(width, height, view, transparent);
};
/*
PolyK library
url: http://polyk.ivank.net
@ -4106,7 +4129,7 @@ PIXI.PolyK._convex = function(ax, ay, bx, by, cx, cy, sign)
{
return ((ay-by)*(cx-bx) + (bx-ax)*(cy-by) >= 0) === sign;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -4162,7 +4185,7 @@ PIXI.compileProgram = function(gl, vertexSrc, fragmentSrc)
return shaderProgram;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
* @author Richard Davey http://www.photonstorm.com @photonstorm
@ -4511,7 +4534,7 @@ PIXI.PixiShader.defaultVertexSrc = [
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
* @author Richard Davey http://www.photonstorm.com @photonstorm
@ -4658,7 +4681,7 @@ PIXI.PixiFastShader.prototype.destroy = function()
this.attributes = null;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -4739,7 +4762,7 @@ PIXI.StripShader.prototype.init = function()
this.program = program;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -4844,7 +4867,7 @@ PIXI.PrimitiveShader.prototype.destroy = function()
this.attribute = null;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -5386,7 +5409,7 @@ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData)
r, g, b, alpha);
}
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -5949,7 +5972,7 @@ PIXI.WebGLRenderer.prototype.destroy = function()
PIXI.WebGLRenderer.glContextId = 0;
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -6046,7 +6069,7 @@ PIXI.WebGLMaskManager.prototype.destroy = function()
{
this.maskStack = null;
this.gl = null;
};
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -6208,7 +6231,7 @@ PIXI.WebGLShaderManager.prototype.destroy = function()
this.gl = null;
};
/**
* @author Mat Groves
*
@ -6489,6 +6512,9 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
var uvs = tilingSprite._uvs;
tilingSprite.tilePosition.x %= texture.baseTexture.width;
tilingSprite.tilePosition.y %= texture.baseTexture.height;
var offsetX = tilingSprite.tilePosition.x/texture.baseTexture.width;
var offsetY = tilingSprite.tilePosition.y/texture.baseTexture.height;
@ -6702,7 +6728,7 @@ PIXI.WebGLSpriteBatch.prototype.destroy = function()
this.gl = null;
};
/**
* @author Mat Groves
*
@ -7054,7 +7080,7 @@ PIXI.WebGLFastSpriteBatch.prototype.setBlendMode = function(blendMode)
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -7519,7 +7545,7 @@ PIXI.WebGLFilterManager.prototype.destroy = function()
gl.deleteBuffer(this.uvBuffer);
gl.deleteBuffer(this.colorBuffer);
gl.deleteBuffer(this.indexBuffer);
};
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -7604,7 +7630,7 @@ PIXI.FilterTexture.prototype.destroy = function()
this.frameBuffer = null;
this.texture = null;
};
/**
* @author Mat Groves
*
@ -7655,7 +7681,7 @@ PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, context)
PIXI.CanvasMaskManager.prototype.popMask = function(context)
{
context.restore();
};
};
/**
* @author Mat Groves
@ -7899,7 +7925,7 @@ PIXI.CanvasTinter.canUseMultiply = PIXI.canUseNewCanvasBlendModes();
PIXI.CanvasTinter.tintMethod = PIXI.CanvasTinter.canUseMultiply ? PIXI.CanvasTinter.tintWithMultiply : PIXI.CanvasTinter.tintWithPerPixel;
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -8280,7 +8306,7 @@ PIXI.CanvasBuffer.prototype.resize = function(width, height)
this.height = this.canvas.height = height;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -8518,7 +8544,7 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context)
}
}
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -9148,7 +9174,7 @@ PIXI.Graphics.POLY = 0;
PIXI.Graphics.RECT = 1;
PIXI.Graphics.CIRC = 2;
PIXI.Graphics.ELIP = 3;
/**
* @author Mat Groves http://matgroves.com/
*/
@ -9262,7 +9288,7 @@ PIXI.Strip.prototype.onTextureUpdate = function()
this.updateFrame = true;
};
// some helper functions..
/* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -9453,7 +9479,7 @@ PIXI.Rope.prototype.setTexture = function(texture)
this.texture = texture;
this.updateFrame = true;
};
/**
* @author Mat Groves http://matgroves.com/
*/
@ -9679,6 +9705,10 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
var tilePosition = this.tilePosition;
var tileScale = this.tileScale;
tilePosition.x %= this.tilingTexture.baseTexture.width;
tilePosition.y %= this.tilingTexture.baseTexture.height;
// console.log(tileScale.x)
// offset
context.scale(tileScale.x,tileScale.y);
@ -9831,7 +9861,7 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
this.tilingTexture.baseTexture._powerOf2 = true;
};
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
* based on pixi impact spine implementation made by Eemeli Kelokorpi (@ekelokorpi) https://github.com/ekelokorpi
@ -11300,7 +11330,7 @@ PIXI.Spine.prototype.createSprite = function (slot, descriptor) {
slot.sprites[descriptor.name] = sprite;
return sprite;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -11369,34 +11399,7 @@ PIXI.BaseTexture = function(source, scaleMode)
if(!source)return;
if(this.source instanceof Image || this.source instanceof HTMLImageElement)
{
if(this.source.complete)
{
this.hasLoaded = true;
this.width = this.source.width;
this.height = this.source.height;
PIXI.texturesToUpdate.push(this);
}
else
{
var scope = this;
this.source.onload = function() {
scope.hasLoaded = true;
scope.width = scope.source.width;
scope.height = scope.source.height;
// add it to somewhere...
PIXI.texturesToUpdate.push(scope);
scope.dispatchEvent( { type: 'loaded', content: scope } );
};
//this.image.src = imageUrl;
}
}
else
if(this.source.complete || this.source.getContext)
{
this.hasLoaded = true;
this.width = this.source.width;
@ -11404,6 +11407,22 @@ PIXI.BaseTexture = function(source, scaleMode)
PIXI.texturesToUpdate.push(this);
}
else
{
var scope = this;
this.source.onload = function() {
scope.hasLoaded = true;
scope.width = scope.source.width;
scope.height = scope.source.height;
// add it to somewhere...
PIXI.texturesToUpdate.push(scope);
scope.dispatchEvent( { type: 'loaded', content: scope } );
};
//this.image.src = imageUrl;
}
this.imageUrl = null;
this._powerOf2 = false;
@ -11425,10 +11444,9 @@ PIXI.BaseTexture.prototype.constructor = PIXI.BaseTexture;
*/
PIXI.BaseTexture.prototype.destroy = function()
{
if(this.source instanceof Image)
if(this.imageUrl)
{
if (this.imageUrl in PIXI.BaseTextureCache)
delete PIXI.BaseTextureCache[this.imageUrl];
delete PIXI.BaseTextureCache[this.imageUrl];
this.imageUrl = null;
this.source.src = null;
}
@ -11500,7 +11518,7 @@ PIXI.BaseTexture.fromCanvas = function(canvas, scaleMode)
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -11759,7 +11777,7 @@ PIXI.TextureUvs = function()
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -11949,7 +11967,7 @@ PIXI.RenderTexture.prototype.renderCanvas = function(displayObject, position, cl
PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -12109,7 +12127,7 @@ PIXI.AssetLoader.prototype.onAssetLoaded = function()
if(this.onComplete) this.onComplete();
}
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -12173,7 +12191,7 @@ PIXI.JsonLoader.prototype.constructor = PIXI.JsonLoader;
* @method load
*/
PIXI.JsonLoader.prototype.load = function () {
this.ajaxRequest = new PIXI.AjaxRequest();
this.ajaxRequest = new PIXI.AjaxRequest(this.crossorigin);
var scope = this;
this.ajaxRequest.onreadystatechange = function () {
scope.onJSONLoaded();
@ -12284,7 +12302,7 @@ PIXI.JsonLoader.prototype.onError = function () {
type: 'error',
content: this
});
};
};
/**
* @author Martin Kelm http://mkelm.github.com
*/
@ -12475,7 +12493,7 @@ PIXI.AtlasLoader.prototype.onError = function () {
content: this
});
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -12575,7 +12593,7 @@ PIXI.SpriteSheetLoader.prototype.onLoaded = function () {
content: this
});
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -12690,7 +12708,7 @@ PIXI.ImageLoader.prototype.loadFramedSpriteSheet = function(frameWidth, frameHei
this.onLoaded();
}
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -12865,7 +12883,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
{
this.dispatchEvent({type: 'loaded', content: this});
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
* based on pixi impact spine implementation made by Eemeli Kelokorpi (@ekelokorpi) https://github.com/ekelokorpi
@ -12948,7 +12966,7 @@ PIXI.SpineLoader.prototype.onLoaded = function () {
this.dispatchEvent({type: "loaded", content: this});
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -12995,7 +13013,7 @@ PIXI.AbstractFilter = function(fragmentSrc, uniforms)
*/
this.fragmentSrc = fragmentSrc || [];
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13089,7 +13107,7 @@ Object.defineProperty(PIXI.AlphaMaskFilter.prototype, 'map', {
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13148,7 +13166,7 @@ Object.defineProperty(PIXI.ColorMatrixFilter.prototype, 'matrix', {
set: function(value) {
this.uniforms.matrix.value = value;
}
});
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13200,7 +13218,7 @@ Object.defineProperty(PIXI.GrayFilter.prototype, 'gray', {
this.uniforms.gray.value = value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13330,7 +13348,7 @@ Object.defineProperty(PIXI.DisplacementFilter.prototype, 'offset', {
this.uniforms.offset.value = value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13392,7 +13410,7 @@ Object.defineProperty(PIXI.PixelateFilter.prototype, 'size', {
this.uniforms.pixelSize.value = value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13446,7 +13464,7 @@ Object.defineProperty(PIXI.BlurXFilter.prototype, 'blur', {
this.uniforms.blur.value = (1/7000) * value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13499,7 +13517,7 @@ Object.defineProperty(PIXI.BlurYFilter.prototype, 'blur', {
this.uniforms.blur.value = (1/7000) * value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13567,7 +13585,7 @@ Object.defineProperty(PIXI.BlurFilter.prototype, 'blurY', {
this.blurYFilter.blur = value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13620,7 +13638,7 @@ Object.defineProperty(PIXI.InvertFilter.prototype, 'invert', {
this.uniforms.invert.value = value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13674,7 +13692,7 @@ Object.defineProperty(PIXI.SepiaFilter.prototype, 'sepia', {
this.uniforms.sepia.value = value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13775,7 +13793,7 @@ Object.defineProperty(PIXI.TwistFilter.prototype, 'angle', {
this.dirty = true;
this.uniforms.angle.value = value;
}
});
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13827,7 +13845,7 @@ Object.defineProperty(PIXI.ColorStepFilter.prototype, 'step', {
this.uniforms.step.value = value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
* original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js
@ -13913,7 +13931,7 @@ Object.defineProperty(PIXI.DotScreenFilter.prototype, 'angle', {
this.dirty = true;
this.uniforms.angle.value = value;
}
});
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -13980,7 +13998,7 @@ Object.defineProperty(PIXI.CrossHatchFilter.prototype, 'blur', {
this.uniforms.blur.value = (1/7000) * value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -14030,7 +14048,7 @@ Object.defineProperty(PIXI.RGBSplitFilter.prototype, 'angle', {
this.uniforms.blur.value = (1/7000) * value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/

File diff suppressed because one or more lines are too long