C# Code
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace GraphicsSample
{
public partial class FrmFillPolygon : Form
{
public FrmFillPolygon()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
FillPolygonWinding(e);
}
public void FillPolygonWinding(PaintEventArgs e)
{
PointF point1 = new PointF(50.0F, 50.0F);
PointF point2 = new PointF(100.0F, 25.0F);
PointF point3 = new PointF(200.0F, 5.0F);
PointF point4 = new PointF(250.0F, 50.0F);
PointF point5 = new PointF(300.0F, 100.0F);
PointF point6 = new PointF(350.0F, 200.0F);
PointF point7 = new PointF(250.0F, 250.0F);
PointF[] curvePoints = { point1, point2, point3, point4, point5, point6, point7 };
FillMode fillMode = FillMode.Winding;
e.Graphics.FillPolygon(Brushes.LightBlue, curvePoints, fillMode);
}
}
}
範例筆記- [250,50] 和 [300,100] 個人感覺剛好形成一條直線,導致 [250,50] 沒有很明顯
- 該範例設定 FillMode 其實看不出效果
- 參考資料
- FillMode 列舉
沒有留言:
張貼留言