Mail Archives: djgpp/1997/07/31/07:49:26
In article <33DF4527 DOT 671 AT mindspring DOT com>, Derek Greene
<topcoder AT mindspring DOT com> writes
>i have used bresenham's circle routines experimentally, it has GREAT
>speed (more so then lookup tables I think :) buuut, it leaves gaps,
>right gaps, in the circle, has anyone else noticed this? can anyone
>tell me what's wrong, is there ANY way to fix this?
Is this Bresenhams circle routine??
Or is it the one where you calculate an eigth of a circle and draw the
full circle from these calcs, never seen that one in action though.
/* Quick circles.
*/
#include <stdio.h>
#include <allegro.h>
#include <time.h>
int main()
{
BITMAP *buffer;
PALLETE pal;
int d,x,y,r;
double x2,y2;
pal[0].r = 0;
pal[0].g = 0;
pal[0].b = 0;
pal[1].r = 63;
pal[1].g = 63;
pal[1].b = 63;
allegro_init();
install_keyboard();
set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0);
set_pallete(pal);
buffer = create_bitmap(SCREEN_W, SCREEN_H);
x=160;
y=100;
while(!keypressed()){
for (r=1 ; r<180 ; r++){
x2=0;
y2=r/2.0;
for (d=1 ; d< r*7 ; d++){
x2 =x2+y2/r;
y2 =y2-x2/r;
_putpixel(buffer,x+x2, y+y2, 1);
}
vsync();
blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
clear(buffer);
}
}
return 0;
}
--
http://www.jenkinsdavid.demon.co.uk for C programmers.
David Jenkins
- Raw text -