From 77d8f3844311c9c43d25b31a91bc1a6ee69d1122 Mon Sep 17 00:00:00 2001 From: rodri Date: Mon, 20 Jun 2022 21:29:22 +0000 Subject: added zoom. --- vmodeled/main.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/vmodeled/main.c b/vmodeled/main.c index 0dc01aa..4384b02 100644 --- a/vmodeled/main.c +++ b/vmodeled/main.c @@ -24,6 +24,7 @@ struct VModel RFrame worldrf; VModel *model; +int scale = 1; void resized(void); @@ -126,17 +127,22 @@ drawvmodel(Image *dst, VModel *mdl) char *s; Point pts[3]; Point2 *p; + Matrix S = { + scale, 0, 1, + 0, scale, 1, + 0, 0, 1, + }; p = mdl->pts; for(s = mdl->strokefmt; s != 0 && p-mdl->pts < mdl->npts; s++) switch(*s){ case 'l': - line(dst, toscreen(p[0]), toscreen(p[1]), 0, 0, 0, display->white, ZP); + line(dst, toscreen(xform(p[0], S)), toscreen(xform(p[1], S)), 0, 0, 0, display->white, ZP); p += 2; break; case 'c': for(i = 0; i < nelem(pts); i++) - pts[i] = toscreen(p[i]); + pts[i] = toscreen(xform(p[i], S)); bezspline(dst, pts, nelem(pts), 0, 0, 0, display->white, ZP); p += 3; break; @@ -175,6 +181,20 @@ lmb(Mousectl *mc, Keyboardctl *) fprint(2, "%v\n", mpos); } +void +zoomin(void) +{ + scale++; + fprint(2, "scale %d\n", scale); +} + +void +zoomout(void) +{ + scale--; + fprint(2, "scale %d\n", scale); +} + void mouse(Mousectl *mc, Keyboardctl *kc) { @@ -182,6 +202,10 @@ mouse(Mousectl *mc, Keyboardctl *kc) lmb(mc, kc); if((mc->buttons&4) != 0) rmb(mc, kc); + if((mc->buttons&8) != 0) + zoomin(); + if((mc->buttons&16) != 0) + zoomout(); } void -- cgit v1.2.3