C#. How to draw a circle on the center of the console?
First user inputs the radius of the circle.
Then the circle is drawn on the center of the console.
Thanks much in advance
- AnalProgrammerLv 79 years agoFavorite Answer
There are no circles or triangles or polygons in computing. Only rectangles that contain a graphic.
So to draw a circle you need the method and the parameters
The first parameter is the pen.
The next two are the x, y coordinates of the top left corner of the rectangle that surrounds the circle.
The next two parameters are the height and width of the rectangle that surrounds the circle, well as the circle will be touching the rectangle the diameters across the north, south and east, west planes.
Now to draw a circle in the centre of a frame you need to know the size of the frame. Height and width.
Divide both by two to get the approximate centre point. You will not get the true centre if either the height or width are odd.
Now subtract from the height and width half the height and width of the rectangle to get the coordinates of the circle you wish to draw.