bingram

2D binary n-gram visualization inspired by ..cantor.dust..
git clone https://git.sinitax.com/sinitax/bingram
Log | Files | Refs | sfeed.txt

commit bfc06901ee84ad52febf3fe67a89f789e16fc5b8
parent 7020e07405e693da9e40ed33b38a71f354d4708c
Author: Louis Burda <quent.burda@gmail.com>
Date:   Mon, 13 Feb 2023 01:52:23 +0100

Fix zoom centering

Diffstat:
Mbingram.c | 16++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/bingram.c b/bingram.c @@ -150,6 +150,19 @@ update_trigram_colors(void) memset(trigram_colors, 0, sizeof(Color) * 256 * 256 * 256); } +void +center_zoom(void) +{ + if (show_bar) { + zoom_x = -1.F * bar_width / zoom + - (1.F * (window_width - bar_width) + / zoom - data_width) / 2.F; + } else { + zoom_x = -(1.F * window_width / zoom - data_width) / 2.F; + } + zoom_y = -(1.F * window_height / zoom - data_height) / 2.F; +} + bool key_press_hold(int key) { @@ -224,8 +237,7 @@ vis(void) } if (IsKeyPressed(KEY_G)) zoom = 2; - zoom_x = (data_width - 1.F * window_width / zoom) / 2.F; - zoom_y = (data_height - 1.F * window_height / zoom) / 2.F; + center_zoom(); ImageResize(&window_image, window_width, window_height); if (window_init_frames) window_init_frames -= 1;