#### Archived

This topic is now archived and is closed to further replies.

# Filled Ellipse

This topic is 5274 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''ve searched on google and i''ve searched these forums but i can''t find what i need. Can anyone help me out with drawing filled ellipses from the bounding rectangle of the ellipse? I read somewhere about a few techniques such as building the ellipse from rectangles etc but i can''t understand it or convert it to usable code. Thanks

##### Share on other sites
Well first, you need to tell us what API you're using. For instance, in SDL there is no easy way to do this. In DirectX or OpenGL, it can be done as such...

radians = 0for point in range(numPoints):    oldRadians=radians    radians = numPoints*2*pi/point    draw_triangle((0,0), (width * cos(oldRadians),  height * sin(oldRadians)), (width * cos(radians), height * sin(radians)), myColor)

Note that width and height are the width and height of the rectangle, at that this always draws the ellipse centered at the origin (translation is simple though). Also, this is just rough pseudo-code in the style of python.

[edited by - darkhamster on June 7, 2004 8:24:32 PM]

##### Share on other sites
Sorry, i''m using DirectDraw. I''m accessing the surface memory in order to write my own drawing functions. I''ve done a rectangle drawing function and now i need an ellipse drawing function.

Should i write a filled triangle drawing function and then use that to draw my ellipses? If i use the triangle method then will my ellipse function draw circles ok aswell? And could you explain the code a bit more? What is numPoints and where does it come from? What does range() do?

Thanks

##### Share on other sites
For each line the elipse spans you find the left most point and the right most point and draw a line between them.

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633350
• Total Posts
3011470
• ### Who's Online (See full list)

There are no registered users currently online

×