Of the ones I have tried this (BresnHam Method) still seems the best. I can get slightly better circles using sin/cosine tables but it takes 4 times as many steps to
get only a slightly better result. To test I drew 600 concentric circles with radii from 1 to 600 (1200 screen height) then a screen update and look for holes. Too many holes and you will get bizzare artifacts (gaps appear ) when you zoom in/out This one gets a few when I zoom out the BMP screen caps with PSP, but that is not
a real problem.
void (jbSDL_DrawPixel) (SDL_Surface * dst, Uint16 x, Uint16 y, Uint32 pixel); / This is from the libsdl.org draw pixel example. Not included */
/*=======================================================================================================================
*/
int jbSDL_DrawCircle(SDL_Surface *uscreen, const short xc, const short yc, const unsigned short radius, const unsigned short dsp_width,
const unsigned short dsp_height, Uint32 ucolor)
{
short x,x2,y2;
short w,r,d;
r = radius;
x = 0;
d = 2 * (1 - radius);
w = 2.0 * dsp_width / dsp_height;
while(r >= 0)
{
x2 = xc + x;
y2 = yc + r;
if(x2 >= 0 && x2 <= dsp_width && y2 >= 0 && y2 <= dsp_height) (*jbSDL_DrawPixel) (uscreen, x2, y2, ucolor);
y2 = yc - r;
if(x2 >= 0 && x2 <= dsp_width && y2 >= 0 && y2 <= dsp_height) (*jbSDL_DrawPixel) (uscreen, x2, y2, ucolor);
x2 = xc - x;
y2 = yc + r;
if(x2 >= 0 && x2 <= dsp_width && y2 >= 0 && y2 <= dsp_height) (*jbSDL_DrawPixel) (uscreen, x2, y2, ucolor);
y2 = yc - r;
if(x2 >= 0 && x2 <= dsp_width && y2 >= 0 && y2 <= dsp_height) (*jbSDL_DrawPixel) (uscreen, x2, y2, ucolor);
if (d + r > 0)
d -= (w * --r) - 1;
if (x > d)
d += (2 * ++x) + 1;
}
return 0;
}