-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBresenhamDashLine.cpp
More file actions
47 lines (40 loc) · 964 Bytes
/
Copy pathBresenhamDashLine.cpp
File metadata and controls
47 lines (40 loc) · 964 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<graphics.h>
#include<stdio.h>
void drawline(int x1,int y1,int x2,int y2);
int main11()
{
initwindow(500,500,"line");
int x1=1,x2=100,y1=100,y2=100;
int dx=x2-x1;
int dy=y2-y1;
int p=2*dy-dx;
int cnt=0;
int x,y;
x=x1;
y=y1;
putpixel(x,y,10);
while(x<x2)
{
x++;
if(p<0)
{
y1++;
p+=(2*dy)-(2*dx);
}
else
{
p+=2*dy;
}
if(cnt!=20)
{
putpixel(x,y,10);
cnt+=1;
}
else
{ cnt=0;
x+=5;
}
}
delay(50000);
return 0;
}