Graphics Codes in C


Here are some awesome graphics codes..



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();
}




0 comments:

Post a Comment

 
Twitter Bird Gadget