Martin Smellworse
Martin Smellworse

Reputation: 1762

How to draw a filled polygon using Graphics

Within the System.Drawing.Graphics namespace you can draw a polygon like this:

using (Graphics g = Graphics.FromImage(bmp))
{
  g.DrawPolygon(Pens.Black, myArray);
}

and there is a method to create a filled polygon g.FillPolygon().

How can you create a polygon (so it has a border) and then fill it?

Upvotes: 2

Views: 9523

Answers (1)

matthewr
matthewr

Reputation: 4749

Just draw the filled polygon then draw the perimeter so it looks like it has a border:

using (Graphics g = Graphics.FromImage(bmp))
{
    g.FillPolygon(fillBrush, myArray);
    g.DrawPolygon(borderPen, myArray);
}

Upvotes: 6

Related Questions