GraphicsPath gp = new GraphicsPath(); gp.AddArc(0, 0, 16, 16, 90, 270); GraphicsPath gp = new GraphicsPath(); gp.AddArc(4, 4, 16, 16, 90, 270); GraphicsPath gp = new GraphicsPath(); gp.AddArc(6, 6, 16, 16, 90, 270); 这三组语句是在三个函数里面的,有影响吗?
public void AddArc( int x, int y, int width,//矩形宽度 int height,//矩形高度 float startAngle, float sweepAngle ); 所以应该是 0,0,16,16,90,270 2,2,12,12,90,270 4,4,8,8,90,270
Point[] p1={ new Point(100,0), new Point(125,50), new Point(100,100), new Point(75,50), }; GraphicsPath mypath=new GraphicsPath(); mypath.AddPolygon(p1); PathGradientBrush pathBrush = new PathGradientBrush(mypath); pathBrush.CenterColor=Color.Blue; e.Graphics.FillPath(pathBrush,mypath); e.Graphics.DrawPath(mypen,mypath);
Point[] p2={ new Point(100,100), new Point(150,100), new Point(181,150), new Point(125,150) };
mypath.AddPolygon(p2); pathBrush = new PathGradientBrush(mypath); pathBrush.CenterColor=Color.Blue; e.Graphics.FillPath(pathBrush,mypath); e.Graphics.DrawPath(mypen,mypath);
Point[] p3={
new Point(100,100), new Point(75,150), new Point(20,150), new Point(50,100) }; mypath.AddPolygon(p3); pathBrush = new PathGradientBrush(mypath); pathBrush.CenterColor=Color.Blue; e.Graphics.FillPath(pathBrush,mypath); e.Graphics.DrawPath(mypen,mypath);
} 这是个菱形的主要代码,望大家一起参考一下啊
你看这是不是你想要的??
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Rectangle rect = new Rectangle(60, 60, 120, 120); Rectangle rect1 = new Rectangle(90, 90, 60, 60); Rectangle rect2 = new Rectangle(105, 105, 30, 30); e.Graphics.DrawArc(new Pen(Color.Black,75F),rect,90,270); e.Graphics.DrawArc(new Pen(Color.Yellow,45F),rect1,90,270); e.Graphics.DrawArc(new Pen(Color.Red,30F),rect2,90,270); }
{
Rectangle rect = new Rectangle(0, 0, 120, 120);
Rectangle rect1 = new Rectangle(0, 0, 60, 60);
Rectangle rect2 = new Rectangle(0, 0, 30, 30);
GraphicsPath gp = new GraphicsPath();
e.Graphics.DrawArc(new Pen(Color.Black),rect,90,270);
e.Graphics.DrawArc(new Pen(Color.Yellow),rect1,90,270);
e.Graphics.DrawArc(new Pen(Color.Red),rect2,90,270);
}
int y=200;Bitmap myImage = new Bitmap(x,y);
Graphics g = Graphics.FromImage(myImage); g.DrawArc(Pens.Yellow,0, 0, 16, 16, 90, 270);
g.DrawArc(Pens.Yellow,4, 4, 16, 16, 90, 270);
g.DrawArc(Pens.Yellow,6, 6, 16, 16, 90, 270);
pictureBox1.Image=myImage;
还有,你每次都是new GraphicsPath(),之前AddArc的东西已经不在了
gp.AddArc(0, 0, 16, 16, 90, 270);
GraphicsPath gp = new GraphicsPath();
gp.AddArc(4, 4, 16, 16, 90, 270);
GraphicsPath gp = new GraphicsPath();
gp.AddArc(6, 6, 16, 16, 90, 270);
这三组语句是在三个函数里面的,有影响吗?
int x,
int y,
int width,//矩形宽度
int height,//矩形高度
float startAngle,
float sweepAngle
);
所以应该是
0,0,16,16,90,270
2,2,12,12,90,270
4,4,8,8,90,270
{
Pen mypen=new Pen(Color.Honeydew);
Point[] p1={ new Point(100,0),
new Point(125,50),
new Point(100,100),
new Point(75,50),
};
GraphicsPath mypath=new GraphicsPath();
mypath.AddPolygon(p1);
PathGradientBrush pathBrush = new PathGradientBrush(mypath);
pathBrush.CenterColor=Color.Blue;
e.Graphics.FillPath(pathBrush,mypath);
e.Graphics.DrawPath(mypen,mypath);
Point[] p2={
new Point(100,100),
new Point(150,100),
new Point(181,150),
new Point(125,150)
};
mypath.AddPolygon(p2);
pathBrush = new PathGradientBrush(mypath);
pathBrush.CenterColor=Color.Blue;
e.Graphics.FillPath(pathBrush,mypath);
e.Graphics.DrawPath(mypen,mypath);
Point[] p3={
new Point(100,100),
new Point(75,150),
new Point(20,150),
new Point(50,100)
};
mypath.AddPolygon(p3);
pathBrush = new PathGradientBrush(mypath);
pathBrush.CenterColor=Color.Blue;
e.Graphics.FillPath(pathBrush,mypath);
e.Graphics.DrawPath(mypen,mypath);
}
这是个菱形的主要代码,望大家一起参考一下啊
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Rectangle rect = new Rectangle(60, 60, 120, 120);
Rectangle rect1 = new Rectangle(90, 90, 60, 60);
Rectangle rect2 = new Rectangle(105, 105, 30, 30);
e.Graphics.DrawArc(new Pen(Color.Black,75F),rect,90,270);
e.Graphics.DrawArc(new Pen(Color.Yellow,45F),rect1,90,270);
e.Graphics.DrawArc(new Pen(Color.Red,30F),rect2,90,270);
}