Graphics.DrawPie Method
Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, and a height and two radial lines.
Overload List
Draws a pie shape defined by an ellipse specified by a Rectangle structure and two radial lines.
[Visual Basic] Overloads Public Sub DrawPie(Pen, Rectangle, Single, Single)
[C#] public void DrawPie(Pen, Rectangle, float, float);
[C++] public: void DrawPie(Pen*, Rectangle, float, float);
[JScript] public function DrawPie(Pen, Rectangle, float, float);
Draws a pie shape defined by an ellipse specified by a RectangleF structure and two radial lines.
[Visual Basic] Overloads Public Sub DrawPie(Pen, RectangleF, Single, Single)
[C#] public void DrawPie(Pen, RectangleF, float, float);
[C++] public: void DrawPie(Pen*, RectangleF, float, float);
[JScript] public function DrawPie(Pen, RectangleF, float, float);
Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, and a height and two radial lines.
[Visual Basic] Overloads Public Sub DrawPie(Pen, Integer, Integer, Integer, Integer, Integer, Integer)
[C#] public void DrawPie(Pen, int, int, int, int, int, int);
[C++] public: void DrawPie(Pen*, int, int, int, int, int, int);
[JScript] public function DrawPie(Pen, int, int, int, int, int, int);
Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, and a height and two radial lines.
[Visual Basic] Overloads Public Sub DrawPie(Pen, Single, Single, Single, Single, Single, Single)
[C#] public void DrawPie(Pen, float, float, float, float, float, float);
[C++] public: void DrawPie(Pen*, float, float, float, float, float, float);
[JScript] public function DrawPie(Pen, float, float, float, float, float, float);
Example
[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:
- Creates a black pen.
- Creates the position and size of a rectangle that bounds a complete ellipse.
- Defines the angles at which to start drawing (relative to the x axis) and through which to draw (both in a clockwise direction).
- Draws the pie segment to the screen.
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of DrawPie. For other examples that might be available, see the individual overload topics.
[Visual Basic] Public Sub DrawPieFloat(e As PaintEventArgs) ' Create pen. Dim blackPen As New Pen(Color.Black, 3) ' Create location and size of ellipse. Dim x As Single = 0F Dim y As Single = 0F Dim width As Single = 200F Dim height As Single = 100F ' Create start and sweep angles. Dim startAngle As Single = 0F Dim sweepAngle As Single = 45F ' Draw pie to screen. e.Graphics.DrawPie(blackPen, x, y, width, height, _ startAngle, sweepAngle) End Sub [C#] public void DrawPieFloat(PaintEventArgs e) { // Create pen. Pen blackPen = new Pen(Color.Black, 3); // Create location and size of ellipse. float x = 0.0F; float y = 0.0F; float width = 200.0F; float height = 100.0F; // Create start and sweep angles. float startAngle = 0.0F; float sweepAngle = 45.0F; // Draw pie to screen. e.Graphics.DrawPie(blackPen, x, y, width, height, startAngle, sweepAngle); }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
See Also
Graphics Class | Graphics Members | System.Drawing Namespace