diff --git a/src/core/graphics/canvas/CanvasGraphicsRenderer.js b/src/core/graphics/canvas/CanvasGraphicsRenderer.js index 5c9aec9..7c387db 100644 --- a/src/core/graphics/canvas/CanvasGraphicsRenderer.js +++ b/src/core/graphics/canvas/CanvasGraphicsRenderer.js @@ -83,25 +83,14 @@ { context.beginPath(); - var points = shape.points; + this.renderPolygon(shape.points, shape.closed, context); - context.moveTo(points[0], points[1]); - - for (var j=1; j < points.length/2; j++) + for (var j = 0; j < data.holes.length; j++) { - context.lineTo(points[j * 2], points[j * 2 + 1]); + var hole = data.holes[j]; + this.renderPolygon(hole.points, true, context); } - if (shape.closed) - { - context.lineTo(points[0], points[1]); - } - - // if the first and last point are the same close the path - much neater :) - if (points[0] === points[points.length-2] && points[1] === points[points.length-1]) - { - context.closePath(); - } if (data.fill) { @@ -267,6 +256,21 @@ } }; +CanvasGraphicsRenderer.prototype.renderPolygon = function (points, close, context) +{ + context.moveTo(points[0], points[1]); + + for (var j=1; j < points.length/2; j++) + { + context.lineTo(points[j * 2], points[j * 2 + 1]); + } + + if (close) + { + context.closePath(); + } +}; + /* * destroy graphics object *