diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index f762ed3..b8ba208 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -974,8 +974,8 @@ theta = (x2 - x) / (y2 - y); } - rw = ((h * Math.sin(theta)) + (w * Math.cos(theta))) / 2; - rh = ((w * Math.sin(theta)) + (h * Math.cos(theta))) / 2; + rw = Math.abs((h * Math.sin(theta)) + (w * Math.cos(theta))) / 2; + rh = Math.abs((w * Math.sin(theta)) + (h * Math.cos(theta))) / 2; cx = (x2 + x) / 2; cy = (y2 + y) / 2; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index f762ed3..b8ba208 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -974,8 +974,8 @@ theta = (x2 - x) / (y2 - y); } - rw = ((h * Math.sin(theta)) + (w * Math.cos(theta))) / 2; - rh = ((w * Math.sin(theta)) + (h * Math.cos(theta))) / 2; + rw = Math.abs((h * Math.sin(theta)) + (w * Math.cos(theta))) / 2; + rh = Math.abs((w * Math.sin(theta)) + (h * Math.cos(theta))) / 2; cx = (x2 + x) / 2; cy = (y2 + y) / 2; diff --git a/test/core/Graphics.js b/test/core/Graphics.js index e868daa..020ecaf 100644 --- a/test/core/Graphics.js +++ b/test/core/Graphics.js @@ -93,14 +93,14 @@ const graphics = new PIXI.Graphics(); graphics.lineStyle(20, 0, 0.5); - graphics.moveTo(10, 10); - graphics.lineTo(50, 10); + graphics.moveTo(0, 0); + graphics.lineTo(50, 0); graphics.lineTo(50, 50); - graphics.lineTo(10, 50); - graphics.lineTo(10, 10); + graphics.lineTo(0, 50); + graphics.lineTo(0, 0); - expect(graphics.width).to.be.equals(50); - expect(graphics.height).to.be.equals(50); + expect(graphics.width).to.be.equals(70); + expect(graphics.height).to.be.equals(70); }); }); });