diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index 81ac225..54d363f 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -1,7 +1,7 @@ import WebGLManager from './WebGLManager'; import RenderTarget from '../utils/RenderTarget'; import Quad from '../utils/Quad'; -import * as math from '../../../math'; +import { Rectangle } from '../../../math'; import Shader from '../../../Shader'; import filterTransforms from '../filters/filterTransforms'; import bitTwiddle from 'bit-twiddle'; @@ -18,8 +18,8 @@ constructor() { this.renderTarget = null; - this.sourceFrame = new math.Rectangle(); - this.destinationFrame = new math.Rectangle(); + this.sourceFrame = new Rectangle(); + this.destinationFrame = new Rectangle(); this.filters = []; this.target = null; this.resolution = 1; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index 81ac225..54d363f 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -1,7 +1,7 @@ import WebGLManager from './WebGLManager'; import RenderTarget from '../utils/RenderTarget'; import Quad from '../utils/Quad'; -import * as math from '../../../math'; +import { Rectangle } from '../../../math'; import Shader from '../../../Shader'; import filterTransforms from '../filters/filterTransforms'; import bitTwiddle from 'bit-twiddle'; @@ -18,8 +18,8 @@ constructor() { this.renderTarget = null; - this.sourceFrame = new math.Rectangle(); - this.destinationFrame = new math.Rectangle(); + this.sourceFrame = new Rectangle(); + this.destinationFrame = new Rectangle(); this.filters = []; this.target = null; this.resolution = 1; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index a356a90..2f84e56 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Rectangle, Matrix } from '../../../math'; import { RESOLUTION, SCALE_MODES } from '../../../const'; import { GLFramebuffer } from 'pixi-gl-core'; @@ -55,7 +55,7 @@ * * @member {PIXI.Rectangle} */ - this.size = new math.Rectangle(0, 0, 1, 1); + this.size = new Rectangle(0, 0, 1, 1); /** * The current resolution / device pixel ratio @@ -70,7 +70,7 @@ * * @member {PIXI.Matrix} */ - this.projectionMatrix = new math.Matrix(); + this.projectionMatrix = new Matrix(); /** * The object's transform @@ -91,7 +91,7 @@ * * @member {glCore.GLBuffer} */ - this.defaultFrame = new math.Rectangle(); + this.defaultFrame = new Rectangle(); this.destinationFrame = null; this.sourceFrame = null; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index 81ac225..54d363f 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -1,7 +1,7 @@ import WebGLManager from './WebGLManager'; import RenderTarget from '../utils/RenderTarget'; import Quad from '../utils/Quad'; -import * as math from '../../../math'; +import { Rectangle } from '../../../math'; import Shader from '../../../Shader'; import filterTransforms from '../filters/filterTransforms'; import bitTwiddle from 'bit-twiddle'; @@ -18,8 +18,8 @@ constructor() { this.renderTarget = null; - this.sourceFrame = new math.Rectangle(); - this.destinationFrame = new math.Rectangle(); + this.sourceFrame = new Rectangle(); + this.destinationFrame = new Rectangle(); this.filters = []; this.target = null; this.resolution = 1; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index a356a90..2f84e56 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Rectangle, Matrix } from '../../../math'; import { RESOLUTION, SCALE_MODES } from '../../../const'; import { GLFramebuffer } from 'pixi-gl-core'; @@ -55,7 +55,7 @@ * * @member {PIXI.Rectangle} */ - this.size = new math.Rectangle(0, 0, 1, 1); + this.size = new Rectangle(0, 0, 1, 1); /** * The current resolution / device pixel ratio @@ -70,7 +70,7 @@ * * @member {PIXI.Matrix} */ - this.projectionMatrix = new math.Matrix(); + this.projectionMatrix = new Matrix(); /** * The object's transform @@ -91,7 +91,7 @@ * * @member {glCore.GLBuffer} */ - this.defaultFrame = new math.Rectangle(); + this.defaultFrame = new Rectangle(); this.destinationFrame = null; this.sourceFrame = null; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index f434b1e..da3c609 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -1,10 +1,10 @@ -import * as math from '../math'; +import { Point, ObservablePoint, Rectangle } from '../math'; +import { sign, TextureCache } from '../utils'; +import { BLEND_MODES } from '../const'; import Texture from '../textures/Texture'; import Container from '../display/Container'; -import * as utils from '../utils'; -import { BLEND_MODES } from '../const'; -const tempPoint = new math.Point(); +const tempPoint = new Point(); /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -37,7 +37,7 @@ * @member {PIXI.ObservablePoint} * @private */ - this._anchor = new math.ObservablePoint(this.onAnchorUpdate, this); + this._anchor = new ObservablePoint(this.onAnchorUpdate, this); /** * The texture that the sprite is using @@ -134,12 +134,12 @@ // so if _width is 0 then width was not set.. if (this._width) { - this.scale.x = utils.sign(this.scale.x) * this._width / this.texture.orig.width; + this.scale.x = sign(this.scale.x) * this._width / this.texture.orig.width; } if (this._height) { - this.scale.y = utils.sign(this.scale.y) * this._height / this.texture.orig.height; + this.scale.y = sign(this.scale.y) * this._height / this.texture.orig.height; } } @@ -339,7 +339,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; @@ -433,7 +433,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -477,9 +477,9 @@ */ set width(value) { - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -501,9 +501,9 @@ */ set height(value) { - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index 81ac225..54d363f 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -1,7 +1,7 @@ import WebGLManager from './WebGLManager'; import RenderTarget from '../utils/RenderTarget'; import Quad from '../utils/Quad'; -import * as math from '../../../math'; +import { Rectangle } from '../../../math'; import Shader from '../../../Shader'; import filterTransforms from '../filters/filterTransforms'; import bitTwiddle from 'bit-twiddle'; @@ -18,8 +18,8 @@ constructor() { this.renderTarget = null; - this.sourceFrame = new math.Rectangle(); - this.destinationFrame = new math.Rectangle(); + this.sourceFrame = new Rectangle(); + this.destinationFrame = new Rectangle(); this.filters = []; this.target = null; this.resolution = 1; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index a356a90..2f84e56 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Rectangle, Matrix } from '../../../math'; import { RESOLUTION, SCALE_MODES } from '../../../const'; import { GLFramebuffer } from 'pixi-gl-core'; @@ -55,7 +55,7 @@ * * @member {PIXI.Rectangle} */ - this.size = new math.Rectangle(0, 0, 1, 1); + this.size = new Rectangle(0, 0, 1, 1); /** * The current resolution / device pixel ratio @@ -70,7 +70,7 @@ * * @member {PIXI.Matrix} */ - this.projectionMatrix = new math.Matrix(); + this.projectionMatrix = new Matrix(); /** * The object's transform @@ -91,7 +91,7 @@ * * @member {glCore.GLBuffer} */ - this.defaultFrame = new math.Rectangle(); + this.defaultFrame = new Rectangle(); this.destinationFrame = null; this.sourceFrame = null; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index f434b1e..da3c609 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -1,10 +1,10 @@ -import * as math from '../math'; +import { Point, ObservablePoint, Rectangle } from '../math'; +import { sign, TextureCache } from '../utils'; +import { BLEND_MODES } from '../const'; import Texture from '../textures/Texture'; import Container from '../display/Container'; -import * as utils from '../utils'; -import { BLEND_MODES } from '../const'; -const tempPoint = new math.Point(); +const tempPoint = new Point(); /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -37,7 +37,7 @@ * @member {PIXI.ObservablePoint} * @private */ - this._anchor = new math.ObservablePoint(this.onAnchorUpdate, this); + this._anchor = new ObservablePoint(this.onAnchorUpdate, this); /** * The texture that the sprite is using @@ -134,12 +134,12 @@ // so if _width is 0 then width was not set.. if (this._width) { - this.scale.x = utils.sign(this.scale.x) * this._width / this.texture.orig.width; + this.scale.x = sign(this.scale.x) * this._width / this.texture.orig.width; } if (this._height) { - this.scale.y = utils.sign(this.scale.y) * this._height / this.texture.orig.height; + this.scale.y = sign(this.scale.y) * this._height / this.texture.orig.height; } } @@ -339,7 +339,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; @@ -433,7 +433,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -477,9 +477,9 @@ */ set width(value) { - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -501,9 +501,9 @@ */ set height(value) { - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/sprites/canvas/CanvasSpriteRenderer.js b/src/core/sprites/canvas/CanvasSpriteRenderer.js index 627f504..b51bb02 100644 --- a/src/core/sprites/canvas/CanvasSpriteRenderer.js +++ b/src/core/sprites/canvas/CanvasSpriteRenderer.js @@ -1,9 +1,9 @@ import CanvasRenderer from '../../renderers/canvas/CanvasRenderer'; import { SCALE_MODES } from '../../const'; -import * as math from '../../math'; +import { Matrix, GroupD8 } from '../../math'; import CanvasTinter from './CanvasTinter'; -const canvasRenderWorldTransform = new math.Matrix(); +const canvasRenderWorldTransform = new Matrix(); /** * @author Mat Groves @@ -87,7 +87,7 @@ { wt.copy(canvasRenderWorldTransform); wt = canvasRenderWorldTransform; - math.GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); + GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); // the anchor has already been applied above, so lets set it to zero dx = 0; dy = 0; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index 81ac225..54d363f 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -1,7 +1,7 @@ import WebGLManager from './WebGLManager'; import RenderTarget from '../utils/RenderTarget'; import Quad from '../utils/Quad'; -import * as math from '../../../math'; +import { Rectangle } from '../../../math'; import Shader from '../../../Shader'; import filterTransforms from '../filters/filterTransforms'; import bitTwiddle from 'bit-twiddle'; @@ -18,8 +18,8 @@ constructor() { this.renderTarget = null; - this.sourceFrame = new math.Rectangle(); - this.destinationFrame = new math.Rectangle(); + this.sourceFrame = new Rectangle(); + this.destinationFrame = new Rectangle(); this.filters = []; this.target = null; this.resolution = 1; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index a356a90..2f84e56 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Rectangle, Matrix } from '../../../math'; import { RESOLUTION, SCALE_MODES } from '../../../const'; import { GLFramebuffer } from 'pixi-gl-core'; @@ -55,7 +55,7 @@ * * @member {PIXI.Rectangle} */ - this.size = new math.Rectangle(0, 0, 1, 1); + this.size = new Rectangle(0, 0, 1, 1); /** * The current resolution / device pixel ratio @@ -70,7 +70,7 @@ * * @member {PIXI.Matrix} */ - this.projectionMatrix = new math.Matrix(); + this.projectionMatrix = new Matrix(); /** * The object's transform @@ -91,7 +91,7 @@ * * @member {glCore.GLBuffer} */ - this.defaultFrame = new math.Rectangle(); + this.defaultFrame = new Rectangle(); this.destinationFrame = null; this.sourceFrame = null; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index f434b1e..da3c609 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -1,10 +1,10 @@ -import * as math from '../math'; +import { Point, ObservablePoint, Rectangle } from '../math'; +import { sign, TextureCache } from '../utils'; +import { BLEND_MODES } from '../const'; import Texture from '../textures/Texture'; import Container from '../display/Container'; -import * as utils from '../utils'; -import { BLEND_MODES } from '../const'; -const tempPoint = new math.Point(); +const tempPoint = new Point(); /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -37,7 +37,7 @@ * @member {PIXI.ObservablePoint} * @private */ - this._anchor = new math.ObservablePoint(this.onAnchorUpdate, this); + this._anchor = new ObservablePoint(this.onAnchorUpdate, this); /** * The texture that the sprite is using @@ -134,12 +134,12 @@ // so if _width is 0 then width was not set.. if (this._width) { - this.scale.x = utils.sign(this.scale.x) * this._width / this.texture.orig.width; + this.scale.x = sign(this.scale.x) * this._width / this.texture.orig.width; } if (this._height) { - this.scale.y = utils.sign(this.scale.y) * this._height / this.texture.orig.height; + this.scale.y = sign(this.scale.y) * this._height / this.texture.orig.height; } } @@ -339,7 +339,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; @@ -433,7 +433,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -477,9 +477,9 @@ */ set width(value) { - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -501,9 +501,9 @@ */ set height(value) { - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/sprites/canvas/CanvasSpriteRenderer.js b/src/core/sprites/canvas/CanvasSpriteRenderer.js index 627f504..b51bb02 100644 --- a/src/core/sprites/canvas/CanvasSpriteRenderer.js +++ b/src/core/sprites/canvas/CanvasSpriteRenderer.js @@ -1,9 +1,9 @@ import CanvasRenderer from '../../renderers/canvas/CanvasRenderer'; import { SCALE_MODES } from '../../const'; -import * as math from '../../math'; +import { Matrix, GroupD8 } from '../../math'; import CanvasTinter from './CanvasTinter'; -const canvasRenderWorldTransform = new math.Matrix(); +const canvasRenderWorldTransform = new Matrix(); /** * @author Mat Groves @@ -87,7 +87,7 @@ { wt.copy(canvasRenderWorldTransform); wt = canvasRenderWorldTransform; - math.GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); + GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); // the anchor has already been applied above, so lets set it to zero dx = 0; dy = 0; diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 6058e3d..5dfc36f 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb, rgb2hex } from '../../utils'; import canUseNewCanvasBlendModes from '../../renderers/canvas/utils/canUseNewCanvasBlendModes'; /** @@ -187,7 +187,7 @@ crop.height ); - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); const r = rgbValues[0]; const g = rgbValues[1]; const b = rgbValues[2]; @@ -217,13 +217,13 @@ { const step = CanvasTinter.cacheStepsPerColorChannel; - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); rgbValues[0] = Math.min(255, (rgbValues[0] / step) * step); rgbValues[1] = Math.min(255, (rgbValues[1] / step) * step); rgbValues[2] = Math.min(255, (rgbValues[2] / step) * step); - return utils.rgb2hex(rgbValues); + return rgb2hex(rgbValues); }, /** diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index 81ac225..54d363f 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -1,7 +1,7 @@ import WebGLManager from './WebGLManager'; import RenderTarget from '../utils/RenderTarget'; import Quad from '../utils/Quad'; -import * as math from '../../../math'; +import { Rectangle } from '../../../math'; import Shader from '../../../Shader'; import filterTransforms from '../filters/filterTransforms'; import bitTwiddle from 'bit-twiddle'; @@ -18,8 +18,8 @@ constructor() { this.renderTarget = null; - this.sourceFrame = new math.Rectangle(); - this.destinationFrame = new math.Rectangle(); + this.sourceFrame = new Rectangle(); + this.destinationFrame = new Rectangle(); this.filters = []; this.target = null; this.resolution = 1; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index a356a90..2f84e56 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Rectangle, Matrix } from '../../../math'; import { RESOLUTION, SCALE_MODES } from '../../../const'; import { GLFramebuffer } from 'pixi-gl-core'; @@ -55,7 +55,7 @@ * * @member {PIXI.Rectangle} */ - this.size = new math.Rectangle(0, 0, 1, 1); + this.size = new Rectangle(0, 0, 1, 1); /** * The current resolution / device pixel ratio @@ -70,7 +70,7 @@ * * @member {PIXI.Matrix} */ - this.projectionMatrix = new math.Matrix(); + this.projectionMatrix = new Matrix(); /** * The object's transform @@ -91,7 +91,7 @@ * * @member {glCore.GLBuffer} */ - this.defaultFrame = new math.Rectangle(); + this.defaultFrame = new Rectangle(); this.destinationFrame = null; this.sourceFrame = null; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index f434b1e..da3c609 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -1,10 +1,10 @@ -import * as math from '../math'; +import { Point, ObservablePoint, Rectangle } from '../math'; +import { sign, TextureCache } from '../utils'; +import { BLEND_MODES } from '../const'; import Texture from '../textures/Texture'; import Container from '../display/Container'; -import * as utils from '../utils'; -import { BLEND_MODES } from '../const'; -const tempPoint = new math.Point(); +const tempPoint = new Point(); /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -37,7 +37,7 @@ * @member {PIXI.ObservablePoint} * @private */ - this._anchor = new math.ObservablePoint(this.onAnchorUpdate, this); + this._anchor = new ObservablePoint(this.onAnchorUpdate, this); /** * The texture that the sprite is using @@ -134,12 +134,12 @@ // so if _width is 0 then width was not set.. if (this._width) { - this.scale.x = utils.sign(this.scale.x) * this._width / this.texture.orig.width; + this.scale.x = sign(this.scale.x) * this._width / this.texture.orig.width; } if (this._height) { - this.scale.y = utils.sign(this.scale.y) * this._height / this.texture.orig.height; + this.scale.y = sign(this.scale.y) * this._height / this.texture.orig.height; } } @@ -339,7 +339,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; @@ -433,7 +433,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -477,9 +477,9 @@ */ set width(value) { - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -501,9 +501,9 @@ */ set height(value) { - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/sprites/canvas/CanvasSpriteRenderer.js b/src/core/sprites/canvas/CanvasSpriteRenderer.js index 627f504..b51bb02 100644 --- a/src/core/sprites/canvas/CanvasSpriteRenderer.js +++ b/src/core/sprites/canvas/CanvasSpriteRenderer.js @@ -1,9 +1,9 @@ import CanvasRenderer from '../../renderers/canvas/CanvasRenderer'; import { SCALE_MODES } from '../../const'; -import * as math from '../../math'; +import { Matrix, GroupD8 } from '../../math'; import CanvasTinter from './CanvasTinter'; -const canvasRenderWorldTransform = new math.Matrix(); +const canvasRenderWorldTransform = new Matrix(); /** * @author Mat Groves @@ -87,7 +87,7 @@ { wt.copy(canvasRenderWorldTransform); wt = canvasRenderWorldTransform; - math.GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); + GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); // the anchor has already been applied above, so lets set it to zero dx = 0; dy = 0; diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 6058e3d..5dfc36f 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb, rgb2hex } from '../../utils'; import canUseNewCanvasBlendModes from '../../renderers/canvas/utils/canUseNewCanvasBlendModes'; /** @@ -187,7 +187,7 @@ crop.height ); - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); const r = rgbValues[0]; const g = rgbValues[1]; const b = rgbValues[2]; @@ -217,13 +217,13 @@ { const step = CanvasTinter.cacheStepsPerColorChannel; - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); rgbValues[0] = Math.min(255, (rgbValues[0] / step) * step); rgbValues[1] = Math.min(255, (rgbValues[1] / step) * step); rgbValues[2] = Math.min(255, (rgbValues[2] / step) * step); - return utils.rgb2hex(rgbValues); + return rgb2hex(rgbValues); }, /** diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 02c72b9..38841dd 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -1,8 +1,8 @@ /* eslint max-depth: [2, 8] */ import Sprite from '../sprites/Sprite'; import Texture from '../textures/Texture'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Rectangle } from '../math'; +import { sign } from '../utils'; import { TEXT_GRADIENT, RESOLUTION } from '../const'; import TextStyle from './TextStyle'; @@ -37,8 +37,8 @@ const canvas = document.createElement('canvas'); const texture = Texture.fromCanvas(canvas); - texture.orig = new math.Rectangle(); - texture.trim = new math.Rectangle(); + texture.orig = new Rectangle(); + texture.trim = new Rectangle(); super(texture); @@ -719,9 +719,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -747,9 +747,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index 81ac225..54d363f 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -1,7 +1,7 @@ import WebGLManager from './WebGLManager'; import RenderTarget from '../utils/RenderTarget'; import Quad from '../utils/Quad'; -import * as math from '../../../math'; +import { Rectangle } from '../../../math'; import Shader from '../../../Shader'; import filterTransforms from '../filters/filterTransforms'; import bitTwiddle from 'bit-twiddle'; @@ -18,8 +18,8 @@ constructor() { this.renderTarget = null; - this.sourceFrame = new math.Rectangle(); - this.destinationFrame = new math.Rectangle(); + this.sourceFrame = new Rectangle(); + this.destinationFrame = new Rectangle(); this.filters = []; this.target = null; this.resolution = 1; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index a356a90..2f84e56 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Rectangle, Matrix } from '../../../math'; import { RESOLUTION, SCALE_MODES } from '../../../const'; import { GLFramebuffer } from 'pixi-gl-core'; @@ -55,7 +55,7 @@ * * @member {PIXI.Rectangle} */ - this.size = new math.Rectangle(0, 0, 1, 1); + this.size = new Rectangle(0, 0, 1, 1); /** * The current resolution / device pixel ratio @@ -70,7 +70,7 @@ * * @member {PIXI.Matrix} */ - this.projectionMatrix = new math.Matrix(); + this.projectionMatrix = new Matrix(); /** * The object's transform @@ -91,7 +91,7 @@ * * @member {glCore.GLBuffer} */ - this.defaultFrame = new math.Rectangle(); + this.defaultFrame = new Rectangle(); this.destinationFrame = null; this.sourceFrame = null; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index f434b1e..da3c609 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -1,10 +1,10 @@ -import * as math from '../math'; +import { Point, ObservablePoint, Rectangle } from '../math'; +import { sign, TextureCache } from '../utils'; +import { BLEND_MODES } from '../const'; import Texture from '../textures/Texture'; import Container from '../display/Container'; -import * as utils from '../utils'; -import { BLEND_MODES } from '../const'; -const tempPoint = new math.Point(); +const tempPoint = new Point(); /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -37,7 +37,7 @@ * @member {PIXI.ObservablePoint} * @private */ - this._anchor = new math.ObservablePoint(this.onAnchorUpdate, this); + this._anchor = new ObservablePoint(this.onAnchorUpdate, this); /** * The texture that the sprite is using @@ -134,12 +134,12 @@ // so if _width is 0 then width was not set.. if (this._width) { - this.scale.x = utils.sign(this.scale.x) * this._width / this.texture.orig.width; + this.scale.x = sign(this.scale.x) * this._width / this.texture.orig.width; } if (this._height) { - this.scale.y = utils.sign(this.scale.y) * this._height / this.texture.orig.height; + this.scale.y = sign(this.scale.y) * this._height / this.texture.orig.height; } } @@ -339,7 +339,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; @@ -433,7 +433,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -477,9 +477,9 @@ */ set width(value) { - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -501,9 +501,9 @@ */ set height(value) { - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/sprites/canvas/CanvasSpriteRenderer.js b/src/core/sprites/canvas/CanvasSpriteRenderer.js index 627f504..b51bb02 100644 --- a/src/core/sprites/canvas/CanvasSpriteRenderer.js +++ b/src/core/sprites/canvas/CanvasSpriteRenderer.js @@ -1,9 +1,9 @@ import CanvasRenderer from '../../renderers/canvas/CanvasRenderer'; import { SCALE_MODES } from '../../const'; -import * as math from '../../math'; +import { Matrix, GroupD8 } from '../../math'; import CanvasTinter from './CanvasTinter'; -const canvasRenderWorldTransform = new math.Matrix(); +const canvasRenderWorldTransform = new Matrix(); /** * @author Mat Groves @@ -87,7 +87,7 @@ { wt.copy(canvasRenderWorldTransform); wt = canvasRenderWorldTransform; - math.GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); + GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); // the anchor has already been applied above, so lets set it to zero dx = 0; dy = 0; diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 6058e3d..5dfc36f 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb, rgb2hex } from '../../utils'; import canUseNewCanvasBlendModes from '../../renderers/canvas/utils/canUseNewCanvasBlendModes'; /** @@ -187,7 +187,7 @@ crop.height ); - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); const r = rgbValues[0]; const g = rgbValues[1]; const b = rgbValues[2]; @@ -217,13 +217,13 @@ { const step = CanvasTinter.cacheStepsPerColorChannel; - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); rgbValues[0] = Math.min(255, (rgbValues[0] / step) * step); rgbValues[1] = Math.min(255, (rgbValues[1] / step) * step); rgbValues[2] = Math.min(255, (rgbValues[2] / step) * step); - return utils.rgb2hex(rgbValues); + return rgb2hex(rgbValues); }, /** diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 02c72b9..38841dd 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -1,8 +1,8 @@ /* eslint max-depth: [2, 8] */ import Sprite from '../sprites/Sprite'; import Texture from '../textures/Texture'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Rectangle } from '../math'; +import { sign } from '../utils'; import { TEXT_GRADIENT, RESOLUTION } from '../const'; import TextStyle from './TextStyle'; @@ -37,8 +37,8 @@ const canvas = document.createElement('canvas'); const texture = Texture.fromCanvas(canvas); - texture.orig = new math.Rectangle(); - texture.trim = new math.Rectangle(); + texture.orig = new Rectangle(); + texture.trim = new Rectangle(); super(texture); @@ -719,9 +719,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -747,9 +747,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/text/TextStyle.js b/src/core/text/TextStyle.js index ba6d2fc..20d4a0a 100644 --- a/src/core/text/TextStyle.js +++ b/src/core/text/TextStyle.js @@ -2,7 +2,7 @@ /* eslint-disable */ import { TEXT_GRADIENT } from '../const'; -import * as utils from '../utils'; +import { hex2string } from '../utils'; const defaultStyle = { align: 'left', @@ -439,7 +439,7 @@ { if (typeof color === 'number') { - return utils.hex2string(color); + return hex2string(color); } else if (Array.isArray(color)) { @@ -447,7 +447,7 @@ { if (typeof color[i] === 'number') { - color[i] = utils.hex2string(color[i]); + color[i] = hex2string(color[i]); } } } diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index 81ac225..54d363f 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -1,7 +1,7 @@ import WebGLManager from './WebGLManager'; import RenderTarget from '../utils/RenderTarget'; import Quad from '../utils/Quad'; -import * as math from '../../../math'; +import { Rectangle } from '../../../math'; import Shader from '../../../Shader'; import filterTransforms from '../filters/filterTransforms'; import bitTwiddle from 'bit-twiddle'; @@ -18,8 +18,8 @@ constructor() { this.renderTarget = null; - this.sourceFrame = new math.Rectangle(); - this.destinationFrame = new math.Rectangle(); + this.sourceFrame = new Rectangle(); + this.destinationFrame = new Rectangle(); this.filters = []; this.target = null; this.resolution = 1; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index a356a90..2f84e56 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Rectangle, Matrix } from '../../../math'; import { RESOLUTION, SCALE_MODES } from '../../../const'; import { GLFramebuffer } from 'pixi-gl-core'; @@ -55,7 +55,7 @@ * * @member {PIXI.Rectangle} */ - this.size = new math.Rectangle(0, 0, 1, 1); + this.size = new Rectangle(0, 0, 1, 1); /** * The current resolution / device pixel ratio @@ -70,7 +70,7 @@ * * @member {PIXI.Matrix} */ - this.projectionMatrix = new math.Matrix(); + this.projectionMatrix = new Matrix(); /** * The object's transform @@ -91,7 +91,7 @@ * * @member {glCore.GLBuffer} */ - this.defaultFrame = new math.Rectangle(); + this.defaultFrame = new Rectangle(); this.destinationFrame = null; this.sourceFrame = null; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index f434b1e..da3c609 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -1,10 +1,10 @@ -import * as math from '../math'; +import { Point, ObservablePoint, Rectangle } from '../math'; +import { sign, TextureCache } from '../utils'; +import { BLEND_MODES } from '../const'; import Texture from '../textures/Texture'; import Container from '../display/Container'; -import * as utils from '../utils'; -import { BLEND_MODES } from '../const'; -const tempPoint = new math.Point(); +const tempPoint = new Point(); /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -37,7 +37,7 @@ * @member {PIXI.ObservablePoint} * @private */ - this._anchor = new math.ObservablePoint(this.onAnchorUpdate, this); + this._anchor = new ObservablePoint(this.onAnchorUpdate, this); /** * The texture that the sprite is using @@ -134,12 +134,12 @@ // so if _width is 0 then width was not set.. if (this._width) { - this.scale.x = utils.sign(this.scale.x) * this._width / this.texture.orig.width; + this.scale.x = sign(this.scale.x) * this._width / this.texture.orig.width; } if (this._height) { - this.scale.y = utils.sign(this.scale.y) * this._height / this.texture.orig.height; + this.scale.y = sign(this.scale.y) * this._height / this.texture.orig.height; } } @@ -339,7 +339,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; @@ -433,7 +433,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -477,9 +477,9 @@ */ set width(value) { - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -501,9 +501,9 @@ */ set height(value) { - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/sprites/canvas/CanvasSpriteRenderer.js b/src/core/sprites/canvas/CanvasSpriteRenderer.js index 627f504..b51bb02 100644 --- a/src/core/sprites/canvas/CanvasSpriteRenderer.js +++ b/src/core/sprites/canvas/CanvasSpriteRenderer.js @@ -1,9 +1,9 @@ import CanvasRenderer from '../../renderers/canvas/CanvasRenderer'; import { SCALE_MODES } from '../../const'; -import * as math from '../../math'; +import { Matrix, GroupD8 } from '../../math'; import CanvasTinter from './CanvasTinter'; -const canvasRenderWorldTransform = new math.Matrix(); +const canvasRenderWorldTransform = new Matrix(); /** * @author Mat Groves @@ -87,7 +87,7 @@ { wt.copy(canvasRenderWorldTransform); wt = canvasRenderWorldTransform; - math.GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); + GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); // the anchor has already been applied above, so lets set it to zero dx = 0; dy = 0; diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 6058e3d..5dfc36f 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb, rgb2hex } from '../../utils'; import canUseNewCanvasBlendModes from '../../renderers/canvas/utils/canUseNewCanvasBlendModes'; /** @@ -187,7 +187,7 @@ crop.height ); - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); const r = rgbValues[0]; const g = rgbValues[1]; const b = rgbValues[2]; @@ -217,13 +217,13 @@ { const step = CanvasTinter.cacheStepsPerColorChannel; - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); rgbValues[0] = Math.min(255, (rgbValues[0] / step) * step); rgbValues[1] = Math.min(255, (rgbValues[1] / step) * step); rgbValues[2] = Math.min(255, (rgbValues[2] / step) * step); - return utils.rgb2hex(rgbValues); + return rgb2hex(rgbValues); }, /** diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 02c72b9..38841dd 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -1,8 +1,8 @@ /* eslint max-depth: [2, 8] */ import Sprite from '../sprites/Sprite'; import Texture from '../textures/Texture'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Rectangle } from '../math'; +import { sign } from '../utils'; import { TEXT_GRADIENT, RESOLUTION } from '../const'; import TextStyle from './TextStyle'; @@ -37,8 +37,8 @@ const canvas = document.createElement('canvas'); const texture = Texture.fromCanvas(canvas); - texture.orig = new math.Rectangle(); - texture.trim = new math.Rectangle(); + texture.orig = new Rectangle(); + texture.trim = new Rectangle(); super(texture); @@ -719,9 +719,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -747,9 +747,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/text/TextStyle.js b/src/core/text/TextStyle.js index ba6d2fc..20d4a0a 100644 --- a/src/core/text/TextStyle.js +++ b/src/core/text/TextStyle.js @@ -2,7 +2,7 @@ /* eslint-disable */ import { TEXT_GRADIENT } from '../const'; -import * as utils from '../utils'; +import { hex2string } from '../utils'; const defaultStyle = { align: 'left', @@ -439,7 +439,7 @@ { if (typeof color === 'number') { - return utils.hex2string(color); + return hex2string(color); } else if (Array.isArray(color)) { @@ -447,7 +447,7 @@ { if (typeof color[i] === 'number') { - color[i] = utils.hex2string(color[i]); + color[i] = hex2string(color[i]); } } } diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 73b1d75..e8ab42a 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -1,4 +1,7 @@ -import * as utils from '../utils'; +import { + uid, getImageTypeOfUrl, decomposeDataUri, getSvgSize, + getResolutionOfUrl, BaseTextureCache, TextureCache, +} from '../utils'; import { RESOLUTION, SCALE_MODES, MIPMAP_TEXTURES, WRAP_MODES } from '../const'; import EventEmitter from 'eventemitter3'; import determineCrossOrigin from '../utils/determineCrossOrigin'; @@ -22,7 +25,7 @@ { super(); - this.uid = utils.uid(); + this.uid = uid(); this.touched = 0; @@ -388,7 +391,7 @@ return; } - const dataUri = utils.decomposeDataUri(this.imageUrl); + const dataUri = decomposeDataUri(this.imageUrl); let imageType; if (dataUri && dataUri.mediaType === 'image') @@ -396,7 +399,7 @@ // Check for subType validity const firstSubType = dataUri.subType.split('+')[0]; - imageType = utils.getImageTypeOfUrl(`.${firstSubType}`); + imageType = getImageTypeOfUrl(`.${firstSubType}`); if (!imageType) { @@ -405,7 +408,7 @@ } else { - imageType = utils.getImageTypeOfUrl(this.imageUrl); + imageType = getImageTypeOfUrl(this.imageUrl); if (!imageType) { @@ -428,7 +431,7 @@ return; } - const dataUri = utils.decomposeDataUri(this.imageUrl); + const dataUri = decomposeDataUri(this.imageUrl); if (dataUri) { @@ -507,7 +510,7 @@ */ _loadSvgSourceUsingString(svgString) { - const svgSize = utils.getSvgSize(svgString); + const svgSize = getSvgSize(svgString); const svgWidth = svgSize.width; const svgHeight = svgSize.height; @@ -532,7 +535,7 @@ canvas.width = this.realWidth; canvas.height = this.realHeight; - canvas._pixiId = `canvas_${utils.uid()}`; + canvas._pixiId = `canvas_${uid()}`; // Draw the Svg to the canvas canvas @@ -544,7 +547,7 @@ this.source = canvas; // Add also the canvas in cache (destroy clears by `imageUrl` and `source._pixiId`) - utils.BaseTextureCache[canvas._pixiId] = this; + BaseTextureCache[canvas._pixiId] = this; this.isLoading = false; this._sourceLoaded(); @@ -571,8 +574,8 @@ { if (this.imageUrl) { - delete utils.BaseTextureCache[this.imageUrl]; - delete utils.TextureCache[this.imageUrl]; + delete BaseTextureCache[this.imageUrl]; + delete TextureCache[this.imageUrl]; this.imageUrl = null; @@ -584,7 +587,7 @@ // An svg source has both `imageUrl` and `__pixiId`, so no `else if` here if (this.source && this.source._pixiId) { - delete utils.BaseTextureCache[this.source._pixiId]; + delete BaseTextureCache[this.source._pixiId]; } this.source = null; @@ -632,7 +635,7 @@ */ static fromImage(imageUrl, crossorigin, scaleMode, sourceScale) { - let baseTexture = utils.BaseTextureCache[imageUrl]; + let baseTexture = BaseTextureCache[imageUrl]; if (!baseTexture) { @@ -654,11 +657,11 @@ } // if there is an @2x at the end of the url we are going to assume its a highres image - baseTexture.resolution = utils.getResolutionOfUrl(imageUrl); + baseTexture.resolution = getResolutionOfUrl(imageUrl); image.src = imageUrl; // Setting this triggers load - utils.BaseTextureCache[imageUrl] = baseTexture; + BaseTextureCache[imageUrl] = baseTexture; } return baseTexture; @@ -676,15 +679,15 @@ { if (!canvas._pixiId) { - canvas._pixiId = `canvas_${utils.uid()}`; + canvas._pixiId = `canvas_${uid()}`; } - let baseTexture = utils.BaseTextureCache[canvas._pixiId]; + let baseTexture = BaseTextureCache[canvas._pixiId]; if (!baseTexture) { baseTexture = new BaseTexture(canvas, scaleMode); - utils.BaseTextureCache[canvas._pixiId] = baseTexture; + BaseTextureCache[canvas._pixiId] = baseTexture; } return baseTexture; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index 81ac225..54d363f 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -1,7 +1,7 @@ import WebGLManager from './WebGLManager'; import RenderTarget from '../utils/RenderTarget'; import Quad from '../utils/Quad'; -import * as math from '../../../math'; +import { Rectangle } from '../../../math'; import Shader from '../../../Shader'; import filterTransforms from '../filters/filterTransforms'; import bitTwiddle from 'bit-twiddle'; @@ -18,8 +18,8 @@ constructor() { this.renderTarget = null; - this.sourceFrame = new math.Rectangle(); - this.destinationFrame = new math.Rectangle(); + this.sourceFrame = new Rectangle(); + this.destinationFrame = new Rectangle(); this.filters = []; this.target = null; this.resolution = 1; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index a356a90..2f84e56 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Rectangle, Matrix } from '../../../math'; import { RESOLUTION, SCALE_MODES } from '../../../const'; import { GLFramebuffer } from 'pixi-gl-core'; @@ -55,7 +55,7 @@ * * @member {PIXI.Rectangle} */ - this.size = new math.Rectangle(0, 0, 1, 1); + this.size = new Rectangle(0, 0, 1, 1); /** * The current resolution / device pixel ratio @@ -70,7 +70,7 @@ * * @member {PIXI.Matrix} */ - this.projectionMatrix = new math.Matrix(); + this.projectionMatrix = new Matrix(); /** * The object's transform @@ -91,7 +91,7 @@ * * @member {glCore.GLBuffer} */ - this.defaultFrame = new math.Rectangle(); + this.defaultFrame = new Rectangle(); this.destinationFrame = null; this.sourceFrame = null; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index f434b1e..da3c609 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -1,10 +1,10 @@ -import * as math from '../math'; +import { Point, ObservablePoint, Rectangle } from '../math'; +import { sign, TextureCache } from '../utils'; +import { BLEND_MODES } from '../const'; import Texture from '../textures/Texture'; import Container from '../display/Container'; -import * as utils from '../utils'; -import { BLEND_MODES } from '../const'; -const tempPoint = new math.Point(); +const tempPoint = new Point(); /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -37,7 +37,7 @@ * @member {PIXI.ObservablePoint} * @private */ - this._anchor = new math.ObservablePoint(this.onAnchorUpdate, this); + this._anchor = new ObservablePoint(this.onAnchorUpdate, this); /** * The texture that the sprite is using @@ -134,12 +134,12 @@ // so if _width is 0 then width was not set.. if (this._width) { - this.scale.x = utils.sign(this.scale.x) * this._width / this.texture.orig.width; + this.scale.x = sign(this.scale.x) * this._width / this.texture.orig.width; } if (this._height) { - this.scale.y = utils.sign(this.scale.y) * this._height / this.texture.orig.height; + this.scale.y = sign(this.scale.y) * this._height / this.texture.orig.height; } } @@ -339,7 +339,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; @@ -433,7 +433,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -477,9 +477,9 @@ */ set width(value) { - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -501,9 +501,9 @@ */ set height(value) { - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/sprites/canvas/CanvasSpriteRenderer.js b/src/core/sprites/canvas/CanvasSpriteRenderer.js index 627f504..b51bb02 100644 --- a/src/core/sprites/canvas/CanvasSpriteRenderer.js +++ b/src/core/sprites/canvas/CanvasSpriteRenderer.js @@ -1,9 +1,9 @@ import CanvasRenderer from '../../renderers/canvas/CanvasRenderer'; import { SCALE_MODES } from '../../const'; -import * as math from '../../math'; +import { Matrix, GroupD8 } from '../../math'; import CanvasTinter from './CanvasTinter'; -const canvasRenderWorldTransform = new math.Matrix(); +const canvasRenderWorldTransform = new Matrix(); /** * @author Mat Groves @@ -87,7 +87,7 @@ { wt.copy(canvasRenderWorldTransform); wt = canvasRenderWorldTransform; - math.GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); + GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); // the anchor has already been applied above, so lets set it to zero dx = 0; dy = 0; diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 6058e3d..5dfc36f 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb, rgb2hex } from '../../utils'; import canUseNewCanvasBlendModes from '../../renderers/canvas/utils/canUseNewCanvasBlendModes'; /** @@ -187,7 +187,7 @@ crop.height ); - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); const r = rgbValues[0]; const g = rgbValues[1]; const b = rgbValues[2]; @@ -217,13 +217,13 @@ { const step = CanvasTinter.cacheStepsPerColorChannel; - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); rgbValues[0] = Math.min(255, (rgbValues[0] / step) * step); rgbValues[1] = Math.min(255, (rgbValues[1] / step) * step); rgbValues[2] = Math.min(255, (rgbValues[2] / step) * step); - return utils.rgb2hex(rgbValues); + return rgb2hex(rgbValues); }, /** diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 02c72b9..38841dd 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -1,8 +1,8 @@ /* eslint max-depth: [2, 8] */ import Sprite from '../sprites/Sprite'; import Texture from '../textures/Texture'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Rectangle } from '../math'; +import { sign } from '../utils'; import { TEXT_GRADIENT, RESOLUTION } from '../const'; import TextStyle from './TextStyle'; @@ -37,8 +37,8 @@ const canvas = document.createElement('canvas'); const texture = Texture.fromCanvas(canvas); - texture.orig = new math.Rectangle(); - texture.trim = new math.Rectangle(); + texture.orig = new Rectangle(); + texture.trim = new Rectangle(); super(texture); @@ -719,9 +719,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -747,9 +747,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/text/TextStyle.js b/src/core/text/TextStyle.js index ba6d2fc..20d4a0a 100644 --- a/src/core/text/TextStyle.js +++ b/src/core/text/TextStyle.js @@ -2,7 +2,7 @@ /* eslint-disable */ import { TEXT_GRADIENT } from '../const'; -import * as utils from '../utils'; +import { hex2string } from '../utils'; const defaultStyle = { align: 'left', @@ -439,7 +439,7 @@ { if (typeof color === 'number') { - return utils.hex2string(color); + return hex2string(color); } else if (Array.isArray(color)) { @@ -447,7 +447,7 @@ { if (typeof color[i] === 'number') { - color[i] = utils.hex2string(color[i]); + color[i] = hex2string(color[i]); } } } diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 73b1d75..e8ab42a 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -1,4 +1,7 @@ -import * as utils from '../utils'; +import { + uid, getImageTypeOfUrl, decomposeDataUri, getSvgSize, + getResolutionOfUrl, BaseTextureCache, TextureCache, +} from '../utils'; import { RESOLUTION, SCALE_MODES, MIPMAP_TEXTURES, WRAP_MODES } from '../const'; import EventEmitter from 'eventemitter3'; import determineCrossOrigin from '../utils/determineCrossOrigin'; @@ -22,7 +25,7 @@ { super(); - this.uid = utils.uid(); + this.uid = uid(); this.touched = 0; @@ -388,7 +391,7 @@ return; } - const dataUri = utils.decomposeDataUri(this.imageUrl); + const dataUri = decomposeDataUri(this.imageUrl); let imageType; if (dataUri && dataUri.mediaType === 'image') @@ -396,7 +399,7 @@ // Check for subType validity const firstSubType = dataUri.subType.split('+')[0]; - imageType = utils.getImageTypeOfUrl(`.${firstSubType}`); + imageType = getImageTypeOfUrl(`.${firstSubType}`); if (!imageType) { @@ -405,7 +408,7 @@ } else { - imageType = utils.getImageTypeOfUrl(this.imageUrl); + imageType = getImageTypeOfUrl(this.imageUrl); if (!imageType) { @@ -428,7 +431,7 @@ return; } - const dataUri = utils.decomposeDataUri(this.imageUrl); + const dataUri = decomposeDataUri(this.imageUrl); if (dataUri) { @@ -507,7 +510,7 @@ */ _loadSvgSourceUsingString(svgString) { - const svgSize = utils.getSvgSize(svgString); + const svgSize = getSvgSize(svgString); const svgWidth = svgSize.width; const svgHeight = svgSize.height; @@ -532,7 +535,7 @@ canvas.width = this.realWidth; canvas.height = this.realHeight; - canvas._pixiId = `canvas_${utils.uid()}`; + canvas._pixiId = `canvas_${uid()}`; // Draw the Svg to the canvas canvas @@ -544,7 +547,7 @@ this.source = canvas; // Add also the canvas in cache (destroy clears by `imageUrl` and `source._pixiId`) - utils.BaseTextureCache[canvas._pixiId] = this; + BaseTextureCache[canvas._pixiId] = this; this.isLoading = false; this._sourceLoaded(); @@ -571,8 +574,8 @@ { if (this.imageUrl) { - delete utils.BaseTextureCache[this.imageUrl]; - delete utils.TextureCache[this.imageUrl]; + delete BaseTextureCache[this.imageUrl]; + delete TextureCache[this.imageUrl]; this.imageUrl = null; @@ -584,7 +587,7 @@ // An svg source has both `imageUrl` and `__pixiId`, so no `else if` here if (this.source && this.source._pixiId) { - delete utils.BaseTextureCache[this.source._pixiId]; + delete BaseTextureCache[this.source._pixiId]; } this.source = null; @@ -632,7 +635,7 @@ */ static fromImage(imageUrl, crossorigin, scaleMode, sourceScale) { - let baseTexture = utils.BaseTextureCache[imageUrl]; + let baseTexture = BaseTextureCache[imageUrl]; if (!baseTexture) { @@ -654,11 +657,11 @@ } // if there is an @2x at the end of the url we are going to assume its a highres image - baseTexture.resolution = utils.getResolutionOfUrl(imageUrl); + baseTexture.resolution = getResolutionOfUrl(imageUrl); image.src = imageUrl; // Setting this triggers load - utils.BaseTextureCache[imageUrl] = baseTexture; + BaseTextureCache[imageUrl] = baseTexture; } return baseTexture; @@ -676,15 +679,15 @@ { if (!canvas._pixiId) { - canvas._pixiId = `canvas_${utils.uid()}`; + canvas._pixiId = `canvas_${uid()}`; } - let baseTexture = utils.BaseTextureCache[canvas._pixiId]; + let baseTexture = BaseTextureCache[canvas._pixiId]; if (!baseTexture) { baseTexture = new BaseTexture(canvas, scaleMode); - utils.BaseTextureCache[canvas._pixiId] = baseTexture; + BaseTextureCache[canvas._pixiId] = baseTexture; } return baseTexture; diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 605a5c5..62104c1 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -2,8 +2,8 @@ import VideoBaseTexture from './VideoBaseTexture'; import TextureUvs from './TextureUvs'; import EventEmitter from 'eventemitter3'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Rectangle } from '../math'; +import { TextureCache, BaseTextureCache } from '../utils'; /** * A texture stores the information that represents an image or part of an image. It cannot be added @@ -45,7 +45,7 @@ if (!frame) { this.noFrame = true; - frame = new math.Rectangle(0, 0, 1, 1); + frame = new Rectangle(0, 0, 1, 1); } if (baseTexture instanceof Texture) @@ -102,7 +102,7 @@ * * @member {PIXI.Rectangle} */ - this.orig = orig || frame;// new math.Rectangle(0, 0, 1, 1); + this.orig = orig || frame;// new Rectangle(0, 0, 1, 1); this._rotate = Number(rotate || 0); @@ -120,7 +120,7 @@ { if (this.noFrame) { - frame = new math.Rectangle(0, 0, baseTexture.width, baseTexture.height); + frame = new Rectangle(0, 0, baseTexture.width, baseTexture.height); // if there is no frame we should monitor for any base texture changes.. baseTexture.on('update', this.onBaseTextureUpdated, this); @@ -165,7 +165,7 @@ // TODO this code looks confusing.. boo to abusing getters and setterss! if (this.noFrame) { - this.frame = new math.Rectangle(0, 0, baseTexture.width, baseTexture.height); + this.frame = new Rectangle(0, 0, baseTexture.width, baseTexture.height); } else { @@ -205,9 +205,9 @@ { // delete the texture if it exists in the texture cache.. // this only needs to be removed if the base texture is actually destoryed too.. - if (utils.TextureCache[this.baseTexture.imageUrl]) + if (TextureCache[this.baseTexture.imageUrl]) { - delete utils.TextureCache[this.baseTexture.imageUrl]; + delete TextureCache[this.baseTexture.imageUrl]; } this.baseTexture.destroy(); @@ -270,12 +270,12 @@ */ static fromImage(imageUrl, crossorigin, scaleMode, sourceScale) { - let texture = utils.TextureCache[imageUrl]; + let texture = TextureCache[imageUrl]; if (!texture) { texture = new Texture(BaseTexture.fromImage(imageUrl, crossorigin, scaleMode, sourceScale)); - utils.TextureCache[imageUrl] = texture; + TextureCache[imageUrl] = texture; } return texture; @@ -291,7 +291,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -359,7 +359,7 @@ // TODO pass in scale mode? if (typeof source === 'string') { - const texture = utils.TextureCache[source]; + const texture = TextureCache[source]; if (!texture) { @@ -394,7 +394,7 @@ } /** - * Adds a texture to the global utils.TextureCache. This cache is shared across the whole PIXI object. + * Adds a texture to the global TextureCache. This cache is shared across the whole PIXI object. * * @static * @param {PIXI.Texture} texture - The Texture to add to the cache. @@ -402,11 +402,11 @@ */ static addTextureToCache(texture, id) { - utils.TextureCache[id] = texture; + TextureCache[id] = texture; } /** - * Remove a texture from the global utils.TextureCache. + * Remove a texture from the global TextureCache. * * @static * @param {string} id - The id of the texture to be removed @@ -414,10 +414,10 @@ */ static removeTextureFromCache(id) { - const texture = utils.TextureCache[id]; + const texture = TextureCache[id]; - delete utils.TextureCache[id]; - delete utils.BaseTextureCache[id]; + delete TextureCache[id]; + delete BaseTextureCache[id]; return texture; } diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index 81ac225..54d363f 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -1,7 +1,7 @@ import WebGLManager from './WebGLManager'; import RenderTarget from '../utils/RenderTarget'; import Quad from '../utils/Quad'; -import * as math from '../../../math'; +import { Rectangle } from '../../../math'; import Shader from '../../../Shader'; import filterTransforms from '../filters/filterTransforms'; import bitTwiddle from 'bit-twiddle'; @@ -18,8 +18,8 @@ constructor() { this.renderTarget = null; - this.sourceFrame = new math.Rectangle(); - this.destinationFrame = new math.Rectangle(); + this.sourceFrame = new Rectangle(); + this.destinationFrame = new Rectangle(); this.filters = []; this.target = null; this.resolution = 1; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index a356a90..2f84e56 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Rectangle, Matrix } from '../../../math'; import { RESOLUTION, SCALE_MODES } from '../../../const'; import { GLFramebuffer } from 'pixi-gl-core'; @@ -55,7 +55,7 @@ * * @member {PIXI.Rectangle} */ - this.size = new math.Rectangle(0, 0, 1, 1); + this.size = new Rectangle(0, 0, 1, 1); /** * The current resolution / device pixel ratio @@ -70,7 +70,7 @@ * * @member {PIXI.Matrix} */ - this.projectionMatrix = new math.Matrix(); + this.projectionMatrix = new Matrix(); /** * The object's transform @@ -91,7 +91,7 @@ * * @member {glCore.GLBuffer} */ - this.defaultFrame = new math.Rectangle(); + this.defaultFrame = new Rectangle(); this.destinationFrame = null; this.sourceFrame = null; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index f434b1e..da3c609 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -1,10 +1,10 @@ -import * as math from '../math'; +import { Point, ObservablePoint, Rectangle } from '../math'; +import { sign, TextureCache } from '../utils'; +import { BLEND_MODES } from '../const'; import Texture from '../textures/Texture'; import Container from '../display/Container'; -import * as utils from '../utils'; -import { BLEND_MODES } from '../const'; -const tempPoint = new math.Point(); +const tempPoint = new Point(); /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -37,7 +37,7 @@ * @member {PIXI.ObservablePoint} * @private */ - this._anchor = new math.ObservablePoint(this.onAnchorUpdate, this); + this._anchor = new ObservablePoint(this.onAnchorUpdate, this); /** * The texture that the sprite is using @@ -134,12 +134,12 @@ // so if _width is 0 then width was not set.. if (this._width) { - this.scale.x = utils.sign(this.scale.x) * this._width / this.texture.orig.width; + this.scale.x = sign(this.scale.x) * this._width / this.texture.orig.width; } if (this._height) { - this.scale.y = utils.sign(this.scale.y) * this._height / this.texture.orig.height; + this.scale.y = sign(this.scale.y) * this._height / this.texture.orig.height; } } @@ -339,7 +339,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; @@ -433,7 +433,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -477,9 +477,9 @@ */ set width(value) { - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -501,9 +501,9 @@ */ set height(value) { - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/sprites/canvas/CanvasSpriteRenderer.js b/src/core/sprites/canvas/CanvasSpriteRenderer.js index 627f504..b51bb02 100644 --- a/src/core/sprites/canvas/CanvasSpriteRenderer.js +++ b/src/core/sprites/canvas/CanvasSpriteRenderer.js @@ -1,9 +1,9 @@ import CanvasRenderer from '../../renderers/canvas/CanvasRenderer'; import { SCALE_MODES } from '../../const'; -import * as math from '../../math'; +import { Matrix, GroupD8 } from '../../math'; import CanvasTinter from './CanvasTinter'; -const canvasRenderWorldTransform = new math.Matrix(); +const canvasRenderWorldTransform = new Matrix(); /** * @author Mat Groves @@ -87,7 +87,7 @@ { wt.copy(canvasRenderWorldTransform); wt = canvasRenderWorldTransform; - math.GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); + GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); // the anchor has already been applied above, so lets set it to zero dx = 0; dy = 0; diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 6058e3d..5dfc36f 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb, rgb2hex } from '../../utils'; import canUseNewCanvasBlendModes from '../../renderers/canvas/utils/canUseNewCanvasBlendModes'; /** @@ -187,7 +187,7 @@ crop.height ); - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); const r = rgbValues[0]; const g = rgbValues[1]; const b = rgbValues[2]; @@ -217,13 +217,13 @@ { const step = CanvasTinter.cacheStepsPerColorChannel; - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); rgbValues[0] = Math.min(255, (rgbValues[0] / step) * step); rgbValues[1] = Math.min(255, (rgbValues[1] / step) * step); rgbValues[2] = Math.min(255, (rgbValues[2] / step) * step); - return utils.rgb2hex(rgbValues); + return rgb2hex(rgbValues); }, /** diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 02c72b9..38841dd 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -1,8 +1,8 @@ /* eslint max-depth: [2, 8] */ import Sprite from '../sprites/Sprite'; import Texture from '../textures/Texture'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Rectangle } from '../math'; +import { sign } from '../utils'; import { TEXT_GRADIENT, RESOLUTION } from '../const'; import TextStyle from './TextStyle'; @@ -37,8 +37,8 @@ const canvas = document.createElement('canvas'); const texture = Texture.fromCanvas(canvas); - texture.orig = new math.Rectangle(); - texture.trim = new math.Rectangle(); + texture.orig = new Rectangle(); + texture.trim = new Rectangle(); super(texture); @@ -719,9 +719,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -747,9 +747,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/text/TextStyle.js b/src/core/text/TextStyle.js index ba6d2fc..20d4a0a 100644 --- a/src/core/text/TextStyle.js +++ b/src/core/text/TextStyle.js @@ -2,7 +2,7 @@ /* eslint-disable */ import { TEXT_GRADIENT } from '../const'; -import * as utils from '../utils'; +import { hex2string } from '../utils'; const defaultStyle = { align: 'left', @@ -439,7 +439,7 @@ { if (typeof color === 'number') { - return utils.hex2string(color); + return hex2string(color); } else if (Array.isArray(color)) { @@ -447,7 +447,7 @@ { if (typeof color[i] === 'number') { - color[i] = utils.hex2string(color[i]); + color[i] = hex2string(color[i]); } } } diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 73b1d75..e8ab42a 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -1,4 +1,7 @@ -import * as utils from '../utils'; +import { + uid, getImageTypeOfUrl, decomposeDataUri, getSvgSize, + getResolutionOfUrl, BaseTextureCache, TextureCache, +} from '../utils'; import { RESOLUTION, SCALE_MODES, MIPMAP_TEXTURES, WRAP_MODES } from '../const'; import EventEmitter from 'eventemitter3'; import determineCrossOrigin from '../utils/determineCrossOrigin'; @@ -22,7 +25,7 @@ { super(); - this.uid = utils.uid(); + this.uid = uid(); this.touched = 0; @@ -388,7 +391,7 @@ return; } - const dataUri = utils.decomposeDataUri(this.imageUrl); + const dataUri = decomposeDataUri(this.imageUrl); let imageType; if (dataUri && dataUri.mediaType === 'image') @@ -396,7 +399,7 @@ // Check for subType validity const firstSubType = dataUri.subType.split('+')[0]; - imageType = utils.getImageTypeOfUrl(`.${firstSubType}`); + imageType = getImageTypeOfUrl(`.${firstSubType}`); if (!imageType) { @@ -405,7 +408,7 @@ } else { - imageType = utils.getImageTypeOfUrl(this.imageUrl); + imageType = getImageTypeOfUrl(this.imageUrl); if (!imageType) { @@ -428,7 +431,7 @@ return; } - const dataUri = utils.decomposeDataUri(this.imageUrl); + const dataUri = decomposeDataUri(this.imageUrl); if (dataUri) { @@ -507,7 +510,7 @@ */ _loadSvgSourceUsingString(svgString) { - const svgSize = utils.getSvgSize(svgString); + const svgSize = getSvgSize(svgString); const svgWidth = svgSize.width; const svgHeight = svgSize.height; @@ -532,7 +535,7 @@ canvas.width = this.realWidth; canvas.height = this.realHeight; - canvas._pixiId = `canvas_${utils.uid()}`; + canvas._pixiId = `canvas_${uid()}`; // Draw the Svg to the canvas canvas @@ -544,7 +547,7 @@ this.source = canvas; // Add also the canvas in cache (destroy clears by `imageUrl` and `source._pixiId`) - utils.BaseTextureCache[canvas._pixiId] = this; + BaseTextureCache[canvas._pixiId] = this; this.isLoading = false; this._sourceLoaded(); @@ -571,8 +574,8 @@ { if (this.imageUrl) { - delete utils.BaseTextureCache[this.imageUrl]; - delete utils.TextureCache[this.imageUrl]; + delete BaseTextureCache[this.imageUrl]; + delete TextureCache[this.imageUrl]; this.imageUrl = null; @@ -584,7 +587,7 @@ // An svg source has both `imageUrl` and `__pixiId`, so no `else if` here if (this.source && this.source._pixiId) { - delete utils.BaseTextureCache[this.source._pixiId]; + delete BaseTextureCache[this.source._pixiId]; } this.source = null; @@ -632,7 +635,7 @@ */ static fromImage(imageUrl, crossorigin, scaleMode, sourceScale) { - let baseTexture = utils.BaseTextureCache[imageUrl]; + let baseTexture = BaseTextureCache[imageUrl]; if (!baseTexture) { @@ -654,11 +657,11 @@ } // if there is an @2x at the end of the url we are going to assume its a highres image - baseTexture.resolution = utils.getResolutionOfUrl(imageUrl); + baseTexture.resolution = getResolutionOfUrl(imageUrl); image.src = imageUrl; // Setting this triggers load - utils.BaseTextureCache[imageUrl] = baseTexture; + BaseTextureCache[imageUrl] = baseTexture; } return baseTexture; @@ -676,15 +679,15 @@ { if (!canvas._pixiId) { - canvas._pixiId = `canvas_${utils.uid()}`; + canvas._pixiId = `canvas_${uid()}`; } - let baseTexture = utils.BaseTextureCache[canvas._pixiId]; + let baseTexture = BaseTextureCache[canvas._pixiId]; if (!baseTexture) { baseTexture = new BaseTexture(canvas, scaleMode); - utils.BaseTextureCache[canvas._pixiId] = baseTexture; + BaseTextureCache[canvas._pixiId] = baseTexture; } return baseTexture; diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 605a5c5..62104c1 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -2,8 +2,8 @@ import VideoBaseTexture from './VideoBaseTexture'; import TextureUvs from './TextureUvs'; import EventEmitter from 'eventemitter3'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Rectangle } from '../math'; +import { TextureCache, BaseTextureCache } from '../utils'; /** * A texture stores the information that represents an image or part of an image. It cannot be added @@ -45,7 +45,7 @@ if (!frame) { this.noFrame = true; - frame = new math.Rectangle(0, 0, 1, 1); + frame = new Rectangle(0, 0, 1, 1); } if (baseTexture instanceof Texture) @@ -102,7 +102,7 @@ * * @member {PIXI.Rectangle} */ - this.orig = orig || frame;// new math.Rectangle(0, 0, 1, 1); + this.orig = orig || frame;// new Rectangle(0, 0, 1, 1); this._rotate = Number(rotate || 0); @@ -120,7 +120,7 @@ { if (this.noFrame) { - frame = new math.Rectangle(0, 0, baseTexture.width, baseTexture.height); + frame = new Rectangle(0, 0, baseTexture.width, baseTexture.height); // if there is no frame we should monitor for any base texture changes.. baseTexture.on('update', this.onBaseTextureUpdated, this); @@ -165,7 +165,7 @@ // TODO this code looks confusing.. boo to abusing getters and setterss! if (this.noFrame) { - this.frame = new math.Rectangle(0, 0, baseTexture.width, baseTexture.height); + this.frame = new Rectangle(0, 0, baseTexture.width, baseTexture.height); } else { @@ -205,9 +205,9 @@ { // delete the texture if it exists in the texture cache.. // this only needs to be removed if the base texture is actually destoryed too.. - if (utils.TextureCache[this.baseTexture.imageUrl]) + if (TextureCache[this.baseTexture.imageUrl]) { - delete utils.TextureCache[this.baseTexture.imageUrl]; + delete TextureCache[this.baseTexture.imageUrl]; } this.baseTexture.destroy(); @@ -270,12 +270,12 @@ */ static fromImage(imageUrl, crossorigin, scaleMode, sourceScale) { - let texture = utils.TextureCache[imageUrl]; + let texture = TextureCache[imageUrl]; if (!texture) { texture = new Texture(BaseTexture.fromImage(imageUrl, crossorigin, scaleMode, sourceScale)); - utils.TextureCache[imageUrl] = texture; + TextureCache[imageUrl] = texture; } return texture; @@ -291,7 +291,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -359,7 +359,7 @@ // TODO pass in scale mode? if (typeof source === 'string') { - const texture = utils.TextureCache[source]; + const texture = TextureCache[source]; if (!texture) { @@ -394,7 +394,7 @@ } /** - * Adds a texture to the global utils.TextureCache. This cache is shared across the whole PIXI object. + * Adds a texture to the global TextureCache. This cache is shared across the whole PIXI object. * * @static * @param {PIXI.Texture} texture - The Texture to add to the cache. @@ -402,11 +402,11 @@ */ static addTextureToCache(texture, id) { - utils.TextureCache[id] = texture; + TextureCache[id] = texture; } /** - * Remove a texture from the global utils.TextureCache. + * Remove a texture from the global TextureCache. * * @static * @param {string} id - The id of the texture to be removed @@ -414,10 +414,10 @@ */ static removeTextureFromCache(id) { - const texture = utils.TextureCache[id]; + const texture = TextureCache[id]; - delete utils.TextureCache[id]; - delete utils.BaseTextureCache[id]; + delete TextureCache[id]; + delete BaseTextureCache[id]; return texture; } diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 11551b8..b8c1ce5 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -1,5 +1,5 @@ import BaseTexture from './BaseTexture'; -import * as utils from '../utils'; +import { uid, BaseTextureCache } from '../utils'; /** * A texture of a [playing] Video. @@ -155,7 +155,7 @@ { if (this.source && this.source._pixiId) { - delete utils.BaseTextureCache[this.source._pixiId]; + delete BaseTextureCache[this.source._pixiId]; delete this.source._pixiId; } @@ -174,15 +174,15 @@ { if (!video._pixiId) { - video._pixiId = `video_${utils.uid()}`; + video._pixiId = `video_${uid()}`; } - let baseTexture = utils.BaseTextureCache[video._pixiId]; + let baseTexture = BaseTextureCache[video._pixiId]; if (!baseTexture) { baseTexture = new VideoBaseTexture(video, scaleMode); - utils.BaseTextureCache[video._pixiId] = baseTexture; + BaseTextureCache[video._pixiId] = baseTexture; } return baseTexture; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index d87640f..0da9f31 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -1,4 +1,4 @@ -import * as utils from '../utils'; +import { removeItems } from '../utils'; import DisplayObject from './DisplayObject'; /** @@ -166,7 +166,7 @@ const currentIndex = this.getChildIndex(child); - utils.removeItems(this.children, currentIndex, 1); // remove from old position + removeItems(this.children, currentIndex, 1); // remove from old position this.children.splice(index, 0, child); // add at new position this.onChildrenChange(index); } @@ -203,7 +203,7 @@ if (index === -1) continue; child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); @@ -224,7 +224,7 @@ const child = this.getChildAt(index); child.parent = null; - utils.removeItems(this.children, index, 1); + removeItems(this.children, index, 1); // TODO - lets either do all callbacks or all events.. not both! this.onChildrenChange(index); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 64be98f..6d7c02a 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -3,7 +3,7 @@ import TransformStatic from './TransformStatic'; import Transform from './Transform'; import Bounds from './Bounds'; -import * as math from '../math'; +import { Rectangle } from '../math'; // _tempDisplayObjectParent = new DisplayObject(); /** @@ -195,7 +195,7 @@ { if (!this._boundsRect) { - this._boundsRect = new math.Rectangle(); + this._boundsRect = new Rectangle(); } rect = this._boundsRect; @@ -222,7 +222,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 8c532f0..8611925 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Point, ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -23,28 +23,28 @@ * * @member {PIXI.Point} */ - this.position = new math.Point(0, 0); + this.position = new Point(0, 0); /** * The scale factor of the object. * * @member {PIXI.Point} */ - this.scale = new math.Point(1, 1); + this.scale = new Point(1, 1); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.Point} */ - this.pivot = new math.Point(0, 0); + this.pivot = new Point(0, 0); /** * The rotation value of the object, in radians diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js index b9cdb2c..ce2d2ef 100644 --- a/src/core/display/TransformBase.js +++ b/src/core/display/TransformBase.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { Matrix } from '../math'; /** * Generic class to deal with traditional 2D matrix transforms @@ -18,14 +18,14 @@ * * @member {PIXI.Matrix} */ - this.worldTransform = new math.Matrix(); + this.worldTransform = new Matrix(); /** * The local matrix transform * * @member {PIXI.Matrix} */ - this.localTransform = new math.Matrix(); + this.localTransform = new Matrix(); this._worldID = 0; } diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cfc6a64..c0c2f33 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,4 +1,4 @@ -import * as math from '../math'; +import { ObservablePoint } from '../math'; import TransformBase from './TransformBase'; /** @@ -22,28 +22,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new math.ObservablePoint(this.onChange, this, 0, 0); + this.position = new ObservablePoint(this.onChange, this, 0, 0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new math.ObservablePoint(this.onChange, this, 1, 1); + this.scale = new ObservablePoint(this.onChange, this, 1, 1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new math.ObservablePoint(this.onChange, this, 0, 0); + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new math.ObservablePoint(this.updateSkew, this, 0, 0); + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); this._rotation = 0; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 10d82d3..7576d46 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -3,16 +3,16 @@ import Texture from '../textures/Texture'; import GraphicsData from './GraphicsData'; import Sprite from '../sprites/Sprite'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Matrix, Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle } from '../math'; +import { hex2rgb, rgb2hex } from '../utils'; import { SHAPES, BLEND_MODES } from '../const'; import Bounds from '../display/Bounds'; import bezierCurveTo from './utils/bezierCurveTo'; import CanvasRenderer from '../renderers/canvas/CanvasRenderer'; let canvasRenderer; -const tempMatrix = new math.Matrix(); -const tempPoint = new math.Point(); +const tempMatrix = new Matrix(); +const tempPoint = new Point(); const tempColor1 = new Float32Array(4); const tempColor2 = new Float32Array(4); @@ -239,7 +239,7 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - const shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + const shape = new Polygon(this.currentPath.shape.points.slice(-2)); shape.closed = false; @@ -266,7 +266,7 @@ */ moveTo(x, y) { - const shape = new math.Polygon([x, y]); + const shape = new Polygon([x, y]); shape.closed = false; this.drawShape(shape); @@ -583,7 +583,7 @@ */ drawRect(x, y, width, height) { - this.drawShape(new math.Rectangle(x, y, width, height)); + this.drawShape(new Rectangle(x, y, width, height)); return this; } @@ -599,7 +599,7 @@ */ drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new math.RoundedRectangle(x, y, width, height, radius)); + this.drawShape(new RoundedRectangle(x, y, width, height, radius)); return this; } @@ -614,7 +614,7 @@ */ drawCircle(x, y, radius) { - this.drawShape(new math.Circle(x, y, radius)); + this.drawShape(new Circle(x, y, radius)); return this; } @@ -630,7 +630,7 @@ */ drawEllipse(x, y, width, height) { - this.drawShape(new math.Ellipse(x, y, width, height)); + this.drawShape(new Ellipse(x, y, width, height)); return this; } @@ -649,7 +649,7 @@ let closed = true; - if (points instanceof math.Polygon) + if (points instanceof Polygon) { closed = points.closed; points = points.points; @@ -667,7 +667,7 @@ } } - const shape = new math.Polygon(points); + const shape = new Polygon(points); shape.closed = closed; @@ -776,14 +776,14 @@ const t1 = tempColor1; const t2 = tempColor2; - utils.hex2rgb(this.graphicsData[0].fillColor, t1); - utils.hex2rgb(this.tint, t2); + hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(this.tint, t2); t1[0] *= t2[0]; t1[1] *= t2[1]; t1[2] *= t2[2]; - this._spriteRect.tint = utils.rgb2hex(t1); + this._spriteRect.tint = rgb2hex(t1); } this._spriteRect.alpha = this.graphicsData[0].fillAlpha; this._spriteRect.worldAlpha = this.worldAlpha * this._spriteRect.alpha; diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index cc5f8e7..fcb5005 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb } from '../../utils'; import { SHAPES } from '../../const'; import ObjectRenderer from '../../renderers/webgl/utils/ObjectRenderer'; import WebGLRenderer from '../../renderers/webgl/WebGLRenderer'; @@ -98,7 +98,7 @@ renderer.bindShader(shaderTemp); shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = utils.hex2rgb(graphics.tint); + shaderTemp.uniforms.tint = hex2rgb(graphics.tint); shaderTemp.uniforms.alpha = graphics.worldAlpha; webGLData.vao.bind() diff --git a/src/core/graphics/webgl/utils/buildCircle.js b/src/core/graphics/webgl/utils/buildCircle.js index 4423d04..0400d13 100644 --- a/src/core/graphics/webgl/utils/buildCircle.js +++ b/src/core/graphics/webgl/utils/buildCircle.js @@ -1,6 +1,6 @@ import buildLine from './buildLine'; import { SHAPES } from '../../../const'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a circle to draw @@ -40,7 +40,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildComplexPoly.js b/src/core/graphics/webgl/utils/buildComplexPoly.js index c5dac35..a1cfe1a 100644 --- a/src/core/graphics/webgl/utils/buildComplexPoly.js +++ b/src/core/graphics/webgl/utils/buildComplexPoly.js @@ -1,4 +1,4 @@ -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a complex polygon to draw @@ -25,7 +25,7 @@ webGLData.points = points; webGLData.alpha = graphicsData.fillAlpha; - webGLData.color = utils.hex2rgb(graphicsData.fillColor); + webGLData.color = hex2rgb(graphicsData.fillColor); // calclate the bounds.. let minX = Infinity; diff --git a/src/core/graphics/webgl/utils/buildLine.js b/src/core/graphics/webgl/utils/buildLine.js index c6d1b22..61c9ee1 100644 --- a/src/core/graphics/webgl/utils/buildLine.js +++ b/src/core/graphics/webgl/utils/buildLine.js @@ -1,5 +1,5 @@ -import * as math from '../../../math'; -import * as utils from '../../../utils'; +import { Point } from '../../../math'; +import { hex2rgb } from '../../../utils'; /** * Builds a line to draw @@ -31,8 +31,8 @@ // } // get first and last point.. figure out the middle! - const firstPoint = new math.Point(points[0], points[1]); - let lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + const firstPoint = new Point(points[0], points[1]); + let lastPoint = new Point(points[points.length - 2], points[points.length - 1]); // if the first point is the last point - gonna have issues :) if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) @@ -43,7 +43,7 @@ points.pop(); points.pop(); - lastPoint = new math.Point(points[points.length - 2], points[points.length - 1]); + lastPoint = new Point(points[points.length - 2], points[points.length - 1]); const midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); const midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); @@ -62,7 +62,7 @@ const width = graphicsData.lineWidth / 2; // sort color - const color = utils.hex2rgb(graphicsData.lineColor); + const color = hex2rgb(graphicsData.lineColor); const alpha = graphicsData.lineAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildPoly.js b/src/core/graphics/webgl/utils/buildPoly.js index 680ee60..36f4f2b 100644 --- a/src/core/graphics/webgl/utils/buildPoly.js +++ b/src/core/graphics/webgl/utils/buildPoly.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; import earcut from 'earcut'; /** @@ -40,7 +40,7 @@ const length = points.length / 2; // sort color - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; const g = color[1] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRectangle.js b/src/core/graphics/webgl/utils/buildRectangle.js index 49f3ce4..f2bba78 100644 --- a/src/core/graphics/webgl/utils/buildRectangle.js +++ b/src/core/graphics/webgl/utils/buildRectangle.js @@ -1,5 +1,5 @@ import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rectangle to draw @@ -24,7 +24,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/graphics/webgl/utils/buildRoundedRectangle.js b/src/core/graphics/webgl/utils/buildRoundedRectangle.js index c923e2a..9abc807 100644 --- a/src/core/graphics/webgl/utils/buildRoundedRectangle.js +++ b/src/core/graphics/webgl/utils/buildRoundedRectangle.js @@ -1,6 +1,6 @@ import earcut from 'earcut'; import buildLine from './buildLine'; -import * as utils from '../../../utils'; +import { hex2rgb } from '../../../utils'; /** * Builds a rounded rectangle to draw @@ -35,7 +35,7 @@ if (graphicsData.fill) { - const color = utils.hex2rgb(graphicsData.fillColor); + const color = hex2rgb(graphicsData.fillColor); const alpha = graphicsData.fillAlpha; const r = color[0] * alpha; diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 53c1366..4025f14 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -1,11 +1,11 @@ -import * as utils from '../utils'; -import * as math from '../math'; +import { sayHello, hex2string, hex2rgb } from '../utils'; +import { Matrix } from '../math'; import { DEFAULT_RENDER_OPTIONS, RENDERER_TYPE } from '../const'; import Container from '../display/Container'; import RenderTexture from '../textures/RenderTexture'; import EventEmitter from 'eventemitter3'; -const tempMatrix = new math.Matrix(); +const tempMatrix = new Matrix(); /** * The SystemRenderer is the base for a Pixi Renderer. It is extended by the {@link PIXI.CanvasRenderer} @@ -40,7 +40,7 @@ { super(); - utils.sayHello(system); + sayHello(system); // prepare options if (options) @@ -294,8 +294,8 @@ set backgroundColor(value) { this._backgroundColor = value; - this._backgroundColorString = utils.hex2string(value); - utils.hex2rgb(value, this._backgroundColorRgba); + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); } } diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 908fd77..cda8a3c 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -2,7 +2,7 @@ import CanvasMaskManager from './utils/CanvasMaskManager'; import CanvasRenderTarget from './utils/CanvasRenderTarget'; import mapCanvasBlendModesToPixi from './utils/mapCanvasBlendModesToPixi'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import { RENDERER_TYPE, SCALE_MODES, BLEND_MODES } from '../../const'; /** @@ -267,4 +267,4 @@ } } -utils.pluginTarget.mixin(CanvasRenderer); +pluginTarget.mixin(CanvasRenderer); diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index b9542b6..0ae3058 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -1,7 +1,7 @@ import { GLTexture } from 'pixi-gl-core'; import { WRAP_MODES, SCALE_MODES } from '../../const'; import RenderTarget from './utils/RenderTarget'; -import * as utils from '../../utils'; +import { removeItems } from '../../utils'; /** * Helper class to create a webGL Texture @@ -182,7 +182,7 @@ if (i !== -1) { - utils.removeItems(this._managedTextures, i, 1); + removeItems(this._managedTextures, i, 1); } } } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 264d1d6..e1ce9ce 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -9,7 +9,7 @@ import WebGLState from './WebGLState'; import mapWebGLDrawModesToPixi from './utils/mapWebGLDrawModesToPixi'; import validateContext from './utils/validateContext'; -import * as utils from '../../utils'; +import { pluginTarget } from '../../utils'; import glCore from 'pixi-gl-core'; import { RENDERER_TYPE } from '../../const'; @@ -564,4 +564,4 @@ } } -utils.pluginTarget.mixin(WebGLRenderer); +pluginTarget.mixin(WebGLRenderer); diff --git a/src/core/renderers/webgl/filters/Filter.js b/src/core/renderers/webgl/filters/Filter.js index 370619e..ed41cf0 100644 --- a/src/core/renderers/webgl/filters/Filter.js +++ b/src/core/renderers/webgl/filters/Filter.js @@ -1,5 +1,5 @@ import extractUniformsFromSrc from './extractUniformsFromSrc'; -import * as utils from '../../../utils'; +import { uid } from '../../../utils'; import { BLEND_MODES } from '../../../const'; const SOURCE_KEY_MAP = {}; @@ -53,7 +53,7 @@ // used for cacheing.. sure there is a better way! if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = utils.uid(); + SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = uid(); } this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index dba9596..d27d815 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Matrix } from '../../../math'; /* * Calculates the mapped matrix @@ -10,7 +10,7 @@ // thia returns a matrix that will normalise map filter cords in the filter to screen space export function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), + // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), // let texture = {width:1136, height:700};//sprite._texture.baseTexture; // TODO unwrap? @@ -40,7 +40,7 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; // TODO unwrap? diff --git a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js index 8b62a48..7bffb7f 100644 --- a/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js @@ -1,5 +1,5 @@ import Filter from '../Filter'; -import * as math from '../../../../math'; +import { Matrix } from '../../../../math'; // @see https://github.com/substack/brfs/issues/25 const glslify = require('glslify'); // eslint-disable-line no-undef @@ -18,7 +18,7 @@ */ constructor(sprite) { - const maskMatrix = new math.Matrix(); + const maskMatrix = new Matrix(); super( glslify('./spriteMaskFilter.vert'), diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index 81ac225..54d363f 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -1,7 +1,7 @@ import WebGLManager from './WebGLManager'; import RenderTarget from '../utils/RenderTarget'; import Quad from '../utils/Quad'; -import * as math from '../../../math'; +import { Rectangle } from '../../../math'; import Shader from '../../../Shader'; import filterTransforms from '../filters/filterTransforms'; import bitTwiddle from 'bit-twiddle'; @@ -18,8 +18,8 @@ constructor() { this.renderTarget = null; - this.sourceFrame = new math.Rectangle(); - this.destinationFrame = new math.Rectangle(); + this.sourceFrame = new Rectangle(); + this.destinationFrame = new Rectangle(); this.filters = []; this.target = null; this.resolution = 1; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index a356a90..2f84e56 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -1,4 +1,4 @@ -import * as math from '../../../math'; +import { Rectangle, Matrix } from '../../../math'; import { RESOLUTION, SCALE_MODES } from '../../../const'; import { GLFramebuffer } from 'pixi-gl-core'; @@ -55,7 +55,7 @@ * * @member {PIXI.Rectangle} */ - this.size = new math.Rectangle(0, 0, 1, 1); + this.size = new Rectangle(0, 0, 1, 1); /** * The current resolution / device pixel ratio @@ -70,7 +70,7 @@ * * @member {PIXI.Matrix} */ - this.projectionMatrix = new math.Matrix(); + this.projectionMatrix = new Matrix(); /** * The object's transform @@ -91,7 +91,7 @@ * * @member {glCore.GLBuffer} */ - this.defaultFrame = new math.Rectangle(); + this.defaultFrame = new Rectangle(); this.destinationFrame = null; this.sourceFrame = null; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index f434b1e..da3c609 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -1,10 +1,10 @@ -import * as math from '../math'; +import { Point, ObservablePoint, Rectangle } from '../math'; +import { sign, TextureCache } from '../utils'; +import { BLEND_MODES } from '../const'; import Texture from '../textures/Texture'; import Container from '../display/Container'; -import * as utils from '../utils'; -import { BLEND_MODES } from '../const'; -const tempPoint = new math.Point(); +const tempPoint = new Point(); /** * The Sprite object is the base for all textured objects that are rendered to the screen @@ -37,7 +37,7 @@ * @member {PIXI.ObservablePoint} * @private */ - this._anchor = new math.ObservablePoint(this.onAnchorUpdate, this); + this._anchor = new ObservablePoint(this.onAnchorUpdate, this); /** * The texture that the sprite is using @@ -134,12 +134,12 @@ // so if _width is 0 then width was not set.. if (this._width) { - this.scale.x = utils.sign(this.scale.x) * this._width / this.texture.orig.width; + this.scale.x = sign(this.scale.x) * this._width / this.texture.orig.width; } if (this._height) { - this.scale.y = utils.sign(this.scale.y) * this._height / this.texture.orig.height; + this.scale.y = sign(this.scale.y) * this._height / this.texture.orig.height; } } @@ -339,7 +339,7 @@ { if (!this._localBoundsRect) { - this._localBoundsRect = new math.Rectangle(); + this._localBoundsRect = new Rectangle(); } rect = this._localBoundsRect; @@ -433,7 +433,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -477,9 +477,9 @@ */ set width(value) { - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -501,9 +501,9 @@ */ set height(value) { - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/sprites/canvas/CanvasSpriteRenderer.js b/src/core/sprites/canvas/CanvasSpriteRenderer.js index 627f504..b51bb02 100644 --- a/src/core/sprites/canvas/CanvasSpriteRenderer.js +++ b/src/core/sprites/canvas/CanvasSpriteRenderer.js @@ -1,9 +1,9 @@ import CanvasRenderer from '../../renderers/canvas/CanvasRenderer'; import { SCALE_MODES } from '../../const'; -import * as math from '../../math'; +import { Matrix, GroupD8 } from '../../math'; import CanvasTinter from './CanvasTinter'; -const canvasRenderWorldTransform = new math.Matrix(); +const canvasRenderWorldTransform = new Matrix(); /** * @author Mat Groves @@ -87,7 +87,7 @@ { wt.copy(canvasRenderWorldTransform); wt = canvasRenderWorldTransform; - math.GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); + GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); // the anchor has already been applied above, so lets set it to zero dx = 0; dy = 0; diff --git a/src/core/sprites/canvas/CanvasTinter.js b/src/core/sprites/canvas/CanvasTinter.js index 6058e3d..5dfc36f 100644 --- a/src/core/sprites/canvas/CanvasTinter.js +++ b/src/core/sprites/canvas/CanvasTinter.js @@ -1,4 +1,4 @@ -import * as utils from '../../utils'; +import { hex2rgb, rgb2hex } from '../../utils'; import canUseNewCanvasBlendModes from '../../renderers/canvas/utils/canUseNewCanvasBlendModes'; /** @@ -187,7 +187,7 @@ crop.height ); - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); const r = rgbValues[0]; const g = rgbValues[1]; const b = rgbValues[2]; @@ -217,13 +217,13 @@ { const step = CanvasTinter.cacheStepsPerColorChannel; - const rgbValues = utils.hex2rgb(color); + const rgbValues = hex2rgb(color); rgbValues[0] = Math.min(255, (rgbValues[0] / step) * step); rgbValues[1] = Math.min(255, (rgbValues[1] / step) * step); rgbValues[2] = Math.min(255, (rgbValues[2] / step) * step); - return utils.rgb2hex(rgbValues); + return rgb2hex(rgbValues); }, /** diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 02c72b9..38841dd 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -1,8 +1,8 @@ /* eslint max-depth: [2, 8] */ import Sprite from '../sprites/Sprite'; import Texture from '../textures/Texture'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Rectangle } from '../math'; +import { sign } from '../utils'; import { TEXT_GRADIENT, RESOLUTION } from '../const'; import TextStyle from './TextStyle'; @@ -37,8 +37,8 @@ const canvas = document.createElement('canvas'); const texture = Texture.fromCanvas(canvas); - texture.orig = new math.Rectangle(); - texture.trim = new math.Rectangle(); + texture.orig = new Rectangle(); + texture.trim = new Rectangle(); super(texture); @@ -719,9 +719,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.x) || 1; + const s = sign(this.scale.x) || 1; - this.scale.x = sign * value / this.texture.orig.width; + this.scale.x = s * value / this.texture.orig.width; this._width = value; } @@ -747,9 +747,9 @@ { this.updateText(true); - const sign = utils.sign(this.scale.y) || 1; + const s = sign(this.scale.y) || 1; - this.scale.y = sign * value / this.texture.orig.height; + this.scale.y = s * value / this.texture.orig.height; this._height = value; } diff --git a/src/core/text/TextStyle.js b/src/core/text/TextStyle.js index ba6d2fc..20d4a0a 100644 --- a/src/core/text/TextStyle.js +++ b/src/core/text/TextStyle.js @@ -2,7 +2,7 @@ /* eslint-disable */ import { TEXT_GRADIENT } from '../const'; -import * as utils from '../utils'; +import { hex2string } from '../utils'; const defaultStyle = { align: 'left', @@ -439,7 +439,7 @@ { if (typeof color === 'number') { - return utils.hex2string(color); + return hex2string(color); } else if (Array.isArray(color)) { @@ -447,7 +447,7 @@ { if (typeof color[i] === 'number') { - color[i] = utils.hex2string(color[i]); + color[i] = hex2string(color[i]); } } } diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 73b1d75..e8ab42a 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -1,4 +1,7 @@ -import * as utils from '../utils'; +import { + uid, getImageTypeOfUrl, decomposeDataUri, getSvgSize, + getResolutionOfUrl, BaseTextureCache, TextureCache, +} from '../utils'; import { RESOLUTION, SCALE_MODES, MIPMAP_TEXTURES, WRAP_MODES } from '../const'; import EventEmitter from 'eventemitter3'; import determineCrossOrigin from '../utils/determineCrossOrigin'; @@ -22,7 +25,7 @@ { super(); - this.uid = utils.uid(); + this.uid = uid(); this.touched = 0; @@ -388,7 +391,7 @@ return; } - const dataUri = utils.decomposeDataUri(this.imageUrl); + const dataUri = decomposeDataUri(this.imageUrl); let imageType; if (dataUri && dataUri.mediaType === 'image') @@ -396,7 +399,7 @@ // Check for subType validity const firstSubType = dataUri.subType.split('+')[0]; - imageType = utils.getImageTypeOfUrl(`.${firstSubType}`); + imageType = getImageTypeOfUrl(`.${firstSubType}`); if (!imageType) { @@ -405,7 +408,7 @@ } else { - imageType = utils.getImageTypeOfUrl(this.imageUrl); + imageType = getImageTypeOfUrl(this.imageUrl); if (!imageType) { @@ -428,7 +431,7 @@ return; } - const dataUri = utils.decomposeDataUri(this.imageUrl); + const dataUri = decomposeDataUri(this.imageUrl); if (dataUri) { @@ -507,7 +510,7 @@ */ _loadSvgSourceUsingString(svgString) { - const svgSize = utils.getSvgSize(svgString); + const svgSize = getSvgSize(svgString); const svgWidth = svgSize.width; const svgHeight = svgSize.height; @@ -532,7 +535,7 @@ canvas.width = this.realWidth; canvas.height = this.realHeight; - canvas._pixiId = `canvas_${utils.uid()}`; + canvas._pixiId = `canvas_${uid()}`; // Draw the Svg to the canvas canvas @@ -544,7 +547,7 @@ this.source = canvas; // Add also the canvas in cache (destroy clears by `imageUrl` and `source._pixiId`) - utils.BaseTextureCache[canvas._pixiId] = this; + BaseTextureCache[canvas._pixiId] = this; this.isLoading = false; this._sourceLoaded(); @@ -571,8 +574,8 @@ { if (this.imageUrl) { - delete utils.BaseTextureCache[this.imageUrl]; - delete utils.TextureCache[this.imageUrl]; + delete BaseTextureCache[this.imageUrl]; + delete TextureCache[this.imageUrl]; this.imageUrl = null; @@ -584,7 +587,7 @@ // An svg source has both `imageUrl` and `__pixiId`, so no `else if` here if (this.source && this.source._pixiId) { - delete utils.BaseTextureCache[this.source._pixiId]; + delete BaseTextureCache[this.source._pixiId]; } this.source = null; @@ -632,7 +635,7 @@ */ static fromImage(imageUrl, crossorigin, scaleMode, sourceScale) { - let baseTexture = utils.BaseTextureCache[imageUrl]; + let baseTexture = BaseTextureCache[imageUrl]; if (!baseTexture) { @@ -654,11 +657,11 @@ } // if there is an @2x at the end of the url we are going to assume its a highres image - baseTexture.resolution = utils.getResolutionOfUrl(imageUrl); + baseTexture.resolution = getResolutionOfUrl(imageUrl); image.src = imageUrl; // Setting this triggers load - utils.BaseTextureCache[imageUrl] = baseTexture; + BaseTextureCache[imageUrl] = baseTexture; } return baseTexture; @@ -676,15 +679,15 @@ { if (!canvas._pixiId) { - canvas._pixiId = `canvas_${utils.uid()}`; + canvas._pixiId = `canvas_${uid()}`; } - let baseTexture = utils.BaseTextureCache[canvas._pixiId]; + let baseTexture = BaseTextureCache[canvas._pixiId]; if (!baseTexture) { baseTexture = new BaseTexture(canvas, scaleMode); - utils.BaseTextureCache[canvas._pixiId] = baseTexture; + BaseTextureCache[canvas._pixiId] = baseTexture; } return baseTexture; diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 605a5c5..62104c1 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -2,8 +2,8 @@ import VideoBaseTexture from './VideoBaseTexture'; import TextureUvs from './TextureUvs'; import EventEmitter from 'eventemitter3'; -import * as math from '../math'; -import * as utils from '../utils'; +import { Rectangle } from '../math'; +import { TextureCache, BaseTextureCache } from '../utils'; /** * A texture stores the information that represents an image or part of an image. It cannot be added @@ -45,7 +45,7 @@ if (!frame) { this.noFrame = true; - frame = new math.Rectangle(0, 0, 1, 1); + frame = new Rectangle(0, 0, 1, 1); } if (baseTexture instanceof Texture) @@ -102,7 +102,7 @@ * * @member {PIXI.Rectangle} */ - this.orig = orig || frame;// new math.Rectangle(0, 0, 1, 1); + this.orig = orig || frame;// new Rectangle(0, 0, 1, 1); this._rotate = Number(rotate || 0); @@ -120,7 +120,7 @@ { if (this.noFrame) { - frame = new math.Rectangle(0, 0, baseTexture.width, baseTexture.height); + frame = new Rectangle(0, 0, baseTexture.width, baseTexture.height); // if there is no frame we should monitor for any base texture changes.. baseTexture.on('update', this.onBaseTextureUpdated, this); @@ -165,7 +165,7 @@ // TODO this code looks confusing.. boo to abusing getters and setterss! if (this.noFrame) { - this.frame = new math.Rectangle(0, 0, baseTexture.width, baseTexture.height); + this.frame = new Rectangle(0, 0, baseTexture.width, baseTexture.height); } else { @@ -205,9 +205,9 @@ { // delete the texture if it exists in the texture cache.. // this only needs to be removed if the base texture is actually destoryed too.. - if (utils.TextureCache[this.baseTexture.imageUrl]) + if (TextureCache[this.baseTexture.imageUrl]) { - delete utils.TextureCache[this.baseTexture.imageUrl]; + delete TextureCache[this.baseTexture.imageUrl]; } this.baseTexture.destroy(); @@ -270,12 +270,12 @@ */ static fromImage(imageUrl, crossorigin, scaleMode, sourceScale) { - let texture = utils.TextureCache[imageUrl]; + let texture = TextureCache[imageUrl]; if (!texture) { texture = new Texture(BaseTexture.fromImage(imageUrl, crossorigin, scaleMode, sourceScale)); - utils.TextureCache[imageUrl] = texture; + TextureCache[imageUrl] = texture; } return texture; @@ -291,7 +291,7 @@ */ static fromFrame(frameId) { - const texture = utils.TextureCache[frameId]; + const texture = TextureCache[frameId]; if (!texture) { @@ -359,7 +359,7 @@ // TODO pass in scale mode? if (typeof source === 'string') { - const texture = utils.TextureCache[source]; + const texture = TextureCache[source]; if (!texture) { @@ -394,7 +394,7 @@ } /** - * Adds a texture to the global utils.TextureCache. This cache is shared across the whole PIXI object. + * Adds a texture to the global TextureCache. This cache is shared across the whole PIXI object. * * @static * @param {PIXI.Texture} texture - The Texture to add to the cache. @@ -402,11 +402,11 @@ */ static addTextureToCache(texture, id) { - utils.TextureCache[id] = texture; + TextureCache[id] = texture; } /** - * Remove a texture from the global utils.TextureCache. + * Remove a texture from the global TextureCache. * * @static * @param {string} id - The id of the texture to be removed @@ -414,10 +414,10 @@ */ static removeTextureFromCache(id) { - const texture = utils.TextureCache[id]; + const texture = TextureCache[id]; - delete utils.TextureCache[id]; - delete utils.BaseTextureCache[id]; + delete TextureCache[id]; + delete BaseTextureCache[id]; return texture; } diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 11551b8..b8c1ce5 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -1,5 +1,5 @@ import BaseTexture from './BaseTexture'; -import * as utils from '../utils'; +import { uid, BaseTextureCache } from '../utils'; /** * A texture of a [playing] Video. @@ -155,7 +155,7 @@ { if (this.source && this.source._pixiId) { - delete utils.BaseTextureCache[this.source._pixiId]; + delete BaseTextureCache[this.source._pixiId]; delete this.source._pixiId; } @@ -174,15 +174,15 @@ { if (!video._pixiId) { - video._pixiId = `video_${utils.uid()}`; + video._pixiId = `video_${uid()}`; } - let baseTexture = utils.BaseTextureCache[video._pixiId]; + let baseTexture = BaseTextureCache[video._pixiId]; if (!baseTexture) { baseTexture = new VideoBaseTexture(video, scaleMode); - utils.BaseTextureCache[video._pixiId] = baseTexture; + BaseTextureCache[video._pixiId] = baseTexture; } return baseTexture; diff --git a/src/loaders/bitmapFontParser.js b/src/loaders/bitmapFontParser.js index 57e4d5d..b283ef4 100644 --- a/src/loaders/bitmapFontParser.js +++ b/src/loaders/bitmapFontParser.js @@ -1,7 +1,7 @@ -import { Resource } from 'resource-loader'; -import * as core from '../core'; -import * as extras from '../extras'; import * as path from 'path'; +import { Rectangle, Texture, utils } from '../core'; +import { Resource } from 'resource-loader'; +import { BitmapText } from '../extras'; function parse(resource, texture) { @@ -21,7 +21,7 @@ { const charCode = parseInt(letters[i].getAttribute('id'), 10); - const textureRect = new core.Rectangle( + const textureRect = new Rectangle( parseInt(letters[i].getAttribute('x'), 10) + texture.frame.x, parseInt(letters[i].getAttribute('y'), 10) + texture.frame.y, parseInt(letters[i].getAttribute('width'), 10), @@ -33,7 +33,7 @@ yOffset: parseInt(letters[i].getAttribute('yoffset'), 10), xAdvance: parseInt(letters[i].getAttribute('xadvance'), 10), kerning: {}, - texture: new core.Texture(texture.baseTexture, textureRect), + texture: new Texture(texture.baseTexture, textureRect), }; } @@ -57,7 +57,7 @@ // I'm leaving this as a temporary fix so we can test the bitmap fonts in v3 // but it's very likely to change - extras.BitmapText.fonts[data.font] = data; + BitmapText.fonts[data.font] = data; } export default function () @@ -113,10 +113,10 @@ const textureUrl = xmlUrl + resource.data.getElementsByTagName('page')[0].getAttribute('file'); - if (core.utils.TextureCache[textureUrl]) + if (utils.TextureCache[textureUrl]) { // reuse existing texture - parse(resource, core.utils.TextureCache[textureUrl]); + parse(resource, utils.TextureCache[textureUrl]); next(); } else