From 23a56bd50b04211da3cab45f72c3390711b2416b Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Wed, 12 Jul 2023 18:35:08 +0200 Subject: Moved notes and posts into subfolders --- content/drawing-pixels-in-plan9.md | 83 -------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 content/drawing-pixels-in-plan9.md (limited to 'content/drawing-pixels-in-plan9.md') diff --git a/content/drawing-pixels-in-plan9.md b/content/drawing-pixels-in-plan9.md deleted file mode 100644 index 473ccaf..0000000 --- a/content/drawing-pixels-in-plan9.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -title: "Drawing Pixels in Plan9" -url: drawing-pixels-in-plan9.html -date: 2023-05-27T17:41:33+02:00 -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!](/notes/plan9-pixels.png) - -```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 -