Here is a C++ program that draw concentric circles with some special effects.
#include <iostream.h>
#include <graphics.h>
#include <conio.h>
#include <dos.h>
main()
{
int dv,mo;
dv = DETECT;
initgraph(&dv,&mo,"");
// logic to make outer circles
for(int j=40;j<=440;j+=80)
{
for(int i=40;i<=600;i+=80)
{
circle(i,j,40);
}
}
// logic to make concentric circles in each circles
for(j=40;j<=440;j+=80)
{
for(int i=40;i<=600;i+=80)
{
for(int k=0;k<=40;k++)
{
circle(i,j,k);
delay(10);
setcolor(k%16);
}
}
}
// logic to remove alternate drawn concentric circles.
setcolor(0);
int p=0;
for(j=440;j>=0;j-=80,p++)
if (p%2 == 0)
{for(int i=600;i>=0;i-=160)
for(int k=39;k>=0;k--)
{circle(i,j,k);delay(10);}}
else
{for(int i=40;i<600;i+=160)
for(int k=39;k>=0;k--)
{circle(i,j,k);delay(10);}}
getch();
closegraph();
}
#include <iostream.h>
#include <graphics.h>
#include <conio.h>
#include <dos.h>
main()
{
int dv,mo;
dv = DETECT;
initgraph(&dv,&mo,"");
// logic to make outer circles
for(int j=40;j<=440;j+=80)
{
for(int i=40;i<=600;i+=80)
{
circle(i,j,40);
}
}
// logic to make concentric circles in each circles
for(j=40;j<=440;j+=80)
{
for(int i=40;i<=600;i+=80)
{
for(int k=0;k<=40;k++)
{
circle(i,j,k);
delay(10);
setcolor(k%16);
}
}
}
// logic to remove alternate drawn concentric circles.
setcolor(0);
int p=0;
for(j=440;j>=0;j-=80,p++)
if (p%2 == 0)
{for(int i=600;i>=0;i-=160)
for(int k=39;k>=0;k--)
{circle(i,j,k);delay(10);}}
else
{for(int i=40;i<600;i+=160)
for(int k=39;k>=0;k--)
{circle(i,j,k);delay(10);}}
getch();
closegraph();
}
No comments:
Post a Comment