/ Published in: C
This is an implementation of the DDA (Digital Differential Analyzer) Algorithm in Computer Graphics Design in the C programming language.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//Shubham Mehta, Write a program to implement Digital Differential Analyzer Algorithm. #include<stdio.h> #include<conio.h> #include<graphics.h> void main() { int gd, gm; float x, y, x1, x2, y1, y2, slope; clrscr(); slope=(y2-y1)/(x2-x1); gd=DETECT, gm; initgraph(&gd, &gm, "C:\\TC\\BGI"); if(slope<1) { for(; x1<=x2; x1++) { y1+=slope; putpixel(x1, y1, RED); } } else { for(; y1<=y2; y1++) { x1+=slope; putpixel(x1, y1, RED); } } closegraph(); }