Wednesday 6 November 2013

Generating Fractal Images in Computer Graphics (CG) | Computer Graphics Lab Manual | Anna University Chennai | Final Year IT Department



10:PROGRAM:

#include
#include
#include
#include
#include
void DrawSierpinski(void);
void main(void)
{int gd=VGA;
int gm=VGAHI;
initgraph(&gd, &gm, "\\tc\\bgi");
DrawSierpinski();
getch();
}
void DrawSierpinski(void)
{char Direct;
int iterate;
unsigned int x1, y1, x2, y2;
x1 = x2 = 320;
y1 = y2 = 0;
for(iterate = 0; iterate < 10000; iterate++)
{Direct = random(3);
if(Direct == 0)
{
x1 = (x2 + 320) / 2;
y1 = (y2 + 0) / 2;        
}
else if(Direct == 1)
{x1 = (x2 + 0) / 2;
y1 = (y2 + 480) / 2;
}
else if(Direct == 2)
{
x1 = (x2 + 640) / 2;    
y1 = (y2 + 480) / 2;
}
putpixel(x1, y1, WHITE);
x2 = x1;
y2 = y1;

}}

No comments:

Don't You Think this Awesome Post should be shared ??
| Generating Fractal Images in Computer Graphics (CG) | Computer Graphics Lab Manual | Anna University Chennai | Final Year IT Department |
Back To Top Related Posts Plugin for WordPress, Blogger...