Skip to content

make width and height public #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 25, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions adafruit_progressbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def __init__(
self._palette[1] = outline_color
self._palette[2] = bar_color

self._width = width
self._height = height
self.width = width
self.height = height

self._progress_val = 0.0
self.progress = self._progress_val
Expand Down Expand Up @@ -119,17 +119,17 @@ def progress(self, value):
if self._progress_val > value:
# uncolorize range from width*value+margin to width-margin
# from right to left
_prev_pixel = max(2, int(self._width * self._progress_val - 2))
_new_pixel = max(int(self._width * value - 2), 2)
_prev_pixel = max(2, int(self.width * self._progress_val - 2))
_new_pixel = max(int(self.width * value - 2), 2)
for _w in range(_prev_pixel, _new_pixel - 1, -1):
for _h in range(2, self._height - 2):
for _h in range(2, self.height - 2):
self._bitmap[_w, _h] = 0
else:
# fill from the previous x pixel to the new x pixel
_prev_pixel = max(2, int(self._width * self._progress_val - 3))
_new_pixel = min(int(self._width * value - 2), int(self._width * 1.0 - 3))
_prev_pixel = max(2, int(self.width * self._progress_val - 3))
_new_pixel = min(int(self.width * value - 2), int(self.width * 1.0 - 3))
for _w in range(_prev_pixel, _new_pixel + 1):
for _h in range(2, self._height - 2):
for _h in range(2, self.height - 2):
self._bitmap[_w, _h] = 2
self._progress_val = value

Expand Down