Thursday, August 16, 2012
Program to generate different fill pattern over a computer screen in Computer Graphics using C/C++
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<time.h>
#include<stdlib.h>
int main(void)
{
/* request auto detection */
int gd=DETECT,gm;
int x,y,x1,y1,c;
clrscr();
/*initialize graphics and local variable*/
initgraph(&gd,&gm,"c:\\tc\\bgi");
c=getmaxcolor(); //returns the maximum colour value
x=getmaxx()/2; //maximum x co-ordinate
y=getmaxy()/2; // maximum y co-ordinate
x1=getmaxx()/2;
y1=getmaxy()/2;
randomize();
while(!kbhit())
{
setcolor(random(getmaxcolor())); //to set current drawing color
/*to draw a digonal line */
setfillstyle(random(x),random(c)); //set fill pattern & color
floodfill(random(x),random(y),random(c)); //fills a bounded region
}
getch();
closegraph(); //to shutdown the current graphics system
return 0;
}
Related Posts : C,
cg lab,
cg lab programs,
Computer Graphics programs,
programming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment