ref: 77d8f3844311c9c43d25b31a91bc1a6ee69d1122
parent: c6cf604ae9113b5384c253f46bbdd34b0db0bbb5
author: rodri <rgl@antares-labs.eu>
date: Mon Jun 20 17:29:22 EDT 2022
added zoom.
--- a/vmodeled/main.c
+++ b/vmodeled/main.c
@@ -24,6 +24,7 @@
RFrame worldrf;
VModel *model;
+int scale = 1;
void resized(void);
@@ -126,17 +127,22 @@
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;
@@ -176,6 +182,20 @@
}
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)
{
if((mc->buttons&1) != 0)
@@ -182,6 +202,10 @@
lmb(mc, kc);
if((mc->buttons&4) != 0)
rmb(mc, kc);
+ if((mc->buttons&8) != 0)
+ zoomin();
+ if((mc->buttons&16) != 0)
+ zoomout();
}
void