From 12b6b0f6a439c7838daac5e2a1e5764bd0218936 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 6 Nov 2013 20:34:43 -0800 Subject: [PATCH] Zoom and pan a bit less with each keypress This makes it a bit smoother and less jumpy for better control. --- acre-x.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/acre-x.c b/acre-x.c index c1f7c41..e89c7fc 100644 --- a/acre-x.c +++ b/acre-x.c @@ -120,6 +120,8 @@ handle_events(Display *dpy, Window window, Visual *visual, draw (dpy, window, visual, acre, width, height, x_min, x_max); +#define PAN 0.05 +#define ZOOM PAN XNextEvent (dpy, &xev); switch (xev.type) { case KeyPress: @@ -130,26 +132,26 @@ handle_events(Display *dpy, Window window, Visual *visual, } else if (keycode == left_code) { - shift = 0.25 * (x_max - x_min); + shift = PAN * (x_max - x_min); x_min += shift; x_max += shift; } else if (keycode == right_code) { - shift = 0.25 * (x_max - x_min); + shift = PAN * (x_max - x_min); x_min -= shift; x_max -= shift; } else if (keycode == plus_code || keycode == equal_code) { - shift = 0.25 * (x_max - x_min); + shift = ZOOM * (x_max - x_min); x_min += shift; x_max -= shift; } else if (keycode == minus_code) { - shift = 0.5 * (x_max - x_min); + shift = (1- 2*ZOOM) * (x_max - x_min); x_min -= shift; x_max += shift; } -- 2.43.0