Jump to content
  • Advertisement

Archived

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

DarkEvilOne

Filled Ellipse

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 = 0
for 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 this post


Link to post
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 this post


Link to post
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.

google bresenham ellipse algorithm

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!