DDA Line Drawing Program in C
dda_line_drawing_algo.txt
File size: 912 Bytes
File content type: text/plain
Category: Practical Files
Subject: Computer Graphics and Multimedia
#include<stdio.h>
#include<dos.h>
#include<graphics.h>
#include<math.h>
#include<conio.h>
void lineDDA(int x1, int y1, int x2, int y2) {
int dx,dy,steps,k,x,y,xincrement, yincrement;
dx = x2-x1;
dy = y2-y1;
if(abs(dx)>abs(dy))
steps = abs(dx);
else
steps = abs(dy);
xincrement = dx/steps;
yincrement = dy/steps;
x = x1;
y = y1;
putpixel(x,y,67);
for(k=0;k<steps;k++) {
x += xincrement;
y += yincrement;
putpixel(x,y,67);
delay(20);
}
}
void main() {
int x1,y1,x2,y2;
int gd = DETECT, gm = DETECT;
initgraph(&gd, &gm, "");
printf("Enter the starting coordinates of line:\n");
scanf("%d %d", &x1, &y1);
printf("Enter the ending coordinates of line:\n");
scanf("%d %d", &x2, &y2);
lineDDA(x1, y1, x2, y2);
getch();
}
Related searches DDA line drawing algorithm in C, C Program to Draw a Line Using DDA Algorithm
Last Updated: July 16, 2022
Related
Renewable Energy Resources Practical File
Category: Practical FilesJuly 17, 2022
Mobile Computing Akash 2017
Category: Question PapersJuly 16, 2022
Sales Distribution Management Notes Unit 2
Category: NotesJuly 17, 2022
Cupola Furnace Manufacturing Processes (MP)
Category: NotesJuly 16, 2022
IPU CSE 4th Sem Syllabus
Category: SyllabusJuly 17, 2022
IPU Business Policy Notes Unit 4 PDF
Category: NotesJuly 17, 2022
EHVACDC Unit 2
Category: NotesJuly 17, 2022
Notes of Human Value First and Second Unit for Sessional Test
Category: NotesJuly 16, 2022
Business Economics Notes Unit 4
Category: NotesJuly 16, 2022
BBA Research Methodology Notes Unit 4
Category: NotesJuly 17, 2022