@@ -44,10 +44,6 @@ draw_line_width(SDL_Surface *surf, Uint32 color, int x1, int y1, int x2,
44
44
static void
45
45
draw_line (SDL_Surface * surf , int x1 , int y1 , int x2 , int y2 , Uint32 color ,
46
46
int * drawn_area );
47
- void
48
- line_width_corners (float from_x , float from_y , float to_x , float to_y ,
49
- int width , float * x1 , float * y1 , float * x2 , float * y2 ,
50
- float * x3 , float * y3 , float * x4 , float * y4 );
51
47
static void
52
48
draw_aaline (SDL_Surface * surf , Uint32 color , float startx , float starty ,
53
49
float endx , float endy , int * drawn_area ,
@@ -119,17 +115,16 @@ aaline(PyObject *self, PyObject *arg, PyObject *kwargs)
119
115
PyObject * colorobj , * start , * end ;
120
116
SDL_Surface * surf = NULL ;
121
117
float startx , starty , endx , endy ;
122
- int width = 1 ; /* Default width. */
123
118
PyObject * blend = NULL ;
124
119
int drawn_area [4 ] = {INT_MAX , INT_MAX , INT_MIN ,
125
120
INT_MIN }; /* Used to store bounding box values */
126
121
Uint32 color ;
127
- static char * keywords [] = {"surface" , "color" , "start_pos" , "end_pos" ,
128
- "width" , "blend" , NULL };
122
+ static char * keywords [] = {"surface" , "color" , "start_pos" ,
123
+ "end_pos" , "blend" , NULL };
129
124
130
- if (!PyArg_ParseTupleAndKeywords (arg , kwargs , "O!OOO|iO " , keywords ,
125
+ if (!PyArg_ParseTupleAndKeywords (arg , kwargs , "O!OOO|O " , keywords ,
131
126
& pgSurface_Type , & surfobj , & colorobj ,
132
- & start , & end , & width , & blend )) {
127
+ & start , & end , & blend )) {
133
128
return NULL ; /* Exception already set. */
134
129
}
135
130
@@ -162,27 +157,11 @@ aaline(PyObject *self, PyObject *arg, PyObject *kwargs)
162
157
return RAISE (PyExc_TypeError , "invalid end_pos argument" );
163
158
}
164
159
165
- if (width < 1 ) {
166
- return pgRect_New4 ((int )startx , (int )starty , 0 , 0 );
167
- }
168
-
169
160
if (!pgSurface_Lock (surfobj )) {
170
161
return RAISE (PyExc_RuntimeError , "error locking surface" );
171
162
}
172
163
173
- if (width > 1 ) {
174
- float x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4 ;
175
- line_width_corners (startx , starty , endx , endy , width , & x1 , & y1 , & x2 ,
176
- & y2 , & x3 , & y3 , & x4 , & y4 );
177
- draw_line_width (surf , color , (int )startx , (int )starty , (int )endx ,
178
- (int )endy , width , drawn_area );
179
- draw_aaline (surf , color , x1 , y1 , x2 , y2 , drawn_area , 0 , 0 , 0 );
180
- draw_aaline (surf , color , x3 , y3 , x4 , y4 , drawn_area , 0 , 0 , 0 );
181
- }
182
- else {
183
- draw_aaline (surf , color , startx , starty , endx , endy , drawn_area , 0 , 0 ,
184
- 0 );
185
- }
164
+ draw_aaline (surf , color , startx , starty , endx , endy , drawn_area , 0 , 0 , 0 );
186
165
187
166
if (!pgSurface_Unlock (surfobj )) {
188
167
return RAISE (PyExc_RuntimeError , "error unlocking surface" );
@@ -1866,39 +1845,6 @@ draw_line_width(SDL_Surface *surf, Uint32 color, int x1, int y1, int x2,
1866
1845
}
1867
1846
}
1868
1847
1869
- // Calculates 4 points, representing corners of draw_line_width()
1870
- // first two points assemble left line and second two - right line
1871
- void
1872
- line_width_corners (float from_x , float from_y , float to_x , float to_y ,
1873
- int width , float * x1 , float * y1 , float * x2 , float * y2 ,
1874
- float * x3 , float * y3 , float * x4 , float * y4 )
1875
- {
1876
- float aa_width = (float )width / 2 ;
1877
- float extra_width = (1.0f - (width % 2 )) / 2 ;
1878
- int steep = fabs (to_x - from_x ) <= fabs (to_y - from_y );
1879
-
1880
- if (steep ) {
1881
- * x1 = from_x + extra_width + aa_width ;
1882
- * y1 = from_y ;
1883
- * x2 = to_x + extra_width + aa_width ;
1884
- * y2 = to_y ;
1885
- * x3 = from_x + extra_width - aa_width ;
1886
- * y3 = from_y ;
1887
- * x4 = to_x + extra_width - aa_width ;
1888
- * y4 = to_y ;
1889
- }
1890
- else {
1891
- * x1 = from_x ;
1892
- * y1 = from_y + extra_width + aa_width ;
1893
- * x2 = to_x ;
1894
- * y2 = to_y + extra_width + aa_width ;
1895
- * x3 = from_x ;
1896
- * y3 = from_y + extra_width - aa_width ;
1897
- * x4 = to_x ;
1898
- * y4 = to_y + extra_width - aa_width ;
1899
- }
1900
- }
1901
-
1902
1848
/* Algorithm modified from
1903
1849
* https://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm
1904
1850
*/
0 commit comments