绘制多边形后,在顶部绘制代表顶点的圆圈。如果您只使用一种颜色,我建议您将其放入一个for
循环中,但如果您要更改画笔颜色,您不妨单独进行。
将此添加到您的代码中:
SolidBrush blueBrush = new SolidBrush(Color.Blue); // same as brush above, but being consistent
SolidBrush redBrush = new SolidBrush(Color.Red);
SolidBrush greenBrush = new SolidBrush(Color.Green);
int vertexRadius = 1; // change this to make the vertices bigger
surface.fillEllipse(redBrush, new Rectangle(100 - vertexRadius, 100 - vertexRadius, vertexRadius * 2, vertexRadius * 2));
surface.fillEllipse(blueBrush, new Rectangle(75 - vertexRadius, 50 - vertexRadius, vertexRadius * 2, vertexRadius * 2));
surface.fillEllipse(greenBrush, new Rectangle(50 - vertexRadius, 100 - vertexRadius, vertexRadius * 2, vertexRadius * 2));
编辑
我从您的评论中了解到您正在寻找从一个顶点到下一个顶点的渐变。这是根据MSDN文档制作路径渐变的方法。(如果你不想用渐变填充内部,你可以使用线性渐变。)
PathGradientBrush gradientBrush = new PathGradientBrush(points);
Color[] colors = { Color.Red, Color.Blue, Color.Green };
gradientBrush.CenterColor = Color.Black;
gradientBrush.SurroundColors = colors;
然后用新画笔填充多边形:
surface.FillPolygon(gradientBrush, points);