April 8, 2011

Graphics Codes in C

some awesome graphics codes.. Presented by MY C FILES


Code 1




Code 1
/*www.mycfiles.com*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <graphics.h>
#include<stdlib.h>
#include<dos.h>
void main()
{
int dr,md,midx,i, midy,mx, my,x,y,fact;
double pi,tpi,a,t,r;
dr = DETECT;
fact=220;

initgraph(&dr, &md, "c:\\tc\\bgi");
midx = getmaxx()/2; midy = getmaxy()/2;
pi = 3.14159;
tpi = pi * 2.0;

for (a=0.0; a<tpi; a=a+pi/660)
{
r = fact * (cos(8*a));   // r = fact * (cos(a) * sin(a))
x = midx + r * cos(a);
y = midy + r * sin(a);
putpixel(x,y,random(getmaxcolor()));

}



getch();
}






Code 2


Code 2
/*www.mycfiles.com*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <graphics.h>
#include<stdlib.h>
#include<dos.h>
void main()
{
int dr,md,midx,i, midy,mx, my,x,y,fact;
double pi,tpi,a,t,r;
dr = DETECT;
fact=220;

initgraph(&dr, &md, "c:\\tc\\bgi");
midx = getmaxx()/2; midy = getmaxy()/2;
pi = 3.14159;
tpi = pi * 2.0;

for (a=0.0; a<tpi; a=a+pi/180)
{
r = fact * (cos(a) * sin(10+a));
x = midx + r * cos(a);
y = midy + r * sin(a);
putpixel(x,y,random(getmaxcolor()));
getch();

}



getch();
}





Code 3


Code 3
/*www.mycfiles.com*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <graphics.h>
#include<stdlib.h>
#include<dos.h>
void main()
{
int dr,md,midx,i, midy,mx, my,x,y,fact;
double pi,tpi,a,t,r;
dr = DETECT;
fact=120;

initgraph(&dr, &md, "c:\\tc\\bgi");
midx = getmaxx()/2; midy = getmaxy()/2;
pi = 3.14159;
tpi = pi * 2.0;

for (fact=10; fact<=120; fact=fact+10)
{


for (a=0.0; a<tpi; a=a+pi/180)
{
r = fact * (1+cos(a));
x = midx + r * cos(a);
y = midy + r * sin(a);
putpixel(x,y,random(getmaxcolor()));
// getch();

}
getch();
}



getch();
}





Code 4


Code 4
/*www.mycfiles.com*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <graphics.h>
#include<stdlib.h>
#include<dos.h>
void main()
{
int dr,md,midx,i, midy,mx, my,x,y,fact;
double pi,tpi,a,t,r;
dr = DETECT;
fact=120;

initgraph(&dr, &md, "c:\\tc\\bgi");
midx = getmaxx()/2; midy = getmaxy()/2;
pi = 3.14159;
tpi = pi * 2.0;

for (fact=10; fact<=120; fact=fact+10)
{


for (a=0.0; a<tpi; a=a+pi/180)
{
r = fact * (1+cos(3+a));
x = midx + r * cos(a);
y = midy + r * sin(a);
putpixel(x,y,random(getmaxcolor()));
// getch();

}
getch();
}



getch();
}

Hope you will like this one, Post your comment and queries below... :)

Related Posts :



Categories:

1 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Related Posts with Thumbnails