![]() |
Drawing Ellipses and Circles |
|
Ellipses and Circles |
|
An ellipse is a closed continuous line whose points are positioned so that two points exactly opposite each other have the exact same distant from a central point. It can be illustrated as follows:
|
|
Because an ellipse can fit in a rectangle, in GDI+ programming, an ellipse is defined with regards to a rectangle it would fit in. To draw an ellipse, you can use the Graphics::DrawEllipse() method that comes in four versions whose syntaxes are: public:
void DrawEllipse(Pen ^pen,
Rectangle rect);
void DrawEllipse(Pen ^pen,
RectangleF rect);
void DrawEllipse(Pen ^pen,
int x,
int y,
int width,
int height);
void DrawEllipse(Pen ^pen,
float x,
float y,
float width,
float height);
The arguments of this method play the same roll as those of the Graphics::DrawRectangle() method:
Here is an example: System::Void Form1_Paint(System::Object ^ sender,
System::Windows::Forms::PaintEventArgs ^ e)
{
Pen ^penCurrent = gcnew Pen(Color::Red);
e->Graphics->DrawEllipse(penCurrent, Rectangle(20, 20, 226, 144));
}
|
|
|
||
| Home | Copyright © 2007-2013, FunctionX | |
|
|
||