diff options
-rw-r--r-- | dat.h | 27 | ||||
-rw-r--r-- | fns.h | 1 | ||||
-rw-r--r-- | main.c | 23 | ||||
-rw-r--r-- | utils.c | 6 |
4 files changed, 47 insertions, 10 deletions
@@ -1,5 +1,18 @@ +/* palette colors */ +enum { + PCBlack, + PCWhite, + NCOLOR +}; + +enum { + MAXZOOM = 8 +}; + typedef struct Layer Layer; typedef struct Canvas Canvas; +typedef struct HUD HUD; +typedef struct HUDWidget HUDWidget; struct Layer { @@ -17,3 +30,17 @@ struct Canvas Layer layers; Layer *curlayer; }; + +struct HUD +{ + Point2 p; + HUDWidget *widgets; +}; + +struct HUDWidget +{ + Point2 p; + char *fmt; + va_arg va; + HUDWidget *next; +}; @@ -14,5 +14,6 @@ Layer *newlayer(char*, Rectangle, ulong); void rmlayer(Layer*); /* utils */ +int clamp(int, int, int); double fclamp(double, double, double); int alphachan(ulong); @@ -8,18 +8,12 @@ #include "dat.h" #include "fns.h" -/* palette colors */ -enum { - PCBlack, - PCWhite, - NCOLOR -}; - RFrame worldrf; -Image *pal[NCOLOR]; Image *background; Canvas *curcanvas; Image *brushcolor; +Image *pal[NCOLOR]; +int zoom = 1; void resized(void); @@ -252,8 +246,7 @@ lmb(Mousectl *mc, Keyboardctl *) p = Pt(mpos.x,mpos.y); if(eqpt(p, oldp)) continue; - //draw(curcanvas->curlayer->image, rectaddpt(r, p), brushcolor, nil, ZP); - line(curcanvas->curlayer->image, oldp, p, Enddisc, Enddisc, 0, brushcolor, ZP); + line(curcanvas->curlayer->image, oldp, p, Endsquare, Endsquare, 0, brushcolor, ZP); redraw(); } } @@ -267,6 +260,10 @@ mouse(Mousectl *mc, Keyboardctl *kc) mmb(mc, kc); if((mc->buttons&4) != 0) rmb(mc, kc); + if((mc->buttons&8) != 0) + zoom = clamp(++zoom, 0, MAXZOOM); + if((mc->buttons&16) != 0) + zoom = clamp(--zoom, 0, MAXZOOM); } void @@ -276,6 +273,12 @@ key(Rune r) case Kdel: case 'q': threadexitsall(nil); + case '+': + zoom = clamp(++zoom, 0, MAXZOOM); + break; + case '-': + zoom = clamp(--zoom, 0, MAXZOOM); + break; } } @@ -2,6 +2,12 @@ #include <libc.h> #include <draw.h> +int +clamp(int n, int min, int max) +{ + return n < min? min: n > max? max: n; +} + double fclamp(double n, double min, double max) { |