aboutsummaryrefslogtreecommitdiff
path: root/man/man3/color.3
blob: 5428337b37ef80e92bf1306ac6c0bacb97deb8c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
.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
.IR 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 
.IR draw (3)
and
.IR memdraw (3)
library routines that
take colors as arguments.
.SH SOURCE
.B \*9/src/libdraw
.SH SEE ALSO
.IR graphics (3),
.IR allocimage (3),
.IR draw (3),
.IR image (7),
.IR color (7)