'How to create 2D Polygon with C#
I am trying to create this 2D polygon but I get a blank a image after plotting the points.
The Point class takes x and y axes as parameters. Point(x, y)
Bitmap bitmap = new Bitmap(1000, 800, PixelFormat.Format32bppPArgb);
Graphics graphics = Graphics.FromImage(bitmap);
Pen pen = new Pen(System.Drawing.Color.Blue, 2);
Point[] points =
{
new Point(2408, 919),
new Point(2596, 919),
new Point(2596, 1200),
new Point(2408, 919),
new Point(2596, 1505),
new Point(2572, 1505),
new Point(2408, 1200),
new Point(2408, 919)
};
graphics.DrawPolygon(pen, points);
bitmap.Save("DrawPolygon.png");
Update: The polygon now displays as per Jimi's first comment. New issue is the polygon shortest length always sit on the horizontal axis and the polygon lines are crossing.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

