PDA

View Full Version : Weird floodfill() effect



destroyerBEACON
02-25-2002, 10:39 AM
I compiled this code using Turbo C++, and floodfill had a weird diamond-like pattern come out every time the "coin" switched colors. Can anybody explain this?

#include <graphics.h>
#include <conio.h>
#include <dos.h>
void main(void)
{
int driver,mode,r = 50, s = -1, t = 1,x = 100,y = 100;
initgraph(&driver,&mode,"C:\\turbo\\bgi");
while ( !kbhit() )
{
setcolor(WHITE);
ellipse(x,y,0,360,r,50);
if ( t == 1) {setfillstyle(SOLID_FILL,RED) }
else { setfillstyle(SOLID_FILL,BLUE) }
floodfill(x,y,WHITE);
delay(3);
setcolor(BLACK);
ellipse(x,y,0,360,r,50);
r += s;
if (r == 0 && s == -1 || r == 50 && s == 1)
{
s = -s;
if ( s == 1 ) { t = -t; }
}
closegraph();
}