Skip to content

fix for platforms without bitmaptools #81

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
29 changes: 20 additions & 9 deletions adafruit_display_shapes/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
except ImportError:
pass

import bitmaptools
try:
import bitmaptools

HAVE_BITMAPTOOLS = True
except ImportError:
HAVE_BITMAPTOOLS = False

import displayio

__version__ = "0.0.0+auto.0"
Expand Down Expand Up @@ -144,14 +150,19 @@ def pt_on(x, y, pt_size=1):
if pt_size > 1:
x = x + pt_size // 2
y = y + pt_size // 2
bitmaptools.fill_region(
bitmap,
x - (pt_size // 2),
y - (pt_size // 2),
x + (pt_size // 2),
y + (pt_size // 2),
color,
)
if HAVE_BITMAPTOOLS:
bitmaptools.fill_region(
bitmap,
x - (pt_size // 2),
y - (pt_size // 2),
x + (pt_size // 2),
y + (pt_size // 2),
color,
)
else:
for p_x in range(x - (pt_size // 2), x + (pt_size // 2)):
for p_y in range(y - (pt_size // 2), y + (pt_size // 2)):
Polygon._safe_draw(bitmap, (p_x, p_y), color)
else:
Polygon._safe_draw(bitmap, (x, y), color)

Expand Down