×
DREAM IT. BELIEVE IT. ACHIEVE IT.
--Your friends at LectureNotes
Close

Lab Manuals for Computer Graphics - CG By The Engineer Guy

  • Computer Graphics - CG
  • Practical
  • Indian Institute of Information Technology Una - IIITUNA
  • Computer Science Engineering
  • 271 Views
  • 2 Offline Downloads
  • Uploaded 3 months ago
The Engineer Guy
The Engineer Guy
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

INDIAN INSTITUTE OF INFORMATION TECHNOLOGY UNA (H.P.) COMPUTER GRAPHICS LAB FILE  Name – MOHIT SAINI  Roll No. – IIITU17140  Branch – CSE(3rd SEM)  Submitted To : ANJUM SHARMA

Text from page-2

Indian institute of INFORMATION technology una (h.p.) Computer Graphics Lab File Name - Mudit Mangal Roll no - IIITU17149 Branch - CSE Summited To - Anjum Sharma

Text from page-3

INDIAN INSTITUTE OF INFORMATION TECHNOLOGY, UNA(H.P.) Computer Graphics Lab File  Name : Aryan Verma  Roll No. : IIITU17142  Branch : CSE  SUBMITTED TO : Anjum Sharma

Text from page-4

EXPERIMENT-1 Draw a line using DDA Algorithm: 1 #include <graphics.h> 2 #include <iostream> 3 #include <math.h> 4 #include <dos.h> 5 using namespace std; 6 int main( ) 7 { 8 float x,y,x1,y1,x2,y2,dx,dy,step; 9 int i,gd=DETECT,gm; 10 11 initgraph(&gd,&gm,"c:\\turboc3\\bgi"); 12 13 cout<<"Enter the value of x1 and y1 : "; 14 cin>>x1>>y1; 15 cout<<"Enter the value of x2 and y2: "; 16 cin>>x2>>y2; 17 18 dx=abs(x2-x1); 19 dy=abs(y2-y1); 20 21 if(dx>=dy) 22 step=dx; 23 else 24 step=dy; 25 26 dx=dx/step; 27 dy=dy/step; 28 29 x=x1; 30 y=y1; 31 32 i=1; 33 while(i<=step) 34 { 35 putpixel(x,y,5); 36 x=x+dx; 37 y=y+dy; 38 i=i+1; 39 delay(100); 40 } 41 getch(); 42 closegraph(); 43 } 44

Lecture Notes