Skip to content
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

Fix issues with marker rendering. #12

Merged
merged 1 commit into from
Oct 17, 2024
Merged
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
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)