diff options
-rw-r--r-- | dat.h | 5 | ||||
-rw-r--r-- | hud.c | 12 | ||||
-rw-r--r-- | main.c | 25 | ||||
-rw-r--r-- | mkfile | 1 | ||||
-rw-r--r-- | puppeteer.png | bin | 0 -> 7441 bytes | |||
-rw-r--r-- | readme.md | 4 |
6 files changed, 46 insertions, 1 deletions
@@ -35,12 +35,15 @@ struct HUD { Point2 p; HUDWidget *widgets; + + void (*addwidget)(HUD*, Point2, char*, ...); }; struct HUDWidget { Point2 p; char *fmt; - va_arg va; + void *args; + int nargs; HUDWidget *next; }; @@ -0,0 +1,12 @@ +#include <u.h> +#include <libc.h> +#include <draw.h> +#include <geometry.h> +#include "dat.h" +#include "fns.h" + +HUD* +newhud() +{ + return nil; +} @@ -8,6 +8,11 @@ #include "dat.h" #include "fns.h" +enum { + SMPOS, + NSTAT +}; + RFrame worldrf; Image *background; Canvas *curcanvas; @@ -15,6 +20,8 @@ Image *brushcolor; Image *pal[NCOLOR]; int zoom = 1; +char stats[NSTAT][256]; + void resized(void); Point @@ -57,6 +64,16 @@ mkcheckerboard(int w, int h) } void +drawstats(void) +{ + int i; + Point o; + + for(i = 0, o = Pt(10,10); i < nelem(stats); i++, o.y += font->height) + stringn(screen, addpt(screen->r.min, o), pal[PCWhite], ZP, font, stats[i], sizeof stats[i]); +} + +void drawlayer(Layer *l, Canvas *c) { draw(c->image, c->image->r, l->image, nil, ZP); @@ -81,6 +98,7 @@ redraw(void) draw(screen, screen->r, pal[PCBlack], nil, ZP); draw(screen, curcanvas == nil? screen->r: rectaddpt(curcanvas->image->r, toscreen(curcanvas->p)), background, nil, ZP); drawcanvas(curcanvas); + drawstats(); flushimage(display, 1); unlockdisplay(display); } @@ -154,6 +172,7 @@ rmb(Mousectl *mc, Keyboardctl *kc) chan = strtochan(s); cpos = Pt2(Dx(screen->r)/2 - w/2,Dy(screen->r)/2 - h/2,1); curcanvas = newcanvas("default", cpos, Rect(0,0,w,h), chan); + addlayer(curcanvas, "layer #1"); break; case NEWLAYER: if(curcanvas == nil) @@ -254,6 +273,11 @@ lmb(Mousectl *mc, Keyboardctl *) void mouse(Mousectl *mc, Keyboardctl *kc) { + if(curcanvas == nil) + snprint(stats[SMPOS], sizeof stats[SMPOS], "%v", fromscreen(mc->xy)); + else + snprint(stats[SMPOS], sizeof stats[SMPOS], "%v", rframexform(fromscreen(mc->xy), *curcanvas)); + if((mc->buttons&1) != 0) lmb(mc, kc); if((mc->buttons&2) != 0) @@ -296,6 +320,7 @@ threadmain(int argc, char *argv[]) Keyboardctl *kc; Rune r; + GEOMfmtinstall(); ARGBEGIN{ default: usage(); }ARGEND; @@ -4,6 +4,7 @@ BIN=/$objtype/bin TARG=puppeteer OFILES=\ utils.$O\ + hud.$O\ alloc.$O\ layer.$O\ canvas.$O\ diff --git a/puppeteer.png b/puppeteer.png Binary files differnew file mode 100644 index 0000000..247c135 --- /dev/null +++ b/puppeteer.png @@ -1,3 +1,7 @@ # Puppeteer +![A demo screenshot](puppeteer.png) + A 2D drawing and animation suite. + +It's currently a work in progress and subject to radical changes. |