Draw ellipse and arc of basic graphics

To draw an ellipse: Graphics and Pen objects are required. The Graphics object provides the DrawEllipse method, and the Pen object stores the line properties, such as width and color, used to render the ellipse.

 

 

private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Pen p = new Pen(Color.Red,5);
            // last two parameters
            //1 startangle The angle to rotate clockwise from the X axis
            //2 The angle from the start angle to the end point of the arc in a clockwise direction
            g.DrawArc(p,0,50,200,200,0,120);
            // draw fan
        
            // System.Drawing.Pen, which determines the color, width and style of the fan.
            //
            //   x:
            // The x-coordinate of the upper-left corner of the border that defines the ellipse to which the sector belongs.
            //
            // and:
            // The y coordinate of the upper left corner of the border that defines the ellipse to which the sector belongs.
            //
            //   width:
            // The width of the border that defines the ellipse to which the sector belongs.
            //
            //   height:
            // The height of the border, which defines the ellipse to which the sector belongs.
            //
            // startAngle:
            // The angle (in degrees) measured clockwise from the x-axis to the first edge of the sector.
            //
            //   sweepAngle:
            // The angle (in degrees) measured clockwise from the startAngle parameter to the second edge of the sector.
            g.DrawPie(p,0,200,300,200,50,120);
            g.Dispose();

 

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324772694&siteId=291194637