1
- # Copyright (C) 2021 Hugo Dahl for Adafruit Industries
2
- # Copyright (c) 2020 Brent Rubell for Adafruit Industries
1
+ # SPDX-FileCopyrightText: Copyright (c) 2020-2021 Brent Rubell for Adafruit Industries, Hugo Dahl
3
2
#
4
3
# SPDX-License-Identifier: MIT
5
4
@@ -175,7 +174,6 @@ def _draw_outline(self):
175
174
def progress (self ):
176
175
"""The percentage of the progress bar expressed as a
177
176
floating point number.
178
-
179
177
"""
180
178
return self ._progress_val
181
179
@@ -210,7 +208,7 @@ def render(self, old_value, new_value, progress):
210
208
:return: None
211
209
:rtype: None
212
210
"""
213
- _padding = 1
211
+ _padding = 0
214
212
215
213
print (f"Drawing a visual of progress value { progress } " )
216
214
@@ -230,8 +228,8 @@ def render(self, old_value, new_value, progress):
230
228
self .height - (2 * _padding ) - _border_size
231
229
) # Count padding on the top and bottom
232
230
233
- _prev_value_size = int (old_value * _fill_width )
234
- _new_value_size = int (new_value * _fill_width )
231
+ _prev_value_size = int (old_value * _fill_height )
232
+ _new_value_size = int (new_value * _fill_height )
235
233
236
234
# If we have *ANY* value other than "zero" (minimum), we should
237
235
# have at least one element showing
@@ -241,7 +239,7 @@ def render(self, old_value, new_value, progress):
241
239
# Conversely, if we have *ANY* value other than 100% (maximum),
242
240
# we should NOT show a full bar.
243
241
244
- if _new_value_size == _fill_width and new_value < self ._max :
242
+ if _new_value_size == _fill_height and new_value < self ._max :
245
243
_new_value_size -= 1
246
244
247
245
# Default values for increasing value
@@ -259,23 +257,23 @@ def render(self, old_value, new_value, progress):
259
257
_start = max (_prev_value_size , _start_offset )
260
258
_end = max (_new_value_size , _start_offset )
261
259
elif _prev_value_size == _new_value_size :
262
- return # No action to take. Return
260
+ return # The pre-defined values above the start
261
+ # of the if block are already correct.
263
262
else :
264
- pass
263
+ pass # No value change. Return.
265
264
266
265
# Because range() is ( from-include, to-exclude )...
267
266
_vert_start = _border_thickness + _padding
268
267
_vert_end = _vert_start + _fill_height
269
268
270
- for h in range (_vert_start , _vert_end ):
271
- for w in range (_start , _end , _incr ):
269
+ for h in range (_start , _end , _incr ):
270
+ for w in range (_start_offset , _fill_width ):
272
271
self ._bitmap [w , h ] = _color
273
272
274
273
@property
275
274
def fill (self ):
276
- """The fill of the progress bar. Can be a hex value for a color or ``None`` for
277
- transparent.
278
-
275
+ """The fill of the progress bar. Can be a hex value for a color or
276
+ ``None`` for transparent.
279
277
"""
280
278
return self ._palette [0 ]
281
279
@@ -291,9 +289,8 @@ def height(self):
291
289
292
290
@fill .setter
293
291
def fill (self , color ):
294
- """Sets the fill of the progress bar. Can be a hex value for a color or ``None`` for
295
- transparent.
296
-
292
+ """Sets the fill of the progress bar. Can be a hex value for a color or
293
+ ``None`` for transparent.
297
294
"""
298
295
if color is None :
299
296
self ._palette [2 ] = 0
0 commit comments