about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorelioat <hi@eli.li>2024-01-20 18:21:43 -0500
committerelioat <hi@eli.li>2024-01-20 18:21:43 -0500
commitd3d0f83c3422fcc51e83e8b1e3cbfed1f210140e (patch)
tree34cace8f845d195d1ce147455809609d716bfb48
parent46fa8433752940a4e6d918323575590207063f4e (diff)
downloadtour-d3d0f83c3422fcc51e83e8b1e3cbfed1f210140e.tar.gz
*
-rw-r--r--p9c/draw/draw.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/p9c/draw/draw.c b/p9c/draw/draw.c
new file mode 100644
index 0000000..696ce30
--- /dev/null
+++ b/p9c/draw/draw.c
@@ -0,0 +1,36 @@
+#include <u.h>
+#include <libc.h>
+#include <draw.h>
+#include <event.h>
+
+void
+eresized(int new)
+{
+	if(new&& getwindow(display, Refnone) < 0)
+		sysfatal("can't reattach to window");
+}
+
+void
+main(int argc, char* argv[])
+{
+	Mouse m;
+	Point prevm;
+	initdraw(0, 0, "Example: Mouse");
+	eresized(0);
+	einit(Emouse);
+
+	/* Main loop */
+	for(;;) {
+		m = emouse();
+		if(m.buttons & 4)
+			break;
+		if(m.buttons & 1) {
+			line(screen,
+			     prevm.x == -1 ? m.xy : prevm,
+			     m.xy, Enddisc, Enddisc, 1, display->black, ZP);
+			prevm = m.xy;
+		} else {
+			prevm = Pt(-1, -1);
+		}
+	}
+}
\ No newline at end of file