Code: Select all
void D3DGraphics::DrawCircle( int centerX,int centerY,int radius,Color color )
{
int rSquared = sq( radius );
int xPivot = (int)( radius * 0.70710678118f + 0.5f );
for( int x = 0; x <= xPivot; x++ )
{
int y = (int)(sqrt( (float)( rSquared - sq( x ) ) ) + 0.5f);
PutPixel( centerX + x,centerY + y,color );
PutPixel( centerX - x,centerY + y,color );
PutPixel( centerX + x,centerY - y,color );
PutPixel( centerX - x,centerY - y,color );
PutPixel( centerX + y,centerY + x,color );
PutPixel( centerX - y,centerY + x,color );
PutPixel( centerX + y,centerY - x,color );
PutPixel( centerX - y,centerY - x,color );
}
}
Code: Select all
virtual void Rasterize(Graphics& gfx) const override
{
Vec2 pos = trans*Vec2(0.0f,0.0f);
for (int angle = 0; angle <= 360; angle++)
{
float x = (pos.x + cosf((float)angle) * parent.radius);
float y = (pos.y + sinf((float)angle) * parent.radius);
if (gfx.InBounds(x, y))
{
gfx.PutPixel(x, y, Colors::White);
}
}
}
Cheers