forked from koolkarthik97/Graphics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDDALine.cpp
More file actions
30 lines (29 loc) · 697 Bytes
/
Copy pathDDALine.cpp
File metadata and controls
30 lines (29 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<iostream>
#include<graphics.h>
int ddal(int x1,int x2,int y1, int y2)
{
int x,y,k,steps,xc,yc,dx,dy;
dx=x2-x1;
dy=y2-y1;
if(abs(dx)>abs(dy))
steps=abs(dx);
else
steps=abs(dy);
xc=(dx/steps);
yc=(dy/steps);
x=x1;
y=y1;
for(k=1;k<=steps;k++)
{
x=xc+x;
y=yc+y;
circle(x,y,3);
}
}
int main4()
{
initwindow(500,500,"lineDDA");
ddal(100,400,200,500);
delay(10000);
return 0;
}