@@ -44,10 +44,6 @@ draw_line_width(SDL_Surface *surf, Uint32 color, int x1, int y1, int x2,
4444static void
4545draw_line (SDL_Surface * surf , int x1 , int y1 , int x2 , int y2 , Uint32 color ,
4646 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 );
5147static void
5248draw_aaline (SDL_Surface * surf , Uint32 color , float startx , float starty ,
5349 float endx , float endy , int * drawn_area ,
@@ -119,17 +115,16 @@ aaline(PyObject *self, PyObject *arg, PyObject *kwargs)
119115 PyObject * colorobj , * start , * end ;
120116 SDL_Surface * surf = NULL ;
121117 float startx , starty , endx , endy ;
122- int width = 1 ; /* Default width. */
123118 PyObject * blend = NULL ;
124119 int drawn_area [4 ] = {INT_MAX , INT_MAX , INT_MIN ,
125120 INT_MIN }; /* Used to store bounding box values */
126121 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 };
129124
130- if (!PyArg_ParseTupleAndKeywords (arg , kwargs , "O!OOO|iO " , keywords ,
125+ if (!PyArg_ParseTupleAndKeywords (arg , kwargs , "O!OOO|O " , keywords ,
131126 & pgSurface_Type , & surfobj , & colorobj ,
132- & start , & end , & width , & blend )) {
127+ & start , & end , & blend )) {
133128 return NULL ; /* Exception already set. */
134129 }
135130
@@ -162,27 +157,11 @@ aaline(PyObject *self, PyObject *arg, PyObject *kwargs)
162157 return RAISE (PyExc_TypeError , "invalid end_pos argument" );
163158 }
164159
165- if (width < 1 ) {
166- return pgRect_New4 ((int )startx , (int )starty , 0 , 0 );
167- }
168-
169160 if (!pgSurface_Lock (surfobj )) {
170161 return RAISE (PyExc_RuntimeError , "error locking surface" );
171162 }
172163
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 );
186165
187166 if (!pgSurface_Unlock (surfobj )) {
188167 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,
18661845 }
18671846}
18681847
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-
19021848/* Algorithm modified from
19031849 * https://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm
19041850 */
0 commit comments