12.7K
Here you will learn how to draw animation circles using C++ GUI Graphics Library .
Write a Program to draw animation using increasing circles filled with different colors and patterns.
#include<graphics.h>
#include<conio.h>
void main()
{
intgd=DETECT, gm, i, x, y;
initgraph(&gd, &gm, "C:\\TC\\BGI");
x=getmaxx()/3;
y=getmaxx()/3;
setbkcolor(WHITE);
setcolor(BLUE);
for(i=1;i<=8;i++)
{
setfillstyle(i,i);
delay(20);
circle(x, y, i*20);
floodfill(x-2+i*20,y,BLUE);
}
getch();
closegraph();
}
OUTPUT
Program to make screen saver in that display different size circles filled with different colors and at random places.
#include<stdio.h>
#include<conio.h>
#include"graphics.h"
#include"stdlib.h"
void main()
{
intgd=DETECT,gm,i=0,x,xx,y,yy,r;
//Initializes the graphics system
initgraph(&gd,&gm,"c:\\tc\\bgi");
x=getmaxx();
y=getmaxy();
while(!kbhit())
{
i++;
// setfillstyle(random(i),random(30));
circle(xx=random(x),yy=random(y),random(30));
setfillstyle(random(i),random(30));
floodfill(xx,yy,getmaxcolor());
delay(200);
}
getch();
}
OUTPUT