CG Lab File
CG Lab File
STUDIES
OUTPUT:
PRACTICAL – 3
WAP to Display an asterisk inside a circle.
CODE:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
intgd=DETECT,gm;
initgraph(&gd,&gm,"C:\\turboc3\\bgi");
circle(300,200,75);
line(225,200,375,200);
line(300,125,300,275);
line(250,150,350,250);
line(350,150,250,250);
getch();
}
OUTPUT:
PRACTICAL – 29
WAP to Perform Window-to-View port transformation.
CODE:
#include <graphics.h>
#include <iostream>
int main() {
FILE *ip, *op;
float xwmin, xwmax, ywmax, ywmin;
float xvmin, xmax, yvmax, yvmin;
float x[10], y[10], yv, xv, sx, sy;
int gd = DETECT, gm, i;
ip = fopen("w2vinput.txt", "r");
op = fopen("w2voutput.txt", "w");
fscanf(ip, "%f %f %f %f", &xwmin, &ywmin, &xwmax, &ywmax);
fscanf(ip, "%f %f %f %f", &xvmin, &yvmin, &xvmax, &yvmax);
return 0;
}
OUTPUT:
PRACTICAL – 17
WAP to Scan convert circle using Mid-point circle drawing Algorithm.
CODE:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
Intxc,Yc,R,X,Y,I,P;
Intgd=Detect,Gm;
Initgraph(&Gd,&Gm,"C:\\Turboc3\\Bgi");
Printf("Enter Radius Of The Circle:-\T");
Scanf("%D",&R);
Printf("Enter Center Of The Circle:-\T");
Scanf("%D%D",&Xc, &Yc);
P=1-R;X=0;Y=R;
Do
{If(P<0)
{X=X+1;
P=P+2*X+1;}
Else
{
X=X+1;
Y=Y-1;
P=P+2*X-2*Y+10;}
Putpixel(Xc+X,Yc+Y,1);
Putpixel(Xc-Y,Yc-X,2);
Putpixel(Xc+Y,Yc-X,3);
Putpixel(Xc-Y,Yc+X,4);
Putpixel(Xc+Y,Yc+X,5);
Putpixel(Xc-X,Yc-Y,6);
Putpixel(Xc+X,Yc-Y,7);
Putpixel(Xc-X,Yc+Y,8);}
While(X<Y);
Getch();
Closegraph();
}
OUTPUT:
PRACTICAL – 21
WAP to get the Rotation angle from the user and rotate the triangle accordingly.
CODE:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int gd=DETECT,gm;
int x,y,x1,y1,x2,y2;
float t,r;
initgraph(&gd,&gm,"c:\\TURBOC3\\BGI");
printf("\t\tTRIANGLE BEFORE ROTATION\n");
printf("ENTER TRIANGLE AXIS & COORDINATES:-\t");
scanf("%d%d%d%d%d%d",&x,&y,&x1,&y1,&x2,&y2);
printf("TRIANGLE IS\t\t\t") ;
line(x,y,x1,y1);
line(x1,y1,x2,y2);
line(x2,y2,x,y);
printf("ENTER ANGLE OF ROTATION:-\t");
scanf("%f",&r);
t=r*3.14/180;
x=abs(x*cos(t)-y*sin(t));
y=abs(x*sin(t)+y*cos(t));
x1=abs(x1*cos(t)-y1*sin(t));
y1=abs(x1*sin(t)+y1*cos(t));
x2=abs(x2*cos(t)-y2*sin(t));
y2=abs(x2*sin(t)+y2*cos(t));
printf("\t\tTRIANGLE AFTER ROTATION\n");
line(x,y,x1,y1);
line(x1,y1,x2,y2);
line(x2,y2,x,y);
getch();
closegraph();
}
OUTPUT:
PRACTICAL – 23
WAP to get the Scaling factors from the user and scale the triangle
accordingly.
CODE:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int gd=DETECT,gm;
int x,y,x1,y1,x2,y2,sx,sy;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
printf("BEFORE THE SCALING\n");
printf("ENTER THE COORDINATES OF TRIANGLE\n");
scanf("%d%d%d%d%d%d",&x,&y,&x1,&y1,&x2,&y2);
line(x,y,x1,y1);
line(x1,y1,x2,y2);
line(x2,y2,x,y);
printf("\n\n\n\n\n\n\n\n\n\nENTER THE COORDINATES OF SCALING:\n");
scanf("%d%d",&sx,&sy);
x=sx*x;
y=sy*y;
x1=sx*x1;
y1=sy*y1;
x2=sx*x2;
y2=sy*y2;
printf("\n\n\nAFTER SCALING:-\n");
line(x,y,x1,y1);
line(x1,y1,x2,y2);
line(x2,y2,x,y);
getch();
closegraph();
}
OUTPUT:
PRACTICAL – 28
WAP to Perform the Reflection of a triangle about an arbitrary line.
CODE:
#include <conio.h>
#include <graphics.h>
#include <stdio.h>
void main()
{
int gm, gd = DETECT, ax, x1 = 100;
int x2 = 100, x3 = 200, y1 = 100;
int y2 = 200, y3 = 100;
setcolor(14);
line(x1, y1, x2, y2);
line(x2, y2, x3, y3);
line(x3, y3, x1, y1);
getch();
printf("\nAfter Reflection");
setcolor(4);
line(getmaxx() - x1, getmaxy() - y1, getmaxx() - x2, getmaxy() - y2);
line(getmaxx() - x2, getmaxy() - y2, getmaxx() - x3, getmaxy() - y3);
line(getmaxx() - x3, getmaxy() - y3, getmaxx() - x1, getmaxy() - y1);
setcolor(3);
line(getmaxx() - x1, y1, getmaxx() - x2, y2);
line(getmaxx() - x2, y2, getmaxx() - x3, y3);
line(getmaxx() - x3, y3, getmaxx() - x1, y1);
setcolor(2);
line(x1, getmaxy() - y1, x2, getmaxy() - y2);
line(x2, getmaxy() - y2, x3, getmaxy() - y3);
line(x3, getmaxy() - y3, x1, getmaxy() - y1);
getch();
closegraph();
}
OUTPUT:
PRACTICAL – 24
WAP to get the Shearing factors from the user and perform a shearing
transformation on a rectangle.
CODE:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int gd=DETECT,gm;
int x,y,x1,y1,x2,y2;
initgraph(&gd,&gm,"c:\\TURBOC3\\BGI");
printf("ENTER RECTANGLE COORDINATES:-\t");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
rectangle(x1,y1,x2,y2);
printf("ENTER SHEARING VALUE FOR X AXIS:-\t");
scanf("%d",&x);
rectangle(x1,y1,x2*x,y2);
printf("ENTER SHEARING VALUE FOR Y AXIS:-\t");
scanf("%d",&y);
rectangle(x1,y1,x2,y2*y);
getch();
closegraph();
}
OUTPUT:
PRACTICAL – 30
WAP to Implement Cohen Sutherland line clipping algorithm.
CODE:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT, gm;
float i,xmax,ymax,xmin,ymin,x1,y1,x2,y2,m;
float start[4],end[4],code[4];
clrscr();
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
printf("\n\tEnter the bottom-left coordinate of viewport: ");
scanf("%f %f",&xmin,&ymin);
printf("\n\tEnter the top-right coordinate of viewport: ");
scanf("%f %f",&xmax,&ymax);
printf("\nEnter the coordinates for starting point of line: ");
scanf("%f %f",&x1,&y1);
printf("\nEnter the coordinates for ending point of line: ");
scanf("%f %f",&x2,&y2);
for(i=0;i <4;i++)
{
start[i]=0;
end[i]=0;
}
m=(y2-y1)/(x2-x1);
if(x1 <xmin) start[0]=1;
if(x1 >xmax) start[1]=1;
if(y1 >ymax) start[2]=1;
if(y1 <ymin) start[3]=1;
if(x2 <xmin) end[0]=1;
if(x2 >xmax) end[1]=1;
if(y2 >ymax) end[2]=1;
if(y2 <ymin) end[3]=1;
for(i=0;i <4;i++)
code[i]=start[i]&&end[i];
if((code[0]==0)&&(code[1]==0)&&(code[2]==0)&&(code[3]==0))
{
if((start[0]==0)&&(start[1]==0)&&(start[2]==0)&&(start[3]==0)&&(end[0]==0)&&(end[1]==0
)&&(end[2]==0)&&(end[3]==0))
{
cleardevice();
printf("\n\t\tThe line is totally visible\n\t\tand not a clipping candidate");
rectangle(xmin,ymin,xmax,ymax);
line(x1,y1,x2,y2);
getch();
}
else
{
cleardevice();
printf("\n\t\tLine is partially visible");
rectangle(xmin,ymin,xmax,ymax);
line(x1,y1,x2,y2);
getch();
if((start[2]==0)&&(start[3]==1))
{
x1=x1+(ymin-y1)/m;
y1=ymin;
}
if((end[2]==0)&&(end[3]==1))
{
x2=x2+(ymin-y2)/m;
y2=ymin;
}
if((start[2]==1)&&(start[3]==0))
{
x1=x1+(ymax-y1)/m;
y1=ymax;
}
if((end[2]==1)&&(end[3]==0))
{
x2=x2+(ymax-y2)/m;
y2=ymax;
}
if((start[1]==0)&&(start[0]==1))
{
y1=y1+m*(xmin-x1);
x1=xmin;
}
if((end[1]==0)&&(end[0]==1))
{
y2=y2+m*(xmin-x2);
x2=xmin;
}
if((start[1]==1)&&(start[0]==0))
{
y1=y1+m*(xmax-x1);
x1=xmax;
}
if((end[1]==1)&&(end[0]==0))
{
y2=y2+m*(xmax-x2);
x2=xmax;
}
clrscr();
cleardevice();
printf("\n\t\tAfter clippling:");
rectangle(xmin,ymin,xmax,ymax);
line(x1,y1,x2,y2);
getch();
}
}
else
{
clrscr();
cleardevice();
printf("\nLine is invisible");
rectangle(xmin,ymin,xmax,ymax);
}
getch();
closegraph();
}
OUTPUT:
PRACTICAL – 22
Program to rotate a circle outside another circle.
CODE:
#include <conio.h>
#include <graphics.h>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void drawEllipse(int xc, int yc, int a, int b, float alpha, int color)
{
float t = 3.14 / 180;
alpha = 360 - alpha;
setcolor(color);
int theta;
putpixel(xc + x, yc - y, color);
}
}
void slidePattern(int xc, int yc, int r, int a, int b, int alpha, float p, int color)
{
setcolor(color);
float t = 3.14 / 180;
float t1, t2, d;
float angle = (p * alpha);
h = (a * a) + (b * b);
h /= 2;
p1 = sqrt(h);
p1 /= r;
p1 = 1 / (p1);
int main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, " C:\\TURBOC3\\BGI ");
closegraph();
return 0;
}
OUTPUT:
PRACTICAL – 9
Program to draw Flying Balloons.
CODE:
#include<stdio.h>
#include"conio.h"
#include<dos.h>
#include<graphics.h>
void main(){
int gd=DETECT,gm,x,y,w,z,i;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
for(i=100;i<=210;i++)
{
delay(5);
cleardevice();
setfillstyle(SOLID_FILL,BLUE);
circle(150,250-i,40);
line(150,290-i,150,500-i);
floodfill(150,250-i,WHITE);
setfillstyle(SOLID_FILL,YELLOW);
circle(250,250-i,40);
line(250,290-i,250,500-i);
floodfill(250,250-i,WHITE);
setfillstyle(SOLID_FILL,RED);
circle(350,250-i,40);
line(350,290-i,350,500-i);
floodfill(350,250-i,WHITE);
}
getch();
closegraph();
}
OUTPUT:
PRACTICAL – 10
Show Bouncing Ball Animation.
CODE:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<stdlib.h>
void main()
{
int gd = DETECT, gm;
int i, x, y, flag=0;
initgraph(&gd, &gm, "C:\\TC\\BGI");
x = getmaxx()/2;
y = 30;
while(!kbhit())
{
if(y >= getmaxy()-30 || y <= 30)
flag = !flag;
setcolor(RED);
setfillstyle(SOLID_FILL, RED);
circle(x, y, 30);
floodfill(x, y, RED);
delay(25);
cleardevice();
if(flag)
{
y = y + 2;
}
else
{
y = y - 2;
}}
getch();
closegraph();
}
OUTPUT:
PRACTICAL – 11
Draw pie chart of family income and Expenditure.
CODE:
#include<graphics.h>
int main() {
int gd = DETECT, gm, x, y;
initgraph(&gd, &gm, "C:\\TC\\BGI");
settextstyle(BOLD_FONT,HORIZ_DIR,2);
outtextxy(220,10,"PIE CHART");
/* Setting cordinate of center of circle */
x = getmaxx()/2;
y = getmaxy()/2;
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1);
setfillstyle(SOLID_FILL, RED);
pieslice(x, y, 0, 60, 120);
outtextxy(x + 140, y - 70, "FOOD");
setfillstyle(SOLID_FILL, YELLOW);
pieslice(x, y, 60, 160, 120);
outtextxy(x - 30, y - 170, "RENT");
setfillstyle(SOLID_FILL, GREEN);
pieslice(x, y, 160, 220, 120);
outtextxy(x - 250, y, "ELECTRICITY");
setfillstyle(SOLID_FILL, BROWN);
pieslice(x, y, 220, 360, 120);
outtextxy(x, y + 150, "SAVINGS");
closegraph();
return 0;
}
OUTPUT:
PRACTICAL – 8
Show changing radius of circle.
CODE:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int gd=DETECT,gm;
int x,y,r,angle,xc,yc;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
x=0;
y=r;
angle=0;
printf("ENTER XC,YC,RADIUS OF CIRCLE:-\t");
scanf("%d%d%d",&xc,&yc,&r);
while(angle<=360)
{
putpixel(xc+x,yc+y,6);
x=r*cos(angle);
y=r*sin(angle);
angle=angle+1;
}
getch();
}
OUTPUT:
PRACTICAL – 25
WAP to Perform fixed point Scaling.
CODE:
#include <stdio.h>
#include <conio.h>
void main() {
int fixedPointValue, scaleFactor;
int scaledValue;
clrscr();
printf("Enter fixed point value: ");
scanf("%d", &fixedPointValue);
printf("Enter scale factor: ");
scanf("%d", &scaleFactor);
setcolor(WHITE);
drawClockFace(xc, yc, 100);
setcolor(YELLOW);
drawHand(xc, yc, 50, hourAngle);
setcolor(GREEN);
drawHand(xc, yc, 70, minuteAngle);
setcolor(GREEN);
drawHand(xc, yc, 90, secondAngle);
}
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TURBOC3\\BGI");
while (!kbhit()) {
cleardevice();
drawClock(getmaxx() / 2, getmaxy() / 2);
delay(1000);
}
getch();
closegraph();
return 0;
}
OUTPUT:
PRACTICAL – 14
Draw a moving cycle.
CODE:
#include <conio.h>
#include <dos.h>
#include <graphics.h>
#include <iostream.h>
int main()
{
int gd = DETECT, gm, i, a;
initgraph(&gd, &gm, "C:\\TURBOC3\\BGI");
delay(10);
cleardevice();
}
getch();
closegraph();
}
OUTPUT:
PRACTICAL – 12
Design a screensaver.
CODE:
#include <graphics.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>
#include <time.h>
if (pattern == 0) {
setfillstyle(SOLID_FILL, getcolor());
} else if (pattern == 1) {
setfillstyle(HATCH_FILL, getcolor());
} else if (pattern == 2) {
setfillstyle(XHATCH_FILL, getcolor());
} else {
setfillstyle(INTERLEAVE_FILL, getcolor());
}
floodfill(x, y, getcolor());
circle(x, y, radius);
}
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TURBOC3\\BGI");
srand(time(NULL));
while (!kbhit()) {
cleardevice();
for (int i = 0; i < 50; i++) {
int x = rand() % getmaxx();
int y = rand() % getmaxy();
int radius = rand() % 30 + 10;
drawRandomCircle(x, y, radius);
}
delay(100);
}
getch();
closegraph();
return 0;
}
OUTPUT:
PRACTICAL – 15
Show Moving Car Animation.
CODE:
#include<stdio.h>
#include"conio.h"
#include<dos.h>
#include<graphics.h>
void main(){
int gd=DETECT,gm,x,y,w,z,i;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
for(i=100;i<=400;i++)
{
delay(10);
cleardevice();
rectangle(400-i,200,600-i,250);
rectangle(480-i,210,510-i,230);//window of car
line(420-i,200,460-i,160);
line(460-i,160,540-i,160);
line(540-i,160,580-i,200);
circle(450-i,250,20);//wheel of car
circle(550-i,250,20); //wheel of car
circle(450-i,250,10);
circle(550-i,250,10);
}
getch();
closegraph();
}
OUTPUT:
PRACTICAL – 2
Display a string “Hello User” in the centre of the screen using Outtextxy()
function.
CODE:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main()
{
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "C:\\TC\\BGI");
getch();
closegraph();
return 0;
}
OUTPUT:
PRACTICAL – 26
WAP to Perform fixed point Rotation.
CODE:
#include <stdio.h>
#include <conio.h>
void main() {
int x, y, angle;
float radian, cosine, sine, newX, newY;
clrscr();
printf("Enter Fixed Point (x,y) for Rotation:");
scanf("%d", &x);
getch();
}
OUTPUT:
PRACTICAL – 4
Display nested circles.
CODE:
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
void main(){
int gd = DETECT,gm;
int x ,y;
initgraph(&gd, &gm, "C:\\TC\\BGI");
x = getmaxx()/2;
y = getmaxy()/2;
outtextxy(240, 50, "Concentric Circles");
setcolor(RED);
circle(x, y, 30);
setcolor(GREEN);
circle(x, y, 50);
setcolor(YELLOW);
circle(x, y, 70);
setcolor(BLUE);
circle(x, y, 90);
getch();
closegraph();
}
OUTPUT:
PRACTICAL – 5
Display nested rectangles.
CODE:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main()
{
int gdriver = DETECT, gmode;
int left, top, right, bottom;
initgraph(&gdriver, &gmode, "C://TC//bgi");
left = 100;
top = 100;
right = 400;
bottom = 300;
for (int i = 0; i < 5; i++) {
rectangle(left, top, right, bottom);
left += 20;
top += 20;
right -= 20;
bottom -= 20;
}
getch();
closegraph();
return 0;
}
OUTPUT:
PRACTICAL – 7
Write a program to display HUT.
CODE:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "");
getch();
closegraph();
return 0;
}
OUTPUT:
PRACTICAL – 20
WAP to get the Translation vector from the user and translate the triangle
accordingly.
CODE:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
int x,y,x1,y1,x2,y2,tx,ty;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
printf("BEFORE THE TRANSLATION\n");
printf("ENTER THE COORDINATES OF TRIANGLE\n");
scanf("%d%d%d%d%d%d",&x,&y,&x1,&y1,&x2,&y2);
line(x,y,x1,y1);
line(x1,y1,x2,y2);
line(x2,y2,x,y);
printf("\n\n\n\n\n\n\n\n\n\nENTER TRANSLATION COORDINATES:\n\n");
scanf("%d%d",&tx,&ty);
x=x+tx;
y=y+ty;
x1=x1+tx;
y1=y1+ty;
x2=x2+tx;
y2=y2+ty;
printf("\n\n\nAFTER TRANSLATION:-\n");
line(x,y,x1,y1);
line(x1,y1,x2,y2);
line(x2,y2,x,y);
getch();
closegraph();
}
OUTPUT:
PRACTICAL – 19
WAP to Scan convert circle using Polynomial method.
CODE:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
void main()
{
intgd=DETECT,gm;
intx,y,r,xc,yc;
initgraph(&gd,&gm,"C:\\turboc3\\bgi");
x=0;
printf("ENTER XC,YC,RADIUS OF CIRCLE:-\t");
scanf("%d%d%d",&xc,&yc,&r);
y=r;
while(x<=y)
{putpixel(xc+x,yc+y,4);
putpixel(xc+y,yc+x,4);
putpixel(xc-x,yc+y,4);
putpixel(xc-y,yc+x,4);
putpixel(xc-y,yc-x,4);
putpixel(xc-x,yc-y,4);
putpixel(xc+x,yc-y,4);
putpixel(xc+y,yc-x,4);
x=x+1;y=sqrt(r*r-x*x);}getch();
}
OUTPUT:
PRACTICAL – 18
WAP to Scan convert circle using Trigonometric method.
CODE:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int gd=DETECT,gm;
int x,y,r,angle,xc,yc;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
x=0;
y=r;
angle=0;
printf("ENTER XC,YC,RADIUS OF CIRCLE:-\t");
scanf("%d%d%d",&xc,&yc,&r);
while(angle<=360)
{
putpixel(xc+x,yc+y,6);
x=r*cos(angle);
y=r*sin(angle);
angle=angle+1;
}
getch();
}
OUTPUT:
PRACTICAL – 27
WAP to Perform two transformations in succession on same object.
CODE:
#include <stdio.h>
int main() {
int x, y, newX, newY, scaleFactor, translationX, translationY;
newX = x * scaleFactor;
newY = y * scaleFactor;
newX += translationX;
newY += translationY;
return 0;
}
OUTPUT:
PRACTICAL – 1
WAP to Display Coordinate Axes.
CODE:
#include<graphics.h>
#include<conio.h>
#include<stdio.h>
void main(){
int a,b,i;
int gd=DETECT,gm;
initgraph(&gd,&gm,"//turboc 3\\bgi");
a=getmaxx();
b=getmaxy();
line(a/2,0,a/2,b);
line(0,b/2,a,b/2);
outtextxy(a-50,b/2,"X AXIS");
outtextxy(a/2,b-50,"Y AXIS");
for(i=0;i<a;i+=35){
line(a/2+i,b/2-10,a/2+i,b/2+10);
line(a/2-i,b/2+10,a/2-i,b/2-10);
line(a/2+10,b/2-i,a/2-10,b/2-i);
line(a/2-10,b/2+i,a/2+10,b/2+i);}
getch();
}
OUTPUT:
PRACTICAL – 6
WAP to Display different Colorful Shapes.
CODE:
#include <graphics.h>
#include <conio.h>
void main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\Turboc3\\BGI");
setbkcolor(BLACK);
cleardevice();
setcolor(RED);
setfillstyle(SOLID_FILL, RED);
floodfill(300, 100, RED);
circle(300, 100, 50);
setcolor(YELLOW);
setfillstyle(SOLID_FILL, YELLOW);
int x[] = {250, 350, 300};
int y[] = {200, 200, 100};
fillpoly(3, x, y);
setcolor(BLUE);
setfillstyle(SOLID_FILL, BLUE);
rectangle(400, 150, 600, 250);
floodfill(500, 200, BLUE);
setcolor(MAGENTA);
setfillstyle(SOLID_FILL, MAGENTA);
rectangle(400, 300, 500, 400);
floodfill(450, 350, MAGENTA);
getch();
closegraph();
}
OUTPUT: