Yin - Yang : Using C and grahics
Hey guys, here's the simple program to demonstrate Yin-Yang. Many of you might have seen the symbol but not have known the name. Here's the pic of the Yin- Yang.
Yin - Yang can be thought of as the complementary forces balancing each other in a harmonious way.
Yang is the white part with the black dot on it and Yin is the black part with the white dot in it. As mentioned in the figure, they can be veiwed as any complementary things such as negative-positive, light-dark, love-hate, sun-moon and so on. If we closely each part is complementary of other. So, some say for every living soul, male and female complement each other but as a whole they complete each other. If you want to know about the Yin-Yang then here is the link: http://en.wikipedia.org/wiki/Yin_and_yang
OK, without further due let us see the code.
/*
Programmer: Ashok Kumar Shrestha (ak007)
Program Details: Creates Yin - Yang and rotates in anticlockwise
*/
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
void move(int,int);
struct arccoordstype arcinfo;
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int stangle = 0, endangle = 360;
initgraph(&gdriver, &gmode, "..\\bgi");
midx = getmaxx() / 2;
midy = getmaxy() / 2;
move(midx,midy);
getch();
closegraph();
return 0;
}
void yy_crcl(int midx,int midy,int sangl,int eangl,int n)
{
int i,j,angl=360/n,x,y,k;
while(!kbhit())
{ sangl=90+k,eangl=100+k;
k+=1;
for(i=0;i<n;i++)
{
setcolor(15+i*2);
arc(midx,midy,sangl+i*angl,eangl+i*angl,50);
getarccoords(&arcinfo);
x=arcinfo.xend; y=arcinfo.yend;
setcolor(15+i*2);
circle(x,y,15);
circle(x,y,13);
circle(x,y,10);
setcolor(i?15:1);
for(j=0;j<17;j++)
circle(x,y,17+j*2);
circle(x,y,50);
}
}
}
void move(int midx, int midy)
{
int n=2;
while(!kbhit())
{
yy_crcl(midx,midy,90,100,n);
}
getch();
exit(0);
}
//End of the program
Here is the screen shot of the output. Hope you guys like it.
Yin - Yang can be thought of as the complementary forces balancing each other in a harmonious way.
Yang is the white part with the black dot on it and Yin is the black part with the white dot in it. As mentioned in the figure, they can be veiwed as any complementary things such as negative-positive, light-dark, love-hate, sun-moon and so on. If we closely each part is complementary of other. So, some say for every living soul, male and female complement each other but as a whole they complete each other. If you want to know about the Yin-Yang then here is the link: http://en.wikipedia.org/wiki/Yin_and_yang
OK, without further due let us see the code.
/*
Programmer: Ashok Kumar Shrestha (ak007)
Program Details: Creates Yin - Yang and rotates in anticlockwise
*/
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
void move(int,int);
struct arccoordstype arcinfo;
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int stangle = 0, endangle = 360;
initgraph(&gdriver, &gmode, "..\\bgi");
midx = getmaxx() / 2;
midy = getmaxy() / 2;
move(midx,midy);
getch();
closegraph();
return 0;
}
void yy_crcl(int midx,int midy,int sangl,int eangl,int n)
{
int i,j,angl=360/n,x,y,k;
while(!kbhit())
{ sangl=90+k,eangl=100+k;
k+=1;
for(i=0;i<n;i++)
{
setcolor(15+i*2);
arc(midx,midy,sangl+i*angl,eangl+i*angl,50);
getarccoords(&arcinfo);
x=arcinfo.xend; y=arcinfo.yend;
setcolor(15+i*2);
circle(x,y,15);
circle(x,y,13);
circle(x,y,10);
setcolor(i?15:1);
for(j=0;j<17;j++)
circle(x,y,17+j*2);
circle(x,y,50);
}
}
}
void move(int midx, int midy)
{
int n=2;
while(!kbhit())
{
yy_crcl(midx,midy,90,100,n);
}
getch();
exit(0);
}
//End of the program
Here is the screen shot of the output. Hope you guys like it.
Note: If you are having error in running any of the code I have posted then please save the file with .cpp extension. You won't get any error after wards. Enjoy coding..
Comments
Post a Comment