CG Draft
CG Draft
YASH MODI
LABORATORY REPORT
Computer Graphics Lab (CSL355)
Submitted by
YASH MODI
2022BCSE051
B.Tech. CSE
th
(6 Semester – Section ‘A’)
Submitted to
SPRING 2025
2022BCSE051
YASH MODI
2022BCSE051
YASH MODI
CONTENTS
Page Faculty
Week # Date Experiment
No. Sign
Self-Declaration
I have done all the above programs on my own to the best of my knowledge.
Student’s Signature
2022BCSE051
YASH MODI
2022BCSE051
YASH MODI
LAB: 01
Graphics.h Library
mode.
▪ graphdriver: Pointer to store detected driver.
▪ graphmode: Pointer to store detected mode.
LAB 2
1.STAR
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void) {
int gdriver = DETECT, gmode, errorcode;
int xmax, ymax;
errorcode = graphresult();
if (errorcode != grOk) {
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
setcolor(getmaxcolor());
xmax = getmaxx();
ymax = getmaxy();
getch();
2022BCSE051
YASH MODI
closegraph();
return 0;
}
OUTPUT:
2.HUT:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void) {
int gdriver = DETECT, gmode, errorcode;
int left, top, right, bottom;
errorcode = graphresult();
if (errorcode != grOk) {
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
getch();
closegraph();
return 0;
}
OUTPUT:
3.Concentric Circle:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void) {
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;
errorcode = graphresult();
if (errorcode != grOk) {
2022BCSE051
YASH MODI
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());
getch();
closegraph();
return 0;
}
OUTPUT:
2022BCSE051
YASH MODI
4.Moving Car:
#include <graphics.h>
#include <winbgim.h>
#include <conio.h> // For getch()
int main() {
initwindow(getmaxwidth(), getmaxheight(), "Car Animation");
int y1 = getmaxy() / 2;
int page = 0;
getch();
closegraph();
return 0;
}
OUTPUT
2022BCSE051
YASH MODI
LAB 03
#include <graphics.h>
#include <conio.h>
#include <math.h>
#include <dos.h> // Required for delay()
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TURBOC3\\BGI");
getch();
closegraph();
return 0;
2022BCSE051
YASH MODI
}
2022BCSE051
YASH MODI
LAB 04
getch();
closegraph();
return 0;
2022BCSE051
YASH MODI
Output: