COLOR(3)

πŸ“¦
version 0_git20260208 Β· 2 versions
, in alpine 3.24, arch rolling, nixos 26.05, nixpkgs unstable

πŸ’– 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. πŸ’–