vtgl

terminal emulator implemented in OpenGL
git clone anongit@rnpnr.xyz:vtgl.git
Log | Files | Refs | Feed | LICENSE

Commit: c14801bdafaf974c2c4f52b2b5b8b9b5be02c6ec
Parent: 7225750df35edf7ee20298f5dbb1dff44bd5c634
Author: Randy Palamar
Date:   Thu, 28 Nov 2024 09:51:50 -0700

mouse_to_cell_space: properly round cell

Diffstat:
Mvtgl.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/vtgl.c b/vtgl.c @@ -567,12 +567,12 @@ render_framebuffer(Term *t, RenderCell *render_buf) static iv2 mouse_to_cell_space(Term *t, v2 mouse) { - iv2 result = {0}; v2 cell_size = get_cell_size(&t->fa); v2 top_left = get_terminal_top_left(t); - result.x = (i32)((mouse.x - top_left.x) / cell_size.w); - result.y = (i32)((top_left.y - mouse.y) / cell_size.h); + iv2 result; + result.x = (i32)((mouse.x - top_left.x) / cell_size.w + 0.5); + result.y = (i32)((top_left.y - mouse.y) / cell_size.h + 0.5); CLAMP(result.x, 0, t->size.w - 1); CLAMP(result.y, 0, t->size.h - 1);