cape.color
: Color conversion tools¶
This module contains tools to convert color strings to RGB values. The
primary tool is to get a variety of colors via name (instead of just
'r'
, 'g'
, 'b'
, 'c'
, 'm'
, 'y'
, 'k'
, and
'w'
). However, there additional tools to convert a hex code to RGB
and vice-versa.
- Versions:
2017-01-05
@ddalle
: Version 1.0
- cape.color.Hex2RGB(col)¶
Convert hex-code color to RGB values
- Call:
>>> rgb = Hex2RGB(col) >>> r, g, b = Hex2RGB(col)
- Inputs:
- col:
str
Six-digit hex code including
'#'
character
- col:
- Outputs:
- rgb:
list
[int
] len: 3
Vector of RGB values
- r: 0 <=
int
<= 255 Red value
- g: 0 <=
int
<= 255 Green value
- b: 0 <=
int
<= 255 Blue value
- rgb:
- Versions:
2017-01-05
@ddalle
: Version 1.0
- cape.color.RGB2Hex(col)¶
Convert RGB integer values to a hex code
- Call:
>>> hx = RGB2Hex(col) >>> hx = RGB2Hex((r,g,b))
- Inputs:
- col:
tuple
|list
Indexable RGB specification
- r: 0 <=
int
<= 255 Red value
- g: 0 <=
int
<= 255 Green value
- b: 0 <=
int
<= 255 Blue value
- col:
- Outputs:
- hx:
str
Six-digit hex code including
'#'
character
- hx:
- Versions:
2017-01-05
@ddalle
: Version 1.0
- cape.color.ToRGB(col)¶
Convert generic value to RGB
- Call:
>>> rgb = ToRGB(col) >>> rgb = ToRGB(hx) >>> rgb = ToRGB(cname) >>> rgb = ToRGB(rgb) >>> rgb = ToRGB(RGB)
- Inputs:
- col:
str
|list
Generic color specification
- hx:
str
Six-digit hex code starting with
'#'
character- rgb:
list
[int
] Vector of RGB values
- cname:
str
Color by name, such as
"orange"
- V: 0 <=
float
<= 1 Grayscale value
- RGB:
list
[float
] Vector of fractional RGB values, 0 to 1 (inclusive)
- col:
- Outputs:
- rgb:
list
[int
] Vector of RGB values
- rgb:
- Versions:
2017-01-05
@ddalle
: Version 1.0