Archived

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

Filled Ellipse Algorithm

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

Recommended Posts

Can someone explain how I can scan convert a filled ellipse? I have the following code that was posted here previously for a filled circle that. I was thinking I could build off of it. The equation for width is what's giving me the trouble.
void FILLED_Circle_MIDPOINT(float xc, float yc, int R)
{
const int Rsqr = R*R;

for(int y = 0; y < R ; ++y )
{
int width = sqrt( Rsqr - y*y );// find width of circle at this y

for(int x = 0; x < width; ++x) //draw a horizontal line of that width

{
SetPixel( g_hdc, xc+x, yc+y, RGB(g_color.red, g_color.green, g_color.blue) );
SetPixel( g_hdc, xc+x, yc-y, RGB(g_color.red, g_color.green, g_color.blue) );
SetPixel( g_hdc, xc-x, yc+y, RGB(g_color.red, g_color.green, g_color.blue) );
SetPixel( g_hdc, xc-x, yc-y, RGB(g_color.red, g_color.green, g_color.blue) );
}
}
}

[edited by - SinisterIllusion on June 16, 2003 6:21:54 PM]

Share on other sites
Add an aspect ratio parameter, and multiply width by that

My Site

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• Forum Statistics

• Total Topics
633705
• Total Posts
3013464
×