Fast way to draw FILLED circles

// Draw circle with midpoint algorythm (integer math only) uses octet
mirroring
// Modified the previous midpoint a litle, so that drawing is only done
when the y-coord changes
void circle( int xc, int yc, int R, SDL_Surface *PIX, unsigned char col)
{
int x=0,xx=0;
int y=R,yy=R+R;
int p=1-R;

// Draw the Y=0 line
line(PIX, xc-y, yc, xc+y, yc, col);

while(x<y) {
xx+=2; // 2x
if(p>=0) {
yy-=2; // 2
y
line(PIX,xc-x,yc-y,xc+x,yc-y,col);
line(PIX,xc-x,yc+y,xc+x,yc+y,col);
line(PIX,xc-y,yc-x,xc+y,yc-x,col);
line(PIX,xc-y,yc+x,xc+y,yc+x,col);
–y;
p -= yy;
}
++x;
p += xx+1;
}
if(x==y) { // On previous circle routine here were a litle bug. Was
only one “=”. :wink:
line(PIX,xc-x,yc-y,xc+x,yc-y,col);
line(PIX,xc-x,yc+y,xc+x,yc+y,col);
}
}

// To use this you need to make your own line routine.On 2002.03.13 03:57 Sami N??t?nen wrote: