-
Notifications
You must be signed in to change notification settings - Fork 3
/
plot_line.c
69 lines (62 loc) · 852 Bytes
/
plot_line.c
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "header.h"
void plot_line(
int x0,
int y0,
int x1,
int y1,
int **pxy_arr,
int *pxy_nbr
)
/*
This is the integer implementation of the Bresenham line algorithm
*/
{
int *xy_arr;
int xy_nbr;
if ( abs(y1 - y0) < abs(x1 - x0) ) {
if ( x0 > x1 ) {
plot_line_low(
x1,
y1,
x0,
y0,
&xy_arr,
&xy_nbr
);
}
else {
plot_line_low(
x0,
y0,
x1,
y1,
&xy_arr,
&xy_nbr
);
}
}
else {
if ( y0 > y1 ) {
plot_line_high(
x1,
y1,
x0,
y0,
&xy_arr,
&xy_nbr
);
}
else {
plot_line_high(
x0,
y0,
x1,
y1,
&xy_arr,
&xy_nbr
);
}
}
(*pxy_arr)= xy_arr;
(*pxy_nbr)= xy_nbr;
}