From 8e46aa0238df85e7b9a2394066cc90c273cd5ae2 Mon Sep 17 00:00:00 2001 From: Pascal Sommer Date: Fri, 26 Feb 2021 22:32:37 +0100 Subject: use exponential increments for zooming --- src/viewport.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/viewport.c b/src/viewport.c index dd289d3..e42c729 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -2,6 +2,7 @@ #include #include +#include struct imv_viewport { double scale; @@ -159,8 +160,8 @@ void imv_viewport_zoom(struct imv_viewport *view, const struct imv_image *image, const int wc_x = view->buffer.width/2; const int wc_y = view->buffer.height/2; - double delta_scale = 0.04 * view->buffer.width * amount / image_width; - view->scale += delta_scale; + const double scale_factor = exp(0.04 * view->buffer.width * amount / image_width); + view->scale *= scale_factor; const double min_scale = 0.1; const double max_scale = 100; -- cgit v1.2.3