Files
plan9port/man/man3/color.3
Dmitri Vereshchagin 10564b1175 tmac/tmac.an: define .MR in a groff compatible way
groff 1.23.0 added .MR to its -man macro package.  The NEWS file states
that the inclusion of the macro "was prompted by its introduction to
Plan 9 from User Space's troff in August 2020."  From d32deab it seems
that the name for Plan 9 from User Space's implementation was suggested
by groff maintainer G. Brandon Robinson.

Not sure if the intention was to make these definitions compatible, but
it would be nice if they were.

Currently, Plan 9 from User Space's .MR expects its second argument to
be parenthesized.  groff's .MR does not.  This results in extra
parentheses appearing in manual references when viewing Plan 9 from User
Space's manual pages on a system using groff.
2025-07-27 09:58:50 -04:00

57 lines
1.3 KiB
Groff

.TH COLOR 3
.SH NAME
cmap2rgb, cmap2rgba, rgb2cmap \- colors and color maps
.SH SYNOPSIS
.B #include <u.h>
.br
.B #include <libc.h>
.br
.B #include <draw.h>
.PP
.B
int rgb2cmap(int red, int green, int blue)
.PP
.B
int cmap2rgb(int col)
.PP
.B
int cmap2rgba(int col)
.SH DESCRIPTION
These routines convert between `true color' red/green/blue triples and the Plan 9 color map.
See
.MR color 7
for a description of RGBV, the standard color map.
.PP
.I 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.
.PP
.I Cmap2rgb
decomposes the color of RGBV index
.I 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.
.I Cmap2rgba
decomposes the color of RGBV index
.I 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
.I cmap2rgba
shifted up 8 bits.
This 32-bit representation is the format used by
.MR draw 3
and
.MR memdraw 3
library routines that
take colors as arguments.
.SH SOURCE
.B \*9/src/libdraw
.SH SEE ALSO
.MR graphics 3 ,
.MR allocimage 3 ,
.MR draw 3 ,
.MR image 7 ,
.MR color 7