private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics gp = e.Graphics;
//绘制第一个图形
//设置第一个图形的点坐标数组
Point[] myPtsA ={new Point(10,10),new Point(90,10),new Point(170,10),new Point(170,50),
new Point(170,90),new Point(90,90), new Point(10,90),new Point(10,50)};
//设置第一个图形的颜色数组
Color[] myColsA = { Color.White, Color.Black,Color.White, Color.Black,
Color.White,Color.Black,Color.White,Color.Black};
PathGradientBrush myPGBrushA = new PathGradientBrush(myPtsA);
myPGBrushA.SurroundColors = myColsA;
myPGBrushA.CenterColor = Color.Blue;
gp.FillRectangle(myPGBrushA, 10, 10, 160, 80);
//绘制第二个图形
//设置第二个图形的点坐标数组
Point[] myPtsB ={new Point(90, 100),new Point(115,165),new Point(170,170),
new Point(125,210),new Point(140,270),new Point(90,235),new Point(40,270),
new Point(55,210), new Point(10,170), new Point(65,165)};
GraphicsPath myPathB = new GraphicsPath();
myPathB.AddLines(myPtsB);
PathGradientBrush myPGBrushB = new PathGradientBrush(myPathB);
myPGBrushB.CenterColor = Color.Yellow;
//设置第二个图形的颜色数组
Color[] myColorsB = {Color.Red,Color.Yellow,Color.Blue,Color.Green,
Color.White, Color.Black,Color.Brown, Color.Violet,Color.Tomato,Color.Snow};
myPGBrushB.SurroundColors = myColorsB;
gp.FillPath(myPGBrushB, myPathB);
}