engine/source/gamelib/draw.c
// Code to draw a circle.
// I ripped this, not sure how it works...
// It seems it devides the circle into 8 parts, which are drawn
// simultaneously.
// Not much optimization, though, since every pixel is clipped
// separately.
Code to draw a circle.
I ripped this, not sure how it works
It seems it devides the circle into 8 parts, which are drawn
simultaneously.
Not much optimization, though, since every pixel is clipped
separately.
Code to draw a circle . I ripped this not sure how it works It seems it devides the circle into 8 parts which are drawn simultaneously . Not much optimization though since every pixel is clipped separately .
void circle(int x, int y, int rad, int col, s_screen *screen, int alpha)
{
    int cx = 0;				
    int cy = rad;				
    int df = 1 - rad;
    int d_e = 3;
    int d_se = -2 * rad + 5;
    do
    {
        _putpixel(x + cx, y + cy, col, screen, alpha);
        if(cx)
        {
            _putpixel(x - cx, y + cy, col, screen, alpha);
        }
        if(cy)
        {
            _putpixel(x + cx, y - cy, col, screen, alpha);
        }
        if(cx && cy)
        {
            _putpixel(x - cx, y - cy, col, screen, alpha);
        }
        if(cx != cy)
        {
            _putpixel(x + cy, y + cx, col, screen, alpha);
            if(cx)
            {
                _putpixel(x + cy, y - cx, col, screen, alpha);
            }
            if(cy)
            {
                _putpixel(x - cy, y + cx, col, screen, alpha);
            }
            if(cx && cy)
            {
                _putpixel(x - cy, y - cx, col, screen, alpha);
            }
        }
        if(df < 0)
        {
            df   += d_e;
            d_e  += 2;
            d_se += 2;
        }
        else
        {
            df   += d_se;
            d_e  += 2;
            d_se += 4;
            --cy;
        }
        ++cx;
    }
    while(cx <= cy);
}
void circle ( int x , int y , int rad , int col , s_screen * screen , int alpha ) { int cx = 0 ; int cy = rad ; int df = 1 - rad ; int d_e = 3 ; int d_se = -2 * rad + 5 ; do { _putpixel ( x + cx , y + cy , col , screen , alpha ) ; if ( cx ) { _putpixel ( x - cx , y + cy , col , screen , alpha ) ; } if ( cy ) { _putpixel ( x + cx , y - cy , col , screen , alpha ) ; } if ( cx && cy ) { _putpixel ( x - cx , y - cy , col , screen , alpha ) ; } if ( cx != cy ) { _putpixel ( x + cy , y + cx , col , screen , alpha ) ; if ( cx ) { _putpixel ( x + cy , y - cx , col , screen , alpha ) ; } if ( cy ) { _putpixel ( x - cy , y + cx , col , screen , alpha ) ; } if ( cx && cy ) { _putpixel ( x - cy , y - cx , col , screen , alpha ) ; } } if ( df < 0 ) { df += d_e ; d_e += 2 ; d_se += 2 ; } else { df += d_se ; d_e += 2 ; d_se += 4 ; -- cy ; } ++ cx ; } while ( cx <= cy ) ; }
Code to draw a circle.
Code to draw a circle .
// 'Circle X' // 'Circle Y'