Example #1
0
void
designer< T, C, N >::drawCircle( T cx, T cy, T radius ) {

	/** === Midpoint circle algorithm === **/

	int	x = 0,
		y = radius;

	int	d	= 1 - radius,
		dE	= 1,
		dSE	= -2 * radius;

	for ( ; x < y; ++x, dE += 2, d += dE ) {

		drawCirclePoints( cx, cy, x, y );

		if ( d >= 0 )
			y--, d += dSE += 2;
	}

	drawCirclePoints( cx, cy, x, y );
}
Example #2
0
void drawCircle(AE::Graphics::Device::PixelBuffer *pixelBuffer, AE::Graphics::Color &color, const AE::Math::Point2<AE::int32> &center, const AE::int32 &radius)
{
	AE::int32 deltaE, deltaSE, d;

	AE::Math::Point2<AE::int32> point(0, radius);

	d = 1 - radius;

	deltaE  = 3;
	deltaSE = -2*radius + 5;

#	define incrementE  ( 2*point.x + 3 );
#	define incrementSE ( 2*(point.x - point.y) + 5 );

	drawCirclePoints( pixelBuffer, color, center, point );

	while ( point.x < point.y )
	{
		if ( d < 0)
		{
			/* Go to E */
			d += incrementE;
			deltaSE += 2;
		}
		else
		{
			/* Go to SE */
			d += incrementSE;
			point.y--;
			deltaSE += 4;
		}

		point.x++;
		deltaE  += 2;

		drawCirclePoints( pixelBuffer, color, center, point );
	}
}