Graphics new method 'drawPolygon'
See original GitHub issue/**
* 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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Graphics.DrawPolygon Method (System.Drawing)
Draws a series of line segments that connect an array of Point structures. How to: Set Pen Width and Alignment - Windows Forms...
Read more >DrawPolygon Method - Graphics Mill
Graphics.DrawPolygon Method. Draws a polygon defined by an array of PointF structures. Namespace: Aurigma.GraphicsMill.AdvancedDrawing. Assembly: Aurigma.
Read more >java.awt.Graphics.drawPolygon java code examples - Tabnine
public static void drawDiamondSelectorCorner(Graphics g, Color outline, Color body, int x, int y, int size) { int [] xs = new int[] {x,...
Read more >What is drawpolygon() in Java? - Educative.io
The drawpolygon() method is a method of the Graphics class in Java that is used to draw polygons. ... JFrame frame = new...
Read more >Drawing polygons with Graphics methods drawPolygon and ...
Selection from Java 8 Fundamentals: Modern Java Development with Lambdas, Streams, and Introducing Java 9's JShell and the Java Platform Module System ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Very nice. There is a drawPolyStar for regular polygons with a tiny API of dp(). I guess something like pg() might work - anyone else have a thought? I know most draws start with d but not drawRoundRectComplex. Another option might be dg(). We could double up in the chart below with dp/pg.
Another thing that I have found that even if you cp() a the end - which may be done automatically under the hood, that the line corner does not take the same corner point setting. So I think on our version of createjs drawPolyStar for ZIM, we keep going for one more turn - we will check that out as we consider the addition.
Here is an example of it working on the ZIM version of CreateJS - with same code as added to the repo here. https://zimjs.com/explore/molnar.html