@pixi/math
Advanced tools
Comparing version 5.0.0-alpha.3 to 5.0.0-rc
/*! | ||
* @pixi/math - v5.0.0-alpha.3 | ||
* Compiled Tue, 03 Jul 2018 04:08:21 UTC | ||
* @pixi/math - v5.0.0-rc | ||
* Compiled Fri, 01 Feb 2019 04:50:10 UTC | ||
* | ||
@@ -46,4 +46,4 @@ * @pixi/math is licensed under the MIT License. | ||
* | ||
* @param {PIXI.Point} p - The point to copy from | ||
* @returns Returns itself. | ||
* @param {PIXI.IPoint} p - The point to copy from | ||
* @returns {PIXI.IPoint} Returns itself. | ||
*/ | ||
@@ -60,4 +60,4 @@ Point.prototype.copyFrom = function copyFrom (p) | ||
* | ||
* @param {PIXI.Point} p - The point to copy. | ||
* @returns Given point with values updated | ||
* @param {PIXI.IPoint} p - The point to copy. | ||
* @returns {PIXI.IPoint} Given point with values updated | ||
*/ | ||
@@ -74,3 +74,3 @@ Point.prototype.copyTo = function copyTo (p) | ||
* | ||
* @param {PIXI.Point} p - The point to check | ||
* @param {PIXI.IPoint} p - The point to check | ||
* @returns {boolean} Whether the given point equal to this point | ||
@@ -99,4 +99,5 @@ */ | ||
* 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. | ||
* | ||
* An ObservablePoint is a point that triggers a callback when the point's position is changed. | ||
* | ||
* @class | ||
@@ -120,2 +121,23 @@ * @memberof PIXI | ||
/** | ||
* Creates a clone of this point. | ||
* The callback and scope params can be overidden otherwise they will default | ||
* to the clone object's values. | ||
* | ||
* @override | ||
* @param {Function} [cb=null] - callback when changed | ||
* @param {object} [scope=null] - owner of callback | ||
* @return {PIXI.ObservablePoint} a copy of the point | ||
*/ | ||
ObservablePoint.prototype.clone = function clone (cb, scope) | ||
{ | ||
if ( cb === void 0 ) cb = null; | ||
if ( scope === void 0 ) scope = null; | ||
var _cb = cb || this.cb; | ||
var _scope = scope || this.scope; | ||
return new ObservablePoint(_cb, _scope, this._x, this._y); | ||
}; | ||
/** | ||
* Sets the point to a new x and y position. | ||
@@ -143,4 +165,4 @@ * If y is omitted, both x and y will be set to x. | ||
* | ||
* @param {PIXI.Point} p - The point to copy from. | ||
* @returns Returns itself. | ||
* @param {PIXI.IPoint} p - The point to copy from. | ||
* @returns {PIXI.IPoint} Returns itself. | ||
*/ | ||
@@ -162,4 +184,4 @@ ObservablePoint.prototype.copyFrom = function copyFrom (p) | ||
* | ||
* @param {PIXI.Point} p - The point to copy. | ||
* @returns Given point with values updated | ||
* @param {PIXI.IPoint} p - The point to copy. | ||
* @returns {PIXI.IPoint} Given point with values updated | ||
*/ | ||
@@ -174,2 +196,13 @@ ObservablePoint.prototype.copyTo = function copyTo (p) | ||
/** | ||
* Returns true if the given point is equal to this point | ||
* | ||
* @param {PIXI.IPoint} p - The point to check | ||
* @returns {boolean} Whether the given point equal to this point | ||
*/ | ||
ObservablePoint.prototype.equals = function equals (p) | ||
{ | ||
return (p.x === this._x) && (p.y === this._y); | ||
}; | ||
/** | ||
* The position of the displayObject on the x axis relative to the local coordinates of the parent. | ||
@@ -215,8 +248,13 @@ * | ||
/** | ||
* A number, or a string containing a number. | ||
* @memberof PIXI | ||
* @typedef {(PIXI.Point|PIXI.ObservablePoint)} IPoint | ||
*/ | ||
/** | ||
* Two Pi. | ||
* | ||
* @static | ||
* @constant | ||
* @constant {number} PI_2 | ||
* @memberof PIXI | ||
* @type {number} | ||
*/ | ||
@@ -229,5 +267,4 @@ var PI_2 = Math.PI * 2; | ||
* @static | ||
* @constant | ||
* @constant {number} RAD_TO_DEG | ||
* @memberof PIXI | ||
* @type {number} | ||
*/ | ||
@@ -240,5 +277,4 @@ var RAD_TO_DEG = 180 / Math.PI; | ||
* @static | ||
* @constant | ||
* @constant {number} DEG_TO_RAD | ||
* @memberof PIXI | ||
* @type {number} | ||
*/ | ||
@@ -270,8 +306,10 @@ var DEG_TO_RAD = Math.PI / 180; | ||
/** | ||
* The PixiJS Matrix class as an object, which makes it a lot faster, | ||
* here is a representation of it : | ||
* The PixiJS Matrix as a class makes it a lot faster. | ||
* | ||
* Here is a representation of it: | ||
* ```js | ||
* | a | c | tx| | ||
* | b | d | ty| | ||
* | 0 | 0 | 1 | | ||
* | ||
* ``` | ||
* @class | ||
@@ -750,2 +788,3 @@ * @memberof PIXI | ||
* @const | ||
* @member {PIXI.Matrix} | ||
*/ | ||
@@ -762,2 +801,3 @@ staticAccessors.IDENTITY.get = function () | ||
* @const | ||
* @member {PIXI.Matrix} | ||
*/ | ||
@@ -772,2 +812,3 @@ staticAccessors.TEMP_MATRIX.get = function () | ||
// Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group of order 16 | ||
var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1]; | ||
@@ -993,3 +1034,3 @@ var uy = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1]; | ||
/** | ||
* The pivot point of the displayObject that it rotates around | ||
* The pivot point of the displayObject that it rotates around. | ||
* | ||
@@ -1140,4 +1181,7 @@ * @member {PIXI.ObservablePoint} | ||
{ | ||
this._rotation = value; | ||
this.updateSkew(); | ||
if (this._rotation !== value) | ||
{ | ||
this._rotation = value; | ||
this.updateSkew(); | ||
} | ||
}; | ||
@@ -1246,2 +1290,3 @@ | ||
* @constant | ||
* @member {PIXI.Rectangle} | ||
*/ | ||
@@ -1345,40 +1390,11 @@ staticAccessors$1.EMPTY.get = function () | ||
{ | ||
if (this.x < rectangle.x) | ||
{ | ||
this.width += this.x; | ||
if (this.width < 0) | ||
{ | ||
this.width = 0; | ||
} | ||
var x1 = Math.max(this.x, rectangle.x); | ||
var x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width); | ||
var y1 = Math.max(this.y, rectangle.y); | ||
var y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height); | ||
this.x = rectangle.x; | ||
} | ||
if (this.y < rectangle.y) | ||
{ | ||
this.height += this.y; | ||
if (this.height < 0) | ||
{ | ||
this.height = 0; | ||
} | ||
this.y = rectangle.y; | ||
} | ||
if (this.x + this.width > rectangle.x + rectangle.width) | ||
{ | ||
this.width = rectangle.width - this.x; | ||
if (this.width < 0) | ||
{ | ||
this.width = 0; | ||
} | ||
} | ||
if (this.y + this.height > rectangle.y + rectangle.height) | ||
{ | ||
this.height = rectangle.height - this.y; | ||
if (this.height < 0) | ||
{ | ||
this.height = 0; | ||
} | ||
} | ||
this.x = x1; | ||
this.width = Math.max(x2 - x1, 0); | ||
this.y = y1; | ||
this.height = Math.max(y2 - y1, 0); | ||
}; | ||
@@ -1429,3 +1445,3 @@ | ||
/** | ||
* The Circle object can be used to specify a hit area for displayObjects | ||
* The Circle object is used to help draw graphics and can also be used to specify a hit area for displayObjects. | ||
* | ||
@@ -1515,3 +1531,3 @@ * @class | ||
/** | ||
* The Ellipse object can be used to specify a hit area for displayObjects | ||
* The Ellipse object is used to help draw graphics and can also be used to specify a hit area for displayObjects. | ||
* | ||
@@ -1521,8 +1537,8 @@ * @class | ||
*/ | ||
var Ellipse = function Ellipse(x, y, width, height) | ||
var Ellipse = function Ellipse(x, y, halfWidth, halfHeight) | ||
{ | ||
if ( x === void 0 ) x = 0; | ||
if ( y === void 0 ) y = 0; | ||
if ( width === void 0 ) width = 0; | ||
if ( height === void 0 ) height = 0; | ||
if ( halfWidth === void 0 ) halfWidth = 0; | ||
if ( halfHeight === void 0 ) halfHeight = 0; | ||
@@ -1545,3 +1561,3 @@ /** | ||
*/ | ||
this.width = width; | ||
this.width = halfWidth; | ||
@@ -1552,3 +1568,3 @@ /** | ||
*/ | ||
this.height = height; | ||
this.height = halfHeight; | ||
@@ -1611,2 +1627,4 @@ /** | ||
/** | ||
* A class to define a shape via user defined co-orinates. | ||
* | ||
* @class | ||
@@ -1692,4 +1710,2 @@ * @memberof PIXI | ||
{ | ||
var this$1 = this; | ||
var inside = false; | ||
@@ -1703,6 +1719,6 @@ | ||
{ | ||
var xi = this$1.points[i * 2]; | ||
var yi = this$1.points[(i * 2) + 1]; | ||
var xj = this$1.points[j * 2]; | ||
var yj = this$1.points[(j * 2) + 1]; | ||
var xi = this.points[i * 2]; | ||
var yi = this.points[(i * 2) + 1]; | ||
var xj = this.points[j * 2]; | ||
var yj = this.points[(j * 2) + 1]; | ||
var intersect = ((yi > y) !== (yj > y)) && (x < ((xj - xi) * ((y - yi) / (yj - yi))) + xi); | ||
@@ -1709,0 +1725,0 @@ |
164
lib/math.js
/*! | ||
* @pixi/math - v5.0.0-alpha.3 | ||
* Compiled Tue, 03 Jul 2018 04:08:21 UTC | ||
* @pixi/math - v5.0.0-rc | ||
* Compiled Fri, 01 Feb 2019 04:50:10 UTC | ||
* | ||
@@ -50,4 +50,4 @@ * @pixi/math is licensed under the MIT License. | ||
* | ||
* @param {PIXI.Point} p - The point to copy from | ||
* @returns Returns itself. | ||
* @param {PIXI.IPoint} p - The point to copy from | ||
* @returns {PIXI.IPoint} Returns itself. | ||
*/ | ||
@@ -64,4 +64,4 @@ Point.prototype.copyFrom = function copyFrom (p) | ||
* | ||
* @param {PIXI.Point} p - The point to copy. | ||
* @returns Given point with values updated | ||
* @param {PIXI.IPoint} p - The point to copy. | ||
* @returns {PIXI.IPoint} Given point with values updated | ||
*/ | ||
@@ -78,3 +78,3 @@ Point.prototype.copyTo = function copyTo (p) | ||
* | ||
* @param {PIXI.Point} p - The point to check | ||
* @param {PIXI.IPoint} p - The point to check | ||
* @returns {boolean} Whether the given point equal to this point | ||
@@ -103,4 +103,5 @@ */ | ||
* 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. | ||
* | ||
* An ObservablePoint is a point that triggers a callback when the point's position is changed. | ||
* | ||
* @class | ||
@@ -124,2 +125,23 @@ * @memberof PIXI | ||
/** | ||
* Creates a clone of this point. | ||
* The callback and scope params can be overidden otherwise they will default | ||
* to the clone object's values. | ||
* | ||
* @override | ||
* @param {Function} [cb=null] - callback when changed | ||
* @param {object} [scope=null] - owner of callback | ||
* @return {PIXI.ObservablePoint} a copy of the point | ||
*/ | ||
ObservablePoint.prototype.clone = function clone (cb, scope) | ||
{ | ||
if ( cb === void 0 ) cb = null; | ||
if ( scope === void 0 ) scope = null; | ||
var _cb = cb || this.cb; | ||
var _scope = scope || this.scope; | ||
return new ObservablePoint(_cb, _scope, this._x, this._y); | ||
}; | ||
/** | ||
* Sets the point to a new x and y position. | ||
@@ -147,4 +169,4 @@ * If y is omitted, both x and y will be set to x. | ||
* | ||
* @param {PIXI.Point} p - The point to copy from. | ||
* @returns Returns itself. | ||
* @param {PIXI.IPoint} p - The point to copy from. | ||
* @returns {PIXI.IPoint} Returns itself. | ||
*/ | ||
@@ -166,4 +188,4 @@ ObservablePoint.prototype.copyFrom = function copyFrom (p) | ||
* | ||
* @param {PIXI.Point} p - The point to copy. | ||
* @returns Given point with values updated | ||
* @param {PIXI.IPoint} p - The point to copy. | ||
* @returns {PIXI.IPoint} Given point with values updated | ||
*/ | ||
@@ -178,2 +200,13 @@ ObservablePoint.prototype.copyTo = function copyTo (p) | ||
/** | ||
* Returns true if the given point is equal to this point | ||
* | ||
* @param {PIXI.IPoint} p - The point to check | ||
* @returns {boolean} Whether the given point equal to this point | ||
*/ | ||
ObservablePoint.prototype.equals = function equals (p) | ||
{ | ||
return (p.x === this._x) && (p.y === this._y); | ||
}; | ||
/** | ||
* The position of the displayObject on the x axis relative to the local coordinates of the parent. | ||
@@ -219,8 +252,13 @@ * | ||
/** | ||
* A number, or a string containing a number. | ||
* @memberof PIXI | ||
* @typedef {(PIXI.Point|PIXI.ObservablePoint)} IPoint | ||
*/ | ||
/** | ||
* Two Pi. | ||
* | ||
* @static | ||
* @constant | ||
* @constant {number} PI_2 | ||
* @memberof PIXI | ||
* @type {number} | ||
*/ | ||
@@ -233,5 +271,4 @@ var PI_2 = Math.PI * 2; | ||
* @static | ||
* @constant | ||
* @constant {number} RAD_TO_DEG | ||
* @memberof PIXI | ||
* @type {number} | ||
*/ | ||
@@ -244,5 +281,4 @@ var RAD_TO_DEG = 180 / Math.PI; | ||
* @static | ||
* @constant | ||
* @constant {number} DEG_TO_RAD | ||
* @memberof PIXI | ||
* @type {number} | ||
*/ | ||
@@ -274,8 +310,10 @@ var DEG_TO_RAD = Math.PI / 180; | ||
/** | ||
* The PixiJS Matrix class as an object, which makes it a lot faster, | ||
* here is a representation of it : | ||
* The PixiJS Matrix as a class makes it a lot faster. | ||
* | ||
* Here is a representation of it: | ||
* ```js | ||
* | a | c | tx| | ||
* | b | d | ty| | ||
* | 0 | 0 | 1 | | ||
* | ||
* ``` | ||
* @class | ||
@@ -754,2 +792,3 @@ * @memberof PIXI | ||
* @const | ||
* @member {PIXI.Matrix} | ||
*/ | ||
@@ -766,2 +805,3 @@ staticAccessors.IDENTITY.get = function () | ||
* @const | ||
* @member {PIXI.Matrix} | ||
*/ | ||
@@ -776,2 +816,3 @@ staticAccessors.TEMP_MATRIX.get = function () | ||
// Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group of order 16 | ||
var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1]; | ||
@@ -997,3 +1038,3 @@ var uy = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1]; | ||
/** | ||
* The pivot point of the displayObject that it rotates around | ||
* The pivot point of the displayObject that it rotates around. | ||
* | ||
@@ -1144,4 +1185,7 @@ * @member {PIXI.ObservablePoint} | ||
{ | ||
this._rotation = value; | ||
this.updateSkew(); | ||
if (this._rotation !== value) | ||
{ | ||
this._rotation = value; | ||
this.updateSkew(); | ||
} | ||
}; | ||
@@ -1250,2 +1294,3 @@ | ||
* @constant | ||
* @member {PIXI.Rectangle} | ||
*/ | ||
@@ -1349,40 +1394,11 @@ staticAccessors$1.EMPTY.get = function () | ||
{ | ||
if (this.x < rectangle.x) | ||
{ | ||
this.width += this.x; | ||
if (this.width < 0) | ||
{ | ||
this.width = 0; | ||
} | ||
var x1 = Math.max(this.x, rectangle.x); | ||
var x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width); | ||
var y1 = Math.max(this.y, rectangle.y); | ||
var y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height); | ||
this.x = rectangle.x; | ||
} | ||
if (this.y < rectangle.y) | ||
{ | ||
this.height += this.y; | ||
if (this.height < 0) | ||
{ | ||
this.height = 0; | ||
} | ||
this.y = rectangle.y; | ||
} | ||
if (this.x + this.width > rectangle.x + rectangle.width) | ||
{ | ||
this.width = rectangle.width - this.x; | ||
if (this.width < 0) | ||
{ | ||
this.width = 0; | ||
} | ||
} | ||
if (this.y + this.height > rectangle.y + rectangle.height) | ||
{ | ||
this.height = rectangle.height - this.y; | ||
if (this.height < 0) | ||
{ | ||
this.height = 0; | ||
} | ||
} | ||
this.x = x1; | ||
this.width = Math.max(x2 - x1, 0); | ||
this.y = y1; | ||
this.height = Math.max(y2 - y1, 0); | ||
}; | ||
@@ -1433,3 +1449,3 @@ | ||
/** | ||
* The Circle object can be used to specify a hit area for displayObjects | ||
* The Circle object is used to help draw graphics and can also be used to specify a hit area for displayObjects. | ||
* | ||
@@ -1519,3 +1535,3 @@ * @class | ||
/** | ||
* The Ellipse object can be used to specify a hit area for displayObjects | ||
* The Ellipse object is used to help draw graphics and can also be used to specify a hit area for displayObjects. | ||
* | ||
@@ -1525,8 +1541,8 @@ * @class | ||
*/ | ||
var Ellipse = function Ellipse(x, y, width, height) | ||
var Ellipse = function Ellipse(x, y, halfWidth, halfHeight) | ||
{ | ||
if ( x === void 0 ) x = 0; | ||
if ( y === void 0 ) y = 0; | ||
if ( width === void 0 ) width = 0; | ||
if ( height === void 0 ) height = 0; | ||
if ( halfWidth === void 0 ) halfWidth = 0; | ||
if ( halfHeight === void 0 ) halfHeight = 0; | ||
@@ -1549,3 +1565,3 @@ /** | ||
*/ | ||
this.width = width; | ||
this.width = halfWidth; | ||
@@ -1556,3 +1572,3 @@ /** | ||
*/ | ||
this.height = height; | ||
this.height = halfHeight; | ||
@@ -1615,2 +1631,4 @@ /** | ||
/** | ||
* A class to define a shape via user defined co-orinates. | ||
* | ||
* @class | ||
@@ -1696,4 +1714,2 @@ * @memberof PIXI | ||
{ | ||
var this$1 = this; | ||
var inside = false; | ||
@@ -1707,6 +1723,6 @@ | ||
{ | ||
var xi = this$1.points[i * 2]; | ||
var yi = this$1.points[(i * 2) + 1]; | ||
var xj = this$1.points[j * 2]; | ||
var yj = this$1.points[(j * 2) + 1]; | ||
var xi = this.points[i * 2]; | ||
var yi = this.points[(i * 2) + 1]; | ||
var xj = this.points[j * 2]; | ||
var yj = this.points[(j * 2) + 1]; | ||
var intersect = ((yi > y) !== (yj > y)) && (x < ((xj - xi) * ((y - yi) / (yj - yi))) + xi); | ||
@@ -1713,0 +1729,0 @@ |
{ | ||
"name": "@pixi/math", | ||
"version": "5.0.0-alpha.3", | ||
"version": "5.0.0-rc", | ||
"main": "lib/math.js", | ||
"module": "lib/math.es.js", | ||
"description": "PixiJS Application", | ||
"description": "Collection of math utilities", | ||
"author": "Mat Groves", | ||
@@ -28,4 +28,5 @@ "contributors": [ | ||
"devDependencies": { | ||
"floss": "^2.1.3" | ||
} | ||
"floss": "^2.1.5" | ||
}, | ||
"gitHead": "9026a1bbca9a9d86b7a3b6d5eb4fa2c3145c2b85" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
255881
3197
110336