/* Graphics Simulation Program */ #include #include #include #include #include #include #include int main () { clrscr (); int gdriver = DETECT, gmode, errorcode; initgraph (&gdriver, &gmode, "g:\\bgi"); errorcode = graphresult (); if (errorcode != grOk) { printf ("Graphics error: %s \n", grapherrormsg (errorcode)); printf ("Press Anykey to halt: "); getch (); exit (1); } /* "graphics main prorgam lines" go here */ int x, y, xmax, ymax; unsigned color; xmax = getmaxx(); ymax = getmaxy(); randomize (); while (!kbhit()) { x = random (xmax); y = random (ymax); color = random (getmaxcolor () ); setcolor(color); setfillstyle(HATCH_FILL, color); if (getpixel (x, y) != BLACK) { line(0,0,x,y); //putpixel (x, y, BLACK); } else { fillellipse(x,y,20,20); //putpixel (x, y, color); } } getch (); closegraph (); return 0; }