diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 9e65938..333f6fd 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -491,9 +491,9 @@ const startX = cx + (Math.cos(startAngle) * radius); const startY = cy + (Math.sin(startAngle) * radius); - const points = this.currentPath.shape.points; + let points = this.currentPath ? this.currentPath.shape.points : null; - if (this.currentPath) + if (points) { if (points[points.length - 2] !== startX || points[points.length - 1] !== startY) { @@ -503,6 +503,7 @@ else { this.moveTo(startX, startY); + points = this.currentPath.shape.points; } const theta = sweep / (segs * 2); diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 9e65938..333f6fd 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -491,9 +491,9 @@ const startX = cx + (Math.cos(startAngle) * radius); const startY = cy + (Math.sin(startAngle) * radius); - const points = this.currentPath.shape.points; + let points = this.currentPath ? this.currentPath.shape.points : null; - if (this.currentPath) + if (points) { if (points[points.length - 2] !== startX || points[points.length - 1] !== startY) { @@ -503,6 +503,7 @@ else { this.moveTo(startX, startY); + points = this.currentPath.shape.points; } const theta = sweep / (segs * 2); diff --git a/test/core/Graphics.js b/test/core/Graphics.js index c7c7a45..926bd59 100644 --- a/test/core/Graphics.js +++ b/test/core/Graphics.js @@ -128,4 +128,33 @@ expect(graphics.containsPoint(point)).to.be.false; }); }); + + describe('complex drawing #1: draw triangle, rounder rect and an arc (issue #3433)', () => + { + it('should not throw', () => + { + const graphics = new PIXI.Graphics(); + + // set a fill and line style + graphics.beginFill(0xFF3300); + graphics.lineStyle(4, 0xffd900, 1); + + // draw a shape + graphics.moveTo(50, 50); + graphics.lineTo(250, 50); + graphics.lineTo(100, 100); + graphics.lineTo(50, 50); + graphics.endFill(); + + graphics.lineStyle(2, 0xFF00FF, 1); + graphics.beginFill(0xFF00BB, 0.25); + graphics.drawRoundedRect(150, 450, 300, 100, 15); + graphics.endFill(); + + graphics.beginFill(); + graphics.lineStyle(4, 0x00ff00, 1); + graphics.arc(300, 100, 20, 0, Math.PI); + graphics.endFill(); + }); + }); });