Open
Description
/**
* Draw Polygon
* @param {[x, y][]} posList Position List
*/
createjs.Graphics.prototype.drawPolygon = function (...posList) {
const copyPosList = [...posList];
if (copyPosList.length === 0) return this;
const firstPos = copyPosList.splice(0, 1)[0];
let chain = this.moveTo(firstPos[0], firstPos[1]);
for (const pos of copyPosList) chain = chain.lineTo(pos[0], pos[1]);
return chain.lineTo(firstPos[0], firstPos[1]);
};
This is a method that I defined in my project.
I searched for that how to draw polygon using EaselJS.
There were no methods of that. people have their own method for drawing a polygon.
It's not that hard to make your own method for it.
But I think It would be better that EaselJS provides us the method.