aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dat.h5
-rw-r--r--hud.c12
-rw-r--r--main.c25
-rw-r--r--mkfile1
-rw-r--r--puppeteer.pngbin0 -> 7441 bytes
-rw-r--r--readme.md4
6 files changed, 46 insertions, 1 deletions
diff --git a/dat.h b/dat.h
index 8e42349..352a394 100644
--- a/dat.h
+++ b/dat.h
@@ -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;
};
diff --git a/hud.c b/hud.c
new file mode 100644
index 0000000..b1084c7
--- /dev/null
+++ b/hud.c
@@ -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;
+}
diff --git a/main.c b/main.c
index 3d5d8b5..902ac8f 100644
--- a/main.c
+++ b/main.c
@@ -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;
diff --git a/mkfile b/mkfile
index 5fa680c..4072486 100644
--- a/mkfile
+++ b/mkfile
@@ -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
new file mode 100644
index 0000000..247c135
--- /dev/null
+++ b/puppeteer.png
Binary files differ
diff --git a/readme.md b/readme.md
index 7f51b4a..0383015 100644
--- a/readme.md
+++ b/readme.md
@@ -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.