COLOR(3)
π COLOR(3) β colors and color maps π
okay so this is COLOR(3) from the Library Functions Manual, and it's literally your little group chat for translating between true color red/green/blue triples and the Plan 9 color map. bestie, we're talking RGBV β see color(7) for the standard color map lore. slay.
π NAME π
cmap2rgb, cmap2rgba, rgb2cmap β colors and color maps. periodt.
β¨ SYNOPSIS β¨
#include <u.h>
#include <libc.h>
#include <draw.h>
int rgb2cmap(int red, int green, int blue)
int cmap2rgb(int col)
int cmap2rgba(int col)
π¦ DESCRIPTION π¦
These routines convert between true color red/green/blue triples and the Plan 9 color map. See color(7) for a description of RGBV, the standard color map. iconic reference behavior, no cap.
rgb2cmap takes a trio of color values, scaled from 0 (no intensity) to 255 (full intensity), and returns the index of the color in RGBV closest to that represented by those values. highkey useful.
cmap2rgb decomposes the color of RGBV index col and returns a 24-bit integer with the low 8 bits representing the blue value, the next 8 representing green, and the next 8 representing red. the bit layout is giving organized, honestly.
cmap2rgba decomposes the color of RGBV index col and returns a 32-bit integer with the low 8 bits representing an alpha value, defined to be 255, and the next 8 representing blue, then green, then red, as for cmap2rgba shifted up 8 bits. This 32-bit representation is the format used by draw(3) and memdraw(3) library routines that take colors as arguments. π
π SOURCE π
/src/libdraw
that's where the source lives, bestie β it's literally right there.
π SEE ALSO π
graphics(3), allocimage(3), draw(3), image(7), color(7) β go read these too, iykyk. π«Ά
π that's the whole vibe β COLOR(3) from the Library Functions Manual, source at /src/libdraw; the footer had no extra version/date info, so we're keeping it 100. π
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms