Skip to content

Commit

Permalink
Fix issues with marker rendering. (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
corranwebster authored Oct 17, 2024
1 parent b595c4c commit 624d7ee
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/tempe/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

0 comments on commit 624d7ee

Please sign in to comment.