上一篇【学习笔记】Windows GDI绘图(五)图形路径GraphicsPath详解(上)介绍了GraphicsPath类的构造函数、属性和方法AddArc添加椭圆弧、AddBezier添加贝赛尔曲线、AddClosedCurve添加封闭基数样条曲线、AddCurve添加开放基数样条曲线、基数样条如何转Bezier、AddEllipse添加椭圆、AddLine添加线段。
革命尚未成功,同志仍需努力!
文章目录

GraphicsPath方法
AddLines添加线段
原型:
public void AddLines (params System.Drawing.Point[] points);
public void AddLines (params System.Drawing.PointF[] points);
添加一系列的线段到GraphicsPath中。
// 定义三角形的顶点
Point[] points =
{
new Point(150,150),
new Point(300,300),
new Point(0,300),
new Point(150,150)
};
using (var myPath = new GraphicsPath())
{
myPath.AddLines(points);
e.Graphics.DrawPath(penRed, myPath);
}
通过点集绘制线段
AddPath附加路径
原型:
public void AddPath (System.Drawing.Drawing2D.GraphicsPath addingPath, bool connect);
connect,当前路径与附加的路径是否相连
将指定的GraphicsPath附加到当前Path中
Point[] myArray =
{
new Point(120,120),
new Point(240,240),
new Point(0,240),
new Point(120,120)
};
GraphicsPath myPath = new GraphicsPath();
myPath.AddLines(myArray);
Point[] myArray2 =
{
new Point(120,100),
new Point(20,20),
new Point(220,20),
new Point(120,100)
};
GraphicsPath myPath2 = new GraphicsPath();
myPath2.AddLines(myArray2);
// Add the second path to the first path.
myPath.AddPath(myPath2, false);//各自独立
// Draw the combined path to the screen.
e.Graphics.DrawPath(penRed, myPath);
myPath.Reset();
myPath.AddLines(myArray);
myPath.AddPath(myPath2, true);//相连
myPath.Transform(new Matrix(1, 0, 0, 1, 400, 0));
e.Graphics.DrawPath(penLightGreen, myPath);
AddPie添加饼形
原型:
public void AddPie (System.Drawing.Rectangle rect, float startAngle, float sweepAngle);
public void AddPie (int x, int y, int width, int height, float startAngle, float sweepAngle);
public void AddPie (float x, <