Computer Graphics Lab Manual
Computer Graphics Lab Manual
Computer Graphics Lab Manual
Raipur
LAB MANUAL
OF
“COMPUTER GRAPHICS”
GRAPHICS
NAME:
ROLLNO:
SEMESTER /YEAR:
DEPARTMENT
EPARTMENT OF COMPUTER SCIENCE
Shri Rawatpura Sarkar University, Raipur
CERTIFICATE
Date: Date:
INDEX
2. PROGRAM OF 2D BAR
3. PROGRAM OF BAR 3D
4. PROGRAM OF CIRCLE
6. PROGRAM OF ELLIPSE
PROGRAM OF LINE
8.
#include<graphics.h>
#include<iostream.h>
#include<dos.h>
#include<conio.h>
void main()
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\BGI");
arc(200,200,180,360,40);
getch();
closegraph();
}
AIM:2. PROGRAM OF 2D BAR
#include<graphics.h>
#include<iostream.h>
#include<conio.h>
#include<dos.h>
void main()
intgd=DETECT,gm;
initgraph(&gd,&gm,"c:/turboc3/BGI");
bar(100,100,150,250);
bar(160,150,210,250);
bar(220,80,270,250);
bar(280,200,330,250);
line(100,250,330,250);
outtextxy(200,280,"years");
outtextxy(30,180,"Rate of");
outtextxy(20,190,"illteracy");
getch();
closegraph();
}
AIM:3. PROGRAM OF BAR 3D
#include<graphics.h>
#include<conio.h>
main()
getch();
closegraph();
Return 0;
}
AIM:4. PROGRAM OF CIRCLE
#include<graphics.h>
#include<conio.h>
main()
getch();
closegraph();
return 0;
}
AIM:5. DRAW A CIRCLE USING POLYNOMIAL METHOD
ALGORITHM
#include<graphics.h>
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
void main()
int gd=DETECT,gm;
int h=0,k=0,r;
float c,x=0,y=0;
initgraph(&gd,&gm,"c:\\BGI");
cout<<endl<<endl<<endl;
cin>>h>>k;
cin>>r;
c=(r/M_SQRT2);
while(x<=c)
x=x+1;
y=sqrt(pow(r,2)-pow(x,2));
putpixel(x+h,y+k,RED);
putpixel(-x+h,y+k,RED);
delay(100);
putpixel(-x+h,-y+k,RED);
putpixel(x+h,-y+k,RED);
delay(100);
putpixel(y+h,x+k,RED);
putpixel(-y+h,x+k,RED);
delay(100);
putpixel(-y+h,-x+k,RED);
putpixel(y+h,-x+k,RED);
getch();
closegraph();
}
AIM:6. PROGRAM OF ELLIPSE
#include<graphics.h>
#include<iostream.h>
#include<conio.h>
#include<dos.h>
void main()
intgd=DETECT,gm;
initgraph(&gd,&gm,"c:/turboc3/BGI");
ellipse(320,200,0,360,50,20);
setfillstyle(1,RED);
floodfill(350,200,WHITE);
getch();
closegraph();
}
AIM:7. PROGRAM OF FILL ELLIPSE
#include<graphics.h>
#include<conio.h>
main()
getch();
closegraph();
return 0;
}
AIM:8. PROGRAM OF LINE
#include<graphics.h>
#include<conio.h>
main()
getch();
closegraph();
return 0;
}
AIM:9. PROGRAM OF OUT TEXT XY
#include<graphics.h>
#include<conio.h>
main()
initgraph(&gd,&gm,"C:/turboc3/BGI");
getch();
closegraph();
return 0;
}
AIM:10. PROGRAM OF PUTPIXEL
#include<graphics.h>
#include<conio.h>
main()
getch();
closegraph();
return 0;