From cd6644ea4ddc78597934ab0ef5ba50e3c3daa927 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Sat, 8 Jul 2023 23:25:41 +0200 Subject: Moved to a simpler SSG --- public/drawing-pixels-in-plan9.html | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 public/drawing-pixels-in-plan9.html (limited to 'public/drawing-pixels-in-plan9.html') diff --git a/public/drawing-pixels-in-plan9.html b/public/drawing-pixels-in-plan9.html new file mode 100755 index 0000000..6940a2a --- /dev/null +++ b/public/drawing-pixels-in-plan9.html @@ -0,0 +1,63 @@ +Drawing Pixels in Plan9

Drawing Pixels in Plan9

May 27, 2023

I have started exploring Plan9's graphics capabilities. This is a hello world +alternative for drawing that draws a yellow square on a blue background.

More information:

Plan9 Howdy World!

// main.c
+#include <u.h>
+#include <libc.h>
+#include <draw.h>
+#include <cursor.h>
+
+void
+main()
+{
+  ulong co;
+  Image *im, *bg;
+  co = 0x0000FFFF;
+
+  if (initdraw(nil, nil, argv0) < 0)
+  {
+    sysfatal("%s: %r", argv0);
+  }
+
+  im = allocimage(display, Rect(0, 0, 300, 300), RGB24, 0, DYellow);
+  bg = allocimage(display, Rect(0, 0, 1, 1), RGB24, 1, co);
+
+  if (im == nil || bg == nil)
+  {
+    sysfatal("not enough memory");
+  }
+
+  draw(screen, screen->r, bg, nil, ZP);
+  draw(screen, screen->r, im, nil, Pt(-40, -40));
+
+  flushimage(display, Refnone);
+
+  // Wait 10 seconds before exiting.
+  sleep(10000);
+
+  exits(nil);
+}
+

And then compile with mk (mkfile below):

# mkfile
+</$objtype/mkfile
+
+RC=/rc/bin
+BIN=/$objtype/bin
+MAN=/sys/man
+
+main:
+	$CC $CFLAGS main.c
+	$LD $LDFLAGS -o main main.$O
+

And run with ./main. To exit the program, press Delete key (strange but this +is the alternative for Ctrl+C).

This is very cool indeed!

\ No newline at end of file -- cgit v1.2.3