diff --git a/src/tempe/markers.py b/src/tempe/markers.py index aa2dc61..e3caee5 100644 --- a/src/tempe/markers.py +++ b/src/tempe/markers.py @@ -44,17 +44,17 @@ def draw(self, buffer, x=0, y=0): buffer.hline(px - size // 2, py, size, color) buffer.vline(px, py - size // 2, size, color) elif marker == Marker.CROSS: - d = 17 * size // 48 # very rough approximation of 1/(2*sqrt(2)) + d = (17 * size // 48) + 1 # very rough approximation of 1/(2*sqrt(2)) buffer.line(px - d, py - d, px + d, py + d, color) buffer.line(px - d, py + d, px + d, py - d, color) elif isinstance(marker, str): buffer.text(marker, px - 4, py - 4, color) elif isinstance(marker, framebuf.FrameBuffer): # assume 1-bit framebuffer - no way to test! - palette[1] = color + palette_buf[1] = color buffer.blit(marker, px, py, BLIT_KEY_RGB565, palette) elif isinstance(marker, array): - buffer.polgon(px, py, marker, color, fill=True) + buffer.poly(px, py, marker, color, True) def update(self, geometry=None, colors=None, markers=None): if geometry is not None: @@ -64,3 +64,16 @@ def update(self, geometry=None, colors=None, markers=None): if markers is not None: self.markers = markers super().update() + + def _bounds(self): + max_x = -0x7fff + min_x = 0x7fff + max_y = -0x7fff + min_y = 0x7fff + for geometry in self.geometry: + max_x = max(max_x, geometry[0] + abs(geometry[2])) + min_x = min(min_x, geometry[0] - abs(geometry[2])) + max_y = max(max_y, geometry[1] + abs(geometry[2])) + min_y = min(min_y, geometry[1] - abs(geometry[2])) + + return (min_x - 1, min_y - 1, max_x - min_x + 2, max_y - min_y + 2)