Animation/Movement of Circles Graphics

This program is to display the movement or animation of two circle filled circles . This is a part of Mumbai University MCA Colleges CG Programs MCA Computer Graphics.


This program uses the delay () function to produce the movement.

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,j,m;
float i;
initgraph(&gd,&gm,"C:\\TC\\BGI");
cleardevice();
for(m=1;m<=2;m++)
{
for(i=30,j=639-30;i<=320-30;i++,j--)
{
setcolor(RED);
circle(i,50,30);
setfillstyle(SOLID_FILL,BLUE);
floodfill(i,50,RED);
setcolor(YELLOW);
circle(j,50,30);
setfillstyle(SOLID_FILL,GREEN);
floodfill(j,50,YELLOW);

delay(10);
setcolor(0);
circle(i,50,30);
circle(j,50,30);

}
setcolor(RED);
circle(i-1,50,30);
setfillstyle(SOLID_FILL,BLUE);
floodfill(i-1,50,RED);
setcolor(YELLOW);
circle(j+1,50,30);
setfillstyle(SOLID_FILL,GREEN);
floodfill(j+1,50,YELLOW);

for(;i>=30;i--,j++)
{
setcolor(RED);
circle(i,50,30);
setfillstyle(SOLID_FILL,BLUE);
floodfill(i,50,RED);
setcolor(YELLOW);
circle(j,50,30);
setfillstyle(SOLID_FILL,GREEN);
floodfill(j,50,YELLOW);

delay(20);
setcolor(0);
circle(i,50,30);
circle(j,50,30);
}
}
setcolor(RED);
circle(i+1,50,30);
setfillstyle(SOLID_FILL,BLUE);
floodfill(i+1,50,RED);
setcolor(YELLOW);
circle(j-1,50,30);
setfillstyle(SOLID_FILL,GREEN);
floodfill(j-1,50,YELLOW);

getch();

}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

No comments:

Post a comment