using (Graphics graphics = this.CreateGraphics()){graphics.Clear(Color.White); Point[] points = {//顺时针点坐标new Point(80, 0), new Point(100, 60), new Point(160, 60), new Point(110, 100),new Point(130, 160), new Point(80, 120), new Point(30, 160), new Point(50, 100), new Point(0, 60), new Point(60, 60),new Point(80, 0) };// 创建路径GraphicsPath path = new GraphicsPath();//在路径中添加直线 path.AddLines(points);//创建路径渐变画刷PathGradientBrush pgb = new PathGradientBrush(path);//设置中心点色彩(终点色)pgb.CenterColor = Color.Red;//设置每个端点的色彩(终点色)//设置路径渐变画刷的边缘色pgb.SurroundColors = new Color[] { Color.Aqua, Color.Green,Color.Pink, Color.White, Color.Yellow, Color.Green, Color.Blue, Color.Silver,Color.Black, Color.Green };// 填充目标路径 graphics.FillPath(pgb, path);path.Dispose();pgb.Dispose();}
转载于:https://www.cnblogs.com/wjshan0808/p/4236012.html