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
Diffraction Notes
Category: NotesJuly 16, 2022
Productions and Operations Management Notes Unit 2
Category: NotesJuly 17, 2022
Advance Control System Unit 2
Category: NotesJuly 17, 2022
Partition Technique and Merger Table
Category: NotesJuly 16, 2022
Business Laws Notes PDF Unit 4
Category: NotesJuly 17, 2022
Ultrasonics Notes
Category: NotesJuly 16, 2022
BBA MPOB Notes Unit 2
Category: NotesJuly 16, 2022
Expansion and Approximation Notes
Category: NotesJuly 16, 2022
Physics First Year Practical File
Category: Practical FilesJuly 16, 2022
Complete Java Notes PDF (Q/A Format)
Category: NotesJuly 16, 2022