简体   繁体   English

如何使用图形绘制填充的多边形

[英]How to draw a filled polygon using Graphics

Within the System.Drawing.Graphics namespace you can draw a polygon like this: 在System.Drawing.Graphics命名空间内,您可以绘制一个像这样的多边形:

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

and there is a method to create a filled polygon g.FillPolygon() . 还有一种创建填充多边形g.FillPolygon()

How can you create a polygon (so it has a border) and then fill it? 如何创建多边形(使其具有边框)然后填充它?

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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM