#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <dos.h>
int main() {
/* request auto detection */
int gdriver = DETECT, gmode, err;
int i, j, midx, midy, xrad, yrad, tmpx, tmpy;
/* initialize graphic mode */
initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI");
err = graphresult();
if (err != grOk) {
/* error occurred */
printf("Graphics Error: %s\n",
grapherrormsg(err));
return 0;
}
/* mid position in x and y-axis */
midx = getmaxx() / 2;
midy = getmaxy() / 2;
xrad = 20, yrad = 10;
for (i = 1; i <= 15; i++) {
xrad = xrad + 20;
yrad = yrad + 10;
tmpx = xrad, tmpy = yrad;
/* drawing ellipse in to out */
for (j = i; j > 0; j--) {
setcolor(j);
setfillstyle(SOLID_FILL, j);
ellipse(midx, midy, 0, 360, tmpx, tmpy);
floodfill(midx, midy, j);
tmpx = tmpx - 20;
tmpy = tmpy - 10;
}
sleep(1);
}
/* drawing ellipse out to in */
for (i = 15; i > 0; i--) {
setcolor(i);
setfillstyle(SOLID_FILL, i);
ellipse(midx, midy, 0, 360, xrad, yrad);
floodfill(midx, midy, i);
xrad = xrad - 20;
yrad = yrad - 10;
delay(200);
}
getch();
/* deallocate memory allocated for graphic screen */
closegraph();
return 0;
}
0 comments:
Post a Comment