五、使用GDI+画椭圆

前面利用DrawArc能绘制出椭圆来。

GDI+还有专门绘制椭圆的函数DrawEllipse

DrawEllipse(Pen,Rectangle)

DrawEllipse(Pen,RectangleF)

DrawEllipse(Pen,Int32,Int32,Int32,Int32)

DrawEllipse(Pen,Single,Single,Single,Single)
private void Form1_Paint(object sender, PaintEventArgs e)
{    
    //创建画板从Paint事件中的直接引用Graphics对象
    Graphics graphics = e.Graphics;

    graphics.Clear(Color.Black);

    //定义画笔
    Pen pen = new Pen(Color.White, 3.0f);
    Pen thickPen = new Pen(Color.White,2.0f);
    Pen thick = new Pen(Color.Red, 2.0f);

    graphics.DrawEllipse(pen, new Rectangle(50, 50, 100, 200));

}

如果我把Rectangle的width和height设置为登长的话

graphics.DrawEllipse(pen, new Rectangle(50, 50, 100, 100));


又多了一种画圆的方法,通过DrawArc函数可以画圆,今天是第二种。

posted on 2012-05-17 22:23  kiny  阅读(927)  评论(0编辑  收藏  举报