diff options
| author | Cliff Click <cliffc@acm.org> | 2026-11-11 15:40:22 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-11-12 13:48:30 -0800 |
| commit | 0720fd8ed0aa92248622a9f3c3ebd522b002fd91 (patch) | |
| tree | 3ba939eb4e786373cedc54e1afe0bbdbfd16dc01 /chapter31/src/main/smp/sys/draw.smp | |
| parent | 18c04fd4aab0ad0bf3b3eece9551cc7aa7b9f796 (diff) | |
| download | Simple-0720fd8ed0aa92248622a9f3c3ebd522b002fd91.tar.gz Simple-0720fd8ed0aa92248622a9f3c3ebd522b002fd91.zip | |
graphic tictactoe
Hex & octal digits
Diffstat (limited to 'chapter31/src/main/smp/sys/draw.smp')
| -rw-r--r-- | chapter31/src/main/smp/sys/draw.smp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/chapter31/src/main/smp/sys/draw.smp b/chapter31/src/main/smp/sys/draw.smp new file mode 100644 index 00000000..0721659a --- /dev/null +++ b/chapter31/src/main/smp/sys/draw.smp @@ -0,0 +1,17 @@ +// Software raster drawing. No window or native calls; pixels are packed RGB (0x00RRGGBB). +u32 BLACK = 0x000000; +u32 WHITE = 0xffffff; +u32 RED = 0xe05252; +u32 GREEN = 0x48b88c; +u32 BLUE = 0x558ee6; + +// Components are clamped to bytes rather than wrapping. +val rgb = { int r, int g, int b -> + r = r<0 ? 0 : r>255 ? 255 : r; + g = g<0 ? 0 : g>255 ? 255 : g; + b = b<0 ? 0 : b>255 ? 255 : b; + u32 color = (r<<16) | (g<<8) | b; + return color; +}; + +val Canvas = Canvas; // Pixel canvas and drawing methods |
