填充函数 |
函数功能描述 |
FillClosedCurve |
填充闭合曲线 |
FillEllipse |
填充椭圆 |
FillPath |
填充路径 |
FillPie |
填充扇形 |
FillPolygon |
填充多边形 |
FillRectangle |
填充矩形 |
FillRectangles |
填充矩形集 |
FillRegion |
填充区域 |
下图简单展示单色画刷的应用:
Demo 代码:
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.Clear(Color.White);
//构建绿色的单色画刷
SolidBrush greenSB = new SolidBrush(Color.Green);
//填充椭圆
g.FillEllipse(greenSB,50,50,200,100);
//使用 .NET 内置的单身画刷(内置的画刷不需要手动释放)
g.FillRectangle(Brushes.Red,300,50,200,100);
//定义曲线、多边形端点坐标
PointF pt1 = new PointF(100.0f,250.0f);
PointF pt2 = new PointF(200.0f,200.0f);
PointF pt3 = new PointF(250.0f,350.0f);
PointF pt4 = new PointF(50.0f,300.0f);
PointF pt5 = new PointF(100.0f,250.0f);
//定义曲线端点并填充
PointF[] closedCurvePts = new PointF[] { pt1, pt2, pt3, pt4 };
g.FillClosedCurve(greenSB,closedCurvePts);
//定义多边形端点并填充
PointF[] polygonPts = new PointF[] { pt1,pt2,pt3,pt4,pt5};
g.TranslateTransform(300,0);
g.FillPolygon(Brushes.LightBlue,polygonPts);
//释放资源
greenSB.Dispose();
}