g.DrawRectangle(yellow, 100, 50, 100, 60);
g.DrawEllipse(yellow, 100, 50, 100, 60);
The code above would produce a rectangle with cordinates (100, 50) having a width of 100 and a height of 60. The ellipse will fit perfectly in this rectangle. In other words, the cordinates (x, y) of an ellipse is not the center of it, but rather its top, left placing.
If you'd want an ellipse centered at (100, 50) you'd simply have to to substract half of its width from x, and half of its height from y.
int x = 100;
int y = 50;
int width = 100;
int height = 60;
g.DrawEllipse(yellow, x-width/2, y-height/2, width, height);
Did that answer your question
|