question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
danzencommented, Jan 22, 2021

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.

image

1reaction
danzencommented, Apr 2, 2021

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 image

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found