Jump to content
  • Advertisement

Archived

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

SinisterIllusion

Filled Ellipse Algorithm

This topic is 5485 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

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


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!