Skip to content

Commit 8ab0011

Browse files
committed
Added support for drawing ellipses and arrays of points
1 parent b909f70 commit 8ab0011

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

v3/src/gameobjects/graphics/Graphics.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,48 @@ var Graphics = new Class({
317317
return this;
318318
},
319319

320+
// STROKE LINES BETWEEN AN ARRAY OF POINTS
321+
322+
strokePoints: function (points)
323+
{
324+
this.beginPath();
325+
326+
this.moveTo(points[0].x, points[0].y);
327+
328+
for (var i = 1; i < points.length; i++)
329+
{
330+
this.lineTo(points[i].x, points[i].y);
331+
}
332+
333+
this.closePath();
334+
335+
this.strokePath();
336+
337+
return this;
338+
},
339+
340+
// ELLIPSE
341+
342+
strokeEllipseShape: function (ellipse, smoothness)
343+
{
344+
if (smoothness === undefined) { smoothness = 32; }
345+
346+
var points = ellipse.getPoints(smoothness);
347+
348+
return this.strokePoints(points);
349+
},
350+
351+
strokeEllipse: function (x, y, width, height, smoothness)
352+
{
353+
if (smoothness === undefined) { smoothness = 32; }
354+
355+
var ellipse = new Ellipse(x, y, width, height);
356+
357+
var points = ellipse.getPoints(smoothness);
358+
359+
return this.strokePoints(points);
360+
},
361+
320362
// ARC
321363

322364
arc: function (x, y, radius, startAngle, endAngle, anticlockwise)
@@ -329,6 +371,8 @@ var Graphics = new Class({
329371
return this;
330372
},
331373

374+
// TRANSFORM
375+
332376
save: function ()
333377
{
334378
this.commandBuffer.push(

0 commit comments

Comments
 (0)