moai/src/moaicore/MOAIImage.cpp
//----------------------------------------------------------------//
// TODO: should fill ellipse (not just circle)
should fill ellipse (not just circle)
should fill ellipse ( not just circle )
void MOAIImage::FillCircle ( float centerX, float centerY, float xRad, u32 color ) {
	int radius = ( int )xRad;
	int x0 = ( int )centerX;
	int y0 = ( int )centerY;
	int f = 1 - radius;
    int ddF_x = 1;
    int ddF_y = -2 * radius;
    int x = 0;
    int y = radius;
	this->DrawLine ( x0, y0 + radius, x0, y0 - radius, color );
    this->DrawLine ( x0 + radius, y0, x0 - radius, y0, color );
    while ( x < y ) {
		if(f >= 0) {
			y--;
			ddF_y += 2;
			f += ddF_y;
		}
		x++;
		ddF_x += 2;
		f += ddF_x;
		this->DrawLine ( x0 - x, y0 + y, x0 + x, y0 + y, color );
		this->DrawLine ( x0 - x, y0 - y, x0 + x, y0 - y, color );
		this->DrawLine ( x0 + y, y0 + x, x0 - y, y0 + x, color );
		this->DrawLine ( x0 + y, y0 - x, x0 - y, y0 - x, color );
    }
}
void MOAIImage :: FillCircle ( float centerX , float centerY , float xRad , u32 color ) { int radius = ( int ) xRad ; int x0 = ( int ) centerX ; int y0 = ( int ) centerY ; int f = 1 - radius ; int ddF_x = 1 ; int ddF_y = -2 * radius ; int x = 0 ; int y = radius ; this -> DrawLine ( x0 , y0 + radius , x0 , y0 - radius , color ) ; this -> DrawLine ( x0 + radius , y0 , x0 - radius , y0 , color ) ; while ( x < y ) { if ( f >= 0 ) { y -- ; ddF_y += 2 ; f += ddF_y ; } x ++ ; ddF_x += 2 ; f += ddF_x ; this -> DrawLine ( x0 - x , y0 + y , x0 + x , y0 + y , color ) ; this -> DrawLine ( x0 - x , y0 - y , x0 + x , y0 - y , color ) ; this -> DrawLine ( x0 + y , y0 + x , x0 - y , y0 + x , color ) ; this -> DrawLine ( x0 + y , y0 - x , x0 - y , y0 - x , color ) ; } }
TODO: should fill ellipse (not just circle)
TODO : should fill ellipse ( not just circle )
//ddF_x == 2 * x + 1; // ddF_y == -2 * y; // f == x*x + y*y - radius*radius + 2*x - y + 1;