pyrocko.color¶
Color utilities and built-in color palettes for a consistent look.
Color formats¶
|
Integer values for red, green blue, alpha, in the range Color('RGBA(255, 255, 255, 255)') # from string
Color('RGB(255, 255, 255)')
Color(255, 255, 255, 255) # from values
Color(255, 255, 255)
|
|
Floating point values in the range Color('rgba(1, 1, 1, 1)') # from string
Color('rgb(1, 1, 1)')
Color(1.0, 1.0, 1.0, 1.0) # from values
Color(1.0, 1.0, 1.0)
|
|
Hexadecimal value with 3, 4, 6 or 8 digits.: Color('#fff')
Color('#ffff')
Color('#ffffff')
Color('#ffffffff')
|
|
See Color('white')
Color('butter1')
Color('skyblue2')
|
Functions
|
Translate color string into rgba tuple. |
|
Simplifiy a hex color code if possible |
|
Convert integer to floating point color component |
|
Convert floating point to integer color component |
Classes
|
Color with red, green, blue and alpha values. |
|
Group of predefined colors. |
|
Undocumented. |
Exceptions
Raised for invalid color specifications and conversions. |
|
Raised for invalid color string definitions. |
- exception ColorError[source]¶
Bases:
ValueError
Raised for invalid color specifications and conversions.
- exception InvalidColorString(s)[source]¶
Bases:
ColorError
Raised for invalid color string definitions.
- parse_color(s)[source]¶
Translate color string into rgba tuple.
- Parameters:
s (str) – Color definition.
- Returns:
Color value in
rgba
form.- Return type:
- to_int_255(f)[source]¶
Convert floating point to integer color component
Convert a floating point color component (range [0.0, 1.0]) to an integer color component (range [0, 255])
- to_float_1(i)[source]¶
Convert integer to floating point color component
Convert an integer color component (range [0, 255]) to a floating point color component (range [0.0, 1.0])
- simplify_hex(s)[source]¶
Simplifiy a hex color code if possible
- E.g.:
#ffffffff -> #fff
#11aabbff -> #1ab
- class Color(*args, **kwargs)[source]¶
Bases:
SObject
Color with red, green, blue and alpha values.
The color can be specified as a color string or by giving the component values in
int
orfloat
format.Examples:
Color('black') Color('RGBA(255, 255, 255, 255)') Color('RGB(255, 255, 255)') Color('rgba(1.0, 1.0, 1.0, 1.0')') Color('rgb(1.0, 1.0, 1.0')') Color(255, 255, 255, 255) Color(255, 255, 255) Color(1.0, 1.0, 1.0, 1.0) Color(1.0, 1.0, 1.0) Color(r=1.0, g=1.0, b=1.0, a=1.0)
The internal representation is
rgba
.- ♦ name¶
str
, optional
- property rgb¶
Red, green and blue floating point color components.
- property rgba¶
Red, green, blue and alpha floating point color components.
- property RGB¶
Red, green and blue integer color components.
- property RGBA¶
Red, green, blue and alpha integer color components.
- property str_hex¶
Hex color string.
- property str_rgb¶
Red, green and blue floating point color components as string.
Output will be like
'rgb(<red>, <green>, <blue>)'.
- property str_RGB¶
Red, green and blue integer color components as string.
Output will be like
'RGB(<red>, <green>, <blue>)'
- property str_rgba¶
Red, green, blue and alpha floating point color components as string.
Output will be like
'rgba(<red>, <green>, <blue>, <alpha>)'
.
- property str_RGBA¶
Red, green, blue and alpha integer color components as string’
Output will be like
'RGBA(<red>, <green>, <blue>, <alpha>)'
.