summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wasp/apps/testapp.py8
-rw-r--r--wasp/draw565.py17
2 files changed, 16 insertions, 9 deletions
diff --git a/wasp/apps/testapp.py b/wasp/apps/testapp.py
index 2b2e05b..6b813e4 100644
--- a/wasp/apps/testapp.py
+++ b/wasp/apps/testapp.py
@@ -183,10 +183,10 @@ class TestApp():
t = machine.Timer(id=1, period=8000000)
t.start()
for x, y in points:
- draw.line(120, 120, 120+x, 120+y, 0xfbc0)
- draw.line(120, 120, 120+y, 120-x, 0x07c0)
- draw.line(120, 120, 120-x, 120-y, 0x6b3f)
- draw.line(120, 120, 120-y, 120+x, 0xffe0)
+ draw.line(120, 120, 120+x, 120+y, 4, 0xfb00) # red
+ draw.line(120, 120, 120+y, 120-x, 3, 0x07c0) # green
+ draw.line(120, 120, 120-x, 120-y, 5, 0x6b3f) # blue
+ draw.line(120, 120, 120-y, 120+x, 2, 0xffe0) # yellow
elapsed = t.time()
t.stop()
del t
diff --git a/wasp/draw565.py b/wasp/draw565.py
index 869a6d6..26e7aef 100644
--- a/wasp/draw565.py
+++ b/wasp/draw565.py
@@ -356,7 +356,7 @@ class Draw565(object):
return chunks
- def line(self, x0, y0, x1, y1, color=None):
+ def line(self, x0, y0, x1, y1, width=1, color=None):
"""Draw a line between points (x0, y0) and (x1, y1).
Example:
@@ -370,14 +370,21 @@ class Draw565(object):
:param y0: Y coordinate of the start of the line
:param x1: X coordinate of the end of the line
:param y1: Y coordinate of the end of the line
+ :param width: Width of the line in pixels
:param color: Colour to draw line, defaults to the foreground colour
"""
if color is None:
color = self._bgfg & 0xffff
- px = bytes(((color >> 8) & 0xFF, color & 0xFF))
+ px = bytes(((color >> 8) & 0xFF, color & 0xFF)) * (width * width)
write_data = self._display.write_data
set_window = self._display.set_window
+ dw = (width - 1) // 2
+ x0 -= dw
+ y0 -= dw
+ x1 -= dw
+ y1 -= dw
+
dx = abs(x1 - x0)
sx = 1 if x0 < x1 else -1
dy = -abs(y1 - y0)
@@ -387,12 +394,12 @@ class Draw565(object):
if x1 < x0 or y1 < y0:
x0, x1 = x1, x0
y0, y1 = y1, y0
- w = 1 if dx == 0 else dx
- h = 1 if dy == 0 else -dy
+ w = width if dx == 0 else dx
+ h = width if dy == 0 else -dy
self.fill(color, x0, y0, w, h)
return
while True:
- set_window(x0, y0, 1, 1)
+ set_window(x0, y0, width, width)
write_data(px)
if x0 == x1 and y0 == y1:
break