From 1100562e29f6476448b656dbddd4cf22505523f6 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Sun, 10 Mar 2024 14:59:14 +0100 Subject: Move back to JBMAFP --- _posts/notes/2023-05-27-drawing-pixels-in-plan9.md | 84 ---------------------- 1 file changed, 84 deletions(-) delete mode 100644 _posts/notes/2023-05-27-drawing-pixels-in-plan9.md (limited to '_posts/notes/2023-05-27-drawing-pixels-in-plan9.md') diff --git a/_posts/notes/2023-05-27-drawing-pixels-in-plan9.md b/_posts/notes/2023-05-27-drawing-pixels-in-plan9.md deleted file mode 100644 index 3d37a2c..0000000 --- a/_posts/notes/2023-05-27-drawing-pixels-in-plan9.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -title: "Drawing Pixels in Plan9" -permalink: /drawing-pixels-in-plan9.html -date: 2023-05-27T17:41:33+02:00 -layout: post -type: note -draft: false -tags: [plan9, graphics] ---- - -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: - -- [draw.h header file](https://github.com/0intro/plan9/blob/main/sys/include/draw.h) - contains all the drawing functions -- [draw man page](https://9fans.github.io/plan9port/man/man3/draw.html) - has a bit more digestable descriptions of the draw functions -- [graphics man page](https://9fans.github.io/plan9port/man/man3/graphics.html) - has a bit more digestable descriptions of the graphics functions -- [all man pages](https://9fans.github.io/plan9port/man/man3/) - can be a valuable resource for learning about the system - -![Plan9 Howdy World!](/assets/notes/plan9-pixels.png){:loading="lazy"} - -```c -// main.c -#include -#include -#include -#include - -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): - -```makefile -# mkfile -