diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index 1e0f270..4c5034f 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -7,8 +7,7 @@ * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded * otherwise black rectangles will be drawn instead. * - * A RenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: * * ```js * let renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); @@ -23,15 +22,16 @@ * renderer.render(sprite, renderTexture); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * - * renderer.render(doc, renderTexture); // Renders to center of renderTexture + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index 1e0f270..4c5034f 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -7,8 +7,7 @@ * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded * otherwise black rectangles will be drawn instead. * - * A RenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: * * ```js * let renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); @@ -23,15 +22,16 @@ * renderer.render(sprite, renderTexture); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * - * renderer.render(doc, renderTexture); // Renders to center of renderTexture + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/test/core/Application.js b/test/core/Application.js new file mode 100644 index 0000000..aa726b0 --- /dev/null +++ b/test/core/Application.js @@ -0,0 +1,20 @@ +'use strict'; + +describe('PIXI.Application', function () +{ + it('should generate application', function (done) + { + expect(PIXI.Application).to.be.a.function; + const app = new PIXI.Application(); + + expect(app.stage).to.be.instanceof(PIXI.Container); + expect(app.ticker).to.be.instanceof(PIXI.ticker.Ticker); + expect(app.renderer).to.be.ok; + + app.ticker.addOnce(() => + { + app.destroy(); + done(); + }); + }); +}); diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index 1e0f270..4c5034f 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -7,8 +7,7 @@ * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded * otherwise black rectangles will be drawn instead. * - * A RenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: * * ```js * let renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); @@ -23,15 +22,16 @@ * renderer.render(sprite, renderTexture); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * - * renderer.render(doc, renderTexture); // Renders to center of renderTexture + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/test/core/Application.js b/test/core/Application.js new file mode 100644 index 0000000..aa726b0 --- /dev/null +++ b/test/core/Application.js @@ -0,0 +1,20 @@ +'use strict'; + +describe('PIXI.Application', function () +{ + it('should generate application', function (done) + { + expect(PIXI.Application).to.be.a.function; + const app = new PIXI.Application(); + + expect(app.stage).to.be.instanceof(PIXI.Container); + expect(app.ticker).to.be.instanceof(PIXI.ticker.Ticker); + expect(app.renderer).to.be.ok; + + app.ticker.addOnce(() => + { + app.destroy(); + done(); + }); + }); +}); diff --git a/test/core/BaseTexture.js b/test/core/BaseTexture.js index a5fd99a..8b93478 100644 --- a/test/core/BaseTexture.js +++ b/test/core/BaseTexture.js @@ -1,10 +1,10 @@ 'use strict'; -describe('BaseTexture', () => +describe('BaseTexture', function () { - describe('updateImageType', () => + describe('updateImageType', function () { - it('should allow no extension', () => + it('should allow no extension', function () { const baseTexture = new PIXI.BaseTexture(); diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index 1e0f270..4c5034f 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -7,8 +7,7 @@ * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded * otherwise black rectangles will be drawn instead. * - * A RenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: * * ```js * let renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); @@ -23,15 +22,16 @@ * renderer.render(sprite, renderTexture); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * - * renderer.render(doc, renderTexture); // Renders to center of renderTexture + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/test/core/Application.js b/test/core/Application.js new file mode 100644 index 0000000..aa726b0 --- /dev/null +++ b/test/core/Application.js @@ -0,0 +1,20 @@ +'use strict'; + +describe('PIXI.Application', function () +{ + it('should generate application', function (done) + { + expect(PIXI.Application).to.be.a.function; + const app = new PIXI.Application(); + + expect(app.stage).to.be.instanceof(PIXI.Container); + expect(app.ticker).to.be.instanceof(PIXI.ticker.Ticker); + expect(app.renderer).to.be.ok; + + app.ticker.addOnce(() => + { + app.destroy(); + done(); + }); + }); +}); diff --git a/test/core/BaseTexture.js b/test/core/BaseTexture.js index a5fd99a..8b93478 100644 --- a/test/core/BaseTexture.js +++ b/test/core/BaseTexture.js @@ -1,10 +1,10 @@ 'use strict'; -describe('BaseTexture', () => +describe('BaseTexture', function () { - describe('updateImageType', () => + describe('updateImageType', function () { - it('should allow no extension', () => + it('should allow no extension', function () { const baseTexture = new PIXI.BaseTexture(); diff --git a/test/core/Container.js b/test/core/Container.js index a88a2e3..8a10b40 100644 --- a/test/core/Container.js +++ b/test/core/Container.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Container', () => +describe('PIXI.Container', function () { - describe('parent', () => + describe('parent', function () { - it('should be present when adding children to Container', () => + it('should be present when adding children to Container', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -16,9 +16,9 @@ }); }); - describe('events', () => + describe('events', function () { - it('should trigger "added" and "removed" events on its children', () => + it('should trigger "added" and "removed" events on its children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -48,9 +48,9 @@ }); }); - describe('addChild', () => + describe('addChild', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -59,7 +59,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChild(child); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -72,9 +72,9 @@ }); }); - describe('removeChildAt', () => + describe('removeChildAt', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -82,7 +82,7 @@ assertRemovedFromParent(parent, null, child, () => { parent.removeChildAt(0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -97,9 +97,9 @@ }); }); - describe('addChildAt', () => + describe('addChildAt', function () { - it('should allow placements at start', () => + it('should allow placements at start', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -111,7 +111,7 @@ expect(container.children[0]).to.be.equals(child); }); - it('should allow placements at end', () => + it('should allow placements at end', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -123,7 +123,7 @@ expect(container.children[1]).to.be.equals(child); }); - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -134,7 +134,7 @@ expect(() => container.addChildAt(child, 2)).to.throw('The index 2 supplied is out of bounds 1'); }); - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -143,7 +143,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChildAt(child, 0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -159,9 +159,9 @@ }); }); - describe('removeChild', () => + describe('removeChild', function () { - it('should ignore non-children', () => + it('should ignore non-children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -173,7 +173,7 @@ expect(container.children.length).to.be.equals(1); }); - it('should remove all children supplied', () => + it('should remove all children supplied', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -188,7 +188,7 @@ expect(container.children.length).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -204,9 +204,9 @@ }); }); - describe('getChildIndex', () => + describe('getChildIndex', function () { - it('should return the correct index', () => + it('should return the correct index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -216,7 +216,7 @@ expect(container.getChildIndex(child)).to.be.equals(1); }); - it('should throw when child does not exist', () => + it('should throw when child does not exist', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -226,9 +226,9 @@ }); }); - describe('getChildAt', () => + describe('getChildAt', function () { - it('should throw when out-of-bounds', () => + it('should throw when out-of-bounds', function () { const container = new PIXI.Container(); @@ -237,9 +237,9 @@ }); }); - describe('setChildIndex', () => + describe('setChildIndex', function () { - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -250,7 +250,7 @@ expect(() => container.setChildIndex(child, 1)).to.throw('The supplied index is out of bounds'); }); - it('should throw when child does not belong', () => + it('should throw when child does not belong', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -261,7 +261,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should set index', () => + it('should set index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -279,7 +279,7 @@ expect(container.children.indexOf(child)).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -295,9 +295,9 @@ }); }); - describe('swapChildren', () => + describe('swapChildren', function () { - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -317,7 +317,7 @@ expect(spy).to.have.been.calledWith(0); }); - it('should not call onChildrenChange if supplied children are equal', () => + it('should not call onChildrenChange if supplied children are equal', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -331,7 +331,7 @@ expect(spy).to.not.have.been.called; }); - it('should throw if children do not belong', () => + it('should throw if children do not belong', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -344,7 +344,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should result in swapped child positions', () => + it('should result in swapped child positions', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -362,9 +362,9 @@ }); }); - describe('render', () => + describe('render', function () { - it('should not render when object not visible', () => + it('should not render when object not visible', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -379,7 +379,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when alpha is zero', () => + it('should not render when alpha is zero', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -394,7 +394,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when object not renderable', () => + it('should not render when object not renderable', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -409,7 +409,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should render children', () => + it('should render children', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -426,9 +426,9 @@ }); }); - describe('removeChildren', () => + describe('removeChildren', function () { - it('should remove all children when no arguments supplied', () => + it('should remove all children when no arguments supplied', function () { const container = new PIXI.Container(); let removed = []; @@ -443,7 +443,7 @@ expect(removed.length).to.be.equals(3); }); - it('should return empty array if no children', () => + it('should return empty array if no children', function () { const container = new PIXI.Container(); const removed = container.removeChildren(); @@ -451,7 +451,7 @@ expect(removed.length).to.be.equals(0); }); - it('should handle a range greater than length', () => + it('should handle a range greater than length', function () { const container = new PIXI.Container(); let removed = []; @@ -462,7 +462,7 @@ expect(removed.length).to.be.equals(1); }); - it('should throw outside acceptable range', () => + it('should throw outside acceptable range', function () { const container = new PIXI.Container(); @@ -477,9 +477,9 @@ }); }); - describe('destroy', () => + describe('destroy', function () { - it('should not destroy children by default', () => + it('should not destroy children by default', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -491,7 +491,7 @@ expect(child.transform).to.not.be.null; }); - it('should allow children destroy', () => + it('should allow children destroy', function () { let container = new PIXI.Container(); let child = new PIXI.DisplayObject(); @@ -515,9 +515,9 @@ }); }); - describe('width', () => + describe('width', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -529,7 +529,7 @@ expect(container.width).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -543,7 +543,7 @@ expect(container.scale.x).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); @@ -555,9 +555,9 @@ }); }); - describe('height', () => + describe('height', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -569,7 +569,7 @@ expect(container.height).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -583,7 +583,7 @@ expect(container.scale.y).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index 1e0f270..4c5034f 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -7,8 +7,7 @@ * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded * otherwise black rectangles will be drawn instead. * - * A RenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: * * ```js * let renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); @@ -23,15 +22,16 @@ * renderer.render(sprite, renderTexture); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * - * renderer.render(doc, renderTexture); // Renders to center of renderTexture + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/test/core/Application.js b/test/core/Application.js new file mode 100644 index 0000000..aa726b0 --- /dev/null +++ b/test/core/Application.js @@ -0,0 +1,20 @@ +'use strict'; + +describe('PIXI.Application', function () +{ + it('should generate application', function (done) + { + expect(PIXI.Application).to.be.a.function; + const app = new PIXI.Application(); + + expect(app.stage).to.be.instanceof(PIXI.Container); + expect(app.ticker).to.be.instanceof(PIXI.ticker.Ticker); + expect(app.renderer).to.be.ok; + + app.ticker.addOnce(() => + { + app.destroy(); + done(); + }); + }); +}); diff --git a/test/core/BaseTexture.js b/test/core/BaseTexture.js index a5fd99a..8b93478 100644 --- a/test/core/BaseTexture.js +++ b/test/core/BaseTexture.js @@ -1,10 +1,10 @@ 'use strict'; -describe('BaseTexture', () => +describe('BaseTexture', function () { - describe('updateImageType', () => + describe('updateImageType', function () { - it('should allow no extension', () => + it('should allow no extension', function () { const baseTexture = new PIXI.BaseTexture(); diff --git a/test/core/Container.js b/test/core/Container.js index a88a2e3..8a10b40 100644 --- a/test/core/Container.js +++ b/test/core/Container.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Container', () => +describe('PIXI.Container', function () { - describe('parent', () => + describe('parent', function () { - it('should be present when adding children to Container', () => + it('should be present when adding children to Container', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -16,9 +16,9 @@ }); }); - describe('events', () => + describe('events', function () { - it('should trigger "added" and "removed" events on its children', () => + it('should trigger "added" and "removed" events on its children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -48,9 +48,9 @@ }); }); - describe('addChild', () => + describe('addChild', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -59,7 +59,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChild(child); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -72,9 +72,9 @@ }); }); - describe('removeChildAt', () => + describe('removeChildAt', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -82,7 +82,7 @@ assertRemovedFromParent(parent, null, child, () => { parent.removeChildAt(0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -97,9 +97,9 @@ }); }); - describe('addChildAt', () => + describe('addChildAt', function () { - it('should allow placements at start', () => + it('should allow placements at start', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -111,7 +111,7 @@ expect(container.children[0]).to.be.equals(child); }); - it('should allow placements at end', () => + it('should allow placements at end', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -123,7 +123,7 @@ expect(container.children[1]).to.be.equals(child); }); - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -134,7 +134,7 @@ expect(() => container.addChildAt(child, 2)).to.throw('The index 2 supplied is out of bounds 1'); }); - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -143,7 +143,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChildAt(child, 0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -159,9 +159,9 @@ }); }); - describe('removeChild', () => + describe('removeChild', function () { - it('should ignore non-children', () => + it('should ignore non-children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -173,7 +173,7 @@ expect(container.children.length).to.be.equals(1); }); - it('should remove all children supplied', () => + it('should remove all children supplied', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -188,7 +188,7 @@ expect(container.children.length).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -204,9 +204,9 @@ }); }); - describe('getChildIndex', () => + describe('getChildIndex', function () { - it('should return the correct index', () => + it('should return the correct index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -216,7 +216,7 @@ expect(container.getChildIndex(child)).to.be.equals(1); }); - it('should throw when child does not exist', () => + it('should throw when child does not exist', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -226,9 +226,9 @@ }); }); - describe('getChildAt', () => + describe('getChildAt', function () { - it('should throw when out-of-bounds', () => + it('should throw when out-of-bounds', function () { const container = new PIXI.Container(); @@ -237,9 +237,9 @@ }); }); - describe('setChildIndex', () => + describe('setChildIndex', function () { - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -250,7 +250,7 @@ expect(() => container.setChildIndex(child, 1)).to.throw('The supplied index is out of bounds'); }); - it('should throw when child does not belong', () => + it('should throw when child does not belong', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -261,7 +261,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should set index', () => + it('should set index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -279,7 +279,7 @@ expect(container.children.indexOf(child)).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -295,9 +295,9 @@ }); }); - describe('swapChildren', () => + describe('swapChildren', function () { - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -317,7 +317,7 @@ expect(spy).to.have.been.calledWith(0); }); - it('should not call onChildrenChange if supplied children are equal', () => + it('should not call onChildrenChange if supplied children are equal', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -331,7 +331,7 @@ expect(spy).to.not.have.been.called; }); - it('should throw if children do not belong', () => + it('should throw if children do not belong', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -344,7 +344,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should result in swapped child positions', () => + it('should result in swapped child positions', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -362,9 +362,9 @@ }); }); - describe('render', () => + describe('render', function () { - it('should not render when object not visible', () => + it('should not render when object not visible', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -379,7 +379,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when alpha is zero', () => + it('should not render when alpha is zero', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -394,7 +394,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when object not renderable', () => + it('should not render when object not renderable', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -409,7 +409,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should render children', () => + it('should render children', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -426,9 +426,9 @@ }); }); - describe('removeChildren', () => + describe('removeChildren', function () { - it('should remove all children when no arguments supplied', () => + it('should remove all children when no arguments supplied', function () { const container = new PIXI.Container(); let removed = []; @@ -443,7 +443,7 @@ expect(removed.length).to.be.equals(3); }); - it('should return empty array if no children', () => + it('should return empty array if no children', function () { const container = new PIXI.Container(); const removed = container.removeChildren(); @@ -451,7 +451,7 @@ expect(removed.length).to.be.equals(0); }); - it('should handle a range greater than length', () => + it('should handle a range greater than length', function () { const container = new PIXI.Container(); let removed = []; @@ -462,7 +462,7 @@ expect(removed.length).to.be.equals(1); }); - it('should throw outside acceptable range', () => + it('should throw outside acceptable range', function () { const container = new PIXI.Container(); @@ -477,9 +477,9 @@ }); }); - describe('destroy', () => + describe('destroy', function () { - it('should not destroy children by default', () => + it('should not destroy children by default', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -491,7 +491,7 @@ expect(child.transform).to.not.be.null; }); - it('should allow children destroy', () => + it('should allow children destroy', function () { let container = new PIXI.Container(); let child = new PIXI.DisplayObject(); @@ -515,9 +515,9 @@ }); }); - describe('width', () => + describe('width', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -529,7 +529,7 @@ expect(container.width).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -543,7 +543,7 @@ expect(container.scale.x).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); @@ -555,9 +555,9 @@ }); }); - describe('height', () => + describe('height', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -569,7 +569,7 @@ expect(container.height).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -583,7 +583,7 @@ expect(container.scale.y).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); diff --git a/test/core/DisplayObject.js b/test/core/DisplayObject.js index ebf1195..7826e71 100755 --- a/test/core/DisplayObject.js +++ b/test/core/DisplayObject.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.DisplayObject', () => +describe('PIXI.DisplayObject', function () { - describe('constructor', () => + describe('constructor', function () { - it('should initialise properties', () => + it('should initialise properties', function () { const object = new PIXI.DisplayObject(); @@ -14,7 +14,7 @@ expect(object.visible).to.be.true; }); - it('should set the correct Transform', () => + it('should set the correct Transform', function () { PIXI.settings.TRANSFORM_MODE = PIXI.TRANSFORM_MODE.DYNAMIC; @@ -30,9 +30,9 @@ }); }); - describe('setParent', () => + describe('setParent', function () { - it('should add itself to a Container', () => + it('should add itself to a Container', function () { const child = new PIXI.DisplayObject(); const container = new PIXI.Container(); @@ -43,7 +43,7 @@ expect(child.parent).to.equal(container); }); - it('should throw if not Container', () => + it('should throw if not Container', function () { const child = new PIXI.DisplayObject(); const notAContainer = {}; @@ -53,9 +53,9 @@ }); }); - describe('setTransform', () => + describe('setTransform', function () { - it('should set correct properties', () => + it('should set correct properties', function () { const object = new PIXI.DisplayObject(); @@ -72,7 +72,7 @@ expect(object.pivot.y).to.be.equal(9); }); - it('should convert zero scale to one', () => + it('should convert zero scale to one', function () { const object = new PIXI.DisplayObject(); @@ -83,9 +83,9 @@ }); }); - describe('worldVisible', () => + describe('worldVisible', function () { - it('should traverse parents', () => + it('should traverse parents', function () { const grandParent = new PIXI.Container(); const parent = new PIXI.Container(); diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index 1e0f270..4c5034f 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -7,8 +7,7 @@ * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded * otherwise black rectangles will be drawn instead. * - * A RenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: * * ```js * let renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); @@ -23,15 +22,16 @@ * renderer.render(sprite, renderTexture); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * - * renderer.render(doc, renderTexture); // Renders to center of renderTexture + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/test/core/Application.js b/test/core/Application.js new file mode 100644 index 0000000..aa726b0 --- /dev/null +++ b/test/core/Application.js @@ -0,0 +1,20 @@ +'use strict'; + +describe('PIXI.Application', function () +{ + it('should generate application', function (done) + { + expect(PIXI.Application).to.be.a.function; + const app = new PIXI.Application(); + + expect(app.stage).to.be.instanceof(PIXI.Container); + expect(app.ticker).to.be.instanceof(PIXI.ticker.Ticker); + expect(app.renderer).to.be.ok; + + app.ticker.addOnce(() => + { + app.destroy(); + done(); + }); + }); +}); diff --git a/test/core/BaseTexture.js b/test/core/BaseTexture.js index a5fd99a..8b93478 100644 --- a/test/core/BaseTexture.js +++ b/test/core/BaseTexture.js @@ -1,10 +1,10 @@ 'use strict'; -describe('BaseTexture', () => +describe('BaseTexture', function () { - describe('updateImageType', () => + describe('updateImageType', function () { - it('should allow no extension', () => + it('should allow no extension', function () { const baseTexture = new PIXI.BaseTexture(); diff --git a/test/core/Container.js b/test/core/Container.js index a88a2e3..8a10b40 100644 --- a/test/core/Container.js +++ b/test/core/Container.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Container', () => +describe('PIXI.Container', function () { - describe('parent', () => + describe('parent', function () { - it('should be present when adding children to Container', () => + it('should be present when adding children to Container', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -16,9 +16,9 @@ }); }); - describe('events', () => + describe('events', function () { - it('should trigger "added" and "removed" events on its children', () => + it('should trigger "added" and "removed" events on its children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -48,9 +48,9 @@ }); }); - describe('addChild', () => + describe('addChild', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -59,7 +59,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChild(child); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -72,9 +72,9 @@ }); }); - describe('removeChildAt', () => + describe('removeChildAt', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -82,7 +82,7 @@ assertRemovedFromParent(parent, null, child, () => { parent.removeChildAt(0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -97,9 +97,9 @@ }); }); - describe('addChildAt', () => + describe('addChildAt', function () { - it('should allow placements at start', () => + it('should allow placements at start', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -111,7 +111,7 @@ expect(container.children[0]).to.be.equals(child); }); - it('should allow placements at end', () => + it('should allow placements at end', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -123,7 +123,7 @@ expect(container.children[1]).to.be.equals(child); }); - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -134,7 +134,7 @@ expect(() => container.addChildAt(child, 2)).to.throw('The index 2 supplied is out of bounds 1'); }); - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -143,7 +143,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChildAt(child, 0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -159,9 +159,9 @@ }); }); - describe('removeChild', () => + describe('removeChild', function () { - it('should ignore non-children', () => + it('should ignore non-children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -173,7 +173,7 @@ expect(container.children.length).to.be.equals(1); }); - it('should remove all children supplied', () => + it('should remove all children supplied', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -188,7 +188,7 @@ expect(container.children.length).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -204,9 +204,9 @@ }); }); - describe('getChildIndex', () => + describe('getChildIndex', function () { - it('should return the correct index', () => + it('should return the correct index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -216,7 +216,7 @@ expect(container.getChildIndex(child)).to.be.equals(1); }); - it('should throw when child does not exist', () => + it('should throw when child does not exist', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -226,9 +226,9 @@ }); }); - describe('getChildAt', () => + describe('getChildAt', function () { - it('should throw when out-of-bounds', () => + it('should throw when out-of-bounds', function () { const container = new PIXI.Container(); @@ -237,9 +237,9 @@ }); }); - describe('setChildIndex', () => + describe('setChildIndex', function () { - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -250,7 +250,7 @@ expect(() => container.setChildIndex(child, 1)).to.throw('The supplied index is out of bounds'); }); - it('should throw when child does not belong', () => + it('should throw when child does not belong', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -261,7 +261,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should set index', () => + it('should set index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -279,7 +279,7 @@ expect(container.children.indexOf(child)).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -295,9 +295,9 @@ }); }); - describe('swapChildren', () => + describe('swapChildren', function () { - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -317,7 +317,7 @@ expect(spy).to.have.been.calledWith(0); }); - it('should not call onChildrenChange if supplied children are equal', () => + it('should not call onChildrenChange if supplied children are equal', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -331,7 +331,7 @@ expect(spy).to.not.have.been.called; }); - it('should throw if children do not belong', () => + it('should throw if children do not belong', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -344,7 +344,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should result in swapped child positions', () => + it('should result in swapped child positions', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -362,9 +362,9 @@ }); }); - describe('render', () => + describe('render', function () { - it('should not render when object not visible', () => + it('should not render when object not visible', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -379,7 +379,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when alpha is zero', () => + it('should not render when alpha is zero', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -394,7 +394,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when object not renderable', () => + it('should not render when object not renderable', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -409,7 +409,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should render children', () => + it('should render children', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -426,9 +426,9 @@ }); }); - describe('removeChildren', () => + describe('removeChildren', function () { - it('should remove all children when no arguments supplied', () => + it('should remove all children when no arguments supplied', function () { const container = new PIXI.Container(); let removed = []; @@ -443,7 +443,7 @@ expect(removed.length).to.be.equals(3); }); - it('should return empty array if no children', () => + it('should return empty array if no children', function () { const container = new PIXI.Container(); const removed = container.removeChildren(); @@ -451,7 +451,7 @@ expect(removed.length).to.be.equals(0); }); - it('should handle a range greater than length', () => + it('should handle a range greater than length', function () { const container = new PIXI.Container(); let removed = []; @@ -462,7 +462,7 @@ expect(removed.length).to.be.equals(1); }); - it('should throw outside acceptable range', () => + it('should throw outside acceptable range', function () { const container = new PIXI.Container(); @@ -477,9 +477,9 @@ }); }); - describe('destroy', () => + describe('destroy', function () { - it('should not destroy children by default', () => + it('should not destroy children by default', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -491,7 +491,7 @@ expect(child.transform).to.not.be.null; }); - it('should allow children destroy', () => + it('should allow children destroy', function () { let container = new PIXI.Container(); let child = new PIXI.DisplayObject(); @@ -515,9 +515,9 @@ }); }); - describe('width', () => + describe('width', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -529,7 +529,7 @@ expect(container.width).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -543,7 +543,7 @@ expect(container.scale.x).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); @@ -555,9 +555,9 @@ }); }); - describe('height', () => + describe('height', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -569,7 +569,7 @@ expect(container.height).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -583,7 +583,7 @@ expect(container.scale.y).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); diff --git a/test/core/DisplayObject.js b/test/core/DisplayObject.js index ebf1195..7826e71 100755 --- a/test/core/DisplayObject.js +++ b/test/core/DisplayObject.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.DisplayObject', () => +describe('PIXI.DisplayObject', function () { - describe('constructor', () => + describe('constructor', function () { - it('should initialise properties', () => + it('should initialise properties', function () { const object = new PIXI.DisplayObject(); @@ -14,7 +14,7 @@ expect(object.visible).to.be.true; }); - it('should set the correct Transform', () => + it('should set the correct Transform', function () { PIXI.settings.TRANSFORM_MODE = PIXI.TRANSFORM_MODE.DYNAMIC; @@ -30,9 +30,9 @@ }); }); - describe('setParent', () => + describe('setParent', function () { - it('should add itself to a Container', () => + it('should add itself to a Container', function () { const child = new PIXI.DisplayObject(); const container = new PIXI.Container(); @@ -43,7 +43,7 @@ expect(child.parent).to.equal(container); }); - it('should throw if not Container', () => + it('should throw if not Container', function () { const child = new PIXI.DisplayObject(); const notAContainer = {}; @@ -53,9 +53,9 @@ }); }); - describe('setTransform', () => + describe('setTransform', function () { - it('should set correct properties', () => + it('should set correct properties', function () { const object = new PIXI.DisplayObject(); @@ -72,7 +72,7 @@ expect(object.pivot.y).to.be.equal(9); }); - it('should convert zero scale to one', () => + it('should convert zero scale to one', function () { const object = new PIXI.DisplayObject(); @@ -83,9 +83,9 @@ }); }); - describe('worldVisible', () => + describe('worldVisible', function () { - it('should traverse parents', () => + it('should traverse parents', function () { const grandParent = new PIXI.Container(); const parent = new PIXI.Container(); diff --git a/test/core/Graphics.js b/test/core/Graphics.js index 50f775b..2a64946 100644 --- a/test/core/Graphics.js +++ b/test/core/Graphics.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Graphics', () => +describe('PIXI.Graphics', function () { - describe('constructor', () => + describe('constructor', function () { - it('should set defaults', () => + it('should set defaults', function () { const graphics = new PIXI.Graphics(); @@ -16,9 +16,9 @@ }); }); - describe('lineTo', () => + describe('lineTo', function () { - it('should return correct bounds - north', () => + it('should return correct bounds - north', function () { const graphics = new PIXI.Graphics(); @@ -31,7 +31,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - south', () => + it('should return correct bounds - south', function () { const graphics = new PIXI.Graphics(); @@ -44,7 +44,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - east', () => + it('should return correct bounds - east', function () { const graphics = new PIXI.Graphics(); @@ -56,7 +56,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds - west', () => + it('should return correct bounds - west', function () { const graphics = new PIXI.Graphics(); @@ -69,7 +69,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds when stacked with circle', () => + it('should return correct bounds when stacked with circle', function () { const graphics = new PIXI.Graphics(); @@ -88,7 +88,7 @@ expect(graphics.height).to.be.equals(100); }); - it('should return correct bounds when square', () => + it('should return correct bounds when square', function () { const graphics = new PIXI.Graphics(); @@ -104,9 +104,9 @@ }); }); - describe('containsPoint', () => + describe('containsPoint', function () { - it('should return true when point inside', () => + it('should return true when point inside', function () { const point = new PIXI.Point(1, 1); const graphics = new PIXI.Graphics(); @@ -117,7 +117,7 @@ expect(graphics.containsPoint(point)).to.be.true; }); - it('should return false when point outside', () => + it('should return false when point outside', function () { const point = new PIXI.Point(20, 20); const graphics = new PIXI.Graphics(); @@ -129,9 +129,9 @@ }); }); - describe('arc', () => + describe('arc', function () { - it('should draw an arc', () => + it('should draw an arc', function () { const graphics = new PIXI.Graphics(); @@ -142,7 +142,7 @@ expect(graphics.currentPath).to.be.not.null; }); - it('should not throw with other shapes', () => + it('should not throw with other shapes', function () { // complex drawing #1: draw triangle, rounder rect and an arc (issue #3433) const graphics = new PIXI.Graphics(); @@ -169,7 +169,7 @@ expect(() => graphics.arc(300, 100, 20, 0, Math.PI)).to.not.throw(); }); - it('should do nothing when startAngle and endAngle are equal', () => + it('should do nothing when startAngle and endAngle are equal', function () { const graphics = new PIXI.Graphics(); @@ -180,7 +180,7 @@ expect(graphics.currentPath).to.be.null; }); - it('should do nothing if sweep equals zero', () => + it('should do nothing if sweep equals zero', function () { const graphics = new PIXI.Graphics(); @@ -192,9 +192,9 @@ }); }); - describe('_calculateBounds', () => + describe('_calculateBounds', function () { - it('should only call updateLocalBounds once', () => + it('should only call updateLocalBounds once', function () { const graphics = new PIXI.Graphics(); const spy = sinon.spy(graphics, 'updateLocalBounds'); diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index 1e0f270..4c5034f 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -7,8 +7,7 @@ * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded * otherwise black rectangles will be drawn instead. * - * A RenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: * * ```js * let renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); @@ -23,15 +22,16 @@ * renderer.render(sprite, renderTexture); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * - * renderer.render(doc, renderTexture); // Renders to center of renderTexture + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/test/core/Application.js b/test/core/Application.js new file mode 100644 index 0000000..aa726b0 --- /dev/null +++ b/test/core/Application.js @@ -0,0 +1,20 @@ +'use strict'; + +describe('PIXI.Application', function () +{ + it('should generate application', function (done) + { + expect(PIXI.Application).to.be.a.function; + const app = new PIXI.Application(); + + expect(app.stage).to.be.instanceof(PIXI.Container); + expect(app.ticker).to.be.instanceof(PIXI.ticker.Ticker); + expect(app.renderer).to.be.ok; + + app.ticker.addOnce(() => + { + app.destroy(); + done(); + }); + }); +}); diff --git a/test/core/BaseTexture.js b/test/core/BaseTexture.js index a5fd99a..8b93478 100644 --- a/test/core/BaseTexture.js +++ b/test/core/BaseTexture.js @@ -1,10 +1,10 @@ 'use strict'; -describe('BaseTexture', () => +describe('BaseTexture', function () { - describe('updateImageType', () => + describe('updateImageType', function () { - it('should allow no extension', () => + it('should allow no extension', function () { const baseTexture = new PIXI.BaseTexture(); diff --git a/test/core/Container.js b/test/core/Container.js index a88a2e3..8a10b40 100644 --- a/test/core/Container.js +++ b/test/core/Container.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Container', () => +describe('PIXI.Container', function () { - describe('parent', () => + describe('parent', function () { - it('should be present when adding children to Container', () => + it('should be present when adding children to Container', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -16,9 +16,9 @@ }); }); - describe('events', () => + describe('events', function () { - it('should trigger "added" and "removed" events on its children', () => + it('should trigger "added" and "removed" events on its children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -48,9 +48,9 @@ }); }); - describe('addChild', () => + describe('addChild', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -59,7 +59,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChild(child); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -72,9 +72,9 @@ }); }); - describe('removeChildAt', () => + describe('removeChildAt', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -82,7 +82,7 @@ assertRemovedFromParent(parent, null, child, () => { parent.removeChildAt(0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -97,9 +97,9 @@ }); }); - describe('addChildAt', () => + describe('addChildAt', function () { - it('should allow placements at start', () => + it('should allow placements at start', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -111,7 +111,7 @@ expect(container.children[0]).to.be.equals(child); }); - it('should allow placements at end', () => + it('should allow placements at end', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -123,7 +123,7 @@ expect(container.children[1]).to.be.equals(child); }); - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -134,7 +134,7 @@ expect(() => container.addChildAt(child, 2)).to.throw('The index 2 supplied is out of bounds 1'); }); - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -143,7 +143,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChildAt(child, 0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -159,9 +159,9 @@ }); }); - describe('removeChild', () => + describe('removeChild', function () { - it('should ignore non-children', () => + it('should ignore non-children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -173,7 +173,7 @@ expect(container.children.length).to.be.equals(1); }); - it('should remove all children supplied', () => + it('should remove all children supplied', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -188,7 +188,7 @@ expect(container.children.length).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -204,9 +204,9 @@ }); }); - describe('getChildIndex', () => + describe('getChildIndex', function () { - it('should return the correct index', () => + it('should return the correct index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -216,7 +216,7 @@ expect(container.getChildIndex(child)).to.be.equals(1); }); - it('should throw when child does not exist', () => + it('should throw when child does not exist', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -226,9 +226,9 @@ }); }); - describe('getChildAt', () => + describe('getChildAt', function () { - it('should throw when out-of-bounds', () => + it('should throw when out-of-bounds', function () { const container = new PIXI.Container(); @@ -237,9 +237,9 @@ }); }); - describe('setChildIndex', () => + describe('setChildIndex', function () { - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -250,7 +250,7 @@ expect(() => container.setChildIndex(child, 1)).to.throw('The supplied index is out of bounds'); }); - it('should throw when child does not belong', () => + it('should throw when child does not belong', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -261,7 +261,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should set index', () => + it('should set index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -279,7 +279,7 @@ expect(container.children.indexOf(child)).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -295,9 +295,9 @@ }); }); - describe('swapChildren', () => + describe('swapChildren', function () { - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -317,7 +317,7 @@ expect(spy).to.have.been.calledWith(0); }); - it('should not call onChildrenChange if supplied children are equal', () => + it('should not call onChildrenChange if supplied children are equal', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -331,7 +331,7 @@ expect(spy).to.not.have.been.called; }); - it('should throw if children do not belong', () => + it('should throw if children do not belong', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -344,7 +344,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should result in swapped child positions', () => + it('should result in swapped child positions', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -362,9 +362,9 @@ }); }); - describe('render', () => + describe('render', function () { - it('should not render when object not visible', () => + it('should not render when object not visible', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -379,7 +379,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when alpha is zero', () => + it('should not render when alpha is zero', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -394,7 +394,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when object not renderable', () => + it('should not render when object not renderable', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -409,7 +409,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should render children', () => + it('should render children', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -426,9 +426,9 @@ }); }); - describe('removeChildren', () => + describe('removeChildren', function () { - it('should remove all children when no arguments supplied', () => + it('should remove all children when no arguments supplied', function () { const container = new PIXI.Container(); let removed = []; @@ -443,7 +443,7 @@ expect(removed.length).to.be.equals(3); }); - it('should return empty array if no children', () => + it('should return empty array if no children', function () { const container = new PIXI.Container(); const removed = container.removeChildren(); @@ -451,7 +451,7 @@ expect(removed.length).to.be.equals(0); }); - it('should handle a range greater than length', () => + it('should handle a range greater than length', function () { const container = new PIXI.Container(); let removed = []; @@ -462,7 +462,7 @@ expect(removed.length).to.be.equals(1); }); - it('should throw outside acceptable range', () => + it('should throw outside acceptable range', function () { const container = new PIXI.Container(); @@ -477,9 +477,9 @@ }); }); - describe('destroy', () => + describe('destroy', function () { - it('should not destroy children by default', () => + it('should not destroy children by default', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -491,7 +491,7 @@ expect(child.transform).to.not.be.null; }); - it('should allow children destroy', () => + it('should allow children destroy', function () { let container = new PIXI.Container(); let child = new PIXI.DisplayObject(); @@ -515,9 +515,9 @@ }); }); - describe('width', () => + describe('width', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -529,7 +529,7 @@ expect(container.width).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -543,7 +543,7 @@ expect(container.scale.x).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); @@ -555,9 +555,9 @@ }); }); - describe('height', () => + describe('height', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -569,7 +569,7 @@ expect(container.height).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -583,7 +583,7 @@ expect(container.scale.y).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); diff --git a/test/core/DisplayObject.js b/test/core/DisplayObject.js index ebf1195..7826e71 100755 --- a/test/core/DisplayObject.js +++ b/test/core/DisplayObject.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.DisplayObject', () => +describe('PIXI.DisplayObject', function () { - describe('constructor', () => + describe('constructor', function () { - it('should initialise properties', () => + it('should initialise properties', function () { const object = new PIXI.DisplayObject(); @@ -14,7 +14,7 @@ expect(object.visible).to.be.true; }); - it('should set the correct Transform', () => + it('should set the correct Transform', function () { PIXI.settings.TRANSFORM_MODE = PIXI.TRANSFORM_MODE.DYNAMIC; @@ -30,9 +30,9 @@ }); }); - describe('setParent', () => + describe('setParent', function () { - it('should add itself to a Container', () => + it('should add itself to a Container', function () { const child = new PIXI.DisplayObject(); const container = new PIXI.Container(); @@ -43,7 +43,7 @@ expect(child.parent).to.equal(container); }); - it('should throw if not Container', () => + it('should throw if not Container', function () { const child = new PIXI.DisplayObject(); const notAContainer = {}; @@ -53,9 +53,9 @@ }); }); - describe('setTransform', () => + describe('setTransform', function () { - it('should set correct properties', () => + it('should set correct properties', function () { const object = new PIXI.DisplayObject(); @@ -72,7 +72,7 @@ expect(object.pivot.y).to.be.equal(9); }); - it('should convert zero scale to one', () => + it('should convert zero scale to one', function () { const object = new PIXI.DisplayObject(); @@ -83,9 +83,9 @@ }); }); - describe('worldVisible', () => + describe('worldVisible', function () { - it('should traverse parents', () => + it('should traverse parents', function () { const grandParent = new PIXI.Container(); const parent = new PIXI.Container(); diff --git a/test/core/Graphics.js b/test/core/Graphics.js index 50f775b..2a64946 100644 --- a/test/core/Graphics.js +++ b/test/core/Graphics.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Graphics', () => +describe('PIXI.Graphics', function () { - describe('constructor', () => + describe('constructor', function () { - it('should set defaults', () => + it('should set defaults', function () { const graphics = new PIXI.Graphics(); @@ -16,9 +16,9 @@ }); }); - describe('lineTo', () => + describe('lineTo', function () { - it('should return correct bounds - north', () => + it('should return correct bounds - north', function () { const graphics = new PIXI.Graphics(); @@ -31,7 +31,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - south', () => + it('should return correct bounds - south', function () { const graphics = new PIXI.Graphics(); @@ -44,7 +44,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - east', () => + it('should return correct bounds - east', function () { const graphics = new PIXI.Graphics(); @@ -56,7 +56,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds - west', () => + it('should return correct bounds - west', function () { const graphics = new PIXI.Graphics(); @@ -69,7 +69,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds when stacked with circle', () => + it('should return correct bounds when stacked with circle', function () { const graphics = new PIXI.Graphics(); @@ -88,7 +88,7 @@ expect(graphics.height).to.be.equals(100); }); - it('should return correct bounds when square', () => + it('should return correct bounds when square', function () { const graphics = new PIXI.Graphics(); @@ -104,9 +104,9 @@ }); }); - describe('containsPoint', () => + describe('containsPoint', function () { - it('should return true when point inside', () => + it('should return true when point inside', function () { const point = new PIXI.Point(1, 1); const graphics = new PIXI.Graphics(); @@ -117,7 +117,7 @@ expect(graphics.containsPoint(point)).to.be.true; }); - it('should return false when point outside', () => + it('should return false when point outside', function () { const point = new PIXI.Point(20, 20); const graphics = new PIXI.Graphics(); @@ -129,9 +129,9 @@ }); }); - describe('arc', () => + describe('arc', function () { - it('should draw an arc', () => + it('should draw an arc', function () { const graphics = new PIXI.Graphics(); @@ -142,7 +142,7 @@ expect(graphics.currentPath).to.be.not.null; }); - it('should not throw with other shapes', () => + it('should not throw with other shapes', function () { // complex drawing #1: draw triangle, rounder rect and an arc (issue #3433) const graphics = new PIXI.Graphics(); @@ -169,7 +169,7 @@ expect(() => graphics.arc(300, 100, 20, 0, Math.PI)).to.not.throw(); }); - it('should do nothing when startAngle and endAngle are equal', () => + it('should do nothing when startAngle and endAngle are equal', function () { const graphics = new PIXI.Graphics(); @@ -180,7 +180,7 @@ expect(graphics.currentPath).to.be.null; }); - it('should do nothing if sweep equals zero', () => + it('should do nothing if sweep equals zero', function () { const graphics = new PIXI.Graphics(); @@ -192,9 +192,9 @@ }); }); - describe('_calculateBounds', () => + describe('_calculateBounds', function () { - it('should only call updateLocalBounds once', () => + it('should only call updateLocalBounds once', function () { const graphics = new PIXI.Graphics(); const spy = sinon.spy(graphics, 'updateLocalBounds'); diff --git a/test/core/Polygon.js b/test/core/Polygon.js index 16323cf..24bc6c9 100644 --- a/test/core/Polygon.js +++ b/test/core/Polygon.js @@ -1,17 +1,17 @@ 'use strict'; -describe('PIXI.Polygon', () => +describe('PIXI.Polygon', function () { - describe('constructor', () => + describe('constructor', function () { - it('should accept a spread of values', () => + it('should accept a spread of values', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10); expect(polygon.points.length).to.be.equals(6); }); - it('should accept a spread of points', () => + it('should accept a spread of points', function () { const polygon = new PIXI.Polygon( new PIXI.Point(0, 0), @@ -22,14 +22,14 @@ expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of values', () => + it('should accept an array of values', function () { const polygon = new PIXI.Polygon([0, 0, 10, 0, 0, 10]); expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of points', () => + it('should accept an array of points', function () { const polygon = new PIXI.Polygon([ new PIXI.Point(0, 0), @@ -41,9 +41,9 @@ }); }); - describe('clone', () => + describe('clone', function () { - it('should create a copy', () => + it('should create a copy', function () { const polygon1 = new PIXI.Polygon(0, 0, 10, 0, 0, 10); const polygon2 = polygon1.clone(); @@ -63,9 +63,9 @@ }); }); - describe('close', () => + describe('close', function () { - it('should close the polygon if open', () => + it('should close the polygon if open', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10); @@ -78,7 +78,7 @@ expect(polygon.points[7]).to.be.equals(0); }); - it('should do nothing if already closed', () => + it('should do nothing if already closed', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10, 0, 0); @@ -90,9 +90,9 @@ }); }); - describe('contains', () => + describe('contains', function () { - it('should include points inside', () => + it('should include points inside', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -102,7 +102,7 @@ expect(polygon.contains(9, 9)).to.be.true; }); - it('should exclude bounds', () => + it('should exclude bounds', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -112,7 +112,7 @@ expect(polygon.contains(10, 10)).to.be.false; }); - it('should exclude points outside', () => + it('should exclude points outside', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index 1e0f270..4c5034f 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -7,8 +7,7 @@ * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded * otherwise black rectangles will be drawn instead. * - * A RenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: * * ```js * let renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); @@ -23,15 +22,16 @@ * renderer.render(sprite, renderTexture); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * - * renderer.render(doc, renderTexture); // Renders to center of renderTexture + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/test/core/Application.js b/test/core/Application.js new file mode 100644 index 0000000..aa726b0 --- /dev/null +++ b/test/core/Application.js @@ -0,0 +1,20 @@ +'use strict'; + +describe('PIXI.Application', function () +{ + it('should generate application', function (done) + { + expect(PIXI.Application).to.be.a.function; + const app = new PIXI.Application(); + + expect(app.stage).to.be.instanceof(PIXI.Container); + expect(app.ticker).to.be.instanceof(PIXI.ticker.Ticker); + expect(app.renderer).to.be.ok; + + app.ticker.addOnce(() => + { + app.destroy(); + done(); + }); + }); +}); diff --git a/test/core/BaseTexture.js b/test/core/BaseTexture.js index a5fd99a..8b93478 100644 --- a/test/core/BaseTexture.js +++ b/test/core/BaseTexture.js @@ -1,10 +1,10 @@ 'use strict'; -describe('BaseTexture', () => +describe('BaseTexture', function () { - describe('updateImageType', () => + describe('updateImageType', function () { - it('should allow no extension', () => + it('should allow no extension', function () { const baseTexture = new PIXI.BaseTexture(); diff --git a/test/core/Container.js b/test/core/Container.js index a88a2e3..8a10b40 100644 --- a/test/core/Container.js +++ b/test/core/Container.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Container', () => +describe('PIXI.Container', function () { - describe('parent', () => + describe('parent', function () { - it('should be present when adding children to Container', () => + it('should be present when adding children to Container', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -16,9 +16,9 @@ }); }); - describe('events', () => + describe('events', function () { - it('should trigger "added" and "removed" events on its children', () => + it('should trigger "added" and "removed" events on its children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -48,9 +48,9 @@ }); }); - describe('addChild', () => + describe('addChild', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -59,7 +59,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChild(child); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -72,9 +72,9 @@ }); }); - describe('removeChildAt', () => + describe('removeChildAt', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -82,7 +82,7 @@ assertRemovedFromParent(parent, null, child, () => { parent.removeChildAt(0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -97,9 +97,9 @@ }); }); - describe('addChildAt', () => + describe('addChildAt', function () { - it('should allow placements at start', () => + it('should allow placements at start', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -111,7 +111,7 @@ expect(container.children[0]).to.be.equals(child); }); - it('should allow placements at end', () => + it('should allow placements at end', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -123,7 +123,7 @@ expect(container.children[1]).to.be.equals(child); }); - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -134,7 +134,7 @@ expect(() => container.addChildAt(child, 2)).to.throw('The index 2 supplied is out of bounds 1'); }); - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -143,7 +143,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChildAt(child, 0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -159,9 +159,9 @@ }); }); - describe('removeChild', () => + describe('removeChild', function () { - it('should ignore non-children', () => + it('should ignore non-children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -173,7 +173,7 @@ expect(container.children.length).to.be.equals(1); }); - it('should remove all children supplied', () => + it('should remove all children supplied', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -188,7 +188,7 @@ expect(container.children.length).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -204,9 +204,9 @@ }); }); - describe('getChildIndex', () => + describe('getChildIndex', function () { - it('should return the correct index', () => + it('should return the correct index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -216,7 +216,7 @@ expect(container.getChildIndex(child)).to.be.equals(1); }); - it('should throw when child does not exist', () => + it('should throw when child does not exist', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -226,9 +226,9 @@ }); }); - describe('getChildAt', () => + describe('getChildAt', function () { - it('should throw when out-of-bounds', () => + it('should throw when out-of-bounds', function () { const container = new PIXI.Container(); @@ -237,9 +237,9 @@ }); }); - describe('setChildIndex', () => + describe('setChildIndex', function () { - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -250,7 +250,7 @@ expect(() => container.setChildIndex(child, 1)).to.throw('The supplied index is out of bounds'); }); - it('should throw when child does not belong', () => + it('should throw when child does not belong', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -261,7 +261,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should set index', () => + it('should set index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -279,7 +279,7 @@ expect(container.children.indexOf(child)).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -295,9 +295,9 @@ }); }); - describe('swapChildren', () => + describe('swapChildren', function () { - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -317,7 +317,7 @@ expect(spy).to.have.been.calledWith(0); }); - it('should not call onChildrenChange if supplied children are equal', () => + it('should not call onChildrenChange if supplied children are equal', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -331,7 +331,7 @@ expect(spy).to.not.have.been.called; }); - it('should throw if children do not belong', () => + it('should throw if children do not belong', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -344,7 +344,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should result in swapped child positions', () => + it('should result in swapped child positions', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -362,9 +362,9 @@ }); }); - describe('render', () => + describe('render', function () { - it('should not render when object not visible', () => + it('should not render when object not visible', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -379,7 +379,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when alpha is zero', () => + it('should not render when alpha is zero', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -394,7 +394,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when object not renderable', () => + it('should not render when object not renderable', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -409,7 +409,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should render children', () => + it('should render children', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -426,9 +426,9 @@ }); }); - describe('removeChildren', () => + describe('removeChildren', function () { - it('should remove all children when no arguments supplied', () => + it('should remove all children when no arguments supplied', function () { const container = new PIXI.Container(); let removed = []; @@ -443,7 +443,7 @@ expect(removed.length).to.be.equals(3); }); - it('should return empty array if no children', () => + it('should return empty array if no children', function () { const container = new PIXI.Container(); const removed = container.removeChildren(); @@ -451,7 +451,7 @@ expect(removed.length).to.be.equals(0); }); - it('should handle a range greater than length', () => + it('should handle a range greater than length', function () { const container = new PIXI.Container(); let removed = []; @@ -462,7 +462,7 @@ expect(removed.length).to.be.equals(1); }); - it('should throw outside acceptable range', () => + it('should throw outside acceptable range', function () { const container = new PIXI.Container(); @@ -477,9 +477,9 @@ }); }); - describe('destroy', () => + describe('destroy', function () { - it('should not destroy children by default', () => + it('should not destroy children by default', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -491,7 +491,7 @@ expect(child.transform).to.not.be.null; }); - it('should allow children destroy', () => + it('should allow children destroy', function () { let container = new PIXI.Container(); let child = new PIXI.DisplayObject(); @@ -515,9 +515,9 @@ }); }); - describe('width', () => + describe('width', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -529,7 +529,7 @@ expect(container.width).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -543,7 +543,7 @@ expect(container.scale.x).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); @@ -555,9 +555,9 @@ }); }); - describe('height', () => + describe('height', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -569,7 +569,7 @@ expect(container.height).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -583,7 +583,7 @@ expect(container.scale.y).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); diff --git a/test/core/DisplayObject.js b/test/core/DisplayObject.js index ebf1195..7826e71 100755 --- a/test/core/DisplayObject.js +++ b/test/core/DisplayObject.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.DisplayObject', () => +describe('PIXI.DisplayObject', function () { - describe('constructor', () => + describe('constructor', function () { - it('should initialise properties', () => + it('should initialise properties', function () { const object = new PIXI.DisplayObject(); @@ -14,7 +14,7 @@ expect(object.visible).to.be.true; }); - it('should set the correct Transform', () => + it('should set the correct Transform', function () { PIXI.settings.TRANSFORM_MODE = PIXI.TRANSFORM_MODE.DYNAMIC; @@ -30,9 +30,9 @@ }); }); - describe('setParent', () => + describe('setParent', function () { - it('should add itself to a Container', () => + it('should add itself to a Container', function () { const child = new PIXI.DisplayObject(); const container = new PIXI.Container(); @@ -43,7 +43,7 @@ expect(child.parent).to.equal(container); }); - it('should throw if not Container', () => + it('should throw if not Container', function () { const child = new PIXI.DisplayObject(); const notAContainer = {}; @@ -53,9 +53,9 @@ }); }); - describe('setTransform', () => + describe('setTransform', function () { - it('should set correct properties', () => + it('should set correct properties', function () { const object = new PIXI.DisplayObject(); @@ -72,7 +72,7 @@ expect(object.pivot.y).to.be.equal(9); }); - it('should convert zero scale to one', () => + it('should convert zero scale to one', function () { const object = new PIXI.DisplayObject(); @@ -83,9 +83,9 @@ }); }); - describe('worldVisible', () => + describe('worldVisible', function () { - it('should traverse parents', () => + it('should traverse parents', function () { const grandParent = new PIXI.Container(); const parent = new PIXI.Container(); diff --git a/test/core/Graphics.js b/test/core/Graphics.js index 50f775b..2a64946 100644 --- a/test/core/Graphics.js +++ b/test/core/Graphics.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Graphics', () => +describe('PIXI.Graphics', function () { - describe('constructor', () => + describe('constructor', function () { - it('should set defaults', () => + it('should set defaults', function () { const graphics = new PIXI.Graphics(); @@ -16,9 +16,9 @@ }); }); - describe('lineTo', () => + describe('lineTo', function () { - it('should return correct bounds - north', () => + it('should return correct bounds - north', function () { const graphics = new PIXI.Graphics(); @@ -31,7 +31,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - south', () => + it('should return correct bounds - south', function () { const graphics = new PIXI.Graphics(); @@ -44,7 +44,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - east', () => + it('should return correct bounds - east', function () { const graphics = new PIXI.Graphics(); @@ -56,7 +56,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds - west', () => + it('should return correct bounds - west', function () { const graphics = new PIXI.Graphics(); @@ -69,7 +69,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds when stacked with circle', () => + it('should return correct bounds when stacked with circle', function () { const graphics = new PIXI.Graphics(); @@ -88,7 +88,7 @@ expect(graphics.height).to.be.equals(100); }); - it('should return correct bounds when square', () => + it('should return correct bounds when square', function () { const graphics = new PIXI.Graphics(); @@ -104,9 +104,9 @@ }); }); - describe('containsPoint', () => + describe('containsPoint', function () { - it('should return true when point inside', () => + it('should return true when point inside', function () { const point = new PIXI.Point(1, 1); const graphics = new PIXI.Graphics(); @@ -117,7 +117,7 @@ expect(graphics.containsPoint(point)).to.be.true; }); - it('should return false when point outside', () => + it('should return false when point outside', function () { const point = new PIXI.Point(20, 20); const graphics = new PIXI.Graphics(); @@ -129,9 +129,9 @@ }); }); - describe('arc', () => + describe('arc', function () { - it('should draw an arc', () => + it('should draw an arc', function () { const graphics = new PIXI.Graphics(); @@ -142,7 +142,7 @@ expect(graphics.currentPath).to.be.not.null; }); - it('should not throw with other shapes', () => + it('should not throw with other shapes', function () { // complex drawing #1: draw triangle, rounder rect and an arc (issue #3433) const graphics = new PIXI.Graphics(); @@ -169,7 +169,7 @@ expect(() => graphics.arc(300, 100, 20, 0, Math.PI)).to.not.throw(); }); - it('should do nothing when startAngle and endAngle are equal', () => + it('should do nothing when startAngle and endAngle are equal', function () { const graphics = new PIXI.Graphics(); @@ -180,7 +180,7 @@ expect(graphics.currentPath).to.be.null; }); - it('should do nothing if sweep equals zero', () => + it('should do nothing if sweep equals zero', function () { const graphics = new PIXI.Graphics(); @@ -192,9 +192,9 @@ }); }); - describe('_calculateBounds', () => + describe('_calculateBounds', function () { - it('should only call updateLocalBounds once', () => + it('should only call updateLocalBounds once', function () { const graphics = new PIXI.Graphics(); const spy = sinon.spy(graphics, 'updateLocalBounds'); diff --git a/test/core/Polygon.js b/test/core/Polygon.js index 16323cf..24bc6c9 100644 --- a/test/core/Polygon.js +++ b/test/core/Polygon.js @@ -1,17 +1,17 @@ 'use strict'; -describe('PIXI.Polygon', () => +describe('PIXI.Polygon', function () { - describe('constructor', () => + describe('constructor', function () { - it('should accept a spread of values', () => + it('should accept a spread of values', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10); expect(polygon.points.length).to.be.equals(6); }); - it('should accept a spread of points', () => + it('should accept a spread of points', function () { const polygon = new PIXI.Polygon( new PIXI.Point(0, 0), @@ -22,14 +22,14 @@ expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of values', () => + it('should accept an array of values', function () { const polygon = new PIXI.Polygon([0, 0, 10, 0, 0, 10]); expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of points', () => + it('should accept an array of points', function () { const polygon = new PIXI.Polygon([ new PIXI.Point(0, 0), @@ -41,9 +41,9 @@ }); }); - describe('clone', () => + describe('clone', function () { - it('should create a copy', () => + it('should create a copy', function () { const polygon1 = new PIXI.Polygon(0, 0, 10, 0, 0, 10); const polygon2 = polygon1.clone(); @@ -63,9 +63,9 @@ }); }); - describe('close', () => + describe('close', function () { - it('should close the polygon if open', () => + it('should close the polygon if open', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10); @@ -78,7 +78,7 @@ expect(polygon.points[7]).to.be.equals(0); }); - it('should do nothing if already closed', () => + it('should do nothing if already closed', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10, 0, 0); @@ -90,9 +90,9 @@ }); }); - describe('contains', () => + describe('contains', function () { - it('should include points inside', () => + it('should include points inside', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -102,7 +102,7 @@ expect(polygon.contains(9, 9)).to.be.true; }); - it('should exclude bounds', () => + it('should exclude bounds', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -112,7 +112,7 @@ expect(polygon.contains(10, 10)).to.be.false; }); - it('should exclude points outside', () => + it('should exclude points outside', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); diff --git a/test/core/SpriteRenderer.js b/test/core/SpriteRenderer.js index 01e1f81..bfab7db 100644 --- a/test/core/SpriteRenderer.js +++ b/test/core/SpriteRenderer.js @@ -1,8 +1,8 @@ 'use strict'; -describe('SpriteRenderer', () => +describe('SpriteRenderer', function () { - it('can be destroyed', () => + it('can be destroyed', function () { const destroyable = { destroy: sinon.stub() }; const webgl = { @@ -20,7 +20,7 @@ expect(() => renderer.destroy()).to.not.throw(); }); - it('can be destroyed immediately', () => + it('can be destroyed immediately', function () { const webgl = { on: sinon.stub(), diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index 1e0f270..4c5034f 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -7,8 +7,7 @@ * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded * otherwise black rectangles will be drawn instead. * - * A RenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: * * ```js * let renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); @@ -23,15 +22,16 @@ * renderer.render(sprite, renderTexture); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * - * renderer.render(doc, renderTexture); // Renders to center of renderTexture + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/test/core/Application.js b/test/core/Application.js new file mode 100644 index 0000000..aa726b0 --- /dev/null +++ b/test/core/Application.js @@ -0,0 +1,20 @@ +'use strict'; + +describe('PIXI.Application', function () +{ + it('should generate application', function (done) + { + expect(PIXI.Application).to.be.a.function; + const app = new PIXI.Application(); + + expect(app.stage).to.be.instanceof(PIXI.Container); + expect(app.ticker).to.be.instanceof(PIXI.ticker.Ticker); + expect(app.renderer).to.be.ok; + + app.ticker.addOnce(() => + { + app.destroy(); + done(); + }); + }); +}); diff --git a/test/core/BaseTexture.js b/test/core/BaseTexture.js index a5fd99a..8b93478 100644 --- a/test/core/BaseTexture.js +++ b/test/core/BaseTexture.js @@ -1,10 +1,10 @@ 'use strict'; -describe('BaseTexture', () => +describe('BaseTexture', function () { - describe('updateImageType', () => + describe('updateImageType', function () { - it('should allow no extension', () => + it('should allow no extension', function () { const baseTexture = new PIXI.BaseTexture(); diff --git a/test/core/Container.js b/test/core/Container.js index a88a2e3..8a10b40 100644 --- a/test/core/Container.js +++ b/test/core/Container.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Container', () => +describe('PIXI.Container', function () { - describe('parent', () => + describe('parent', function () { - it('should be present when adding children to Container', () => + it('should be present when adding children to Container', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -16,9 +16,9 @@ }); }); - describe('events', () => + describe('events', function () { - it('should trigger "added" and "removed" events on its children', () => + it('should trigger "added" and "removed" events on its children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -48,9 +48,9 @@ }); }); - describe('addChild', () => + describe('addChild', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -59,7 +59,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChild(child); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -72,9 +72,9 @@ }); }); - describe('removeChildAt', () => + describe('removeChildAt', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -82,7 +82,7 @@ assertRemovedFromParent(parent, null, child, () => { parent.removeChildAt(0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -97,9 +97,9 @@ }); }); - describe('addChildAt', () => + describe('addChildAt', function () { - it('should allow placements at start', () => + it('should allow placements at start', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -111,7 +111,7 @@ expect(container.children[0]).to.be.equals(child); }); - it('should allow placements at end', () => + it('should allow placements at end', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -123,7 +123,7 @@ expect(container.children[1]).to.be.equals(child); }); - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -134,7 +134,7 @@ expect(() => container.addChildAt(child, 2)).to.throw('The index 2 supplied is out of bounds 1'); }); - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -143,7 +143,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChildAt(child, 0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -159,9 +159,9 @@ }); }); - describe('removeChild', () => + describe('removeChild', function () { - it('should ignore non-children', () => + it('should ignore non-children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -173,7 +173,7 @@ expect(container.children.length).to.be.equals(1); }); - it('should remove all children supplied', () => + it('should remove all children supplied', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -188,7 +188,7 @@ expect(container.children.length).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -204,9 +204,9 @@ }); }); - describe('getChildIndex', () => + describe('getChildIndex', function () { - it('should return the correct index', () => + it('should return the correct index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -216,7 +216,7 @@ expect(container.getChildIndex(child)).to.be.equals(1); }); - it('should throw when child does not exist', () => + it('should throw when child does not exist', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -226,9 +226,9 @@ }); }); - describe('getChildAt', () => + describe('getChildAt', function () { - it('should throw when out-of-bounds', () => + it('should throw when out-of-bounds', function () { const container = new PIXI.Container(); @@ -237,9 +237,9 @@ }); }); - describe('setChildIndex', () => + describe('setChildIndex', function () { - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -250,7 +250,7 @@ expect(() => container.setChildIndex(child, 1)).to.throw('The supplied index is out of bounds'); }); - it('should throw when child does not belong', () => + it('should throw when child does not belong', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -261,7 +261,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should set index', () => + it('should set index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -279,7 +279,7 @@ expect(container.children.indexOf(child)).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -295,9 +295,9 @@ }); }); - describe('swapChildren', () => + describe('swapChildren', function () { - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -317,7 +317,7 @@ expect(spy).to.have.been.calledWith(0); }); - it('should not call onChildrenChange if supplied children are equal', () => + it('should not call onChildrenChange if supplied children are equal', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -331,7 +331,7 @@ expect(spy).to.not.have.been.called; }); - it('should throw if children do not belong', () => + it('should throw if children do not belong', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -344,7 +344,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should result in swapped child positions', () => + it('should result in swapped child positions', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -362,9 +362,9 @@ }); }); - describe('render', () => + describe('render', function () { - it('should not render when object not visible', () => + it('should not render when object not visible', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -379,7 +379,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when alpha is zero', () => + it('should not render when alpha is zero', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -394,7 +394,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when object not renderable', () => + it('should not render when object not renderable', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -409,7 +409,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should render children', () => + it('should render children', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -426,9 +426,9 @@ }); }); - describe('removeChildren', () => + describe('removeChildren', function () { - it('should remove all children when no arguments supplied', () => + it('should remove all children when no arguments supplied', function () { const container = new PIXI.Container(); let removed = []; @@ -443,7 +443,7 @@ expect(removed.length).to.be.equals(3); }); - it('should return empty array if no children', () => + it('should return empty array if no children', function () { const container = new PIXI.Container(); const removed = container.removeChildren(); @@ -451,7 +451,7 @@ expect(removed.length).to.be.equals(0); }); - it('should handle a range greater than length', () => + it('should handle a range greater than length', function () { const container = new PIXI.Container(); let removed = []; @@ -462,7 +462,7 @@ expect(removed.length).to.be.equals(1); }); - it('should throw outside acceptable range', () => + it('should throw outside acceptable range', function () { const container = new PIXI.Container(); @@ -477,9 +477,9 @@ }); }); - describe('destroy', () => + describe('destroy', function () { - it('should not destroy children by default', () => + it('should not destroy children by default', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -491,7 +491,7 @@ expect(child.transform).to.not.be.null; }); - it('should allow children destroy', () => + it('should allow children destroy', function () { let container = new PIXI.Container(); let child = new PIXI.DisplayObject(); @@ -515,9 +515,9 @@ }); }); - describe('width', () => + describe('width', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -529,7 +529,7 @@ expect(container.width).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -543,7 +543,7 @@ expect(container.scale.x).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); @@ -555,9 +555,9 @@ }); }); - describe('height', () => + describe('height', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -569,7 +569,7 @@ expect(container.height).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -583,7 +583,7 @@ expect(container.scale.y).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); diff --git a/test/core/DisplayObject.js b/test/core/DisplayObject.js index ebf1195..7826e71 100755 --- a/test/core/DisplayObject.js +++ b/test/core/DisplayObject.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.DisplayObject', () => +describe('PIXI.DisplayObject', function () { - describe('constructor', () => + describe('constructor', function () { - it('should initialise properties', () => + it('should initialise properties', function () { const object = new PIXI.DisplayObject(); @@ -14,7 +14,7 @@ expect(object.visible).to.be.true; }); - it('should set the correct Transform', () => + it('should set the correct Transform', function () { PIXI.settings.TRANSFORM_MODE = PIXI.TRANSFORM_MODE.DYNAMIC; @@ -30,9 +30,9 @@ }); }); - describe('setParent', () => + describe('setParent', function () { - it('should add itself to a Container', () => + it('should add itself to a Container', function () { const child = new PIXI.DisplayObject(); const container = new PIXI.Container(); @@ -43,7 +43,7 @@ expect(child.parent).to.equal(container); }); - it('should throw if not Container', () => + it('should throw if not Container', function () { const child = new PIXI.DisplayObject(); const notAContainer = {}; @@ -53,9 +53,9 @@ }); }); - describe('setTransform', () => + describe('setTransform', function () { - it('should set correct properties', () => + it('should set correct properties', function () { const object = new PIXI.DisplayObject(); @@ -72,7 +72,7 @@ expect(object.pivot.y).to.be.equal(9); }); - it('should convert zero scale to one', () => + it('should convert zero scale to one', function () { const object = new PIXI.DisplayObject(); @@ -83,9 +83,9 @@ }); }); - describe('worldVisible', () => + describe('worldVisible', function () { - it('should traverse parents', () => + it('should traverse parents', function () { const grandParent = new PIXI.Container(); const parent = new PIXI.Container(); diff --git a/test/core/Graphics.js b/test/core/Graphics.js index 50f775b..2a64946 100644 --- a/test/core/Graphics.js +++ b/test/core/Graphics.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Graphics', () => +describe('PIXI.Graphics', function () { - describe('constructor', () => + describe('constructor', function () { - it('should set defaults', () => + it('should set defaults', function () { const graphics = new PIXI.Graphics(); @@ -16,9 +16,9 @@ }); }); - describe('lineTo', () => + describe('lineTo', function () { - it('should return correct bounds - north', () => + it('should return correct bounds - north', function () { const graphics = new PIXI.Graphics(); @@ -31,7 +31,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - south', () => + it('should return correct bounds - south', function () { const graphics = new PIXI.Graphics(); @@ -44,7 +44,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - east', () => + it('should return correct bounds - east', function () { const graphics = new PIXI.Graphics(); @@ -56,7 +56,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds - west', () => + it('should return correct bounds - west', function () { const graphics = new PIXI.Graphics(); @@ -69,7 +69,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds when stacked with circle', () => + it('should return correct bounds when stacked with circle', function () { const graphics = new PIXI.Graphics(); @@ -88,7 +88,7 @@ expect(graphics.height).to.be.equals(100); }); - it('should return correct bounds when square', () => + it('should return correct bounds when square', function () { const graphics = new PIXI.Graphics(); @@ -104,9 +104,9 @@ }); }); - describe('containsPoint', () => + describe('containsPoint', function () { - it('should return true when point inside', () => + it('should return true when point inside', function () { const point = new PIXI.Point(1, 1); const graphics = new PIXI.Graphics(); @@ -117,7 +117,7 @@ expect(graphics.containsPoint(point)).to.be.true; }); - it('should return false when point outside', () => + it('should return false when point outside', function () { const point = new PIXI.Point(20, 20); const graphics = new PIXI.Graphics(); @@ -129,9 +129,9 @@ }); }); - describe('arc', () => + describe('arc', function () { - it('should draw an arc', () => + it('should draw an arc', function () { const graphics = new PIXI.Graphics(); @@ -142,7 +142,7 @@ expect(graphics.currentPath).to.be.not.null; }); - it('should not throw with other shapes', () => + it('should not throw with other shapes', function () { // complex drawing #1: draw triangle, rounder rect and an arc (issue #3433) const graphics = new PIXI.Graphics(); @@ -169,7 +169,7 @@ expect(() => graphics.arc(300, 100, 20, 0, Math.PI)).to.not.throw(); }); - it('should do nothing when startAngle and endAngle are equal', () => + it('should do nothing when startAngle and endAngle are equal', function () { const graphics = new PIXI.Graphics(); @@ -180,7 +180,7 @@ expect(graphics.currentPath).to.be.null; }); - it('should do nothing if sweep equals zero', () => + it('should do nothing if sweep equals zero', function () { const graphics = new PIXI.Graphics(); @@ -192,9 +192,9 @@ }); }); - describe('_calculateBounds', () => + describe('_calculateBounds', function () { - it('should only call updateLocalBounds once', () => + it('should only call updateLocalBounds once', function () { const graphics = new PIXI.Graphics(); const spy = sinon.spy(graphics, 'updateLocalBounds'); diff --git a/test/core/Polygon.js b/test/core/Polygon.js index 16323cf..24bc6c9 100644 --- a/test/core/Polygon.js +++ b/test/core/Polygon.js @@ -1,17 +1,17 @@ 'use strict'; -describe('PIXI.Polygon', () => +describe('PIXI.Polygon', function () { - describe('constructor', () => + describe('constructor', function () { - it('should accept a spread of values', () => + it('should accept a spread of values', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10); expect(polygon.points.length).to.be.equals(6); }); - it('should accept a spread of points', () => + it('should accept a spread of points', function () { const polygon = new PIXI.Polygon( new PIXI.Point(0, 0), @@ -22,14 +22,14 @@ expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of values', () => + it('should accept an array of values', function () { const polygon = new PIXI.Polygon([0, 0, 10, 0, 0, 10]); expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of points', () => + it('should accept an array of points', function () { const polygon = new PIXI.Polygon([ new PIXI.Point(0, 0), @@ -41,9 +41,9 @@ }); }); - describe('clone', () => + describe('clone', function () { - it('should create a copy', () => + it('should create a copy', function () { const polygon1 = new PIXI.Polygon(0, 0, 10, 0, 0, 10); const polygon2 = polygon1.clone(); @@ -63,9 +63,9 @@ }); }); - describe('close', () => + describe('close', function () { - it('should close the polygon if open', () => + it('should close the polygon if open', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10); @@ -78,7 +78,7 @@ expect(polygon.points[7]).to.be.equals(0); }); - it('should do nothing if already closed', () => + it('should do nothing if already closed', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10, 0, 0); @@ -90,9 +90,9 @@ }); }); - describe('contains', () => + describe('contains', function () { - it('should include points inside', () => + it('should include points inside', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -102,7 +102,7 @@ expect(polygon.contains(9, 9)).to.be.true; }); - it('should exclude bounds', () => + it('should exclude bounds', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -112,7 +112,7 @@ expect(polygon.contains(10, 10)).to.be.false; }); - it('should exclude points outside', () => + it('should exclude points outside', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); diff --git a/test/core/SpriteRenderer.js b/test/core/SpriteRenderer.js index 01e1f81..bfab7db 100644 --- a/test/core/SpriteRenderer.js +++ b/test/core/SpriteRenderer.js @@ -1,8 +1,8 @@ 'use strict'; -describe('SpriteRenderer', () => +describe('SpriteRenderer', function () { - it('can be destroyed', () => + it('can be destroyed', function () { const destroyable = { destroy: sinon.stub() }; const webgl = { @@ -20,7 +20,7 @@ expect(() => renderer.destroy()).to.not.throw(); }); - it('can be destroyed immediately', () => + it('can be destroyed immediately', function () { const webgl = { on: sinon.stub(), diff --git a/test/core/TransformStatic.js b/test/core/TransformStatic.js index bb9607a..e6443a9 100644 --- a/test/core/TransformStatic.js +++ b/test/core/TransformStatic.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.TransformStatic', () => +describe('PIXI.TransformStatic', function () { - describe('setFromMatrix', () => + describe('setFromMatrix', function () { - it('should decompose negative scale into rotation', () => + it('should decompose negative scale into rotation', function () { const eps = 1e-3; @@ -32,7 +32,7 @@ expect(otherTransform.rotation).to.be.closeTo(-5 * Math.PI / 6, eps); }); - it('should decompose mirror into skew', () => + it('should decompose mirror into skew', function () { const eps = 1e-3; @@ -60,7 +60,7 @@ expect(otherTransform.rotation).to.equal(0); }); - it('should apply skew before scale, like in adobe animate and spine', () => + it('should apply skew before scale, like in adobe animate and spine', function () { // this example looks the same in CSS and in pixi, made with pixi-animate by @bigtimebuddy diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index 1e0f270..4c5034f 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -7,8 +7,7 @@ * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded * otherwise black rectangles will be drawn instead. * - * A RenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: * * ```js * let renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); @@ -23,15 +22,16 @@ * renderer.render(sprite, renderTexture); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * - * renderer.render(doc, renderTexture); // Renders to center of renderTexture + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/test/core/Application.js b/test/core/Application.js new file mode 100644 index 0000000..aa726b0 --- /dev/null +++ b/test/core/Application.js @@ -0,0 +1,20 @@ +'use strict'; + +describe('PIXI.Application', function () +{ + it('should generate application', function (done) + { + expect(PIXI.Application).to.be.a.function; + const app = new PIXI.Application(); + + expect(app.stage).to.be.instanceof(PIXI.Container); + expect(app.ticker).to.be.instanceof(PIXI.ticker.Ticker); + expect(app.renderer).to.be.ok; + + app.ticker.addOnce(() => + { + app.destroy(); + done(); + }); + }); +}); diff --git a/test/core/BaseTexture.js b/test/core/BaseTexture.js index a5fd99a..8b93478 100644 --- a/test/core/BaseTexture.js +++ b/test/core/BaseTexture.js @@ -1,10 +1,10 @@ 'use strict'; -describe('BaseTexture', () => +describe('BaseTexture', function () { - describe('updateImageType', () => + describe('updateImageType', function () { - it('should allow no extension', () => + it('should allow no extension', function () { const baseTexture = new PIXI.BaseTexture(); diff --git a/test/core/Container.js b/test/core/Container.js index a88a2e3..8a10b40 100644 --- a/test/core/Container.js +++ b/test/core/Container.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Container', () => +describe('PIXI.Container', function () { - describe('parent', () => + describe('parent', function () { - it('should be present when adding children to Container', () => + it('should be present when adding children to Container', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -16,9 +16,9 @@ }); }); - describe('events', () => + describe('events', function () { - it('should trigger "added" and "removed" events on its children', () => + it('should trigger "added" and "removed" events on its children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -48,9 +48,9 @@ }); }); - describe('addChild', () => + describe('addChild', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -59,7 +59,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChild(child); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -72,9 +72,9 @@ }); }); - describe('removeChildAt', () => + describe('removeChildAt', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -82,7 +82,7 @@ assertRemovedFromParent(parent, null, child, () => { parent.removeChildAt(0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -97,9 +97,9 @@ }); }); - describe('addChildAt', () => + describe('addChildAt', function () { - it('should allow placements at start', () => + it('should allow placements at start', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -111,7 +111,7 @@ expect(container.children[0]).to.be.equals(child); }); - it('should allow placements at end', () => + it('should allow placements at end', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -123,7 +123,7 @@ expect(container.children[1]).to.be.equals(child); }); - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -134,7 +134,7 @@ expect(() => container.addChildAt(child, 2)).to.throw('The index 2 supplied is out of bounds 1'); }); - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -143,7 +143,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChildAt(child, 0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -159,9 +159,9 @@ }); }); - describe('removeChild', () => + describe('removeChild', function () { - it('should ignore non-children', () => + it('should ignore non-children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -173,7 +173,7 @@ expect(container.children.length).to.be.equals(1); }); - it('should remove all children supplied', () => + it('should remove all children supplied', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -188,7 +188,7 @@ expect(container.children.length).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -204,9 +204,9 @@ }); }); - describe('getChildIndex', () => + describe('getChildIndex', function () { - it('should return the correct index', () => + it('should return the correct index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -216,7 +216,7 @@ expect(container.getChildIndex(child)).to.be.equals(1); }); - it('should throw when child does not exist', () => + it('should throw when child does not exist', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -226,9 +226,9 @@ }); }); - describe('getChildAt', () => + describe('getChildAt', function () { - it('should throw when out-of-bounds', () => + it('should throw when out-of-bounds', function () { const container = new PIXI.Container(); @@ -237,9 +237,9 @@ }); }); - describe('setChildIndex', () => + describe('setChildIndex', function () { - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -250,7 +250,7 @@ expect(() => container.setChildIndex(child, 1)).to.throw('The supplied index is out of bounds'); }); - it('should throw when child does not belong', () => + it('should throw when child does not belong', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -261,7 +261,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should set index', () => + it('should set index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -279,7 +279,7 @@ expect(container.children.indexOf(child)).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -295,9 +295,9 @@ }); }); - describe('swapChildren', () => + describe('swapChildren', function () { - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -317,7 +317,7 @@ expect(spy).to.have.been.calledWith(0); }); - it('should not call onChildrenChange if supplied children are equal', () => + it('should not call onChildrenChange if supplied children are equal', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -331,7 +331,7 @@ expect(spy).to.not.have.been.called; }); - it('should throw if children do not belong', () => + it('should throw if children do not belong', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -344,7 +344,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should result in swapped child positions', () => + it('should result in swapped child positions', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -362,9 +362,9 @@ }); }); - describe('render', () => + describe('render', function () { - it('should not render when object not visible', () => + it('should not render when object not visible', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -379,7 +379,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when alpha is zero', () => + it('should not render when alpha is zero', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -394,7 +394,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when object not renderable', () => + it('should not render when object not renderable', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -409,7 +409,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should render children', () => + it('should render children', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -426,9 +426,9 @@ }); }); - describe('removeChildren', () => + describe('removeChildren', function () { - it('should remove all children when no arguments supplied', () => + it('should remove all children when no arguments supplied', function () { const container = new PIXI.Container(); let removed = []; @@ -443,7 +443,7 @@ expect(removed.length).to.be.equals(3); }); - it('should return empty array if no children', () => + it('should return empty array if no children', function () { const container = new PIXI.Container(); const removed = container.removeChildren(); @@ -451,7 +451,7 @@ expect(removed.length).to.be.equals(0); }); - it('should handle a range greater than length', () => + it('should handle a range greater than length', function () { const container = new PIXI.Container(); let removed = []; @@ -462,7 +462,7 @@ expect(removed.length).to.be.equals(1); }); - it('should throw outside acceptable range', () => + it('should throw outside acceptable range', function () { const container = new PIXI.Container(); @@ -477,9 +477,9 @@ }); }); - describe('destroy', () => + describe('destroy', function () { - it('should not destroy children by default', () => + it('should not destroy children by default', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -491,7 +491,7 @@ expect(child.transform).to.not.be.null; }); - it('should allow children destroy', () => + it('should allow children destroy', function () { let container = new PIXI.Container(); let child = new PIXI.DisplayObject(); @@ -515,9 +515,9 @@ }); }); - describe('width', () => + describe('width', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -529,7 +529,7 @@ expect(container.width).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -543,7 +543,7 @@ expect(container.scale.x).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); @@ -555,9 +555,9 @@ }); }); - describe('height', () => + describe('height', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -569,7 +569,7 @@ expect(container.height).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -583,7 +583,7 @@ expect(container.scale.y).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); diff --git a/test/core/DisplayObject.js b/test/core/DisplayObject.js index ebf1195..7826e71 100755 --- a/test/core/DisplayObject.js +++ b/test/core/DisplayObject.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.DisplayObject', () => +describe('PIXI.DisplayObject', function () { - describe('constructor', () => + describe('constructor', function () { - it('should initialise properties', () => + it('should initialise properties', function () { const object = new PIXI.DisplayObject(); @@ -14,7 +14,7 @@ expect(object.visible).to.be.true; }); - it('should set the correct Transform', () => + it('should set the correct Transform', function () { PIXI.settings.TRANSFORM_MODE = PIXI.TRANSFORM_MODE.DYNAMIC; @@ -30,9 +30,9 @@ }); }); - describe('setParent', () => + describe('setParent', function () { - it('should add itself to a Container', () => + it('should add itself to a Container', function () { const child = new PIXI.DisplayObject(); const container = new PIXI.Container(); @@ -43,7 +43,7 @@ expect(child.parent).to.equal(container); }); - it('should throw if not Container', () => + it('should throw if not Container', function () { const child = new PIXI.DisplayObject(); const notAContainer = {}; @@ -53,9 +53,9 @@ }); }); - describe('setTransform', () => + describe('setTransform', function () { - it('should set correct properties', () => + it('should set correct properties', function () { const object = new PIXI.DisplayObject(); @@ -72,7 +72,7 @@ expect(object.pivot.y).to.be.equal(9); }); - it('should convert zero scale to one', () => + it('should convert zero scale to one', function () { const object = new PIXI.DisplayObject(); @@ -83,9 +83,9 @@ }); }); - describe('worldVisible', () => + describe('worldVisible', function () { - it('should traverse parents', () => + it('should traverse parents', function () { const grandParent = new PIXI.Container(); const parent = new PIXI.Container(); diff --git a/test/core/Graphics.js b/test/core/Graphics.js index 50f775b..2a64946 100644 --- a/test/core/Graphics.js +++ b/test/core/Graphics.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Graphics', () => +describe('PIXI.Graphics', function () { - describe('constructor', () => + describe('constructor', function () { - it('should set defaults', () => + it('should set defaults', function () { const graphics = new PIXI.Graphics(); @@ -16,9 +16,9 @@ }); }); - describe('lineTo', () => + describe('lineTo', function () { - it('should return correct bounds - north', () => + it('should return correct bounds - north', function () { const graphics = new PIXI.Graphics(); @@ -31,7 +31,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - south', () => + it('should return correct bounds - south', function () { const graphics = new PIXI.Graphics(); @@ -44,7 +44,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - east', () => + it('should return correct bounds - east', function () { const graphics = new PIXI.Graphics(); @@ -56,7 +56,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds - west', () => + it('should return correct bounds - west', function () { const graphics = new PIXI.Graphics(); @@ -69,7 +69,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds when stacked with circle', () => + it('should return correct bounds when stacked with circle', function () { const graphics = new PIXI.Graphics(); @@ -88,7 +88,7 @@ expect(graphics.height).to.be.equals(100); }); - it('should return correct bounds when square', () => + it('should return correct bounds when square', function () { const graphics = new PIXI.Graphics(); @@ -104,9 +104,9 @@ }); }); - describe('containsPoint', () => + describe('containsPoint', function () { - it('should return true when point inside', () => + it('should return true when point inside', function () { const point = new PIXI.Point(1, 1); const graphics = new PIXI.Graphics(); @@ -117,7 +117,7 @@ expect(graphics.containsPoint(point)).to.be.true; }); - it('should return false when point outside', () => + it('should return false when point outside', function () { const point = new PIXI.Point(20, 20); const graphics = new PIXI.Graphics(); @@ -129,9 +129,9 @@ }); }); - describe('arc', () => + describe('arc', function () { - it('should draw an arc', () => + it('should draw an arc', function () { const graphics = new PIXI.Graphics(); @@ -142,7 +142,7 @@ expect(graphics.currentPath).to.be.not.null; }); - it('should not throw with other shapes', () => + it('should not throw with other shapes', function () { // complex drawing #1: draw triangle, rounder rect and an arc (issue #3433) const graphics = new PIXI.Graphics(); @@ -169,7 +169,7 @@ expect(() => graphics.arc(300, 100, 20, 0, Math.PI)).to.not.throw(); }); - it('should do nothing when startAngle and endAngle are equal', () => + it('should do nothing when startAngle and endAngle are equal', function () { const graphics = new PIXI.Graphics(); @@ -180,7 +180,7 @@ expect(graphics.currentPath).to.be.null; }); - it('should do nothing if sweep equals zero', () => + it('should do nothing if sweep equals zero', function () { const graphics = new PIXI.Graphics(); @@ -192,9 +192,9 @@ }); }); - describe('_calculateBounds', () => + describe('_calculateBounds', function () { - it('should only call updateLocalBounds once', () => + it('should only call updateLocalBounds once', function () { const graphics = new PIXI.Graphics(); const spy = sinon.spy(graphics, 'updateLocalBounds'); diff --git a/test/core/Polygon.js b/test/core/Polygon.js index 16323cf..24bc6c9 100644 --- a/test/core/Polygon.js +++ b/test/core/Polygon.js @@ -1,17 +1,17 @@ 'use strict'; -describe('PIXI.Polygon', () => +describe('PIXI.Polygon', function () { - describe('constructor', () => + describe('constructor', function () { - it('should accept a spread of values', () => + it('should accept a spread of values', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10); expect(polygon.points.length).to.be.equals(6); }); - it('should accept a spread of points', () => + it('should accept a spread of points', function () { const polygon = new PIXI.Polygon( new PIXI.Point(0, 0), @@ -22,14 +22,14 @@ expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of values', () => + it('should accept an array of values', function () { const polygon = new PIXI.Polygon([0, 0, 10, 0, 0, 10]); expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of points', () => + it('should accept an array of points', function () { const polygon = new PIXI.Polygon([ new PIXI.Point(0, 0), @@ -41,9 +41,9 @@ }); }); - describe('clone', () => + describe('clone', function () { - it('should create a copy', () => + it('should create a copy', function () { const polygon1 = new PIXI.Polygon(0, 0, 10, 0, 0, 10); const polygon2 = polygon1.clone(); @@ -63,9 +63,9 @@ }); }); - describe('close', () => + describe('close', function () { - it('should close the polygon if open', () => + it('should close the polygon if open', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10); @@ -78,7 +78,7 @@ expect(polygon.points[7]).to.be.equals(0); }); - it('should do nothing if already closed', () => + it('should do nothing if already closed', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10, 0, 0); @@ -90,9 +90,9 @@ }); }); - describe('contains', () => + describe('contains', function () { - it('should include points inside', () => + it('should include points inside', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -102,7 +102,7 @@ expect(polygon.contains(9, 9)).to.be.true; }); - it('should exclude bounds', () => + it('should exclude bounds', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -112,7 +112,7 @@ expect(polygon.contains(10, 10)).to.be.false; }); - it('should exclude points outside', () => + it('should exclude points outside', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); diff --git a/test/core/SpriteRenderer.js b/test/core/SpriteRenderer.js index 01e1f81..bfab7db 100644 --- a/test/core/SpriteRenderer.js +++ b/test/core/SpriteRenderer.js @@ -1,8 +1,8 @@ 'use strict'; -describe('SpriteRenderer', () => +describe('SpriteRenderer', function () { - it('can be destroyed', () => + it('can be destroyed', function () { const destroyable = { destroy: sinon.stub() }; const webgl = { @@ -20,7 +20,7 @@ expect(() => renderer.destroy()).to.not.throw(); }); - it('can be destroyed immediately', () => + it('can be destroyed immediately', function () { const webgl = { on: sinon.stub(), diff --git a/test/core/TransformStatic.js b/test/core/TransformStatic.js index bb9607a..e6443a9 100644 --- a/test/core/TransformStatic.js +++ b/test/core/TransformStatic.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.TransformStatic', () => +describe('PIXI.TransformStatic', function () { - describe('setFromMatrix', () => + describe('setFromMatrix', function () { - it('should decompose negative scale into rotation', () => + it('should decompose negative scale into rotation', function () { const eps = 1e-3; @@ -32,7 +32,7 @@ expect(otherTransform.rotation).to.be.closeTo(-5 * Math.PI / 6, eps); }); - it('should decompose mirror into skew', () => + it('should decompose mirror into skew', function () { const eps = 1e-3; @@ -60,7 +60,7 @@ expect(otherTransform.rotation).to.equal(0); }); - it('should apply skew before scale, like in adobe animate and spine', () => + it('should apply skew before scale, like in adobe animate and spine', function () { // this example looks the same in CSS and in pixi, made with pixi-animate by @bigtimebuddy diff --git a/test/core/index.js b/test/core/index.js index 405a557..2a056a2 100755 --- a/test/core/index.js +++ b/test/core/index.js @@ -1,5 +1,6 @@ 'use strict'; +require('./Application'); require('./TransformStatic'); require('./Bounds'); require('./Container'); diff --git a/package.json b/package.json index 27fbfcb..6a366ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "4.3.2", + "version": "4.3.4", "description": "Pixi.js is a fast lightweight 2D library that works across all devices.", "author": "Mat Groves", "contributors": [ @@ -61,7 +61,7 @@ "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", "pixi-gl-core": "^1.0.3", - "resource-loader": "^2.0.3" + "resource-loader": "^2.0.4" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/scripts/renders/client.js b/scripts/renders/client.js index 16c9565..6faee34 100755 --- a/scripts/renders/client.js +++ b/scripts/renders/client.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../bin/pixi'); +require('../../dist/pixi'); PIXI.utils.skipHello(); const fs = require('fs'); diff --git a/src/accessibility/AccessibilityManager.js b/src/accessibility/AccessibilityManager.js index f86d301..df2716a 100644 --- a/src/accessibility/AccessibilityManager.js +++ b/src/accessibility/AccessibilityManager.js @@ -31,7 +31,7 @@ * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility * * @class - * @memberof PIXI + * @memberof PIXI.accessibility */ export default class AccessibilityManager { diff --git a/src/accessibility/accessibleTarget.js b/src/accessibility/accessibleTarget.js index d79575e..4cda116 100644 --- a/src/accessibility/accessibleTarget.js +++ b/src/accessibility/accessibleTarget.js @@ -2,9 +2,8 @@ * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. * - * @mixin - * @name accessibleTarget - * @memberof PIXI + * @function accessibleTarget + * @memberof PIXI.accessibility * @example * function MyObject() {} * diff --git a/src/accessibility/index.js b/src/accessibility/index.js index c9c8718..568cfb1 100644 --- a/src/accessibility/index.js +++ b/src/accessibility/index.js @@ -1,5 +1,5 @@ /** - * @namespace PIXI.AccessibilityManager + * @namespace PIXI.accessibility */ export { default as accessibleTarget } from './accessibleTarget'; export { default as AccessibilityManager } from './AccessibilityManager'; diff --git a/src/core/Application.js b/src/core/Application.js index 1a0eaf2..bc730db 100644 --- a/src/core/Application.js +++ b/src/core/Application.js @@ -54,16 +54,21 @@ */ this.ticker = new Ticker(); - this.ticker.add(() => - { - this.renderer.render(this.stage); - }); + this.ticker.add(this.render, this); // Start the rendering this.start(); } /** + * Render the current stage. + */ + render() + { + this.renderer.render(this.stage); + } + + /** * Convenience method for stopping the render. */ stop() @@ -88,4 +93,21 @@ { return this.renderer.view; } + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + */ + destroy(removeView) + { + this.stop(); + this.ticker.remove(this.render, this); + this.ticker = null; + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + } } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 3affe36..4e6c77d 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -109,7 +109,7 @@ /** * The original, cached mask of the object * - * @member {PIXI.Rectangle} + * @member {PIXI.Graphics|PIXI.Sprite} * @private */ this._mask = null; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 95f2af4..f37f2f5 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1065,10 +1065,15 @@ canvasRenderer = new CanvasRenderer(); } - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + this.transform.updateLocalTransform(); + this.transform.localTransform.copy(tempMatrix); - canvasRenderer.render(this, canvasBuffer, false, tempMatrix); + tempMatrix.invert(); + + tempMatrix.tx -= bounds.x; + tempMatrix.ty -= bounds.y; + + canvasRenderer.render(this, canvasBuffer, true, tempMatrix); const texture = Texture.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode); diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index b86e23d..50c2f31 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -71,8 +71,8 @@ * This is the small part of gameofbombs.com portal system. It works. * * @author Ivan @ivanpopelyshev - * - * @namespace PIXI.GroupD8 + * @class + * @memberof PIXI */ const GroupD8 = { E: 0, @@ -104,7 +104,7 @@ /** * Adds 180 degrees to rotation. Commutative operation. * - * @method + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to rotate. * @returns {number} rotated number */ @@ -113,12 +113,14 @@ /** * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. * + * @memberof PIXI.GroupD8 * @param {number} rotation - The number to check. * @returns {boolean} Whether or not the width/height should be swapped. */ isSwapWidthHeight: (rotation) => (rotation & 3) === 2, /** + * @memberof PIXI.GroupD8 * @param {number} dx - TODO * @param {number} dy - TODO * @@ -164,6 +166,7 @@ /** * Helps sprite to compensate texture packer rotation. * + * @memberof PIXI.GroupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {number} rotation - The rotation factor to use. * @param {number} tx - sprite anchoring diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index ccce680..1bd2d5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -162,6 +162,9 @@ if (transform) { transform.copy(tempWt); + + // lets not forget to flag the parent transform as dirty... + this._tempDisplayObjectParent.transform._worldID = -1; } else { @@ -169,6 +172,7 @@ } displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); displayObject.parent = cacheParent; // displayObject.hitArea = //TODO add a temp hit area diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 5dfc36f..1cf316b 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -4,7 +4,8 @@ /** * Utility methods for Sprite/Texture tinting. * - * @namespace PIXI.CanvasTinter + * @class + * @memberof PIXI */ const CanvasTinter = { /** diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 92b2eb9..5d50146 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -25,18 +25,17 @@ * baseRenderTexture.render(sprite); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); * - * renderer.render(doc, renderTexture); // Renders to center of RenderTexture + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index 1e0f270..4c5034f 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -7,8 +7,7 @@ * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded * otherwise black rectangles will be drawn instead. * - * A RenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: * * ```js * let renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); @@ -23,15 +22,16 @@ * renderer.render(sprite, renderTexture); * ``` * - * The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual - * position a Container should be used: + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform * * ```js - * let doc = new PIXI.Container(); * - * doc.addChild(sprite); + * sprite.setTransform() * - * renderer.render(doc, renderTexture); // Renders to center of renderTexture + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture * ``` * * @class diff --git a/test/core/Application.js b/test/core/Application.js new file mode 100644 index 0000000..aa726b0 --- /dev/null +++ b/test/core/Application.js @@ -0,0 +1,20 @@ +'use strict'; + +describe('PIXI.Application', function () +{ + it('should generate application', function (done) + { + expect(PIXI.Application).to.be.a.function; + const app = new PIXI.Application(); + + expect(app.stage).to.be.instanceof(PIXI.Container); + expect(app.ticker).to.be.instanceof(PIXI.ticker.Ticker); + expect(app.renderer).to.be.ok; + + app.ticker.addOnce(() => + { + app.destroy(); + done(); + }); + }); +}); diff --git a/test/core/BaseTexture.js b/test/core/BaseTexture.js index a5fd99a..8b93478 100644 --- a/test/core/BaseTexture.js +++ b/test/core/BaseTexture.js @@ -1,10 +1,10 @@ 'use strict'; -describe('BaseTexture', () => +describe('BaseTexture', function () { - describe('updateImageType', () => + describe('updateImageType', function () { - it('should allow no extension', () => + it('should allow no extension', function () { const baseTexture = new PIXI.BaseTexture(); diff --git a/test/core/Container.js b/test/core/Container.js index a88a2e3..8a10b40 100644 --- a/test/core/Container.js +++ b/test/core/Container.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Container', () => +describe('PIXI.Container', function () { - describe('parent', () => + describe('parent', function () { - it('should be present when adding children to Container', () => + it('should be present when adding children to Container', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -16,9 +16,9 @@ }); }); - describe('events', () => + describe('events', function () { - it('should trigger "added" and "removed" events on its children', () => + it('should trigger "added" and "removed" events on its children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -48,9 +48,9 @@ }); }); - describe('addChild', () => + describe('addChild', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -59,7 +59,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChild(child); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -72,9 +72,9 @@ }); }); - describe('removeChildAt', () => + describe('removeChildAt', function () { - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -82,7 +82,7 @@ assertRemovedFromParent(parent, null, child, () => { parent.removeChildAt(0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -97,9 +97,9 @@ }); }); - describe('addChildAt', () => + describe('addChildAt', function () { - it('should allow placements at start', () => + it('should allow placements at start', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -111,7 +111,7 @@ expect(container.children[0]).to.be.equals(child); }); - it('should allow placements at end', () => + it('should allow placements at end', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -123,7 +123,7 @@ expect(container.children[1]).to.be.equals(child); }); - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -134,7 +134,7 @@ expect(() => container.addChildAt(child, 2)).to.throw('The index 2 supplied is out of bounds 1'); }); - it('should remove from current parent', () => + it('should remove from current parent', function () { const parent = new PIXI.Container(); const container = new PIXI.Container(); @@ -143,7 +143,7 @@ assertRemovedFromParent(parent, container, child, () => { container.addChildAt(child, 0); }); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -159,9 +159,9 @@ }); }); - describe('removeChild', () => + describe('removeChild', function () { - it('should ignore non-children', () => + it('should ignore non-children', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -173,7 +173,7 @@ expect(container.children.length).to.be.equals(1); }); - it('should remove all children supplied', () => + it('should remove all children supplied', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -188,7 +188,7 @@ expect(container.children.length).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -204,9 +204,9 @@ }); }); - describe('getChildIndex', () => + describe('getChildIndex', function () { - it('should return the correct index', () => + it('should return the correct index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -216,7 +216,7 @@ expect(container.getChildIndex(child)).to.be.equals(1); }); - it('should throw when child does not exist', () => + it('should throw when child does not exist', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -226,9 +226,9 @@ }); }); - describe('getChildAt', () => + describe('getChildAt', function () { - it('should throw when out-of-bounds', () => + it('should throw when out-of-bounds', function () { const container = new PIXI.Container(); @@ -237,9 +237,9 @@ }); }); - describe('setChildIndex', () => + describe('setChildIndex', function () { - it('should throw on out-of-bounds', () => + it('should throw on out-of-bounds', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -250,7 +250,7 @@ expect(() => container.setChildIndex(child, 1)).to.throw('The supplied index is out of bounds'); }); - it('should throw when child does not belong', () => + it('should throw when child does not belong', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -261,7 +261,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should set index', () => + it('should set index', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -279,7 +279,7 @@ expect(container.children.indexOf(child)).to.be.equals(0); }); - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -295,9 +295,9 @@ }); }); - describe('swapChildren', () => + describe('swapChildren', function () { - it('should call onChildrenChange', () => + it('should call onChildrenChange', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -317,7 +317,7 @@ expect(spy).to.have.been.calledWith(0); }); - it('should not call onChildrenChange if supplied children are equal', () => + it('should not call onChildrenChange if supplied children are equal', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -331,7 +331,7 @@ expect(spy).to.not.have.been.called; }); - it('should throw if children do not belong', () => + it('should throw if children do not belong', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -344,7 +344,7 @@ .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should result in swapped child positions', () => + it('should result in swapped child positions', function () { const container = new PIXI.Container(); const child1 = new PIXI.DisplayObject(); @@ -362,9 +362,9 @@ }); }); - describe('render', () => + describe('render', function () { - it('should not render when object not visible', () => + it('should not render when object not visible', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -379,7 +379,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when alpha is zero', () => + it('should not render when alpha is zero', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -394,7 +394,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should not render when object not renderable', () => + it('should not render when object not renderable', function () { const container = new PIXI.Container(); const webGLSpy = sinon.spy(container._renderWebGL); @@ -409,7 +409,7 @@ expect(canvasSpy).to.not.have.been.called; }); - it('should render children', () => + it('should render children', function () { const container = new PIXI.Container(); const child = new PIXI.Container(); @@ -426,9 +426,9 @@ }); }); - describe('removeChildren', () => + describe('removeChildren', function () { - it('should remove all children when no arguments supplied', () => + it('should remove all children when no arguments supplied', function () { const container = new PIXI.Container(); let removed = []; @@ -443,7 +443,7 @@ expect(removed.length).to.be.equals(3); }); - it('should return empty array if no children', () => + it('should return empty array if no children', function () { const container = new PIXI.Container(); const removed = container.removeChildren(); @@ -451,7 +451,7 @@ expect(removed.length).to.be.equals(0); }); - it('should handle a range greater than length', () => + it('should handle a range greater than length', function () { const container = new PIXI.Container(); let removed = []; @@ -462,7 +462,7 @@ expect(removed.length).to.be.equals(1); }); - it('should throw outside acceptable range', () => + it('should throw outside acceptable range', function () { const container = new PIXI.Container(); @@ -477,9 +477,9 @@ }); }); - describe('destroy', () => + describe('destroy', function () { - it('should not destroy children by default', () => + it('should not destroy children by default', function () { const container = new PIXI.Container(); const child = new PIXI.DisplayObject(); @@ -491,7 +491,7 @@ expect(child.transform).to.not.be.null; }); - it('should allow children destroy', () => + it('should allow children destroy', function () { let container = new PIXI.Container(); let child = new PIXI.DisplayObject(); @@ -515,9 +515,9 @@ }); }); - describe('width', () => + describe('width', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -529,7 +529,7 @@ expect(container.width).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -543,7 +543,7 @@ expect(container.scale.x).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); @@ -555,9 +555,9 @@ }); }); - describe('height', () => + describe('height', function () { - it('should reflect scale', () => + it('should reflect scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -569,7 +569,7 @@ expect(container.height).to.be.equals(20); }); - it('should adjust scale', () => + it('should adjust scale', function () { const container = new PIXI.Container(); const graphics = new PIXI.Graphics(); @@ -583,7 +583,7 @@ expect(container.scale.y).to.be.equals(2); }); - it('should reset scale', () => + it('should reset scale', function () { const container = new PIXI.Container(); diff --git a/test/core/DisplayObject.js b/test/core/DisplayObject.js index ebf1195..7826e71 100755 --- a/test/core/DisplayObject.js +++ b/test/core/DisplayObject.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.DisplayObject', () => +describe('PIXI.DisplayObject', function () { - describe('constructor', () => + describe('constructor', function () { - it('should initialise properties', () => + it('should initialise properties', function () { const object = new PIXI.DisplayObject(); @@ -14,7 +14,7 @@ expect(object.visible).to.be.true; }); - it('should set the correct Transform', () => + it('should set the correct Transform', function () { PIXI.settings.TRANSFORM_MODE = PIXI.TRANSFORM_MODE.DYNAMIC; @@ -30,9 +30,9 @@ }); }); - describe('setParent', () => + describe('setParent', function () { - it('should add itself to a Container', () => + it('should add itself to a Container', function () { const child = new PIXI.DisplayObject(); const container = new PIXI.Container(); @@ -43,7 +43,7 @@ expect(child.parent).to.equal(container); }); - it('should throw if not Container', () => + it('should throw if not Container', function () { const child = new PIXI.DisplayObject(); const notAContainer = {}; @@ -53,9 +53,9 @@ }); }); - describe('setTransform', () => + describe('setTransform', function () { - it('should set correct properties', () => + it('should set correct properties', function () { const object = new PIXI.DisplayObject(); @@ -72,7 +72,7 @@ expect(object.pivot.y).to.be.equal(9); }); - it('should convert zero scale to one', () => + it('should convert zero scale to one', function () { const object = new PIXI.DisplayObject(); @@ -83,9 +83,9 @@ }); }); - describe('worldVisible', () => + describe('worldVisible', function () { - it('should traverse parents', () => + it('should traverse parents', function () { const grandParent = new PIXI.Container(); const parent = new PIXI.Container(); diff --git a/test/core/Graphics.js b/test/core/Graphics.js index 50f775b..2a64946 100644 --- a/test/core/Graphics.js +++ b/test/core/Graphics.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.Graphics', () => +describe('PIXI.Graphics', function () { - describe('constructor', () => + describe('constructor', function () { - it('should set defaults', () => + it('should set defaults', function () { const graphics = new PIXI.Graphics(); @@ -16,9 +16,9 @@ }); }); - describe('lineTo', () => + describe('lineTo', function () { - it('should return correct bounds - north', () => + it('should return correct bounds - north', function () { const graphics = new PIXI.Graphics(); @@ -31,7 +31,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - south', () => + it('should return correct bounds - south', function () { const graphics = new PIXI.Graphics(); @@ -44,7 +44,7 @@ expect(graphics.height).to.be.equals(10); }); - it('should return correct bounds - east', () => + it('should return correct bounds - east', function () { const graphics = new PIXI.Graphics(); @@ -56,7 +56,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds - west', () => + it('should return correct bounds - west', function () { const graphics = new PIXI.Graphics(); @@ -69,7 +69,7 @@ expect(graphics.width).to.be.equals(10); }); - it('should return correct bounds when stacked with circle', () => + it('should return correct bounds when stacked with circle', function () { const graphics = new PIXI.Graphics(); @@ -88,7 +88,7 @@ expect(graphics.height).to.be.equals(100); }); - it('should return correct bounds when square', () => + it('should return correct bounds when square', function () { const graphics = new PIXI.Graphics(); @@ -104,9 +104,9 @@ }); }); - describe('containsPoint', () => + describe('containsPoint', function () { - it('should return true when point inside', () => + it('should return true when point inside', function () { const point = new PIXI.Point(1, 1); const graphics = new PIXI.Graphics(); @@ -117,7 +117,7 @@ expect(graphics.containsPoint(point)).to.be.true; }); - it('should return false when point outside', () => + it('should return false when point outside', function () { const point = new PIXI.Point(20, 20); const graphics = new PIXI.Graphics(); @@ -129,9 +129,9 @@ }); }); - describe('arc', () => + describe('arc', function () { - it('should draw an arc', () => + it('should draw an arc', function () { const graphics = new PIXI.Graphics(); @@ -142,7 +142,7 @@ expect(graphics.currentPath).to.be.not.null; }); - it('should not throw with other shapes', () => + it('should not throw with other shapes', function () { // complex drawing #1: draw triangle, rounder rect and an arc (issue #3433) const graphics = new PIXI.Graphics(); @@ -169,7 +169,7 @@ expect(() => graphics.arc(300, 100, 20, 0, Math.PI)).to.not.throw(); }); - it('should do nothing when startAngle and endAngle are equal', () => + it('should do nothing when startAngle and endAngle are equal', function () { const graphics = new PIXI.Graphics(); @@ -180,7 +180,7 @@ expect(graphics.currentPath).to.be.null; }); - it('should do nothing if sweep equals zero', () => + it('should do nothing if sweep equals zero', function () { const graphics = new PIXI.Graphics(); @@ -192,9 +192,9 @@ }); }); - describe('_calculateBounds', () => + describe('_calculateBounds', function () { - it('should only call updateLocalBounds once', () => + it('should only call updateLocalBounds once', function () { const graphics = new PIXI.Graphics(); const spy = sinon.spy(graphics, 'updateLocalBounds'); diff --git a/test/core/Polygon.js b/test/core/Polygon.js index 16323cf..24bc6c9 100644 --- a/test/core/Polygon.js +++ b/test/core/Polygon.js @@ -1,17 +1,17 @@ 'use strict'; -describe('PIXI.Polygon', () => +describe('PIXI.Polygon', function () { - describe('constructor', () => + describe('constructor', function () { - it('should accept a spread of values', () => + it('should accept a spread of values', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10); expect(polygon.points.length).to.be.equals(6); }); - it('should accept a spread of points', () => + it('should accept a spread of points', function () { const polygon = new PIXI.Polygon( new PIXI.Point(0, 0), @@ -22,14 +22,14 @@ expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of values', () => + it('should accept an array of values', function () { const polygon = new PIXI.Polygon([0, 0, 10, 0, 0, 10]); expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of points', () => + it('should accept an array of points', function () { const polygon = new PIXI.Polygon([ new PIXI.Point(0, 0), @@ -41,9 +41,9 @@ }); }); - describe('clone', () => + describe('clone', function () { - it('should create a copy', () => + it('should create a copy', function () { const polygon1 = new PIXI.Polygon(0, 0, 10, 0, 0, 10); const polygon2 = polygon1.clone(); @@ -63,9 +63,9 @@ }); }); - describe('close', () => + describe('close', function () { - it('should close the polygon if open', () => + it('should close the polygon if open', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10); @@ -78,7 +78,7 @@ expect(polygon.points[7]).to.be.equals(0); }); - it('should do nothing if already closed', () => + it('should do nothing if already closed', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 0, 10, 0, 0); @@ -90,9 +90,9 @@ }); }); - describe('contains', () => + describe('contains', function () { - it('should include points inside', () => + it('should include points inside', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -102,7 +102,7 @@ expect(polygon.contains(9, 9)).to.be.true; }); - it('should exclude bounds', () => + it('should exclude bounds', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -112,7 +112,7 @@ expect(polygon.contains(10, 10)).to.be.false; }); - it('should exclude points outside', () => + it('should exclude points outside', function () { const polygon = new PIXI.Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); diff --git a/test/core/SpriteRenderer.js b/test/core/SpriteRenderer.js index 01e1f81..bfab7db 100644 --- a/test/core/SpriteRenderer.js +++ b/test/core/SpriteRenderer.js @@ -1,8 +1,8 @@ 'use strict'; -describe('SpriteRenderer', () => +describe('SpriteRenderer', function () { - it('can be destroyed', () => + it('can be destroyed', function () { const destroyable = { destroy: sinon.stub() }; const webgl = { @@ -20,7 +20,7 @@ expect(() => renderer.destroy()).to.not.throw(); }); - it('can be destroyed immediately', () => + it('can be destroyed immediately', function () { const webgl = { on: sinon.stub(), diff --git a/test/core/TransformStatic.js b/test/core/TransformStatic.js index bb9607a..e6443a9 100644 --- a/test/core/TransformStatic.js +++ b/test/core/TransformStatic.js @@ -1,10 +1,10 @@ 'use strict'; -describe('PIXI.TransformStatic', () => +describe('PIXI.TransformStatic', function () { - describe('setFromMatrix', () => + describe('setFromMatrix', function () { - it('should decompose negative scale into rotation', () => + it('should decompose negative scale into rotation', function () { const eps = 1e-3; @@ -32,7 +32,7 @@ expect(otherTransform.rotation).to.be.closeTo(-5 * Math.PI / 6, eps); }); - it('should decompose mirror into skew', () => + it('should decompose mirror into skew', function () { const eps = 1e-3; @@ -60,7 +60,7 @@ expect(otherTransform.rotation).to.equal(0); }); - it('should apply skew before scale, like in adobe animate and spine', () => + it('should apply skew before scale, like in adobe animate and spine', function () { // this example looks the same in CSS and in pixi, made with pixi-animate by @bigtimebuddy diff --git a/test/core/index.js b/test/core/index.js index 405a557..2a056a2 100755 --- a/test/core/index.js +++ b/test/core/index.js @@ -1,5 +1,6 @@ 'use strict'; +require('./Application'); require('./TransformStatic'); require('./Bounds'); require('./Container'); diff --git a/test/core/util.js b/test/core/util.js index e851c90..dce6003 100755 --- a/test/core/util.js +++ b/test/core/util.js @@ -96,7 +96,7 @@ describe('getUrlFileExtension', function () { - it('should exist', () => + it('should exist', function () { expect(PIXI.utils.getUrlFileExtension) .to.be.a('function');