Architectural pattern: Using C/C++ and graphics
Hey guys its very simple but beautiful architectural pattern using C/C++ with graphics. I don't know its name, if you guys know then please leave a comment below. Here's the screen shot of the output.
Now, let us see the codes. Here by changing the value of the n we can create different pattern. For this program I have choosen value as 15 but do try with other values also. Here's the code.
/*
Programmer: Ashok Kumar Shrestha (ak007)
Program Details: Generates Awesome Circular pattern 3.1
*/
#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<stdio.h>
main()
{
int gd = DETECT, gm, x, y, color, angle = 0,i,j;
char sstr[20];
int pat[2][200]={0};
int n=15;
struct arccoordstype a, b;
initgraph(&gd, &gm, "..\\BGI");
delay(200);
for(i=0;i<n;i++)
{
setcolor(11);
arc(getmaxx()/2,getmaxy()/2,i*360/n,(i+1)*360/n,225);
getarccoords(&a);
pat[0][i]=a.xstart;
pat[1][i]=a.ystart;
}
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
line(pat[0][i],pat[1][i],pat[0][(j+1)%n],pat[1][(j+1)%n]);
delay(80);
}
}
getch();
closegraph();
return 0;
}
//End of the program
Now, let us see the codes. Here by changing the value of the n we can create different pattern. For this program I have choosen value as 15 but do try with other values also. Here's the code.
/*
Programmer: Ashok Kumar Shrestha (ak007)
Program Details: Generates Awesome Circular pattern 3.1
*/
#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<stdio.h>
main()
{
int gd = DETECT, gm, x, y, color, angle = 0,i,j;
char sstr[20];
int pat[2][200]={0};
int n=15;
struct arccoordstype a, b;
initgraph(&gd, &gm, "..\\BGI");
delay(200);
for(i=0;i<n;i++)
{
setcolor(11);
arc(getmaxx()/2,getmaxy()/2,i*360/n,(i+1)*360/n,225);
getarccoords(&a);
pat[0][i]=a.xstart;
pat[1][i]=a.ystart;
}
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
line(pat[0][i],pat[1][i],pat[0][(j+1)%n],pat[1][(j+1)%n]);
delay(80);
}
}
getch();
closegraph();
return 0;
}
//End of the program
Comments
Post a Comment