diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js deleted file mode 100644 index 836fcdd..0000000 --- a/src/core/display/ObservablePoint.js +++ /dev/null @@ -1,100 +0,0 @@ -/** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. - * An observable point is a point that triggers a callback when the point's position is changed. - * - * @class - * @memberof PIXI - * @param cb {Function} callback when changed - * @param scope {Object} owner of callback - * @param [x=0] {number} position of the point on the x axis - * @param [y=0] {number} position of the point on the y axis - */ -function ObservablePoint(cb, scope, x, y) -{ - this._x = x || 0; - this._y = y || 0; - - this.cb = cb; - this.scope = scope; -} - -ObservablePoint.prototype.constructor = ObservablePoint; -module.exports = ObservablePoint; - - - -Object.defineProperties(ObservablePoint.prototype, { - /** - * The position of the displayObject on the x axis relative to the local coordinates of the parent. - * - * @member {number} - * @memberof PIXI.ObservablePoint# - */ - x: { - get: function () - { - return this._x; - }, - set: function (value) - { - if (this._x !== value) { - this._x = value; - this.cb.call(this.scope); - } - } - }, - /** - * The position of the displayObject on the x axis relative to the local coordinates of the parent. - * - * @member {number} - * @memberof PIXI.ObservablePoint# - */ - y: { - get: function () - { - return this._y; - }, - set: function (value) - { - if (this._y !== value) { - this._y = value; - this.cb.call(this.scope); - } - } - } -}); - -/** - * Sets the point to a new x and y position. - * If y is omitted, both x and y will be set to x. - * - * @param [x=0] {number} position of the point on the x axis - * @param [y=0] {number} position of the point on the y axis - */ -ObservablePoint.prototype.set = function (x, y) -{ - var _x = x || 0; - var _y = y || ( (y !== 0) ? _x : 0 ); - if (this._x !== _x || this._y !== _y) - { - this._x = _x; - this._y = _y; - this.cb.call(this.scope); - } -}; - -/** - * Copies the data from another point - * - * @param point {PIXI.Point|{PIXI.ObservablePoint} point to copy from - */ -ObservablePoint.prototype.copy = function (point) -{ - if (this._x !== point.x || this._y !== point.y) - { - this._x = point.x; - this._y = point.y; - this.cb.call(this.scope); - } -}; diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js deleted file mode 100644 index 836fcdd..0000000 --- a/src/core/display/ObservablePoint.js +++ /dev/null @@ -1,100 +0,0 @@ -/** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. - * An observable point is a point that triggers a callback when the point's position is changed. - * - * @class - * @memberof PIXI - * @param cb {Function} callback when changed - * @param scope {Object} owner of callback - * @param [x=0] {number} position of the point on the x axis - * @param [y=0] {number} position of the point on the y axis - */ -function ObservablePoint(cb, scope, x, y) -{ - this._x = x || 0; - this._y = y || 0; - - this.cb = cb; - this.scope = scope; -} - -ObservablePoint.prototype.constructor = ObservablePoint; -module.exports = ObservablePoint; - - - -Object.defineProperties(ObservablePoint.prototype, { - /** - * The position of the displayObject on the x axis relative to the local coordinates of the parent. - * - * @member {number} - * @memberof PIXI.ObservablePoint# - */ - x: { - get: function () - { - return this._x; - }, - set: function (value) - { - if (this._x !== value) { - this._x = value; - this.cb.call(this.scope); - } - } - }, - /** - * The position of the displayObject on the x axis relative to the local coordinates of the parent. - * - * @member {number} - * @memberof PIXI.ObservablePoint# - */ - y: { - get: function () - { - return this._y; - }, - set: function (value) - { - if (this._y !== value) { - this._y = value; - this.cb.call(this.scope); - } - } - } -}); - -/** - * Sets the point to a new x and y position. - * If y is omitted, both x and y will be set to x. - * - * @param [x=0] {number} position of the point on the x axis - * @param [y=0] {number} position of the point on the y axis - */ -ObservablePoint.prototype.set = function (x, y) -{ - var _x = x || 0; - var _y = y || ( (y !== 0) ? _x : 0 ); - if (this._x !== _x || this._y !== _y) - { - this._x = _x; - this._y = _y; - this.cb.call(this.scope); - } -}; - -/** - * Copies the data from another point - * - * @param point {PIXI.Point|{PIXI.ObservablePoint} point to copy from - */ -ObservablePoint.prototype.copy = function (point) -{ - if (this._x !== point.x || this._y !== point.y) - { - this._x = point.x; - this._y = point.y; - this.cb.call(this.scope); - } -}; diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cddd68e..88478c4 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,5 +1,4 @@ var math = require('../math'); -var ObservablePoint = require('./ObservablePoint'); /** * Transform that takes care about its versions @@ -24,28 +23,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new ObservablePoint(this.onChange, this,0.0); + this.position = new math.ObservablePoint(this.onChange, this,0.0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new ObservablePoint(this.onChange, this,1,1); + this.scale = new math.ObservablePoint(this.onChange, this,1,1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new ObservablePoint(this.onChange, this,0.0); + this.pivot = new math.ObservablePoint(this.onChange, this,0.0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new ObservablePoint(this.updateSkew, this,0.0); + this.skew = new math.ObservablePoint(this.updateSkew, this,0.0); this._rotation = 0; this._sr = Math.sin(0); diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js deleted file mode 100644 index 836fcdd..0000000 --- a/src/core/display/ObservablePoint.js +++ /dev/null @@ -1,100 +0,0 @@ -/** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. - * An observable point is a point that triggers a callback when the point's position is changed. - * - * @class - * @memberof PIXI - * @param cb {Function} callback when changed - * @param scope {Object} owner of callback - * @param [x=0] {number} position of the point on the x axis - * @param [y=0] {number} position of the point on the y axis - */ -function ObservablePoint(cb, scope, x, y) -{ - this._x = x || 0; - this._y = y || 0; - - this.cb = cb; - this.scope = scope; -} - -ObservablePoint.prototype.constructor = ObservablePoint; -module.exports = ObservablePoint; - - - -Object.defineProperties(ObservablePoint.prototype, { - /** - * The position of the displayObject on the x axis relative to the local coordinates of the parent. - * - * @member {number} - * @memberof PIXI.ObservablePoint# - */ - x: { - get: function () - { - return this._x; - }, - set: function (value) - { - if (this._x !== value) { - this._x = value; - this.cb.call(this.scope); - } - } - }, - /** - * The position of the displayObject on the x axis relative to the local coordinates of the parent. - * - * @member {number} - * @memberof PIXI.ObservablePoint# - */ - y: { - get: function () - { - return this._y; - }, - set: function (value) - { - if (this._y !== value) { - this._y = value; - this.cb.call(this.scope); - } - } - } -}); - -/** - * Sets the point to a new x and y position. - * If y is omitted, both x and y will be set to x. - * - * @param [x=0] {number} position of the point on the x axis - * @param [y=0] {number} position of the point on the y axis - */ -ObservablePoint.prototype.set = function (x, y) -{ - var _x = x || 0; - var _y = y || ( (y !== 0) ? _x : 0 ); - if (this._x !== _x || this._y !== _y) - { - this._x = _x; - this._y = _y; - this.cb.call(this.scope); - } -}; - -/** - * Copies the data from another point - * - * @param point {PIXI.Point|{PIXI.ObservablePoint} point to copy from - */ -ObservablePoint.prototype.copy = function (point) -{ - if (this._x !== point.x || this._y !== point.y) - { - this._x = point.x; - this._y = point.y; - this.cb.call(this.scope); - } -}; diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cddd68e..88478c4 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,5 +1,4 @@ var math = require('../math'); -var ObservablePoint = require('./ObservablePoint'); /** * Transform that takes care about its versions @@ -24,28 +23,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new ObservablePoint(this.onChange, this,0.0); + this.position = new math.ObservablePoint(this.onChange, this,0.0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new ObservablePoint(this.onChange, this,1,1); + this.scale = new math.ObservablePoint(this.onChange, this,1,1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new ObservablePoint(this.onChange, this,0.0); + this.pivot = new math.ObservablePoint(this.onChange, this,0.0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new ObservablePoint(this.updateSkew, this,0.0); + this.skew = new math.ObservablePoint(this.updateSkew, this,0.0); this._rotation = 0; this._sr = Math.sin(0); diff --git a/src/core/math/ObservablePoint.js b/src/core/math/ObservablePoint.js new file mode 100644 index 0000000..836fcdd --- /dev/null +++ b/src/core/math/ObservablePoint.js @@ -0,0 +1,100 @@ +/** + * The Point object represents a location in a two-dimensional coordinate system, where x represents + * the horizontal axis and y represents the vertical axis. + * An observable point is a point that triggers a callback when the point's position is changed. + * + * @class + * @memberof PIXI + * @param cb {Function} callback when changed + * @param scope {Object} owner of callback + * @param [x=0] {number} position of the point on the x axis + * @param [y=0] {number} position of the point on the y axis + */ +function ObservablePoint(cb, scope, x, y) +{ + this._x = x || 0; + this._y = y || 0; + + this.cb = cb; + this.scope = scope; +} + +ObservablePoint.prototype.constructor = ObservablePoint; +module.exports = ObservablePoint; + + + +Object.defineProperties(ObservablePoint.prototype, { + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ + x: { + get: function () + { + return this._x; + }, + set: function (value) + { + if (this._x !== value) { + this._x = value; + this.cb.call(this.scope); + } + } + }, + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ + y: { + get: function () + { + return this._y; + }, + set: function (value) + { + if (this._y !== value) { + this._y = value; + this.cb.call(this.scope); + } + } + } +}); + +/** + * Sets the point to a new x and y position. + * If y is omitted, both x and y will be set to x. + * + * @param [x=0] {number} position of the point on the x axis + * @param [y=0] {number} position of the point on the y axis + */ +ObservablePoint.prototype.set = function (x, y) +{ + var _x = x || 0; + var _y = y || ( (y !== 0) ? _x : 0 ); + if (this._x !== _x || this._y !== _y) + { + this._x = _x; + this._y = _y; + this.cb.call(this.scope); + } +}; + +/** + * Copies the data from another point + * + * @param point {PIXI.Point|{PIXI.ObservablePoint} point to copy from + */ +ObservablePoint.prototype.copy = function (point) +{ + if (this._x !== point.x || this._y !== point.y) + { + this._x = point.x; + this._y = point.y; + this.cb.call(this.scope); + } +}; diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js deleted file mode 100644 index 836fcdd..0000000 --- a/src/core/display/ObservablePoint.js +++ /dev/null @@ -1,100 +0,0 @@ -/** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. - * An observable point is a point that triggers a callback when the point's position is changed. - * - * @class - * @memberof PIXI - * @param cb {Function} callback when changed - * @param scope {Object} owner of callback - * @param [x=0] {number} position of the point on the x axis - * @param [y=0] {number} position of the point on the y axis - */ -function ObservablePoint(cb, scope, x, y) -{ - this._x = x || 0; - this._y = y || 0; - - this.cb = cb; - this.scope = scope; -} - -ObservablePoint.prototype.constructor = ObservablePoint; -module.exports = ObservablePoint; - - - -Object.defineProperties(ObservablePoint.prototype, { - /** - * The position of the displayObject on the x axis relative to the local coordinates of the parent. - * - * @member {number} - * @memberof PIXI.ObservablePoint# - */ - x: { - get: function () - { - return this._x; - }, - set: function (value) - { - if (this._x !== value) { - this._x = value; - this.cb.call(this.scope); - } - } - }, - /** - * The position of the displayObject on the x axis relative to the local coordinates of the parent. - * - * @member {number} - * @memberof PIXI.ObservablePoint# - */ - y: { - get: function () - { - return this._y; - }, - set: function (value) - { - if (this._y !== value) { - this._y = value; - this.cb.call(this.scope); - } - } - } -}); - -/** - * Sets the point to a new x and y position. - * If y is omitted, both x and y will be set to x. - * - * @param [x=0] {number} position of the point on the x axis - * @param [y=0] {number} position of the point on the y axis - */ -ObservablePoint.prototype.set = function (x, y) -{ - var _x = x || 0; - var _y = y || ( (y !== 0) ? _x : 0 ); - if (this._x !== _x || this._y !== _y) - { - this._x = _x; - this._y = _y; - this.cb.call(this.scope); - } -}; - -/** - * Copies the data from another point - * - * @param point {PIXI.Point|{PIXI.ObservablePoint} point to copy from - */ -ObservablePoint.prototype.copy = function (point) -{ - if (this._x !== point.x || this._y !== point.y) - { - this._x = point.x; - this._y = point.y; - this.cb.call(this.scope); - } -}; diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index cddd68e..88478c4 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,5 +1,4 @@ var math = require('../math'); -var ObservablePoint = require('./ObservablePoint'); /** * Transform that takes care about its versions @@ -24,28 +23,28 @@ * * @member {PIXI.ObservablePoint} */ - this.position = new ObservablePoint(this.onChange, this,0.0); + this.position = new math.ObservablePoint(this.onChange, this,0.0); /** * The scale factor of the object. * * @member {PIXI.ObservablePoint} */ - this.scale = new ObservablePoint(this.onChange, this,1,1); + this.scale = new math.ObservablePoint(this.onChange, this,1,1); /** * The pivot point of the displayObject that it rotates around * * @member {PIXI.ObservablePoint} */ - this.pivot = new ObservablePoint(this.onChange, this,0.0); + this.pivot = new math.ObservablePoint(this.onChange, this,0.0); /** * The skew amount, on the x and y axis. * * @member {PIXI.ObservablePoint} */ - this.skew = new ObservablePoint(this.updateSkew, this,0.0); + this.skew = new math.ObservablePoint(this.updateSkew, this,0.0); this._rotation = 0; this._sr = Math.sin(0); diff --git a/src/core/math/ObservablePoint.js b/src/core/math/ObservablePoint.js new file mode 100644 index 0000000..836fcdd --- /dev/null +++ b/src/core/math/ObservablePoint.js @@ -0,0 +1,100 @@ +/** + * The Point object represents a location in a two-dimensional coordinate system, where x represents + * the horizontal axis and y represents the vertical axis. + * An observable point is a point that triggers a callback when the point's position is changed. + * + * @class + * @memberof PIXI + * @param cb {Function} callback when changed + * @param scope {Object} owner of callback + * @param [x=0] {number} position of the point on the x axis + * @param [y=0] {number} position of the point on the y axis + */ +function ObservablePoint(cb, scope, x, y) +{ + this._x = x || 0; + this._y = y || 0; + + this.cb = cb; + this.scope = scope; +} + +ObservablePoint.prototype.constructor = ObservablePoint; +module.exports = ObservablePoint; + + + +Object.defineProperties(ObservablePoint.prototype, { + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ + x: { + get: function () + { + return this._x; + }, + set: function (value) + { + if (this._x !== value) { + this._x = value; + this.cb.call(this.scope); + } + } + }, + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ + y: { + get: function () + { + return this._y; + }, + set: function (value) + { + if (this._y !== value) { + this._y = value; + this.cb.call(this.scope); + } + } + } +}); + +/** + * Sets the point to a new x and y position. + * If y is omitted, both x and y will be set to x. + * + * @param [x=0] {number} position of the point on the x axis + * @param [y=0] {number} position of the point on the y axis + */ +ObservablePoint.prototype.set = function (x, y) +{ + var _x = x || 0; + var _y = y || ( (y !== 0) ? _x : 0 ); + if (this._x !== _x || this._y !== _y) + { + this._x = _x; + this._y = _y; + this.cb.call(this.scope); + } +}; + +/** + * Copies the data from another point + * + * @param point {PIXI.Point|{PIXI.ObservablePoint} point to copy from + */ +ObservablePoint.prototype.copy = function (point) +{ + if (this._x !== point.x || this._y !== point.y) + { + this._x = point.x; + this._y = point.y; + this.cb.call(this.scope); + } +}; diff --git a/src/core/math/index.js b/src/core/math/index.js index a43f6e7..8f199d0 100644 --- a/src/core/math/index.js +++ b/src/core/math/index.js @@ -9,13 +9,14 @@ // to avoid circular dependencies and cut down on // internal module requires. - Point: require('./Point'), - Matrix: require('./Matrix'), - GroupD8: require('./GroupD8'), + Point: require('./Point'), + ObservablePoint: require('./ObservablePoint'), + Matrix: require('./Matrix'), + GroupD8: require('./GroupD8'), - Circle: require('./shapes/Circle'), - Ellipse: require('./shapes/Ellipse'), - Polygon: require('./shapes/Polygon'), - Rectangle: require('./shapes/Rectangle'), - RoundedRectangle: require('./shapes/RoundedRectangle') + Circle: require('./shapes/Circle'), + Ellipse: require('./shapes/Ellipse'), + Polygon: require('./shapes/Polygon'), + Rectangle: require('./shapes/Rectangle'), + RoundedRectangle: require('./shapes/RoundedRectangle') };