aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPascal Sommer <p@pascalsommer.ch>2021-02-26 22:32:37 +0100
committerHarry Jeffery <harry@exec64.co.uk>2021-04-14 15:29:38 +0100
commit8e46aa0238df85e7b9a2394066cc90c273cd5ae2 (patch)
tree770b02064c801fbe61b598ff9dbd7361d422724c /src
parent2c0f10a91b847fd97560ceb6c1ee520fa6d3e7ce (diff)
downloadimv-8e46aa0238df85e7b9a2394066cc90c273cd5ae2.tar.gz
use exponential increments for zooming
Diffstat (limited to 'src')
-rw-r--r--src/viewport.c5
1 files changed, 3 insertions, 2 deletions
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 <stdbool.h>
#include <stdlib.h>
+#include <math.h>
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;