File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ void hagl_draw_line(
5656 int16_t dy ;
5757 int16_t sy ;
5858 int16_t err ;
59- int16_t e2 ;
59+ int16_t err2 ;
6060
6161 dx = ABS (x1 - x0 );
6262 sx = x0 < x1 ? 1 : -1 ;
@@ -67,18 +67,36 @@ void hagl_draw_line(
6767 while (1 ) {
6868 surface -> put_pixel ((void * )_surface , x0 , y0 , color );
6969
70- if (x0 == x1 && y0 == y1 ) {
70+ if (( x0 == x1 ) && ( y0 == y1 ) ) {
7171 break ;
72- };
72+ }
73+
74+ err2 = err + err ;
75+
76+ if (err2 > - dx ) {
77+ err -= dy ;
78+ x0 += sx ;
79+ }
80+
81+ if (err2 < dy ) {
82+ err += dx ;
83+ y0 += sy ;
84+ }
85+
86+ surface -> put_pixel ((void * )_surface , x0 , y0 , color );
87+
88+ if ((x0 == x1 ) && (y0 == y1 )) {
89+ break ;
90+ }
7391
74- e2 = err + err ;
92+ err2 = err + err ;
7593
76- if (e2 > - dx ) {
94+ if (err2 > - dx ) {
7795 err -= dy ;
7896 x0 += sx ;
7997 }
8098
81- if (e2 < dy ) {
99+ if (err2 < dy ) {
82100 err += dx ;
83101 y0 += sy ;
84102 }
You can’t perform that action at this time.
0 commit comments