How to draw a polygon using EaselJS?

quik_silv picture quik_silv · Feb 6, 2014 · Viewed 9.7k times · Source

There are Shape.graphic methods to draw circles and rectangles easily, but no obvious method to draw polygons such as hexagons and polygons? How do you draw them using EaselJS?

Answer

quik_silv picture quik_silv · Feb 6, 2014

Actually its very simple, one just needs to use the method moveTo and lineTo. An example to draw a simple triangle,

var polygon = new createjs.Shape();
polygon.graphics.beginStroke("black");
polygon.graphics.moveTo(0, 60).lineTo(60, 60).lineTo(30, 90).lineTo(0, 60);

And come to think of it, there is no need of a drawPolygon method. It won't be used that extensively in my opinion.