Sitelet https://github.com/CreateJS/EaselJS/issues/1058
Skip to content

Graphics new method 'drawPolygon' #1058

Description

@hsk-kr
/**
 * 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions