diff --git a/src/core/math/shapes/Rectangle.js b/src/core/math/shapes/Rectangle.js index 29b312a..0cc0e4d 100644 --- a/src/core/math/shapes/Rectangle.js +++ b/src/core/math/shapes/Rectangle.js @@ -21,25 +21,25 @@ * @member {number} * @default 0 */ - this.x = x; + this.x = Number(x); /** * @member {number} * @default 0 */ - this.y = y; + this.y = Number(y); /** * @member {number} * @default 0 */ - this.width = width; + this.width = Number(width); /** * @member {number} * @default 0 */ - this.height = height; + this.height = Number(height); /** * The type of the object, mainly used to avoid `instanceof` checks diff --git a/src/core/math/shapes/Rectangle.js b/src/core/math/shapes/Rectangle.js index 29b312a..0cc0e4d 100644 --- a/src/core/math/shapes/Rectangle.js +++ b/src/core/math/shapes/Rectangle.js @@ -21,25 +21,25 @@ * @member {number} * @default 0 */ - this.x = x; + this.x = Number(x); /** * @member {number} * @default 0 */ - this.y = y; + this.y = Number(y); /** * @member {number} * @default 0 */ - this.width = width; + this.width = Number(width); /** * @member {number} * @default 0 */ - this.height = height; + this.height = Number(height); /** * The type of the object, mainly used to avoid `instanceof` checks diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 6c3d1e1..3922e52 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -551,8 +551,8 @@ if (frame.x + frame.width > this.baseTexture.width || frame.y + frame.height > this.baseTexture.height) { throw new Error('Texture Error: frame does not fit inside the base Texture dimensions: ' - + `X: ${frame.x} + ${frame.width} > ${this.baseTexture.width} ` - + `Y: ${frame.y} + ${frame.height} > ${this.baseTexture.height}`); + + `X: ${frame.x} + ${frame.width} = ${frame.x + frame.width} > ${this.baseTexture.width} ` + + `Y: ${frame.y} + ${frame.height} = ${frame.y + frame.height} > ${this.baseTexture.height}`); } // this.valid = frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded; diff --git a/src/core/math/shapes/Rectangle.js b/src/core/math/shapes/Rectangle.js index 29b312a..0cc0e4d 100644 --- a/src/core/math/shapes/Rectangle.js +++ b/src/core/math/shapes/Rectangle.js @@ -21,25 +21,25 @@ * @member {number} * @default 0 */ - this.x = x; + this.x = Number(x); /** * @member {number} * @default 0 */ - this.y = y; + this.y = Number(y); /** * @member {number} * @default 0 */ - this.width = width; + this.width = Number(width); /** * @member {number} * @default 0 */ - this.height = height; + this.height = Number(height); /** * The type of the object, mainly used to avoid `instanceof` checks diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 6c3d1e1..3922e52 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -551,8 +551,8 @@ if (frame.x + frame.width > this.baseTexture.width || frame.y + frame.height > this.baseTexture.height) { throw new Error('Texture Error: frame does not fit inside the base Texture dimensions: ' - + `X: ${frame.x} + ${frame.width} > ${this.baseTexture.width} ` - + `Y: ${frame.y} + ${frame.height} > ${this.baseTexture.height}`); + + `X: ${frame.x} + ${frame.width} = ${frame.x + frame.width} > ${this.baseTexture.width} ` + + `Y: ${frame.y} + ${frame.height} = ${frame.y + frame.height} > ${this.baseTexture.height}`); } // this.valid = frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded; diff --git a/test/core/Rectangle.js b/test/core/Rectangle.js index edd5a99..3bd6f13 100644 --- a/test/core/Rectangle.js +++ b/test/core/Rectangle.js @@ -12,6 +12,16 @@ expect(rect.bottom).to.equal(6); }); + it('should cast quantities to number types', function () + { + const rect = new PIXI.Rectangle('5', '5', '1', '1'); + + expect(rect.left).to.equal(5); + expect(rect.top).to.equal(5); + expect(rect.right).to.equal(6); + expect(rect.bottom).to.equal(6); + }); + it('should clone a new rectangle', function () { const rect1 = new PIXI.Rectangle(10, 10, 10, 10);