c#画三角形、并填充颜色
目前知道有两种方法:画多边形、GraphicsPath。但是用画多边形的方式画三角形不太好。老画不正的,截图放大就明显了。
代码
1 Point point1 = new Point(0, 0);
2 Point point2 = new Point(11, 0);
3 Point point3 = new Point(5, 8);
4 Point[] pntArr = {point1, point2, point3};
5
6 e.Graphics.FillPolygon(Brushes.Red, pntArr);
7
2 Point point2 = new Point(11, 0);
3 Point point3 = new Point(5, 8);
4 Point[] pntArr = {point1, point2, point3};
5
6 e.Graphics.FillPolygon(Brushes.Red, pntArr);
7
代码
1 int len = 10;
2 int x = 0;
3 int y = 0;
4 Point[] pntArr = new Point[3];
5 pntArr[0] = new Point(x, y);
6 pntArr[1] = new Point(x - len, y);
7 pntArr[2] = new Point(x - len / 2, (int)(len * Math.Sqrt(3) / 2 + y));
8 &nbs
2 int x = 0;
3 int y = 0;
4 Point[] pntArr = new Point[3];
5 pntArr[0] = new Point(x, y);
6 pntArr[1] = new Point(x - len, y);
7 pntArr[2] = new Point(x - len / 2, (int)(len * Math.Sqrt(3) / 2 + y));
8 &nbs
补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,
部分文章来自网络,