diff --git a/bin/pixi.js b/bin/pixi.js
index 0f15181..33edaea 100644
--- a/bin/pixi.js
+++ b/bin/pixi.js
@@ -10255,7 +10255,7 @@
* World transform and local transform of this object.
* This will be reworked in v4.1, please do not use it yet unless you know what are you doing!
*
- * @member {PIXI.Transform|PIXI.TransformStatic}
+ * @member {PIXI.TransformBase}
*/
this.transform = new TransformClass();
@@ -10803,31 +10803,21 @@
};
},{"../const":41,"../math":65,"./BoundsBuilder":42,"./Transform":45,"./TransformStatic":47,"eventemitter3":11}],45:[function(require,module,exports){
-var math = require('../math');
+var math = require('../math'),
+ TransformBase = require('./TransformBase');
/**
* Generic class to deal with traditional 2D matrix transforms
- * This will be reworked in v4.1, please do not use it yet unless you know what are you doing!
+ * local transformation is calculated from position,scale,skew and rotation
*
* @class
+ * @extends PIXI.TransformBase
* @memberof PIXI
*/
function Transform()
{
- /**
- * The global matrix transform.
- *
- * @member {PIXI.Matrix}
- */
- this.worldTransform = new math.Matrix();
-
- /**
- * The local matrix transform.
- *
- * @member {PIXI.Matrix}
- */
- this.localTransform = new math.Matrix();
+ TransformBase.call(this);
/**
* The coordinate of the object relative to the local coordinates of the parent.
@@ -10857,7 +10847,6 @@
*/
this.pivot = new math.Point(0.0);
-
/**
* The rotation value of the object, in radians
*
@@ -10872,13 +10861,9 @@
this._sy = Math.sin(0);//skewY);
this._nsx = Math.sin(0);//skewX);
this._cx = Math.cos(0);//skewX);
-
- this._dirty = false;
- this.updated = true;
-
- this._worldID = 0;
}
+Transform.prototype = Object.create(TransformBase.prototype);
Transform.prototype.constructor = Transform;
Transform.prototype.updateSkew = function ()
@@ -10890,6 +10875,24 @@
};
/**
+ * Updates only local matrix
+ */
+Transform.prototype.updateLocalTransform = function() {
+ var lt = this.localTransform;
+ var a, b, c, d;
+
+ a = this._cr * this.scale.x;
+ b = this._sr * this.scale.x;
+ c = -this._sr * this.scale.y;
+ d = this._cr * this.scale.y;
+
+ lt.a = this._cy * a + this._sy * c;
+ lt.b = this._cy * b + this._sy * d;
+ lt.c = this._nsx * a + this._cx * c;
+ lt.d = this._nsx * b + this._cx * d;
+};
+
+/**
* Updates the values of the object and applies the parent's transform.
* @param parentTransform {PIXI.Transform} The transform of the parent of this object
*/
@@ -10956,29 +10959,27 @@
module.exports = Transform;
-},{"../math":65}],46:[function(require,module,exports){
+},{"../math":65,"./TransformBase":46}],46:[function(require,module,exports){
var math = require('../math');
/**
* Generic class to deal with traditional 2D matrix transforms
- * This will be reworked in v4.1, please do not use it yet unless you know what are you doing!
*
* @class
* @memberof PIXI
*/
-function TransformManual()
+function TransformBase()
{
/**
- * The global matrix transform.
+ * The global matrix transform. It can be swapped temporarily by some functions like getLocalBounds()
*
* @member {PIXI.Matrix}
*/
this.worldTransform = new math.Matrix();
-
/**
- * The local matrix transform.
- *
+ * The local matrix transform
+ *
* @member {PIXI.Matrix}
*/
this.localTransform = new math.Matrix();
@@ -10986,16 +10987,22 @@
this._worldID = 0;
}
-TransformManual.prototype.constructor = TransformManual;
+TransformBase.prototype.constructor = TransformBase;
+
+/**
+ * TransformBase does not have decomposition, so this function wont do anything
+ */
+TransformBase.prototype.updateLocalTransform = function() { // jshint unused:false
+
+};
/**
* Updates the values of the object and applies the parent's transform.
- * @param parentTransform {PIXI.Transform} The transform of the parent of this object
+ * @param parentTransform {PIXI.TransformBase} The transform of the parent of this object
*
*/
-TransformManual.prototype.updateTransform = function (parentTransform)
+TransformBase.prototype.updateTransform = function (parentTransform)
{
-
var pt = parentTransform.worldTransform;
var wt = this.worldTransform;
var lt = this.localTransform;
@@ -11011,34 +11018,31 @@
this._worldID ++;
};
-module.exports = TransformManual;
+/**
+ * Updates the values of the object and applies the parent's transform.
+ * @param parentTransform {PIXI.Transform} The transform of the parent of this object
+ *
+ */
+TransformBase.prototype.updateWorldTransform = TransformBase.prototype.updateTransform;
+
+TransformBase.IDENTITY = new TransformBase();
+
+module.exports = TransformBase;
},{"../math":65}],47:[function(require,module,exports){
-var math = require('../math');
+var math = require('../math'),
+ TransformBase = require('./TransformBase');
/**
* Transform that takes care about its versions
- * This will be reworked in v4.1, please do not use it yet unless you know what are you doing!
*
* @class
+ * @extends PIXI.TransformBase
* @memberof PIXI
*/
function TransformStatic()
{
- /**
- * The global matrix transform.
- *
- * @member {PIXI.Matrix}
- */
- this.worldTransform = new math.Matrix();
-
- /**
- * The local matrix transform.
- *
- * @member {PIXI.Matrix}
- */
- this.localTransform = new math.Matrix();
-
+ TransformBase.call(this);
/**
* The coordinate of the object relative to the local coordinates of the parent.
*
@@ -11076,13 +11080,10 @@
this._nsx = Math.sin(0);//skewX);
this._cx = Math.cos(0);//skewX);
-
- this._localID = 0;
this._currentLocalID = 0;
- this._parentID = 0;
- this._worldID = 0;
}
+TransformStatic.prototype = Object.create(TransformBase.prototype);
TransformStatic.prototype.constructor = TransformStatic;
TransformStatic.prototype.onChange = function ()
@@ -11101,6 +11102,35 @@
};
/**
+ * Updates only local matrix
+ */
+TransformStatic.prototype.updateLocalTransform = function() {
+ var lt = this.localTransform;
+ if(this._localID !== this._currentLocalID)
+ {
+ // get the matrix values of the displayobject based on its transform properties..
+ var a,b,c,d;
+
+ a = this._cr * this.scale.x;
+ b = this._sr * this.scale.x;
+ c = -this._sr * this.scale.y;
+ d = this._cr * this.scale.y;
+
+ lt.a = this._cy * a + this._sy * c;
+ lt.b = this._cy * b + this._sy * d;
+ lt.c = this._nsx * a + this._cx * c;
+ lt.d = this._nsx * b + this._cx * d;
+
+ lt.tx = this.position._x - (this.pivot._x * lt.a + this.pivot._y * lt.c);
+ lt.ty = this.position._y - (this.pivot._x * lt.b + this.pivot._y * lt.d);
+ this._currentLocalID = this._localID;
+
+ // force an update..
+ this._parentID = -1;
+ }
+};
+
+/**
* Updates the values of the object and applies the parent's transform.
* @param parentTransform {PIXI.Transform} The transform of the parent of this object
*
@@ -11158,6 +11188,7 @@
TransformStatic.prototype.setFromMatrix = function (matrix)
{
matrix.decompose(this);
+ this._localID ++;
};
Object.defineProperties(TransformStatic.prototype, {
@@ -11182,7 +11213,7 @@
module.exports = TransformStatic;
-},{"../math":65}],48:[function(require,module,exports){
+},{"../math":65,"./TransformBase":46}],48:[function(require,module,exports){
var Container = require('../display/Container'),
RenderTexture = require('../textures/RenderTexture'),
Texture = require('../textures/Texture'),
@@ -13691,7 +13722,7 @@
Container: require('./display/Container'),
Transform: require('./display/Transform'),
TransformStatic: require('./display/TransformStatic'),
- TransformManual: require('./display/TransformManual'),
+ TransformBase: require('./display/TransformBase'),
// sprites
Sprite: require('./sprites/Sprite'),
@@ -13767,7 +13798,7 @@
}
});
-},{"./Shader":40,"./const":41,"./display/Container":43,"./display/DisplayObject":44,"./display/Transform":45,"./display/TransformManual":46,"./display/TransformStatic":47,"./graphics/Graphics":48,"./graphics/GraphicsData":49,"./graphics/canvas/CanvasGraphicsRenderer":50,"./graphics/webgl/GraphicsRenderer":52,"./math":65,"./renderers/canvas/CanvasRenderer":72,"./renderers/canvas/utils/CanvasRenderTarget":74,"./renderers/webgl/WebGLRenderer":79,"./renderers/webgl/filters/Filter":81,"./renderers/webgl/filters/spriteMask/SpriteMaskFilter":84,"./renderers/webgl/managers/WebGLManager":88,"./renderers/webgl/utils/ObjectRenderer":89,"./renderers/webgl/utils/Quad":90,"./renderers/webgl/utils/RenderTarget":91,"./sprites/Sprite":96,"./sprites/canvas/CanvasSpriteRenderer":97,"./sprites/canvas/CanvasTinter":98,"./sprites/webgl/SpriteRenderer":100,"./text/Text":102,"./text/TextStyle":103,"./textures/BaseRenderTexture":104,"./textures/BaseTexture":105,"./textures/RenderTexture":106,"./textures/Texture":107,"./textures/TextureUvs":108,"./textures/VideoBaseTexture":109,"./ticker":111,"./utils":114,"pixi-gl-core":20}],61:[function(require,module,exports){
+},{"./Shader":40,"./const":41,"./display/Container":43,"./display/DisplayObject":44,"./display/Transform":45,"./display/TransformBase":46,"./display/TransformStatic":47,"./graphics/Graphics":48,"./graphics/GraphicsData":49,"./graphics/canvas/CanvasGraphicsRenderer":50,"./graphics/webgl/GraphicsRenderer":52,"./math":65,"./renderers/canvas/CanvasRenderer":72,"./renderers/canvas/utils/CanvasRenderTarget":74,"./renderers/webgl/WebGLRenderer":79,"./renderers/webgl/filters/Filter":81,"./renderers/webgl/filters/spriteMask/SpriteMaskFilter":84,"./renderers/webgl/managers/WebGLManager":88,"./renderers/webgl/utils/ObjectRenderer":89,"./renderers/webgl/utils/Quad":90,"./renderers/webgl/utils/RenderTarget":91,"./sprites/Sprite":96,"./sprites/canvas/CanvasSpriteRenderer":97,"./sprites/canvas/CanvasTinter":98,"./sprites/webgl/SpriteRenderer":100,"./text/Text":102,"./text/TextStyle":103,"./textures/BaseRenderTexture":104,"./textures/BaseTexture":105,"./textures/RenderTexture":106,"./textures/Texture":107,"./textures/TextureUvs":108,"./textures/VideoBaseTexture":109,"./ticker":111,"./utils":114,"pixi-gl-core":20}],61:[function(require,module,exports){
// Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group of order 16
var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1];
@@ -14282,8 +14313,8 @@
/**
* Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
- * @param transform {PIXI.Transform} the transform to apply the properties to.
- * @return {PIXI.Transform} The transform with the newly applied properies
+ * @param transform {PIXI.Transform|PIXI.TransformStatic} the transform to apply the properties to.
+ * @return {PIXI.Transform|PIXI.TransformStatic} The transform with the newly applied properies
*/
Matrix.prototype.decompose = function(transform)
{
@@ -18142,7 +18173,7 @@
alphaMaskFilter[0].maskSprite = maskData;
//TODO - may cause issues!
- target.filterArea = maskData.getBounds();
+ target.filterArea = maskData.getBounds(true);
this.renderer.filterManager.pushFilter(target, alphaMaskFilter);
@@ -20441,9 +20472,10 @@
'uniform sampler2D uSamplers[%count%];',
'void main(void){',
- 'vec4 color;',
- '%forloop%',
- 'gl_FragColor = color * vColor;',
+ 'vec4 color;',
+ 'float textureId = floor(vTextureId+0.5);',
+ '%forloop%',
+ 'gl_FragColor = color * vColor;',
'}'
].join('\n');
@@ -20485,7 +20517,7 @@
if(i < maxTextures-1)
{
- src += 'if(vTextureId == ' + i + '.0)';
+ src += 'if(textureId == ' + i + '.0)';
}
src += '\n{';
@@ -21798,6 +21830,9 @@
this.width = width || 100;
this.height = height || 100;
+ this.realWidth = this.width * resolution;
+ this.realHeight = this.height * resolution;
+
this.resolution = resolution || CONST.RESOLUTION;
this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT;
this.hasLoaded = true;
@@ -21849,6 +21884,9 @@
this.width = width;
this.height = height;
+ this.realWidth = this.width * this.resolution;
+ this.realHeight = this.height * this.resolution;
+
if (!this.valid)
{
return;
@@ -23935,7 +23973,7 @@
*/
isWebGLSupported: function ()
{
- var contextOptions = { stencil: true };
+ var contextOptions = { stencil: true, failIfMajorPerformanceCaveat: true };
try
{
if (!window.WebGLRenderingContext)
@@ -24398,6 +24436,21 @@
return core.Filter;
}
},
+
+ /**
+ * @class
+ * @private
+ * @name PIXI.TransformManual
+ * @see PIXI.TransformBase
+ * @deprecated since version 4.0.0
+ */
+ TransformManual: {
+ get: function()
+ {
+ warn('TransformManual has been renamed to TransformBase, please update your pixi-spine');
+ return core.TransformBase;
+ }
+ }
});
core.DisplayObject.prototype.generateTexture = function(renderer, scaleMode, resolution)
@@ -24655,7 +24708,7 @@
};
-},{"./core":60,"./core/const":41,"./extras":127,"./filters":138,"./mesh":154,"./particles":157}],118:[function(require,module,exports){
+},{"./core":60,"./core/const":41,"./extras":127,"./filters":138,"./mesh":155,"./particles":158}],118:[function(require,module,exports){
var core = require('../../core'),
tempRect = new core.Rectangle();
@@ -26218,13 +26271,24 @@
_tempMatrix = new core.Matrix();
DisplayObject.prototype._cacheAsBitmap = false;
-DisplayObject.prototype._originalRenderWebGL = null;
-DisplayObject.prototype._originalRenderCanvas = null;
+DisplayObject.prototype._cacheData = false;
-DisplayObject.prototype._originalUpdateTransform = null;
-DisplayObject.prototype._originalHitTest = null;
-DisplayObject.prototype._originalDestroy = null;
-DisplayObject.prototype._cachedSprite = null;
+// figured theres no point adding ALL the extra variables to prototype.
+// this model can hold the information needed. This can also be generated on demand as
+// most objects are not cached as bitmaps.
+var CacheData = function(){
+
+ this.originalRenderWebGL = null;
+ this.originalRenderCanvas = null;
+
+ this.originalUpdateTransform = null;
+ this.originalHitTest = null;
+ this.originalDestroy = null;
+ this.originalMask = null;
+ this.originalFilterArea = null;
+ this.sprite = null;
+};
+
Object.defineProperties(DisplayObject.prototype, {
@@ -26250,17 +26314,32 @@
this._cacheAsBitmap = value;
+ var data;
+
if (value)
{
- this._originalRenderWebGL = this.renderWebGL;
- this._originalRenderCanvas = this.renderCanvas;
- this._originalUpdateTransform = this.updateTransform;
- this._originalGetBounds = this.getBounds;
+ if(!this._cacheData)
+ {
+ this._cacheData = new CacheData();
+ }
- this._originalDestroy = this.destroy;
+ data = this._cacheData;
- this._originalContainsPoint = this.containsPoint;
+ data.originalRenderWebGL = this.renderWebGL;
+ data.originalRenderCanvas = this.renderCanvas;
+
+ data.originalUpdateTransform = this.updateTransform;
+ data.originalGetBounds = this.getBounds;
+
+ data.originalDestroy = this.destroy;
+
+ data.originalContainsPoint = this.containsPoint;
+
+ data.originalMask = this._mask;
+ data.originalFilterArea = this.filterArea;
+
+
this.renderWebGL = this._renderCachedWebGL;
this.renderCanvas = this._renderCachedCanvas;
@@ -26270,19 +26349,25 @@
}
else
{
- if (this._cachedSprite)
+ data = this._cacheData;
+
+ if (data.sprite)
{
this._destroyCachedDisplayObject();
}
- this.renderWebGL = this._originalRenderWebGL;
- this.renderCanvas = this._originalRenderCanvas;
- this.getBounds = this._originalGetBounds;
- this.destroy = this._originalDestroy;
+ this.renderWebGL = data.originalRenderWebGL;
+ this.renderCanvas = data.originalRenderCanvas;
+ this.getBounds = data.originalGetBounds;
- this.updateTransform = this._originalUpdateTransform;
- this.containsPoint = this._originalContainsPoint;
+ this.destroy = data.originalDestroy;
+
+ this.updateTransform = data.originalUpdateTransform;
+ this.containsPoint = data.originalContainsPoint;
+
+ this._mask = data.originalMask;
+ this.filterArea = data.originalFilterArea;
}
}
}
@@ -26302,10 +26387,9 @@
this._initCachedDisplayObject( renderer );
- this._cachedSprite._transformID = -1;
- this._cachedSprite.worldAlpha = this.worldAlpha;
-
- this._cachedSprite._renderWebGL(renderer);
+ this._cacheData.sprite._transformID = -1;
+ this._cacheData.sprite.worldAlpha = this.worldAlpha;
+ this._cacheData.sprite._renderWebGL(renderer);
};
/**
@@ -26316,7 +26400,7 @@
*/
DisplayObject.prototype._initCachedDisplayObject = function (renderer)
{
- if(this._cachedSprite)
+ if(this._cacheData && this._cacheData.sprite)
{
return;
}
@@ -26357,7 +26441,7 @@
m.ty = -bounds.y;
// set all properties to there original so we can render to a texture
- this.renderWebGL = this._originalRenderWebGL;
+ this.renderWebGL = this._cacheData.originalRenderWebGL;
renderer.render(this, renderTexture, true, m, true);
// now restore the state be setting the new properties
@@ -26370,18 +26454,22 @@
this.updateTransform = this.displayObjectUpdateTransform;
this.getBounds = this._getCachedBounds;
+ this._mask = null;
+ this.filterArea = null;
// create our cached sprite
- this._cachedSprite = new core.Sprite(renderTexture);
- this._cachedSprite.transform.worldTransform = this.transform.worldTransform;
- this._cachedSprite.anchor.x = -( bounds.x / bounds.width );
- this._cachedSprite.anchor.y = -( bounds.y / bounds.height );
+ var cachedSprite = new core.Sprite(renderTexture);
+ cachedSprite.transform.worldTransform = this.transform.worldTransform;
+ cachedSprite.anchor.x = -( bounds.x / bounds.width );
+ cachedSprite.anchor.y = -( bounds.y / bounds.height );
+
+ this._cacheData.sprite = cachedSprite;
// restore the transform of the cached sprite to avoid the nasty flicker..
this.updateTransform();
// map the hit test..
- this.containsPoint = this._cachedSprite.containsPoint.bind(this._cachedSprite);
+ this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite);
};
/**
@@ -26399,9 +26487,9 @@
this._initCachedDisplayObjectCanvas( renderer );
- this._cachedSprite.worldAlpha = this.worldAlpha;
+ this._cacheData.sprite.worldAlpha = this.worldAlpha;
- this._cachedSprite.renderCanvas(renderer);
+ this._cacheData.sprite.renderCanvas(renderer);
};
//TODO this can be the same as the webGL verison.. will need to do a little tweaking first though..
@@ -26413,7 +26501,7 @@
*/
DisplayObject.prototype._initCachedDisplayObjectCanvas = function (renderer)
{
- if(this._cachedSprite)
+ if(this._cacheData && this._cacheData.sprite)
{
return;
}
@@ -26435,7 +26523,7 @@
//m.append(this.transform.worldTransform.)
// set all properties to there original so we can render to a texture
- this.renderCanvas = this._originalRenderCanvas;
+ this.renderCanvas = this._cacheData.originalRenderCanvas;
//renderTexture.render(this, m, true);
renderer.render(this, renderTexture, true, m, false);
@@ -26447,16 +26535,20 @@
this.updateTransform = this.displayObjectUpdateTransform;
this.getBounds = this._getCachedBounds;
+ this._mask = null;
+ this.filterArea = null;
// create our cached sprite
- this._cachedSprite = new core.Sprite(renderTexture);
- this._cachedSprite.transform.worldTransform = this.transform.worldTransform;
- this._cachedSprite.anchor.x = -( bounds.x / bounds.width );
- this._cachedSprite.anchor.y = -( bounds.y / bounds.height );
+ var cachedSprite = new core.Sprite(renderTexture);
+ cachedSprite.transform.worldTransform = this.transform.worldTransform;
+ cachedSprite.anchor.x = -( bounds.x / bounds.width );
+ cachedSprite.anchor.y = -( bounds.y / bounds.height );
this.updateTransform();
- this.containsPoint = this._cachedSprite.containsPoint.bind(this._cachedSprite);
+ this._cacheData.sprite = cachedSprite;
+
+ this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite);
};
/**
@@ -26466,9 +26558,9 @@
*/
DisplayObject.prototype._getCachedBounds = function ()
{
- this._cachedSprite._currentBounds = null;
+ this._cacheData.sprite._currentBounds = null;
- return this._cachedSprite.getBounds(core.Matrix.IDENTITY);
+ return this._cacheData.sprite.getBounds();
};
/**
@@ -26478,14 +26570,14 @@
*/
DisplayObject.prototype._destroyCachedDisplayObject = function ()
{
- this._cachedSprite._texture.destroy(true);
- this._cachedSprite = null;
+ this._cacheData.sprite._texture.destroy(true);
+ this._cacheData.sprite = null;
};
DisplayObject.prototype._cacheAsBitmapDestroy = function ()
{
this.cacheAsBitmap = false;
- this._originalDestroy();
+ this._cacheData.originalDestroy();
};
},{"../core":60}],125:[function(require,module,exports){
@@ -27917,7 +28009,7 @@
global.PIXI = core;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./accessibility":39,"./core":60,"./deprecation":117,"./extract":119,"./extras":127,"./filters":138,"./interaction":144,"./loaders":147,"./mesh":154,"./particles":157,"./polyfill":163,"./prepare":166}],142:[function(require,module,exports){
+},{"./accessibility":39,"./core":60,"./deprecation":117,"./extract":119,"./extras":127,"./filters":138,"./interaction":144,"./loaders":147,"./mesh":155,"./particles":158,"./polyfill":164,"./prepare":167}],142:[function(require,module,exports){
var core = require('../core');
/**
@@ -29648,6 +29740,7 @@
renderer.bindShader(glData.shader);
renderer.bindTexture(this._texture, 0);
+ renderer.state.setBlendMode(this.blendMode);
glData.shader.uniforms.translationMatrix = this.worldTransform.toArray(true);
glData.shader.uniforms.alpha = this.worldAlpha;
@@ -29927,7 +30020,330 @@
TRIANGLES: 1
};
-},{"../core":60,"./webgl/MeshShader":155,"pixi-gl-core":20}],152:[function(require,module,exports){
+},{"../core":60,"./webgl/MeshShader":156,"pixi-gl-core":20}],152:[function(require,module,exports){
+var DEFAULT_BORDER_SIZE= 10;
+
+var Plane = require('./Plane');
+
+/**
+ * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful
+ * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically
+ *
+ *```js
+ * var Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.fromImage('BoxWithRoundedCorners.png'), 15, 15, 15, 15);
+ * ```
+ *
+ * A B
+ * +---+----------------------+---+
+ * C | 1 | 2 | 3 |
+ * +---+----------------------+---+
+ * | | | |
+ * | 4 | 5 | 6 |
+ * | | | |
+ * +---+----------------------+---+
+ * D | 7 | 8 | 9 |
+ * +---+----------------------+---+
+
+ * When changing this objects width and/or height:
+ * areas 1 3 7 and 9 will remain unscaled.
+ * areas 2 and 8 will be stretched horizontally
+ * areas 4 and 6 will be stretched vertically
+ * area 5 will be stretched both horizontally and vertically
+ *
+ *
+ * @class
+ * @extends PIXI.mesh.Plane
+ * @memberof PIXI.mesh
+ * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane.
+ * @param {int} [leftWidth=10] size of the left vertical bar (A)
+ * @param {int} [topHeight=10] size of the top horizontal bar (C)
+ * @param {int} [rightWidth=10] size of the right vertical bar (B)
+ * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D)
+ *
+ */
+function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight)
+{
+ Plane.call(this, texture, 4, 4);
+
+ var uvs = this.uvs;
+ // right and bottom uv's are always 1
+ uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1;
+ uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1;
+
+ this._origWidth = texture.width;
+ this._origHeight = texture.height;
+ this._uvw = 1 / this._origWidth;
+ this._uvh = 1 / this._origHeight;
+ /**
+ * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
+ *
+ * @member {number}
+ * @memberof PIXI.NineSlicePlane#
+ * @override
+ */
+ this.width = texture.width;
+ /**
+ * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
+ *
+ * @member {number}
+ * @memberof PIXI.NineSlicePlane#
+ * @override
+ */
+ this.height = texture.height;
+
+ uvs[2] = uvs[10] = uvs[18] = uvs[26] = this._uvw * leftWidth;
+ uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - this._uvw * rightWidth;
+ uvs[9] = uvs[11] = uvs[13] = uvs[15] = this._uvh * topHeight;
+ uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - this._uvh * bottomHeight;
+
+ /**
+ * The width of the left column (a)
+ *
+ * @member {number}
+ */
+ this.leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE;
+ /**
+ * The width of the right column (b)
+ *
+ * @member {number}
+ */
+ this.rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE;
+ /**
+ * The height of the top row (c)
+ *
+ * @member {number}
+ */
+ this.topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE;
+ /**
+ * The height of the bottom row (d)
+ *
+ * @member {number}
+ */
+ this.bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE;
+}
+
+
+// constructor
+NineSlicePlane.prototype = Object.create( Plane.prototype );
+NineSlicePlane.prototype.constructor = NineSlicePlane;
+module.exports = NineSlicePlane;
+
+Object.defineProperties(NineSlicePlane.prototype, {
+ /**
+ * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
+ *
+ * @member {number}
+ * @memberof PIXI.NineSlicePlane#
+ * @override
+ */
+ width: {
+ get: function ()
+ {
+ return this._width;
+ },
+ set: function (value)
+ {
+ this._width = value;
+ this.updateVerticalVertices();
+ }
+ },
+
+ /**
+ * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
+ *
+ * @member {number}
+ * @memberof PIXI.NineSlicePlane#
+ * @override
+ */
+ height: {
+ get: function ()
+ {
+ return this._height;
+ },
+ set: function (value)
+ {
+ this._height = value;
+ this.updateHorizontalVertices();
+ }
+ },
+
+ /**
+ * The width of the left column
+ *
+ * @member {number}
+ */
+ leftWidth: {
+ get: function()
+ {
+ return this._leftWidth;
+ },
+ set: function (value)
+ {
+ this._leftWidth = value;
+ var uvs = this.uvs;
+ var vertices = this.vertices;
+ uvs[2] = uvs[10] = uvs[18] = uvs[26] = this._uvw * value;
+ vertices[2] = vertices[10] = vertices[18] = vertices[26] = value;
+ this.dirty=true;
+ }
+ },
+ /**
+ * The width of the right column
+ *
+ * @member {number}
+ */
+ rightWidth: {
+ get: function()
+ {
+ return this._rightWidth;
+ },
+ set: function (value)
+ {
+ this._rightWidth = value;
+ var uvs = this.uvs;
+ var vertices = this.vertices;
+ uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - this._uvw * value;
+ vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - value;
+ this.dirty=true;
+ }
+ },
+ /**
+ * The height of the top row
+ *
+ * @member {number}
+ */
+ topHeight: {
+ get: function()
+ {
+ return this._topHeight;
+ },
+ set: function (value)
+ {
+ this._topHeight = value;
+ var uvs = this.uvs;
+ var vertices = this.vertices;
+ uvs[9] = uvs[11] = uvs[13] = uvs[15] = this._uvh * value;
+ vertices[9] = vertices[11] = vertices[13] = vertices[15] = value;
+ this.dirty=true;
+ }
+ },
+ /**
+ * The height of the bottom row
+ *
+ * @member {number}
+ */
+ bottomHeight: {
+ get: function()
+ {
+ return this._bottomHeight;
+ },
+ set: function (value)
+ {
+ this._bottomHeight = value;
+ var uvs = this.uvs;
+ var vertices = this.vertices;
+ uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - this._uvh * value;
+ vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - value;
+ this.dirty=true;
+ }
+ }
+});
+
+NineSlicePlane.prototype.updateHorizontalVertices = function() {
+ var vertices = this.vertices;
+ vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight;
+ vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - this._bottomHeight;
+ vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height;
+};
+
+NineSlicePlane.prototype.updateVerticalVertices = function() {
+ var vertices = this.vertices;
+ vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth;
+ vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - this._rightWidth;
+ vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width ;
+};
+
+/**
+ * Renders the object using the Canvas renderer
+ *
+ * @param renderer {PIXI.CanvasRenderer}
+ * @private
+ */
+NineSlicePlane.prototype._renderCanvas= function (renderer)
+{
+ var context = renderer.context;
+
+ var transform = this.worldTransform;
+ var res = renderer.resolution;
+
+ if (renderer.roundPixels)
+ {
+ context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, (transform.tx * res) | 0, (transform.ty * res) | 0);
+ }
+ else
+ {
+ context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, transform.tx * res, transform.ty * res);
+ }
+
+ var base = this._texture.baseTexture;
+ var textureSource = base.source;
+ var w = base.width;
+ var h = base.height;
+
+ this.drawSegment(context, textureSource, w, h, 0, 1, 10, 11);
+ this.drawSegment(context, textureSource, w, h, 2, 3, 12, 13);
+ this.drawSegment(context, textureSource, w, h, 4, 5, 14, 15);
+ this.drawSegment(context, textureSource, w, h, 8, 9, 18, 19);
+ this.drawSegment(context, textureSource, w, h, 10, 11, 20, 21);
+ this.drawSegment(context, textureSource, w, h, 12, 13, 22, 23);
+ this.drawSegment(context, textureSource, w, h, 16, 17, 26, 27);
+ this.drawSegment(context, textureSource, w, h, 18, 19, 28, 29);
+ this.drawSegment(context, textureSource, w, h, 20, 21, 30, 31);
+};
+
+/**
+ * Renders one segment of the plane.
+ * to mimic the exact drawing behavior of stretching the image like WebGL does, we need to make sure
+ * that the source area is at least 1 pixel in size, otherwise nothing gets drawn when a slice size of 0 is used.
+ *
+ * @param context
+ * @param textureSource
+ * @param w width of the texture
+ * @param h height of the texture
+ * @param x1
+ * @param y1
+ * @param x2
+ * @param y2
+ * @private
+ */
+NineSlicePlane.prototype.drawSegment= function (context, textureSource, w, h, x1, y1, x2, y2)
+{
+ // otherwise you get weird results when using slices of that are 0 wide or high.
+ var uvs = this.uvs;
+ var vertices = this.vertices;
+
+ var sw = (uvs[x2]-uvs[x1]) * w;
+ var sh = (uvs[y2]-uvs[y1]) * h;
+ var dw = vertices[x2] - vertices[x1];
+ var dh = vertices[y2] - vertices[y1];
+
+ // make sure the source is at least 1 pixel wide and high, otherwise nothing will be drawn.
+ if (sw<1) {
+ sw=1;
+ }
+ if (sh<1) {
+ sh=1;
+ }
+ // make sure destination is at least 1 pixel wide and high, otherwise you get lines when rendering close to original size.
+ if (dw<1) {
+ dw=1;
+ }
+ if (dh<1) {
+ dh=1;
+ }
+ context.drawImage(textureSource, uvs[x1] * w, uvs[y1] * h, sw, sh, vertices[x1], vertices[y1], dw, dh);
+};
+},{"./Plane":153}],153:[function(require,module,exports){
var Mesh = require('./Mesh');
/**
@@ -30052,7 +30468,7 @@
}
};
-},{"./Mesh":151}],153:[function(require,module,exports){
+},{"./Mesh":151}],154:[function(require,module,exports){
var Mesh = require('./Mesh');
var core = require('../core');
@@ -30267,7 +30683,7 @@
this.containerUpdateTransform();
};
-},{"../core":60,"./Mesh":151}],154:[function(require,module,exports){
+},{"../core":60,"./Mesh":151}],155:[function(require,module,exports){
/**
* @file Main export of the PIXI extras library
* @author Mat Groves
@@ -30281,11 +30697,12 @@
module.exports = {
Mesh: require('./Mesh'),
Plane: require('./Plane'),
+ NineSlicePlane: require('./NineSlicePlane'),
Rope: require('./Rope'),
MeshShader: require('./webgl/MeshShader')
};
-},{"./Mesh":151,"./Plane":152,"./Rope":153,"./webgl/MeshShader":155}],155:[function(require,module,exports){
+},{"./Mesh":151,"./NineSlicePlane":152,"./Plane":153,"./Rope":154,"./webgl/MeshShader":156}],156:[function(require,module,exports){
var Shader = require('../../core/Shader');
/**
@@ -30333,7 +30750,7 @@
module.exports = MeshShader;
-},{"../../core/Shader":40}],156:[function(require,module,exports){
+},{"../../core/Shader":40}],157:[function(require,module,exports){
var core = require('../core');
/**
@@ -30667,7 +31084,7 @@
this._buffers = null;
};
-},{"../core":60}],157:[function(require,module,exports){
+},{"../core":60}],158:[function(require,module,exports){
/**
* @file Main export of the PIXI extras library
* @author Mat Groves
@@ -30683,7 +31100,7 @@
ParticleRenderer: require('./webgl/ParticleRenderer')
};
-},{"./ParticleContainer":156,"./webgl/ParticleRenderer":159}],158:[function(require,module,exports){
+},{"./ParticleContainer":157,"./webgl/ParticleRenderer":160}],159:[function(require,module,exports){
var glCore = require('pixi-gl-core'),
createIndicesForQuads = require('../../core/utils/createIndicesForQuads');
@@ -30914,7 +31331,7 @@
this.staticBuffer.destroy();
};
-},{"../../core/utils/createIndicesForQuads":112,"pixi-gl-core":20}],159:[function(require,module,exports){
+},{"../../core/utils/createIndicesForQuads":112,"pixi-gl-core":20}],160:[function(require,module,exports){
var core = require('../../core'),
ParticleShader = require('./ParticleShader'),
ParticleBuffer = require('./ParticleBuffer');
@@ -31346,7 +31763,7 @@
this.tempMatrix = null;
};
-},{"../../core":60,"./ParticleBuffer":158,"./ParticleShader":160}],160:[function(require,module,exports){
+},{"../../core":60,"./ParticleBuffer":159,"./ParticleShader":161}],161:[function(require,module,exports){
var Shader = require('../../core/Shader');
/**
@@ -31412,7 +31829,7 @@
module.exports = ParticleShader;
-},{"../../core/Shader":40}],161:[function(require,module,exports){
+},{"../../core/Shader":40}],162:[function(require,module,exports){
// References:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
@@ -31428,7 +31845,7 @@
};
}
-},{}],162:[function(require,module,exports){
+},{}],163:[function(require,module,exports){
// References:
// https://github.com/sindresorhus/object-assign
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
@@ -31438,7 +31855,7 @@
Object.assign = require('object-assign');
}
-},{"object-assign":13}],163:[function(require,module,exports){
+},{"object-assign":13}],164:[function(require,module,exports){
require('./Object.assign');
require('./requestAnimationFrame');
require('./Math.sign');
@@ -31456,7 +31873,7 @@
window.Uint16Array = Array;
}
-},{"./Math.sign":161,"./Object.assign":162,"./requestAnimationFrame":164}],164:[function(require,module,exports){
+},{"./Math.sign":162,"./Object.assign":163,"./requestAnimationFrame":165}],165:[function(require,module,exports){
(function (global){
// References:
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
@@ -31526,7 +31943,7 @@
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{}],165:[function(require,module,exports){
+},{}],166:[function(require,module,exports){
var core = require('../../core');
/**
@@ -31586,13 +32003,13 @@
};
core.CanvasRenderer.registerPlugin('prepare', CanvasPrepare);
-},{"../../core":60}],166:[function(require,module,exports){
+},{"../../core":60}],167:[function(require,module,exports){
module.exports = {
webGL: require('./webgl/WebGLPrepare'),
canvas: require('./canvas/CanvasPrepare')
};
-},{"./canvas/CanvasPrepare":165,"./webgl/WebGLPrepare":167}],167:[function(require,module,exports){
+},{"./canvas/CanvasPrepare":166,"./webgl/WebGLPrepare":168}],168:[function(require,module,exports){
var core = require('../../core'),
SharedTicker = core.ticker.shared;
diff --git a/bin/pixi.js b/bin/pixi.js
index 0f15181..33edaea 100644
--- a/bin/pixi.js
+++ b/bin/pixi.js
@@ -10255,7 +10255,7 @@
* World transform and local transform of this object.
* This will be reworked in v4.1, please do not use it yet unless you know what are you doing!
*
- * @member {PIXI.Transform|PIXI.TransformStatic}
+ * @member {PIXI.TransformBase}
*/
this.transform = new TransformClass();
@@ -10803,31 +10803,21 @@
};
},{"../const":41,"../math":65,"./BoundsBuilder":42,"./Transform":45,"./TransformStatic":47,"eventemitter3":11}],45:[function(require,module,exports){
-var math = require('../math');
+var math = require('../math'),
+ TransformBase = require('./TransformBase');
/**
* Generic class to deal with traditional 2D matrix transforms
- * This will be reworked in v4.1, please do not use it yet unless you know what are you doing!
+ * local transformation is calculated from position,scale,skew and rotation
*
* @class
+ * @extends PIXI.TransformBase
* @memberof PIXI
*/
function Transform()
{
- /**
- * The global matrix transform.
- *
- * @member {PIXI.Matrix}
- */
- this.worldTransform = new math.Matrix();
-
- /**
- * The local matrix transform.
- *
- * @member {PIXI.Matrix}
- */
- this.localTransform = new math.Matrix();
+ TransformBase.call(this);
/**
* The coordinate of the object relative to the local coordinates of the parent.
@@ -10857,7 +10847,6 @@
*/
this.pivot = new math.Point(0.0);
-
/**
* The rotation value of the object, in radians
*
@@ -10872,13 +10861,9 @@
this._sy = Math.sin(0);//skewY);
this._nsx = Math.sin(0);//skewX);
this._cx = Math.cos(0);//skewX);
-
- this._dirty = false;
- this.updated = true;
-
- this._worldID = 0;
}
+Transform.prototype = Object.create(TransformBase.prototype);
Transform.prototype.constructor = Transform;
Transform.prototype.updateSkew = function ()
@@ -10890,6 +10875,24 @@
};
/**
+ * Updates only local matrix
+ */
+Transform.prototype.updateLocalTransform = function() {
+ var lt = this.localTransform;
+ var a, b, c, d;
+
+ a = this._cr * this.scale.x;
+ b = this._sr * this.scale.x;
+ c = -this._sr * this.scale.y;
+ d = this._cr * this.scale.y;
+
+ lt.a = this._cy * a + this._sy * c;
+ lt.b = this._cy * b + this._sy * d;
+ lt.c = this._nsx * a + this._cx * c;
+ lt.d = this._nsx * b + this._cx * d;
+};
+
+/**
* Updates the values of the object and applies the parent's transform.
* @param parentTransform {PIXI.Transform} The transform of the parent of this object
*/
@@ -10956,29 +10959,27 @@
module.exports = Transform;
-},{"../math":65}],46:[function(require,module,exports){
+},{"../math":65,"./TransformBase":46}],46:[function(require,module,exports){
var math = require('../math');
/**
* Generic class to deal with traditional 2D matrix transforms
- * This will be reworked in v4.1, please do not use it yet unless you know what are you doing!
*
* @class
* @memberof PIXI
*/
-function TransformManual()
+function TransformBase()
{
/**
- * The global matrix transform.
+ * The global matrix transform. It can be swapped temporarily by some functions like getLocalBounds()
*
* @member {PIXI.Matrix}
*/
this.worldTransform = new math.Matrix();
-
/**
- * The local matrix transform.
- *
+ * The local matrix transform
+ *
* @member {PIXI.Matrix}
*/
this.localTransform = new math.Matrix();
@@ -10986,16 +10987,22 @@
this._worldID = 0;
}
-TransformManual.prototype.constructor = TransformManual;
+TransformBase.prototype.constructor = TransformBase;
+
+/**
+ * TransformBase does not have decomposition, so this function wont do anything
+ */
+TransformBase.prototype.updateLocalTransform = function() { // jshint unused:false
+
+};
/**
* Updates the values of the object and applies the parent's transform.
- * @param parentTransform {PIXI.Transform} The transform of the parent of this object
+ * @param parentTransform {PIXI.TransformBase} The transform of the parent of this object
*
*/
-TransformManual.prototype.updateTransform = function (parentTransform)
+TransformBase.prototype.updateTransform = function (parentTransform)
{
-
var pt = parentTransform.worldTransform;
var wt = this.worldTransform;
var lt = this.localTransform;
@@ -11011,34 +11018,31 @@
this._worldID ++;
};
-module.exports = TransformManual;
+/**
+ * Updates the values of the object and applies the parent's transform.
+ * @param parentTransform {PIXI.Transform} The transform of the parent of this object
+ *
+ */
+TransformBase.prototype.updateWorldTransform = TransformBase.prototype.updateTransform;
+
+TransformBase.IDENTITY = new TransformBase();
+
+module.exports = TransformBase;
},{"../math":65}],47:[function(require,module,exports){
-var math = require('../math');
+var math = require('../math'),
+ TransformBase = require('./TransformBase');
/**
* Transform that takes care about its versions
- * This will be reworked in v4.1, please do not use it yet unless you know what are you doing!
*
* @class
+ * @extends PIXI.TransformBase
* @memberof PIXI
*/
function TransformStatic()
{
- /**
- * The global matrix transform.
- *
- * @member {PIXI.Matrix}
- */
- this.worldTransform = new math.Matrix();
-
- /**
- * The local matrix transform.
- *
- * @member {PIXI.Matrix}
- */
- this.localTransform = new math.Matrix();
-
+ TransformBase.call(this);
/**
* The coordinate of the object relative to the local coordinates of the parent.
*
@@ -11076,13 +11080,10 @@
this._nsx = Math.sin(0);//skewX);
this._cx = Math.cos(0);//skewX);
-
- this._localID = 0;
this._currentLocalID = 0;
- this._parentID = 0;
- this._worldID = 0;
}
+TransformStatic.prototype = Object.create(TransformBase.prototype);
TransformStatic.prototype.constructor = TransformStatic;
TransformStatic.prototype.onChange = function ()
@@ -11101,6 +11102,35 @@
};
/**
+ * Updates only local matrix
+ */
+TransformStatic.prototype.updateLocalTransform = function() {
+ var lt = this.localTransform;
+ if(this._localID !== this._currentLocalID)
+ {
+ // get the matrix values of the displayobject based on its transform properties..
+ var a,b,c,d;
+
+ a = this._cr * this.scale.x;
+ b = this._sr * this.scale.x;
+ c = -this._sr * this.scale.y;
+ d = this._cr * this.scale.y;
+
+ lt.a = this._cy * a + this._sy * c;
+ lt.b = this._cy * b + this._sy * d;
+ lt.c = this._nsx * a + this._cx * c;
+ lt.d = this._nsx * b + this._cx * d;
+
+ lt.tx = this.position._x - (this.pivot._x * lt.a + this.pivot._y * lt.c);
+ lt.ty = this.position._y - (this.pivot._x * lt.b + this.pivot._y * lt.d);
+ this._currentLocalID = this._localID;
+
+ // force an update..
+ this._parentID = -1;
+ }
+};
+
+/**
* Updates the values of the object and applies the parent's transform.
* @param parentTransform {PIXI.Transform} The transform of the parent of this object
*
@@ -11158,6 +11188,7 @@
TransformStatic.prototype.setFromMatrix = function (matrix)
{
matrix.decompose(this);
+ this._localID ++;
};
Object.defineProperties(TransformStatic.prototype, {
@@ -11182,7 +11213,7 @@
module.exports = TransformStatic;
-},{"../math":65}],48:[function(require,module,exports){
+},{"../math":65,"./TransformBase":46}],48:[function(require,module,exports){
var Container = require('../display/Container'),
RenderTexture = require('../textures/RenderTexture'),
Texture = require('../textures/Texture'),
@@ -13691,7 +13722,7 @@
Container: require('./display/Container'),
Transform: require('./display/Transform'),
TransformStatic: require('./display/TransformStatic'),
- TransformManual: require('./display/TransformManual'),
+ TransformBase: require('./display/TransformBase'),
// sprites
Sprite: require('./sprites/Sprite'),
@@ -13767,7 +13798,7 @@
}
});
-},{"./Shader":40,"./const":41,"./display/Container":43,"./display/DisplayObject":44,"./display/Transform":45,"./display/TransformManual":46,"./display/TransformStatic":47,"./graphics/Graphics":48,"./graphics/GraphicsData":49,"./graphics/canvas/CanvasGraphicsRenderer":50,"./graphics/webgl/GraphicsRenderer":52,"./math":65,"./renderers/canvas/CanvasRenderer":72,"./renderers/canvas/utils/CanvasRenderTarget":74,"./renderers/webgl/WebGLRenderer":79,"./renderers/webgl/filters/Filter":81,"./renderers/webgl/filters/spriteMask/SpriteMaskFilter":84,"./renderers/webgl/managers/WebGLManager":88,"./renderers/webgl/utils/ObjectRenderer":89,"./renderers/webgl/utils/Quad":90,"./renderers/webgl/utils/RenderTarget":91,"./sprites/Sprite":96,"./sprites/canvas/CanvasSpriteRenderer":97,"./sprites/canvas/CanvasTinter":98,"./sprites/webgl/SpriteRenderer":100,"./text/Text":102,"./text/TextStyle":103,"./textures/BaseRenderTexture":104,"./textures/BaseTexture":105,"./textures/RenderTexture":106,"./textures/Texture":107,"./textures/TextureUvs":108,"./textures/VideoBaseTexture":109,"./ticker":111,"./utils":114,"pixi-gl-core":20}],61:[function(require,module,exports){
+},{"./Shader":40,"./const":41,"./display/Container":43,"./display/DisplayObject":44,"./display/Transform":45,"./display/TransformBase":46,"./display/TransformStatic":47,"./graphics/Graphics":48,"./graphics/GraphicsData":49,"./graphics/canvas/CanvasGraphicsRenderer":50,"./graphics/webgl/GraphicsRenderer":52,"./math":65,"./renderers/canvas/CanvasRenderer":72,"./renderers/canvas/utils/CanvasRenderTarget":74,"./renderers/webgl/WebGLRenderer":79,"./renderers/webgl/filters/Filter":81,"./renderers/webgl/filters/spriteMask/SpriteMaskFilter":84,"./renderers/webgl/managers/WebGLManager":88,"./renderers/webgl/utils/ObjectRenderer":89,"./renderers/webgl/utils/Quad":90,"./renderers/webgl/utils/RenderTarget":91,"./sprites/Sprite":96,"./sprites/canvas/CanvasSpriteRenderer":97,"./sprites/canvas/CanvasTinter":98,"./sprites/webgl/SpriteRenderer":100,"./text/Text":102,"./text/TextStyle":103,"./textures/BaseRenderTexture":104,"./textures/BaseTexture":105,"./textures/RenderTexture":106,"./textures/Texture":107,"./textures/TextureUvs":108,"./textures/VideoBaseTexture":109,"./ticker":111,"./utils":114,"pixi-gl-core":20}],61:[function(require,module,exports){
// Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group of order 16
var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1];
@@ -14282,8 +14313,8 @@
/**
* Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
- * @param transform {PIXI.Transform} the transform to apply the properties to.
- * @return {PIXI.Transform} The transform with the newly applied properies
+ * @param transform {PIXI.Transform|PIXI.TransformStatic} the transform to apply the properties to.
+ * @return {PIXI.Transform|PIXI.TransformStatic} The transform with the newly applied properies
*/
Matrix.prototype.decompose = function(transform)
{
@@ -18142,7 +18173,7 @@
alphaMaskFilter[0].maskSprite = maskData;
//TODO - may cause issues!
- target.filterArea = maskData.getBounds();
+ target.filterArea = maskData.getBounds(true);
this.renderer.filterManager.pushFilter(target, alphaMaskFilter);
@@ -20441,9 +20472,10 @@
'uniform sampler2D uSamplers[%count%];',
'void main(void){',
- 'vec4 color;',
- '%forloop%',
- 'gl_FragColor = color * vColor;',
+ 'vec4 color;',
+ 'float textureId = floor(vTextureId+0.5);',
+ '%forloop%',
+ 'gl_FragColor = color * vColor;',
'}'
].join('\n');
@@ -20485,7 +20517,7 @@
if(i < maxTextures-1)
{
- src += 'if(vTextureId == ' + i + '.0)';
+ src += 'if(textureId == ' + i + '.0)';
}
src += '\n{';
@@ -21798,6 +21830,9 @@
this.width = width || 100;
this.height = height || 100;
+ this.realWidth = this.width * resolution;
+ this.realHeight = this.height * resolution;
+
this.resolution = resolution || CONST.RESOLUTION;
this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT;
this.hasLoaded = true;
@@ -21849,6 +21884,9 @@
this.width = width;
this.height = height;
+ this.realWidth = this.width * this.resolution;
+ this.realHeight = this.height * this.resolution;
+
if (!this.valid)
{
return;
@@ -23935,7 +23973,7 @@
*/
isWebGLSupported: function ()
{
- var contextOptions = { stencil: true };
+ var contextOptions = { stencil: true, failIfMajorPerformanceCaveat: true };
try
{
if (!window.WebGLRenderingContext)
@@ -24398,6 +24436,21 @@
return core.Filter;
}
},
+
+ /**
+ * @class
+ * @private
+ * @name PIXI.TransformManual
+ * @see PIXI.TransformBase
+ * @deprecated since version 4.0.0
+ */
+ TransformManual: {
+ get: function()
+ {
+ warn('TransformManual has been renamed to TransformBase, please update your pixi-spine');
+ return core.TransformBase;
+ }
+ }
});
core.DisplayObject.prototype.generateTexture = function(renderer, scaleMode, resolution)
@@ -24655,7 +24708,7 @@
};
-},{"./core":60,"./core/const":41,"./extras":127,"./filters":138,"./mesh":154,"./particles":157}],118:[function(require,module,exports){
+},{"./core":60,"./core/const":41,"./extras":127,"./filters":138,"./mesh":155,"./particles":158}],118:[function(require,module,exports){
var core = require('../../core'),
tempRect = new core.Rectangle();
@@ -26218,13 +26271,24 @@
_tempMatrix = new core.Matrix();
DisplayObject.prototype._cacheAsBitmap = false;
-DisplayObject.prototype._originalRenderWebGL = null;
-DisplayObject.prototype._originalRenderCanvas = null;
+DisplayObject.prototype._cacheData = false;
-DisplayObject.prototype._originalUpdateTransform = null;
-DisplayObject.prototype._originalHitTest = null;
-DisplayObject.prototype._originalDestroy = null;
-DisplayObject.prototype._cachedSprite = null;
+// figured theres no point adding ALL the extra variables to prototype.
+// this model can hold the information needed. This can also be generated on demand as
+// most objects are not cached as bitmaps.
+var CacheData = function(){
+
+ this.originalRenderWebGL = null;
+ this.originalRenderCanvas = null;
+
+ this.originalUpdateTransform = null;
+ this.originalHitTest = null;
+ this.originalDestroy = null;
+ this.originalMask = null;
+ this.originalFilterArea = null;
+ this.sprite = null;
+};
+
Object.defineProperties(DisplayObject.prototype, {
@@ -26250,17 +26314,32 @@
this._cacheAsBitmap = value;
+ var data;
+
if (value)
{
- this._originalRenderWebGL = this.renderWebGL;
- this._originalRenderCanvas = this.renderCanvas;
- this._originalUpdateTransform = this.updateTransform;
- this._originalGetBounds = this.getBounds;
+ if(!this._cacheData)
+ {
+ this._cacheData = new CacheData();
+ }
- this._originalDestroy = this.destroy;
+ data = this._cacheData;
- this._originalContainsPoint = this.containsPoint;
+ data.originalRenderWebGL = this.renderWebGL;
+ data.originalRenderCanvas = this.renderCanvas;
+
+ data.originalUpdateTransform = this.updateTransform;
+ data.originalGetBounds = this.getBounds;
+
+ data.originalDestroy = this.destroy;
+
+ data.originalContainsPoint = this.containsPoint;
+
+ data.originalMask = this._mask;
+ data.originalFilterArea = this.filterArea;
+
+
this.renderWebGL = this._renderCachedWebGL;
this.renderCanvas = this._renderCachedCanvas;
@@ -26270,19 +26349,25 @@
}
else
{
- if (this._cachedSprite)
+ data = this._cacheData;
+
+ if (data.sprite)
{
this._destroyCachedDisplayObject();
}
- this.renderWebGL = this._originalRenderWebGL;
- this.renderCanvas = this._originalRenderCanvas;
- this.getBounds = this._originalGetBounds;
- this.destroy = this._originalDestroy;
+ this.renderWebGL = data.originalRenderWebGL;
+ this.renderCanvas = data.originalRenderCanvas;
+ this.getBounds = data.originalGetBounds;
- this.updateTransform = this._originalUpdateTransform;
- this.containsPoint = this._originalContainsPoint;
+ this.destroy = data.originalDestroy;
+
+ this.updateTransform = data.originalUpdateTransform;
+ this.containsPoint = data.originalContainsPoint;
+
+ this._mask = data.originalMask;
+ this.filterArea = data.originalFilterArea;
}
}
}
@@ -26302,10 +26387,9 @@
this._initCachedDisplayObject( renderer );
- this._cachedSprite._transformID = -1;
- this._cachedSprite.worldAlpha = this.worldAlpha;
-
- this._cachedSprite._renderWebGL(renderer);
+ this._cacheData.sprite._transformID = -1;
+ this._cacheData.sprite.worldAlpha = this.worldAlpha;
+ this._cacheData.sprite._renderWebGL(renderer);
};
/**
@@ -26316,7 +26400,7 @@
*/
DisplayObject.prototype._initCachedDisplayObject = function (renderer)
{
- if(this._cachedSprite)
+ if(this._cacheData && this._cacheData.sprite)
{
return;
}
@@ -26357,7 +26441,7 @@
m.ty = -bounds.y;
// set all properties to there original so we can render to a texture
- this.renderWebGL = this._originalRenderWebGL;
+ this.renderWebGL = this._cacheData.originalRenderWebGL;
renderer.render(this, renderTexture, true, m, true);
// now restore the state be setting the new properties
@@ -26370,18 +26454,22 @@
this.updateTransform = this.displayObjectUpdateTransform;
this.getBounds = this._getCachedBounds;
+ this._mask = null;
+ this.filterArea = null;
// create our cached sprite
- this._cachedSprite = new core.Sprite(renderTexture);
- this._cachedSprite.transform.worldTransform = this.transform.worldTransform;
- this._cachedSprite.anchor.x = -( bounds.x / bounds.width );
- this._cachedSprite.anchor.y = -( bounds.y / bounds.height );
+ var cachedSprite = new core.Sprite(renderTexture);
+ cachedSprite.transform.worldTransform = this.transform.worldTransform;
+ cachedSprite.anchor.x = -( bounds.x / bounds.width );
+ cachedSprite.anchor.y = -( bounds.y / bounds.height );
+
+ this._cacheData.sprite = cachedSprite;
// restore the transform of the cached sprite to avoid the nasty flicker..
this.updateTransform();
// map the hit test..
- this.containsPoint = this._cachedSprite.containsPoint.bind(this._cachedSprite);
+ this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite);
};
/**
@@ -26399,9 +26487,9 @@
this._initCachedDisplayObjectCanvas( renderer );
- this._cachedSprite.worldAlpha = this.worldAlpha;
+ this._cacheData.sprite.worldAlpha = this.worldAlpha;
- this._cachedSprite.renderCanvas(renderer);
+ this._cacheData.sprite.renderCanvas(renderer);
};
//TODO this can be the same as the webGL verison.. will need to do a little tweaking first though..
@@ -26413,7 +26501,7 @@
*/
DisplayObject.prototype._initCachedDisplayObjectCanvas = function (renderer)
{
- if(this._cachedSprite)
+ if(this._cacheData && this._cacheData.sprite)
{
return;
}
@@ -26435,7 +26523,7 @@
//m.append(this.transform.worldTransform.)
// set all properties to there original so we can render to a texture
- this.renderCanvas = this._originalRenderCanvas;
+ this.renderCanvas = this._cacheData.originalRenderCanvas;
//renderTexture.render(this, m, true);
renderer.render(this, renderTexture, true, m, false);
@@ -26447,16 +26535,20 @@
this.updateTransform = this.displayObjectUpdateTransform;
this.getBounds = this._getCachedBounds;
+ this._mask = null;
+ this.filterArea = null;
// create our cached sprite
- this._cachedSprite = new core.Sprite(renderTexture);
- this._cachedSprite.transform.worldTransform = this.transform.worldTransform;
- this._cachedSprite.anchor.x = -( bounds.x / bounds.width );
- this._cachedSprite.anchor.y = -( bounds.y / bounds.height );
+ var cachedSprite = new core.Sprite(renderTexture);
+ cachedSprite.transform.worldTransform = this.transform.worldTransform;
+ cachedSprite.anchor.x = -( bounds.x / bounds.width );
+ cachedSprite.anchor.y = -( bounds.y / bounds.height );
this.updateTransform();
- this.containsPoint = this._cachedSprite.containsPoint.bind(this._cachedSprite);
+ this._cacheData.sprite = cachedSprite;
+
+ this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite);
};
/**
@@ -26466,9 +26558,9 @@
*/
DisplayObject.prototype._getCachedBounds = function ()
{
- this._cachedSprite._currentBounds = null;
+ this._cacheData.sprite._currentBounds = null;
- return this._cachedSprite.getBounds(core.Matrix.IDENTITY);
+ return this._cacheData.sprite.getBounds();
};
/**
@@ -26478,14 +26570,14 @@
*/
DisplayObject.prototype._destroyCachedDisplayObject = function ()
{
- this._cachedSprite._texture.destroy(true);
- this._cachedSprite = null;
+ this._cacheData.sprite._texture.destroy(true);
+ this._cacheData.sprite = null;
};
DisplayObject.prototype._cacheAsBitmapDestroy = function ()
{
this.cacheAsBitmap = false;
- this._originalDestroy();
+ this._cacheData.originalDestroy();
};
},{"../core":60}],125:[function(require,module,exports){
@@ -27917,7 +28009,7 @@
global.PIXI = core;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./accessibility":39,"./core":60,"./deprecation":117,"./extract":119,"./extras":127,"./filters":138,"./interaction":144,"./loaders":147,"./mesh":154,"./particles":157,"./polyfill":163,"./prepare":166}],142:[function(require,module,exports){
+},{"./accessibility":39,"./core":60,"./deprecation":117,"./extract":119,"./extras":127,"./filters":138,"./interaction":144,"./loaders":147,"./mesh":155,"./particles":158,"./polyfill":164,"./prepare":167}],142:[function(require,module,exports){
var core = require('../core');
/**
@@ -29648,6 +29740,7 @@
renderer.bindShader(glData.shader);
renderer.bindTexture(this._texture, 0);
+ renderer.state.setBlendMode(this.blendMode);
glData.shader.uniforms.translationMatrix = this.worldTransform.toArray(true);
glData.shader.uniforms.alpha = this.worldAlpha;
@@ -29927,7 +30020,330 @@
TRIANGLES: 1
};
-},{"../core":60,"./webgl/MeshShader":155,"pixi-gl-core":20}],152:[function(require,module,exports){
+},{"../core":60,"./webgl/MeshShader":156,"pixi-gl-core":20}],152:[function(require,module,exports){
+var DEFAULT_BORDER_SIZE= 10;
+
+var Plane = require('./Plane');
+
+/**
+ * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful
+ * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically
+ *
+ *```js
+ * var Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.fromImage('BoxWithRoundedCorners.png'), 15, 15, 15, 15);
+ * ```
+ *
+ * A B
+ * +---+----------------------+---+
+ * C | 1 | 2 | 3 |
+ * +---+----------------------+---+
+ * | | | |
+ * | 4 | 5 | 6 |
+ * | | | |
+ * +---+----------------------+---+
+ * D | 7 | 8 | 9 |
+ * +---+----------------------+---+
+
+ * When changing this objects width and/or height:
+ * areas 1 3 7 and 9 will remain unscaled.
+ * areas 2 and 8 will be stretched horizontally
+ * areas 4 and 6 will be stretched vertically
+ * area 5 will be stretched both horizontally and vertically
+ *
+ *
+ * @class
+ * @extends PIXI.mesh.Plane
+ * @memberof PIXI.mesh
+ * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane.
+ * @param {int} [leftWidth=10] size of the left vertical bar (A)
+ * @param {int} [topHeight=10] size of the top horizontal bar (C)
+ * @param {int} [rightWidth=10] size of the right vertical bar (B)
+ * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D)
+ *
+ */
+function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight)
+{
+ Plane.call(this, texture, 4, 4);
+
+ var uvs = this.uvs;
+ // right and bottom uv's are always 1
+ uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1;
+ uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1;
+
+ this._origWidth = texture.width;
+ this._origHeight = texture.height;
+ this._uvw = 1 / this._origWidth;
+ this._uvh = 1 / this._origHeight;
+ /**
+ * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
+ *
+ * @member {number}
+ * @memberof PIXI.NineSlicePlane#
+ * @override
+ */
+ this.width = texture.width;
+ /**
+ * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
+ *
+ * @member {number}
+ * @memberof PIXI.NineSlicePlane#
+ * @override
+ */
+ this.height = texture.height;
+
+ uvs[2] = uvs[10] = uvs[18] = uvs[26] = this._uvw * leftWidth;
+ uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - this._uvw * rightWidth;
+ uvs[9] = uvs[11] = uvs[13] = uvs[15] = this._uvh * topHeight;
+ uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - this._uvh * bottomHeight;
+
+ /**
+ * The width of the left column (a)
+ *
+ * @member {number}
+ */
+ this.leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE;
+ /**
+ * The width of the right column (b)
+ *
+ * @member {number}
+ */
+ this.rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE;
+ /**
+ * The height of the top row (c)
+ *
+ * @member {number}
+ */
+ this.topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE;
+ /**
+ * The height of the bottom row (d)
+ *
+ * @member {number}
+ */
+ this.bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE;
+}
+
+
+// constructor
+NineSlicePlane.prototype = Object.create( Plane.prototype );
+NineSlicePlane.prototype.constructor = NineSlicePlane;
+module.exports = NineSlicePlane;
+
+Object.defineProperties(NineSlicePlane.prototype, {
+ /**
+ * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
+ *
+ * @member {number}
+ * @memberof PIXI.NineSlicePlane#
+ * @override
+ */
+ width: {
+ get: function ()
+ {
+ return this._width;
+ },
+ set: function (value)
+ {
+ this._width = value;
+ this.updateVerticalVertices();
+ }
+ },
+
+ /**
+ * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
+ *
+ * @member {number}
+ * @memberof PIXI.NineSlicePlane#
+ * @override
+ */
+ height: {
+ get: function ()
+ {
+ return this._height;
+ },
+ set: function (value)
+ {
+ this._height = value;
+ this.updateHorizontalVertices();
+ }
+ },
+
+ /**
+ * The width of the left column
+ *
+ * @member {number}
+ */
+ leftWidth: {
+ get: function()
+ {
+ return this._leftWidth;
+ },
+ set: function (value)
+ {
+ this._leftWidth = value;
+ var uvs = this.uvs;
+ var vertices = this.vertices;
+ uvs[2] = uvs[10] = uvs[18] = uvs[26] = this._uvw * value;
+ vertices[2] = vertices[10] = vertices[18] = vertices[26] = value;
+ this.dirty=true;
+ }
+ },
+ /**
+ * The width of the right column
+ *
+ * @member {number}
+ */
+ rightWidth: {
+ get: function()
+ {
+ return this._rightWidth;
+ },
+ set: function (value)
+ {
+ this._rightWidth = value;
+ var uvs = this.uvs;
+ var vertices = this.vertices;
+ uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - this._uvw * value;
+ vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - value;
+ this.dirty=true;
+ }
+ },
+ /**
+ * The height of the top row
+ *
+ * @member {number}
+ */
+ topHeight: {
+ get: function()
+ {
+ return this._topHeight;
+ },
+ set: function (value)
+ {
+ this._topHeight = value;
+ var uvs = this.uvs;
+ var vertices = this.vertices;
+ uvs[9] = uvs[11] = uvs[13] = uvs[15] = this._uvh * value;
+ vertices[9] = vertices[11] = vertices[13] = vertices[15] = value;
+ this.dirty=true;
+ }
+ },
+ /**
+ * The height of the bottom row
+ *
+ * @member {number}
+ */
+ bottomHeight: {
+ get: function()
+ {
+ return this._bottomHeight;
+ },
+ set: function (value)
+ {
+ this._bottomHeight = value;
+ var uvs = this.uvs;
+ var vertices = this.vertices;
+ uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - this._uvh * value;
+ vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - value;
+ this.dirty=true;
+ }
+ }
+});
+
+NineSlicePlane.prototype.updateHorizontalVertices = function() {
+ var vertices = this.vertices;
+ vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight;
+ vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - this._bottomHeight;
+ vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height;
+};
+
+NineSlicePlane.prototype.updateVerticalVertices = function() {
+ var vertices = this.vertices;
+ vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth;
+ vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - this._rightWidth;
+ vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width ;
+};
+
+/**
+ * Renders the object using the Canvas renderer
+ *
+ * @param renderer {PIXI.CanvasRenderer}
+ * @private
+ */
+NineSlicePlane.prototype._renderCanvas= function (renderer)
+{
+ var context = renderer.context;
+
+ var transform = this.worldTransform;
+ var res = renderer.resolution;
+
+ if (renderer.roundPixels)
+ {
+ context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, (transform.tx * res) | 0, (transform.ty * res) | 0);
+ }
+ else
+ {
+ context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, transform.tx * res, transform.ty * res);
+ }
+
+ var base = this._texture.baseTexture;
+ var textureSource = base.source;
+ var w = base.width;
+ var h = base.height;
+
+ this.drawSegment(context, textureSource, w, h, 0, 1, 10, 11);
+ this.drawSegment(context, textureSource, w, h, 2, 3, 12, 13);
+ this.drawSegment(context, textureSource, w, h, 4, 5, 14, 15);
+ this.drawSegment(context, textureSource, w, h, 8, 9, 18, 19);
+ this.drawSegment(context, textureSource, w, h, 10, 11, 20, 21);
+ this.drawSegment(context, textureSource, w, h, 12, 13, 22, 23);
+ this.drawSegment(context, textureSource, w, h, 16, 17, 26, 27);
+ this.drawSegment(context, textureSource, w, h, 18, 19, 28, 29);
+ this.drawSegment(context, textureSource, w, h, 20, 21, 30, 31);
+};
+
+/**
+ * Renders one segment of the plane.
+ * to mimic the exact drawing behavior of stretching the image like WebGL does, we need to make sure
+ * that the source area is at least 1 pixel in size, otherwise nothing gets drawn when a slice size of 0 is used.
+ *
+ * @param context
+ * @param textureSource
+ * @param w width of the texture
+ * @param h height of the texture
+ * @param x1
+ * @param y1
+ * @param x2
+ * @param y2
+ * @private
+ */
+NineSlicePlane.prototype.drawSegment= function (context, textureSource, w, h, x1, y1, x2, y2)
+{
+ // otherwise you get weird results when using slices of that are 0 wide or high.
+ var uvs = this.uvs;
+ var vertices = this.vertices;
+
+ var sw = (uvs[x2]-uvs[x1]) * w;
+ var sh = (uvs[y2]-uvs[y1]) * h;
+ var dw = vertices[x2] - vertices[x1];
+ var dh = vertices[y2] - vertices[y1];
+
+ // make sure the source is at least 1 pixel wide and high, otherwise nothing will be drawn.
+ if (sw<1) {
+ sw=1;
+ }
+ if (sh<1) {
+ sh=1;
+ }
+ // make sure destination is at least 1 pixel wide and high, otherwise you get lines when rendering close to original size.
+ if (dw<1) {
+ dw=1;
+ }
+ if (dh<1) {
+ dh=1;
+ }
+ context.drawImage(textureSource, uvs[x1] * w, uvs[y1] * h, sw, sh, vertices[x1], vertices[y1], dw, dh);
+};
+},{"./Plane":153}],153:[function(require,module,exports){
var Mesh = require('./Mesh');
/**
@@ -30052,7 +30468,7 @@
}
};
-},{"./Mesh":151}],153:[function(require,module,exports){
+},{"./Mesh":151}],154:[function(require,module,exports){
var Mesh = require('./Mesh');
var core = require('../core');
@@ -30267,7 +30683,7 @@
this.containerUpdateTransform();
};
-},{"../core":60,"./Mesh":151}],154:[function(require,module,exports){
+},{"../core":60,"./Mesh":151}],155:[function(require,module,exports){
/**
* @file Main export of the PIXI extras library
* @author Mat Groves
@@ -30281,11 +30697,12 @@
module.exports = {
Mesh: require('./Mesh'),
Plane: require('./Plane'),
+ NineSlicePlane: require('./NineSlicePlane'),
Rope: require('./Rope'),
MeshShader: require('./webgl/MeshShader')
};
-},{"./Mesh":151,"./Plane":152,"./Rope":153,"./webgl/MeshShader":155}],155:[function(require,module,exports){
+},{"./Mesh":151,"./NineSlicePlane":152,"./Plane":153,"./Rope":154,"./webgl/MeshShader":156}],156:[function(require,module,exports){
var Shader = require('../../core/Shader');
/**
@@ -30333,7 +30750,7 @@
module.exports = MeshShader;
-},{"../../core/Shader":40}],156:[function(require,module,exports){
+},{"../../core/Shader":40}],157:[function(require,module,exports){
var core = require('../core');
/**
@@ -30667,7 +31084,7 @@
this._buffers = null;
};
-},{"../core":60}],157:[function(require,module,exports){
+},{"../core":60}],158:[function(require,module,exports){
/**
* @file Main export of the PIXI extras library
* @author Mat Groves
@@ -30683,7 +31100,7 @@
ParticleRenderer: require('./webgl/ParticleRenderer')
};
-},{"./ParticleContainer":156,"./webgl/ParticleRenderer":159}],158:[function(require,module,exports){
+},{"./ParticleContainer":157,"./webgl/ParticleRenderer":160}],159:[function(require,module,exports){
var glCore = require('pixi-gl-core'),
createIndicesForQuads = require('../../core/utils/createIndicesForQuads');
@@ -30914,7 +31331,7 @@
this.staticBuffer.destroy();
};
-},{"../../core/utils/createIndicesForQuads":112,"pixi-gl-core":20}],159:[function(require,module,exports){
+},{"../../core/utils/createIndicesForQuads":112,"pixi-gl-core":20}],160:[function(require,module,exports){
var core = require('../../core'),
ParticleShader = require('./ParticleShader'),
ParticleBuffer = require('./ParticleBuffer');
@@ -31346,7 +31763,7 @@
this.tempMatrix = null;
};
-},{"../../core":60,"./ParticleBuffer":158,"./ParticleShader":160}],160:[function(require,module,exports){
+},{"../../core":60,"./ParticleBuffer":159,"./ParticleShader":161}],161:[function(require,module,exports){
var Shader = require('../../core/Shader');
/**
@@ -31412,7 +31829,7 @@
module.exports = ParticleShader;
-},{"../../core/Shader":40}],161:[function(require,module,exports){
+},{"../../core/Shader":40}],162:[function(require,module,exports){
// References:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
@@ -31428,7 +31845,7 @@
};
}
-},{}],162:[function(require,module,exports){
+},{}],163:[function(require,module,exports){
// References:
// https://github.com/sindresorhus/object-assign
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
@@ -31438,7 +31855,7 @@
Object.assign = require('object-assign');
}
-},{"object-assign":13}],163:[function(require,module,exports){
+},{"object-assign":13}],164:[function(require,module,exports){
require('./Object.assign');
require('./requestAnimationFrame');
require('./Math.sign');
@@ -31456,7 +31873,7 @@
window.Uint16Array = Array;
}
-},{"./Math.sign":161,"./Object.assign":162,"./requestAnimationFrame":164}],164:[function(require,module,exports){
+},{"./Math.sign":162,"./Object.assign":163,"./requestAnimationFrame":165}],165:[function(require,module,exports){
(function (global){
// References:
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
@@ -31526,7 +31943,7 @@
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{}],165:[function(require,module,exports){
+},{}],166:[function(require,module,exports){
var core = require('../../core');
/**
@@ -31586,13 +32003,13 @@
};
core.CanvasRenderer.registerPlugin('prepare', CanvasPrepare);
-},{"../../core":60}],166:[function(require,module,exports){
+},{"../../core":60}],167:[function(require,module,exports){
module.exports = {
webGL: require('./webgl/WebGLPrepare'),
canvas: require('./canvas/CanvasPrepare')
};
-},{"./canvas/CanvasPrepare":165,"./webgl/WebGLPrepare":167}],167:[function(require,module,exports){
+},{"./canvas/CanvasPrepare":166,"./webgl/WebGLPrepare":168}],168:[function(require,module,exports){
var core = require('../../core'),
SharedTicker = core.ticker.shared;
diff --git a/bin/pixi.js.map b/bin/pixi.js.map
index dbda514..2b4b808 100644
--- a/bin/pixi.js.map
+++ b/bin/pixi.js.map
@@ -1 +1 @@
-{"version":3,"names":[],"mappings":"","sources":["pixi.js"],"sourcesContent":["(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.PIXI = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o= 0 &&\n arr.length % 1 === 0\n );\n }\n\n function _arrayEach(arr, iterator) {\n var index = -1,\n length = arr.length;\n\n while (++index < length) {\n iterator(arr[index], index, arr);\n }\n }\n\n function _map(arr, iterator) {\n var index = -1,\n length = arr.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iterator(arr[index], index, arr);\n }\n return result;\n }\n\n function _range(count) {\n return _map(Array(count), function (v, i) { return i; });\n }\n\n function _reduce(arr, iterator, memo) {\n _arrayEach(arr, function (x, i, a) {\n memo = iterator(memo, x, i, a);\n });\n return memo;\n }\n\n function _forEachOf(object, iterator) {\n _arrayEach(_keys(object), function (key) {\n iterator(object[key], key);\n });\n }\n\n function _indexOf(arr, item) {\n for (var i = 0; i < arr.length; i++) {\n if (arr[i] === item) return i;\n }\n return -1;\n }\n\n var _keys = Object.keys || function (obj) {\n var keys = [];\n for (var k in obj) {\n if (obj.hasOwnProperty(k)) {\n keys.push(k);\n }\n }\n return keys;\n };\n\n function _keyIterator(coll) {\n var i = -1;\n var len;\n var keys;\n if (_isArrayLike(coll)) {\n len = coll.length;\n return function next() {\n i++;\n return i < len ? i : null;\n };\n } else {\n keys = _keys(coll);\n len = keys.length;\n return function next() {\n i++;\n return i < len ? keys[i] : null;\n };\n }\n }\n\n // Similar to ES6's rest param (http://ariya.ofilabs.com/2013/03/es6-and-rest-parameter.html)\n // This accumulates the arguments passed into an array, after a given index.\n // From underscore.js (https://github.com/jashkenas/underscore/pull/2140).\n function _restParam(func, startIndex) {\n startIndex = startIndex == null ? func.length - 1 : +startIndex;\n return function() {\n var length = Math.max(arguments.length - startIndex, 0);\n var rest = Array(length);\n for (var index = 0; index < length; index++) {\n rest[index] = arguments[index + startIndex];\n }\n switch (startIndex) {\n case 0: return func.call(this, rest);\n case 1: return func.call(this, arguments[0], rest);\n }\n // Currently unused but handle cases outside of the switch statement:\n // var args = Array(startIndex + 1);\n // for (index = 0; index < startIndex; index++) {\n // args[index] = arguments[index];\n // }\n // args[startIndex] = rest;\n // return func.apply(this, args);\n };\n }\n\n function _withoutIndex(iterator) {\n return function (value, index, callback) {\n return iterator(value, callback);\n };\n }\n\n //// exported async module functions ////\n\n //// nextTick implementation with browser-compatible fallback ////\n\n // capture the global reference to guard against fakeTimer mocks\n var _setImmediate = typeof setImmediate === 'function' && setImmediate;\n\n var _delay = _setImmediate ? function(fn) {\n // not a direct alias for IE10 compatibility\n _setImmediate(fn);\n } : function(fn) {\n setTimeout(fn, 0);\n };\n\n if (typeof process === 'object' && typeof process.nextTick === 'function') {\n async.nextTick = process.nextTick;\n } else {\n async.nextTick = _delay;\n }\n async.setImmediate = _setImmediate ? _delay : async.nextTick;\n\n\n async.forEach =\n async.each = function (arr, iterator, callback) {\n return async.eachOf(arr, _withoutIndex(iterator), callback);\n };\n\n async.forEachSeries =\n async.eachSeries = function (arr, iterator, callback) {\n return async.eachOfSeries(arr, _withoutIndex(iterator), callback);\n };\n\n\n async.forEachLimit =\n async.eachLimit = function (arr, limit, iterator, callback) {\n return _eachOfLimit(limit)(arr, _withoutIndex(iterator), callback);\n };\n\n async.forEachOf =\n async.eachOf = function (object, iterator, callback) {\n callback = _once(callback || noop);\n object = object || [];\n\n var iter = _keyIterator(object);\n var key, completed = 0;\n\n while ((key = iter()) != null) {\n completed += 1;\n iterator(object[key], key, only_once(done));\n }\n\n if (completed === 0) callback(null);\n\n function done(err) {\n completed--;\n if (err) {\n callback(err);\n }\n // Check key is null in case iterator isn't exhausted\n // and done resolved synchronously.\n else if (key === null && completed <= 0) {\n callback(null);\n }\n }\n };\n\n async.forEachOfSeries =\n async.eachOfSeries = function (obj, iterator, callback) {\n callback = _once(callback || noop);\n obj = obj || [];\n var nextKey = _keyIterator(obj);\n var key = nextKey();\n function iterate() {\n var sync = true;\n if (key === null) {\n return callback(null);\n }\n iterator(obj[key], key, only_once(function (err) {\n if (err) {\n callback(err);\n }\n else {\n key = nextKey();\n if (key === null) {\n return callback(null);\n } else {\n if (sync) {\n async.setImmediate(iterate);\n } else {\n iterate();\n }\n }\n }\n }));\n sync = false;\n }\n iterate();\n };\n\n\n\n async.forEachOfLimit =\n async.eachOfLimit = function (obj, limit, iterator, callback) {\n _eachOfLimit(limit)(obj, iterator, callback);\n };\n\n function _eachOfLimit(limit) {\n\n return function (obj, iterator, callback) {\n callback = _once(callback || noop);\n obj = obj || [];\n var nextKey = _keyIterator(obj);\n if (limit <= 0) {\n return callback(null);\n }\n var done = false;\n var running = 0;\n var errored = false;\n\n (function replenish () {\n if (done && running <= 0) {\n return callback(null);\n }\n\n while (running < limit && !errored) {\n var key = nextKey();\n if (key === null) {\n done = true;\n if (running <= 0) {\n callback(null);\n }\n return;\n }\n running += 1;\n iterator(obj[key], key, only_once(function (err) {\n running -= 1;\n if (err) {\n callback(err);\n errored = true;\n }\n else {\n replenish();\n }\n }));\n }\n })();\n };\n }\n\n\n function doParallel(fn) {\n return function (obj, iterator, callback) {\n return fn(async.eachOf, obj, iterator, callback);\n };\n }\n function doParallelLimit(fn) {\n return function (obj, limit, iterator, callback) {\n return fn(_eachOfLimit(limit), obj, iterator, callback);\n };\n }\n function doSeries(fn) {\n return function (obj, iterator, callback) {\n return fn(async.eachOfSeries, obj, iterator, callback);\n };\n }\n\n function _asyncMap(eachfn, arr, iterator, callback) {\n callback = _once(callback || noop);\n arr = arr || [];\n var results = _isArrayLike(arr) ? [] : {};\n eachfn(arr, function (value, index, callback) {\n iterator(value, function (err, v) {\n results[index] = v;\n callback(err);\n });\n }, function (err) {\n callback(err, results);\n });\n }\n\n async.map = doParallel(_asyncMap);\n async.mapSeries = doSeries(_asyncMap);\n async.mapLimit = doParallelLimit(_asyncMap);\n\n // reduce only has a series version, as doing reduce in parallel won't\n // work in many situations.\n async.inject =\n async.foldl =\n async.reduce = function (arr, memo, iterator, callback) {\n async.eachOfSeries(arr, function (x, i, callback) {\n iterator(memo, x, function (err, v) {\n memo = v;\n callback(err);\n });\n }, function (err) {\n callback(err, memo);\n });\n };\n\n async.foldr =\n async.reduceRight = function (arr, memo, iterator, callback) {\n var reversed = _map(arr, identity).reverse();\n async.reduce(reversed, memo, iterator, callback);\n };\n\n async.transform = function (arr, memo, iterator, callback) {\n if (arguments.length === 3) {\n callback = iterator;\n iterator = memo;\n memo = _isArray(arr) ? [] : {};\n }\n\n async.eachOf(arr, function(v, k, cb) {\n iterator(memo, v, k, cb);\n }, function(err) {\n callback(err, memo);\n });\n };\n\n function _filter(eachfn, arr, iterator, callback) {\n var results = [];\n eachfn(arr, function (x, index, callback) {\n iterator(x, function (v) {\n if (v) {\n results.push({index: index, value: x});\n }\n callback();\n });\n }, function () {\n callback(_map(results.sort(function (a, b) {\n return a.index - b.index;\n }), function (x) {\n return x.value;\n }));\n });\n }\n\n async.select =\n async.filter = doParallel(_filter);\n\n async.selectLimit =\n async.filterLimit = doParallelLimit(_filter);\n\n async.selectSeries =\n async.filterSeries = doSeries(_filter);\n\n function _reject(eachfn, arr, iterator, callback) {\n _filter(eachfn, arr, function(value, cb) {\n iterator(value, function(v) {\n cb(!v);\n });\n }, callback);\n }\n async.reject = doParallel(_reject);\n async.rejectLimit = doParallelLimit(_reject);\n async.rejectSeries = doSeries(_reject);\n\n function _createTester(eachfn, check, getResult) {\n return function(arr, limit, iterator, cb) {\n function done() {\n if (cb) cb(getResult(false, void 0));\n }\n function iteratee(x, _, callback) {\n if (!cb) return callback();\n iterator(x, function (v) {\n if (cb && check(v)) {\n cb(getResult(true, x));\n cb = iterator = false;\n }\n callback();\n });\n }\n if (arguments.length > 3) {\n eachfn(arr, limit, iteratee, done);\n } else {\n cb = iterator;\n iterator = limit;\n eachfn(arr, iteratee, done);\n }\n };\n }\n\n async.any =\n async.some = _createTester(async.eachOf, toBool, identity);\n\n async.someLimit = _createTester(async.eachOfLimit, toBool, identity);\n\n async.all =\n async.every = _createTester(async.eachOf, notId, notId);\n\n async.everyLimit = _createTester(async.eachOfLimit, notId, notId);\n\n function _findGetResult(v, x) {\n return x;\n }\n async.detect = _createTester(async.eachOf, identity, _findGetResult);\n async.detectSeries = _createTester(async.eachOfSeries, identity, _findGetResult);\n async.detectLimit = _createTester(async.eachOfLimit, identity, _findGetResult);\n\n async.sortBy = function (arr, iterator, callback) {\n async.map(arr, function (x, callback) {\n iterator(x, function (err, criteria) {\n if (err) {\n callback(err);\n }\n else {\n callback(null, {value: x, criteria: criteria});\n }\n });\n }, function (err, results) {\n if (err) {\n return callback(err);\n }\n else {\n callback(null, _map(results.sort(comparator), function (x) {\n return x.value;\n }));\n }\n\n });\n\n function comparator(left, right) {\n var a = left.criteria, b = right.criteria;\n return a < b ? -1 : a > b ? 1 : 0;\n }\n };\n\n async.auto = function (tasks, concurrency, callback) {\n if (typeof arguments[1] === 'function') {\n // concurrency is optional, shift the args.\n callback = concurrency;\n concurrency = null;\n }\n callback = _once(callback || noop);\n var keys = _keys(tasks);\n var remainingTasks = keys.length;\n if (!remainingTasks) {\n return callback(null);\n }\n if (!concurrency) {\n concurrency = remainingTasks;\n }\n\n var results = {};\n var runningTasks = 0;\n\n var hasError = false;\n\n var listeners = [];\n function addListener(fn) {\n listeners.unshift(fn);\n }\n function removeListener(fn) {\n var idx = _indexOf(listeners, fn);\n if (idx >= 0) listeners.splice(idx, 1);\n }\n function taskComplete() {\n remainingTasks--;\n _arrayEach(listeners.slice(0), function (fn) {\n fn();\n });\n }\n\n addListener(function () {\n if (!remainingTasks) {\n callback(null, results);\n }\n });\n\n _arrayEach(keys, function (k) {\n if (hasError) return;\n var task = _isArray(tasks[k]) ? tasks[k]: [tasks[k]];\n var taskCallback = _restParam(function(err, args) {\n runningTasks--;\n if (args.length <= 1) {\n args = args[0];\n }\n if (err) {\n var safeResults = {};\n _forEachOf(results, function(val, rkey) {\n safeResults[rkey] = val;\n });\n safeResults[k] = args;\n hasError = true;\n\n callback(err, safeResults);\n }\n else {\n results[k] = args;\n async.setImmediate(taskComplete);\n }\n });\n var requires = task.slice(0, task.length - 1);\n // prevent dead-locks\n var len = requires.length;\n var dep;\n while (len--) {\n if (!(dep = tasks[requires[len]])) {\n throw new Error('Has nonexistent dependency in ' + requires.join(', '));\n }\n if (_isArray(dep) && _indexOf(dep, k) >= 0) {\n throw new Error('Has cyclic dependencies');\n }\n }\n function ready() {\n return runningTasks < concurrency && _reduce(requires, function (a, x) {\n return (a && results.hasOwnProperty(x));\n }, true) && !results.hasOwnProperty(k);\n }\n if (ready()) {\n runningTasks++;\n task[task.length - 1](taskCallback, results);\n }\n else {\n addListener(listener);\n }\n function listener() {\n if (ready()) {\n runningTasks++;\n removeListener(listener);\n task[task.length - 1](taskCallback, results);\n }\n }\n });\n };\n\n\n\n async.retry = function(times, task, callback) {\n var DEFAULT_TIMES = 5;\n var DEFAULT_INTERVAL = 0;\n\n var attempts = [];\n\n var opts = {\n times: DEFAULT_TIMES,\n interval: DEFAULT_INTERVAL\n };\n\n function parseTimes(acc, t){\n if(typeof t === 'number'){\n acc.times = parseInt(t, 10) || DEFAULT_TIMES;\n } else if(typeof t === 'object'){\n acc.times = parseInt(t.times, 10) || DEFAULT_TIMES;\n acc.interval = parseInt(t.interval, 10) || DEFAULT_INTERVAL;\n } else {\n throw new Error('Unsupported argument type for \\'times\\': ' + typeof t);\n }\n }\n\n var length = arguments.length;\n if (length < 1 || length > 3) {\n throw new Error('Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)');\n } else if (length <= 2 && typeof times === 'function') {\n callback = task;\n task = times;\n }\n if (typeof times !== 'function') {\n parseTimes(opts, times);\n }\n opts.callback = callback;\n opts.task = task;\n\n function wrappedTask(wrappedCallback, wrappedResults) {\n function retryAttempt(task, finalAttempt) {\n return function(seriesCallback) {\n task(function(err, result){\n seriesCallback(!err || finalAttempt, {err: err, result: result});\n }, wrappedResults);\n };\n }\n\n function retryInterval(interval){\n return function(seriesCallback){\n setTimeout(function(){\n seriesCallback(null);\n }, interval);\n };\n }\n\n while (opts.times) {\n\n var finalAttempt = !(opts.times-=1);\n attempts.push(retryAttempt(opts.task, finalAttempt));\n if(!finalAttempt && opts.interval > 0){\n attempts.push(retryInterval(opts.interval));\n }\n }\n\n async.series(attempts, function(done, data){\n data = data[data.length - 1];\n (wrappedCallback || opts.callback)(data.err, data.result);\n });\n }\n\n // If a callback is passed, run this as a controll flow\n return opts.callback ? wrappedTask() : wrappedTask;\n };\n\n async.waterfall = function (tasks, callback) {\n callback = _once(callback || noop);\n if (!_isArray(tasks)) {\n var err = new Error('First argument to waterfall must be an array of functions');\n return callback(err);\n }\n if (!tasks.length) {\n return callback();\n }\n function wrapIterator(iterator) {\n return _restParam(function (err, args) {\n if (err) {\n callback.apply(null, [err].concat(args));\n }\n else {\n var next = iterator.next();\n if (next) {\n args.push(wrapIterator(next));\n }\n else {\n args.push(callback);\n }\n ensureAsync(iterator).apply(null, args);\n }\n });\n }\n wrapIterator(async.iterator(tasks))();\n };\n\n function _parallel(eachfn, tasks, callback) {\n callback = callback || noop;\n var results = _isArrayLike(tasks) ? [] : {};\n\n eachfn(tasks, function (task, key, callback) {\n task(_restParam(function (err, args) {\n if (args.length <= 1) {\n args = args[0];\n }\n results[key] = args;\n callback(err);\n }));\n }, function (err) {\n callback(err, results);\n });\n }\n\n async.parallel = function (tasks, callback) {\n _parallel(async.eachOf, tasks, callback);\n };\n\n async.parallelLimit = function(tasks, limit, callback) {\n _parallel(_eachOfLimit(limit), tasks, callback);\n };\n\n async.series = function(tasks, callback) {\n _parallel(async.eachOfSeries, tasks, callback);\n };\n\n async.iterator = function (tasks) {\n function makeCallback(index) {\n function fn() {\n if (tasks.length) {\n tasks[index].apply(null, arguments);\n }\n return fn.next();\n }\n fn.next = function () {\n return (index < tasks.length - 1) ? makeCallback(index + 1): null;\n };\n return fn;\n }\n return makeCallback(0);\n };\n\n async.apply = _restParam(function (fn, args) {\n return _restParam(function (callArgs) {\n return fn.apply(\n null, args.concat(callArgs)\n );\n });\n });\n\n function _concat(eachfn, arr, fn, callback) {\n var result = [];\n eachfn(arr, function (x, index, cb) {\n fn(x, function (err, y) {\n result = result.concat(y || []);\n cb(err);\n });\n }, function (err) {\n callback(err, result);\n });\n }\n async.concat = doParallel(_concat);\n async.concatSeries = doSeries(_concat);\n\n async.whilst = function (test, iterator, callback) {\n callback = callback || noop;\n if (test()) {\n var next = _restParam(function(err, args) {\n if (err) {\n callback(err);\n } else if (test.apply(this, args)) {\n iterator(next);\n } else {\n callback.apply(null, [null].concat(args));\n }\n });\n iterator(next);\n } else {\n callback(null);\n }\n };\n\n async.doWhilst = function (iterator, test, callback) {\n var calls = 0;\n return async.whilst(function() {\n return ++calls <= 1 || test.apply(this, arguments);\n }, iterator, callback);\n };\n\n async.until = function (test, iterator, callback) {\n return async.whilst(function() {\n return !test.apply(this, arguments);\n }, iterator, callback);\n };\n\n async.doUntil = function (iterator, test, callback) {\n return async.doWhilst(iterator, function() {\n return !test.apply(this, arguments);\n }, callback);\n };\n\n async.during = function (test, iterator, callback) {\n callback = callback || noop;\n\n var next = _restParam(function(err, args) {\n if (err) {\n callback(err);\n } else {\n args.push(check);\n test.apply(this, args);\n }\n });\n\n var check = function(err, truth) {\n if (err) {\n callback(err);\n } else if (truth) {\n iterator(next);\n } else {\n callback(null);\n }\n };\n\n test(check);\n };\n\n async.doDuring = function (iterator, test, callback) {\n var calls = 0;\n async.during(function(next) {\n if (calls++ < 1) {\n next(null, true);\n } else {\n test.apply(this, arguments);\n }\n }, iterator, callback);\n };\n\n function _queue(worker, concurrency, payload) {\n if (concurrency == null) {\n concurrency = 1;\n }\n else if(concurrency === 0) {\n throw new Error('Concurrency must not be zero');\n }\n function _insert(q, data, pos, callback) {\n if (callback != null && typeof callback !== \"function\") {\n throw new Error(\"task callback must be a function\");\n }\n q.started = true;\n if (!_isArray(data)) {\n data = [data];\n }\n if(data.length === 0 && q.idle()) {\n // call drain immediately if there are no tasks\n return async.setImmediate(function() {\n q.drain();\n });\n }\n _arrayEach(data, function(task) {\n var item = {\n data: task,\n callback: callback || noop\n };\n\n if (pos) {\n q.tasks.unshift(item);\n } else {\n q.tasks.push(item);\n }\n\n if (q.tasks.length === q.concurrency) {\n q.saturated();\n }\n });\n async.setImmediate(q.process);\n }\n function _next(q, tasks) {\n return function(){\n workers -= 1;\n\n var removed = false;\n var args = arguments;\n _arrayEach(tasks, function (task) {\n _arrayEach(workersList, function (worker, index) {\n if (worker === task && !removed) {\n workersList.splice(index, 1);\n removed = true;\n }\n });\n\n task.callback.apply(task, args);\n });\n if (q.tasks.length + workers === 0) {\n q.drain();\n }\n q.process();\n };\n }\n\n var workers = 0;\n var workersList = [];\n var q = {\n tasks: [],\n concurrency: concurrency,\n payload: payload,\n saturated: noop,\n empty: noop,\n drain: noop,\n started: false,\n paused: false,\n push: function (data, callback) {\n _insert(q, data, false, callback);\n },\n kill: function () {\n q.drain = noop;\n q.tasks = [];\n },\n unshift: function (data, callback) {\n _insert(q, data, true, callback);\n },\n process: function () {\n while(!q.paused && workers < q.concurrency && q.tasks.length){\n\n var tasks = q.payload ?\n q.tasks.splice(0, q.payload) :\n q.tasks.splice(0, q.tasks.length);\n\n var data = _map(tasks, function (task) {\n return task.data;\n });\n\n if (q.tasks.length === 0) {\n q.empty();\n }\n workers += 1;\n workersList.push(tasks[0]);\n var cb = only_once(_next(q, tasks));\n worker(data, cb);\n }\n },\n length: function () {\n return q.tasks.length;\n },\n running: function () {\n return workers;\n },\n workersList: function () {\n return workersList;\n },\n idle: function() {\n return q.tasks.length + workers === 0;\n },\n pause: function () {\n q.paused = true;\n },\n resume: function () {\n if (q.paused === false) { return; }\n q.paused = false;\n var resumeCount = Math.min(q.concurrency, q.tasks.length);\n // Need to call q.process once per concurrent\n // worker to preserve full concurrency after pause\n for (var w = 1; w <= resumeCount; w++) {\n async.setImmediate(q.process);\n }\n }\n };\n return q;\n }\n\n async.queue = function (worker, concurrency) {\n var q = _queue(function (items, cb) {\n worker(items[0], cb);\n }, concurrency, 1);\n\n return q;\n };\n\n async.priorityQueue = function (worker, concurrency) {\n\n function _compareTasks(a, b){\n return a.priority - b.priority;\n }\n\n function _binarySearch(sequence, item, compare) {\n var beg = -1,\n end = sequence.length - 1;\n while (beg < end) {\n var mid = beg + ((end - beg + 1) >>> 1);\n if (compare(item, sequence[mid]) >= 0) {\n beg = mid;\n } else {\n end = mid - 1;\n }\n }\n return beg;\n }\n\n function _insert(q, data, priority, callback) {\n if (callback != null && typeof callback !== \"function\") {\n throw new Error(\"task callback must be a function\");\n }\n q.started = true;\n if (!_isArray(data)) {\n data = [data];\n }\n if(data.length === 0) {\n // call drain immediately if there are no tasks\n return async.setImmediate(function() {\n q.drain();\n });\n }\n _arrayEach(data, function(task) {\n var item = {\n data: task,\n priority: priority,\n callback: typeof callback === 'function' ? callback : noop\n };\n\n q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item);\n\n if (q.tasks.length === q.concurrency) {\n q.saturated();\n }\n async.setImmediate(q.process);\n });\n }\n\n // Start with a normal queue\n var q = async.queue(worker, concurrency);\n\n // Override push to accept second parameter representing priority\n q.push = function (data, priority, callback) {\n _insert(q, data, priority, callback);\n };\n\n // Remove unshift function\n delete q.unshift;\n\n return q;\n };\n\n async.cargo = function (worker, payload) {\n return _queue(worker, 1, payload);\n };\n\n function _console_fn(name) {\n return _restParam(function (fn, args) {\n fn.apply(null, args.concat([_restParam(function (err, args) {\n if (typeof console === 'object') {\n if (err) {\n if (console.error) {\n console.error(err);\n }\n }\n else if (console[name]) {\n _arrayEach(args, function (x) {\n console[name](x);\n });\n }\n }\n })]));\n });\n }\n async.log = _console_fn('log');\n async.dir = _console_fn('dir');\n /*async.info = _console_fn('info');\n async.warn = _console_fn('warn');\n async.error = _console_fn('error');*/\n\n async.memoize = function (fn, hasher) {\n var memo = {};\n var queues = {};\n var has = Object.prototype.hasOwnProperty;\n hasher = hasher || identity;\n var memoized = _restParam(function memoized(args) {\n var callback = args.pop();\n var key = hasher.apply(null, args);\n if (has.call(memo, key)) { \n async.setImmediate(function () {\n callback.apply(null, memo[key]);\n });\n }\n else if (has.call(queues, key)) {\n queues[key].push(callback);\n }\n else {\n queues[key] = [callback];\n fn.apply(null, args.concat([_restParam(function (args) {\n memo[key] = args;\n var q = queues[key];\n delete queues[key];\n for (var i = 0, l = q.length; i < l; i++) {\n q[i].apply(null, args);\n }\n })]));\n }\n });\n memoized.memo = memo;\n memoized.unmemoized = fn;\n return memoized;\n };\n\n async.unmemoize = function (fn) {\n return function () {\n return (fn.unmemoized || fn).apply(null, arguments);\n };\n };\n\n function _times(mapper) {\n return function (count, iterator, callback) {\n mapper(_range(count), iterator, callback);\n };\n }\n\n async.times = _times(async.map);\n async.timesSeries = _times(async.mapSeries);\n async.timesLimit = function (count, limit, iterator, callback) {\n return async.mapLimit(_range(count), limit, iterator, callback);\n };\n\n async.seq = function (/* functions... */) {\n var fns = arguments;\n return _restParam(function (args) {\n var that = this;\n\n var callback = args[args.length - 1];\n if (typeof callback == 'function') {\n args.pop();\n } else {\n callback = noop;\n }\n\n async.reduce(fns, args, function (newargs, fn, cb) {\n fn.apply(that, newargs.concat([_restParam(function (err, nextargs) {\n cb(err, nextargs);\n })]));\n },\n function (err, results) {\n callback.apply(that, [err].concat(results));\n });\n });\n };\n\n async.compose = function (/* functions... */) {\n return async.seq.apply(null, Array.prototype.reverse.call(arguments));\n };\n\n\n function _applyEach(eachfn) {\n return _restParam(function(fns, args) {\n var go = _restParam(function(args) {\n var that = this;\n var callback = args.pop();\n return eachfn(fns, function (fn, _, cb) {\n fn.apply(that, args.concat([cb]));\n },\n callback);\n });\n if (args.length) {\n return go.apply(this, args);\n }\n else {\n return go;\n }\n });\n }\n\n async.applyEach = _applyEach(async.eachOf);\n async.applyEachSeries = _applyEach(async.eachOfSeries);\n\n\n async.forever = function (fn, callback) {\n var done = only_once(callback || noop);\n var task = ensureAsync(fn);\n function next(err) {\n if (err) {\n return done(err);\n }\n task(next);\n }\n next();\n };\n\n function ensureAsync(fn) {\n return _restParam(function (args) {\n var callback = args.pop();\n args.push(function () {\n var innerArgs = arguments;\n if (sync) {\n async.setImmediate(function () {\n callback.apply(null, innerArgs);\n });\n } else {\n callback.apply(null, innerArgs);\n }\n });\n var sync = true;\n fn.apply(this, args);\n sync = false;\n });\n }\n\n async.ensureAsync = ensureAsync;\n\n async.constant = _restParam(function(values) {\n var args = [null].concat(values);\n return function (callback) {\n return callback.apply(this, args);\n };\n });\n\n async.wrapSync =\n async.asyncify = function asyncify(func) {\n return _restParam(function (args) {\n var callback = args.pop();\n var result;\n try {\n result = func.apply(this, args);\n } catch (e) {\n return callback(e);\n }\n // if result is Promise object\n if (_isObject(result) && typeof result.then === \"function\") {\n result.then(function(value) {\n callback(null, value);\n })[\"catch\"](function(err) {\n callback(err.message ? err : new Error(err));\n });\n } else {\n callback(null, result);\n }\n });\n };\n\n // Node.js\n if (typeof module === 'object' && module.exports) {\n module.exports = async;\n }\n // AMD / RequireJS\n else if (typeof define === 'function' && define.amd) {\n define([], function () {\n return async;\n });\n }\n // included directly via