ref: 1ee28cd5ece6c035af2ab445ec774d7e0cc054ec
parent: 77d8f3844311c9c43d25b31a91bc1a6ee69d1122
author: rodri <rgl@antares-labs.eu>
date: Tue Jun 21 17:58:35 EDT 2022
implemented new zooming functionality (adapted from games/galaxy.)
--- a/vmodeled/main.c
+++ b/vmodeled/main.c
@@ -24,7 +24,7 @@
RFrame worldrf;
VModel *model;
-int scale = 1;
+double scale = 1;
void resized(void);
@@ -182,17 +182,23 @@
}
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 @@
{
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