From 8a14faa66867c2dfdef66c48a0669c00a5e4440e Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Sun, 27 Dec 2020 08:38:54 +0000 Subject: draw565: Improve default argument values for line() Currently there are default argument values for the start and end coordinates but the defaults don't really make any sense since there is no reason to prefer the value 0 over any other. Remove them. Similarly color currently defaults to 0xffff which isn't right. It should default to the foreground colour. Signed-off-by: Daniel Thompson diff --git a/wasp/draw565.py b/wasp/draw565.py index 77bd286..869a6d6 100644 --- a/wasp/draw565.py +++ b/wasp/draw565.py @@ -356,8 +356,8 @@ class Draw565(object): return chunks - def line(self, x0=0, y0=0, x1=0, y1=0, color=0xffff): - """Draw a line between points (x0;y0) and (x1;y1) with color. + def line(self, x0, y0, x1, y1, color=None): + """Draw a line between points (x0, y0) and (x1, y1). Example: @@ -366,13 +366,14 @@ class Draw565(object): draw = wasp.watch.drawable draw.line(0, 120, 240, 240, 0xf800) - :param x0: X coordinate of the start of the line, defaults to 0 - :param x1: Y coordinate of the end of the line, defaults to 0 - :param y0: Y coordinate of the start of the line, defaults to 0 - :param y1: Y coordinate of the end of the line, defaults to 0 - :param color: Color to draw line in, in RGB565 format, defaults to 0xffff + :param x0: X coordinate of the start of the line + :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 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)) write_data = self._display.write_data set_window = self._display.set_window -- cgit v0.10.2