diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..347b5a2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://EditorConfig.org +root = true + +[**.js] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..347b5a2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://EditorConfig.org +root = true + +[**.js] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 47d2e73..cc39a28 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -77,7 +77,7 @@ */ PIXI.Circle.prototype.getBounds = function() { - return new PIXI.Rectangle(this.x - this.radius, this.y - this.radius, this.width, this.height); + return new PIXI.Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2); }; // constructor diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..347b5a2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://EditorConfig.org +root = true + +[**.js] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 47d2e73..cc39a28 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -77,7 +77,7 @@ */ PIXI.Circle.prototype.getBounds = function() { - return new PIXI.Rectangle(this.x - this.radius, this.y - this.radius, this.width, this.height); + return new PIXI.Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2); }; // constructor diff --git a/test/lib/pixi/core/Circle.js b/test/lib/pixi/core/Circle.js new file mode 100644 index 0000000..e7cbd4d --- /dev/null +++ b/test/lib/pixi/core/Circle.js @@ -0,0 +1,22 @@ +function pixi_core_Circle_confirmNewCircle(obj) { + var expect = chai.expect; + + expect(obj).to.be.an.instanceof(PIXI.Circle); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('radius', 0); +} + +function pixi_core_Circle_isBoundedByRectangle(obj, rect) { + var expect = chai.expect; + + expect(rect).to.have.property('x', obj.x - obj.radius); + expect(rect).to.have.property('y', obj.y - obj.radius); + + expect(rect).to.have.property('width', obj.radius * 2); + expect(rect).to.have.property('height', obj.radius * 2); +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..347b5a2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://EditorConfig.org +root = true + +[**.js] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/src/pixi/core/Circle.js b/src/pixi/core/Circle.js index 47d2e73..cc39a28 100644 --- a/src/pixi/core/Circle.js +++ b/src/pixi/core/Circle.js @@ -77,7 +77,7 @@ */ PIXI.Circle.prototype.getBounds = function() { - return new PIXI.Rectangle(this.x - this.radius, this.y - this.radius, this.width, this.height); + return new PIXI.Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2); }; // constructor diff --git a/test/lib/pixi/core/Circle.js b/test/lib/pixi/core/Circle.js new file mode 100644 index 0000000..e7cbd4d --- /dev/null +++ b/test/lib/pixi/core/Circle.js @@ -0,0 +1,22 @@ +function pixi_core_Circle_confirmNewCircle(obj) { + var expect = chai.expect; + + expect(obj).to.be.an.instanceof(PIXI.Circle); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('radius', 0); +} + +function pixi_core_Circle_isBoundedByRectangle(obj, rect) { + var expect = chai.expect; + + expect(rect).to.have.property('x', obj.x - obj.radius); + expect(rect).to.have.property('y', obj.y - obj.radius); + + expect(rect).to.have.property('width', obj.radius * 2); + expect(rect).to.have.property('height', obj.radius * 2); +} diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js index 93a4456..fbcfa17 100644 --- a/test/unit/pixi/core/Circle.js +++ b/test/unit/pixi/core/Circle.js @@ -10,13 +10,12 @@ it('Confirm new instance', function () { var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); - expect(obj).to.be.an.instanceof(Circle); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('radius', 0); + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); }); });