aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2022-06-21 21:58:35 +0000
committerrodri <rgl@antares-labs.eu>2022-06-21 21:58:35 +0000
commit1ee28cd5ece6c035af2ab445ec774d7e0cc054ec (patch)
tree2542cb6e6e9175cf2ae937e1cbfa7f9f00c1ba03
parent77d8f3844311c9c43d25b31a91bc1a6ee69d1122 (diff)
downloadmusw-1ee28cd5ece6c035af2ab445ec774d7e0cc054ec.tar.gz
musw-1ee28cd5ece6c035af2ab445ec774d7e0cc054ec.tar.bz2
musw-1ee28cd5ece6c035af2ab445ec774d7e0cc054ec.zip
implemented new zooming functionality (adapted from games/galaxy.)
-rw-r--r--vmodeled/main.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/vmodeled/main.c b/vmodeled/main.c
index 4384b02..254e410 100644
--- a/vmodeled/main.c
+++ b/vmodeled/main.c
@@ -24,7 +24,7 @@ struct VModel
RFrame worldrf;
VModel *model;
-int scale = 1;
+double scale = 1;
void resized(void);
@@ -182,17 +182,23 @@ lmb(Mousectl *mc, Keyboardctl *)
}
void
-zoomin(void)
+zoom(Mousectl *mc)
{
- scale++;
- fprint(2, "scale %d\n", scale);
-}
+ double oldscale, z;
+ Point oldxy, Δxy;
-void
-zoomout(void)
-{
- scale--;
- fprint(2, "scale %d\n", scale);
+ oldscale = scale;
+ oldxy = mc->xy;
+
+ for(;;){
+ readmouse(mc);
+ if(mc->buttons != 2)
+ break;
+ Δxy = subpt(mc->xy, oldxy);
+ z = tanh((double)Δxy.y/100) + 1;
+ scale = z*oldscale;
+ redraw();
+ }
}
void
@@ -200,12 +206,10 @@ mouse(Mousectl *mc, Keyboardctl *kc)
{
if((mc->buttons&1) != 0)
lmb(mc, kc);
+ if((mc->buttons&2) != 0)
+ zoom(mc);
if((mc->buttons&4) != 0)
rmb(mc, kc);
- if((mc->buttons&8) != 0)
- zoomin();
- if((mc->buttons&16) != 0)
- zoomout();
}
void