Computer Graphics using C - Lab record
April 21, 2017 | Author: vortexape | Category: N/A
Short Description
Computer Graphics using C Lab record. This documents contain basic graphics programs like DDA, Bresenhams etc and many c...
Description
COMPUTER GRAPHICS
Program no: 1 Date: 13/7/2013
ANIMATED SUNRISE
AIM: Write a C program to draw animated sunrise. ALGORITHM: Step 1: Start Step 2: Initialize initgraph and graphics mode Step 3: Declare function mountain() and sun() Step 4: Call the below functions i) sun() - Draw sun using the function circle() and animate it using for loop and function delay() ii) mountain() - Draw mountain using function arc() and line() Step 5: Call cleardevice() Step 6: closegraph() Step 7: Stop
DEPARTMENT OF COMPUTER APPLICATIONS
Page 1
COMPUTER GRAPHICS
PROGRAM: #include #include #include void main() { void sun(); void mountain(); int gd,gm; gd=DETECT; initgraph(&gd,&gm,"c:\\tc\\bgi"); mountain(); sun(); getch(); closegraph(); } void mountain() {
line(0,300,200,147); arc(225,165,30,150,30); line(250,148,400,300); line(350,250,498,151); arc(527,175,43,137,36); line(553,150,640,250); } void sun() {
int i,j,k,l; for(i=230,k=150;i>100;i--,k++) { setcolor(RED); for(j=30;j>0;j--) circle(340,i,j);
DEPARTMENT OF COMPUTER APPLICATIONS
Page 2
COMPUTER GRAPHICS
setcolor(BROWN); mountain(); setcolor(YELLOW); arc(k,250,20,180,6); arc(k-10,250,20,180,6); l=k+50; setcolor(BLUE); arc(l,150,20,180,6); arc(l-10,150,20,180,6); setcolor(5); arc(l+100,200,20,180,6); arc(l+90,200,20,180,6); arc(l+150,170,30,140,6); arc(l+140,170,30,140,6); delay(150); cleardevice(); } cleardevice(); setcolor(BROWN); mountain(); setcolor(YELLOW); for(i=30;i>0;i--) circle(340,90,i); }
DEPARTMENT OF COMPUTER APPLICATIONS
Page 3
COMPUTER GRAPHICS
OUTPUT
DEPARTMENT OF COMPUTER APPLICATIONS
Page 4
COMPUTER GRAPHICS
Program No: 2 Date: 17/7/2013
ANIMATED ROCKET LAUNCHING
AIM: Write a C program to draw an animated rocket launching. ALGORITHM: Step 1: Start Step 2: Initialize intigraph and graphics mode Step 3: Draw rocket using the function rectangle() and line() and animate it using for loop and function delay() Step 4: Call cleardevice() Step 5: Closegraph() Step 6: Stop
DEPARTMENT OF COMPUTER APPLICATIONS
Page 5
COMPUTER GRAPHICS
PROGRAM: #include #include #include void main() { int d,m,i,y; clrscr(); d=DETECT; initgraph(&d,&m,"c:\\tc\\bgi"); for(y=10;y30,then decrement j by 1. b) Set the fill pattern as solid fill. c) Draw a polygon using polygon function. d) Initialize x1=60,y1=100,x2=220,y2=140,x3=340,y3=180. e) Initialize i to 0 and execute the following. i) Set the color as RED when(i30)k--; setfillstyle(9,BROWN); fillpoly(5,back); x1=60;y1=100;x2=220;x3=340;y2=140;y3=180; for(i=0;i
View more...
Comments