aboutsummaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/notes/drawing-pixels-in-plan9.md66
-rw-r--r--content/notes/plan9-screenshot.md4
2 files changed, 70 insertions, 0 deletions
diff --git a/content/notes/drawing-pixels-in-plan9.md b/content/notes/drawing-pixels-in-plan9.md
new file mode 100644
index 0000000..e5f5af4
--- /dev/null
+++ b/content/notes/drawing-pixels-in-plan9.md
@@ -0,0 +1,66 @@
1---
2title: "Drawing Pixels in Plan9"
3url: drawing-pixels-in-plan9.html
4date: 2023-05-27T17:41:33+02:00
5type: notes
6draft: true
7tags: [plan9, graphics]
8---
9
10I have started exploring Plan9's graphics capabilities. This is a hello world
11alternative for drawing that draws a yellow square on a blue background.
12
13![Plan9 Howdy World!](/notes/plan9-pixels.png)
14
15```c
16#include <u.h>
17#include <libc.h>
18#include <draw.h>
19#include <cursor.h>
20
21void main(int argc, char *argv[])
22{
23 ulong co;
24 Image *im, *bg;
25 co = 0xFF0000FF;
26
27 if (initdraw(nil, nil, argv0) < 0)
28 {
29 sysfatal("%s: %r", argv0);
30 }
31
32 im = allocimage(display, Rect(0, 0, 100, 100), RGB24, 0, DYellow);
33 bg = allocimage(display, Rect(0, 0, 1, 1), RGB24, 1, co);
34
35 if (im1 == nil || bg == nil)
36 {
37 sysfatal("get more memory, bub");
38 }
39
40 draw(screen, screen->r, bg, nil, ZP);
41 draw(screen, screen->r, im, nil, Pt(-40, -40));
42
43 flushimage(display, Refnone);
44
45 // Wait 10 seconds before exiting.
46 sleep(10000);
47
48 exits(nil);
49}
50```
51
52And then compile with Makefile:
53
54```makefile
55</$objtype/mkfile
56
57RC=/rc/bin
58BIN=/$objtype/bin
59MAN=/sys/man
60
61main:
62 $CC $CFLAGS main.c
63 $LD $LDFLAGS -o main main.$O
64```
65
66*This is **very cool** indeed!*
diff --git a/content/notes/plan9-screenshot.md b/content/notes/plan9-screenshot.md
index ad11358..71e5808 100644
--- a/content/notes/plan9-screenshot.md
+++ b/content/notes/plan9-screenshot.md
@@ -13,6 +13,10 @@ output it to `/dev/screen`. You can then use `topng` to convert it to a png
13image. 13image.
14 14
15```sh 15```sh
16# Instant screenshot.
16cat /dev/screen | topng > screen.png 17cat /dev/screen | topng > screen.png
18
19# Delayed screenshot (5 seconds).
20sleep 5; cat /dev/screen | topng > screen.png
17``` 21```
18 22