@@ -55,14 +55,14 @@ def __init__(
55
55
close : Optional [bool ] = True ,
56
56
colors : Optional [int ] = 2 ,
57
57
) -> None :
58
- (xs , ys ) = zip (* points )
58
+ (x_s , y_s ) = zip (* points )
59
59
60
- x_offset = min (xs )
61
- y_offset = min (ys )
60
+ x_offset = min (x_s )
61
+ y_offset = min (y_s )
62
62
63
63
# Find the largest and smallest X values to figure out width for bitmap
64
- width = max (xs ) - min (xs ) + 1
65
- height = max (ys ) - min (ys ) + 1
64
+ width = max (x_s ) - min (x_s ) + 1
65
+ height = max (y_s ) - min (y_s ) + 1
66
66
67
67
self ._palette = displayio .Palette (colors + 1 )
68
68
self ._palette .make_transparent (0 )
@@ -99,64 +99,70 @@ def draw(
99
99
for index in range (len (points ) - 1 ):
100
100
Polygon ._line_on (bitmap , points [index ], points [index + 1 ], color_id )
101
101
102
+ # pylint: disable=too-many-arguments
102
103
def _line (
103
104
self ,
104
- x0 : int ,
105
- y0 : int ,
106
- x1 : int ,
107
- y1 : int ,
105
+ x_0 : int ,
106
+ y_0 : int ,
107
+ x_1 : int ,
108
+ y_1 : int ,
108
109
color : int ,
109
110
) -> None :
110
- self ._line_on (self ._bitmap , (x0 , y0 ), (x1 , y1 ), color )
111
+ self ._line_on (self ._bitmap , (x_0 , y_0 ), (x_1 , y_1 ), color )
111
112
113
+ # pylint: enable=too-many-arguments
114
+
115
+ # pylint: disable=too-many-branches, too-many-locals
112
116
@staticmethod
113
117
def _line_on (
114
118
bitmap : displayio .Bitmap ,
115
- p0 : Tuple [int , int ],
116
- p1 : Tuple [int , int ],
119
+ p_0 : Tuple [int , int ],
120
+ p_1 : Tuple [int , int ],
117
121
color : int ,
118
122
) -> None :
119
- (x0 , y0 ) = p0
120
- (x1 , y1 ) = p1
121
- if x0 == x1 :
122
- if y0 > y1 :
123
- y0 , y1 = y1 , y0
124
- for _h in range (y0 , y1 + 1 ):
125
- bitmap [x0 , _h ] = color
126
- elif y0 == y1 :
127
- if x0 > x1 :
128
- x0 , x1 = x1 , x0
129
- for _w in range (x0 , x1 + 1 ):
130
- bitmap [_w , y0 ] = color
123
+ (x_0 , y_0 ) = p_0
124
+ (x_1 , y_1 ) = p_1
125
+ if x_0 == x_1 :
126
+ if y_0 > y_1 :
127
+ y_0 , y_1 = y_1 , y_0
128
+ for _h in range (y_0 , y_1 + 1 ):
129
+ bitmap [x_0 , _h ] = color
130
+ elif y_0 == y_1 :
131
+ if x_0 > x_1 :
132
+ x_0 , x_1 = x_1 , x_0
133
+ for _w in range (x_0 , x_1 + 1 ):
134
+ bitmap [_w , y_0 ] = color
131
135
else :
132
- steep = abs (y1 - y0 ) > abs (x1 - x0 )
136
+ steep = abs (y_1 - y_0 ) > abs (x_1 - x_0 )
133
137
if steep :
134
- x0 , y0 = y0 , x0
135
- x1 , y1 = y1 , x1
138
+ x_0 , y_0 = y_0 , x_0
139
+ x_1 , y_1 = y_1 , x_1
136
140
137
- if x0 > x1 :
138
- x0 , x1 = x1 , x0
139
- y0 , y1 = y1 , y0
141
+ if x_0 > x_1 :
142
+ x_0 , x_1 = x_1 , x_0
143
+ y_0 , y_1 = y_1 , y_0
140
144
141
- dx = x1 - x0
142
- dy = abs (y1 - y0 )
145
+ d_x = x_1 - x_0
146
+ d_y = abs (y_1 - y_0 )
143
147
144
- err = dx / 2
148
+ err = d_x / 2
145
149
146
- if y0 < y1 :
150
+ if y_0 < y_1 :
147
151
ystep = 1
148
152
else :
149
153
ystep = - 1
150
154
151
- for x in range (x0 , x1 + 1 ):
155
+ for x in range (x_0 , x_1 + 1 ):
152
156
if steep :
153
- bitmap [y0 , x ] = color
157
+ bitmap [y_0 , x ] = color
154
158
else :
155
- bitmap [x , y0 ] = color
156
- err -= dy
159
+ bitmap [x , y_0 ] = color
160
+ err -= d_y
157
161
if err < 0 :
158
- y0 += ystep
159
- err += dx
162
+ y_0 += ystep
163
+ err += d_x
164
+
165
+ # pylint: enable=too-many-branches, too-many-locals
160
166
161
167
@property
162
168
def outline (self ) -> Optional [int ]:
0 commit comments