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('whale')
Color('ape-dark')
Color('gray-3')
|
Module Attributes
Pyrocko palette as integer |
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:
ValueErrorRaised for invalid color specifications and conversions.
- exception InvalidColorString(s)[source]¶
Bases:
ColorErrorRaised for invalid color string definitions.
- g_pyrocko_colors_RGB = {'ape': (189, 24, 45), 'ape-dark': (123, 0, 18), 'ape-light': (226, 126, 121), 'chipmunk': (174, 105, 70), 'chipmunk-dark': (129, 69, 37), 'chipmunk-light': (211, 156, 128), 'frog': (134, 154, 55), 'frog-dark': (81, 98, 0), 'frog-light': (192, 207, 150), 'gray-1': (228, 228, 228), 'gray-2': (192, 192, 192), 'gray-3': (157, 157, 157), 'gray-4': (123, 123, 123), 'gray-5': (91, 91, 91), 'gray-6': (61, 61, 61), 'hog': (189, 108, 183), 'hog-dark': (143, 74, 141), 'hog-light': (217, 172, 214), 'lion': (220, 160, 72), 'lion-dark': (171, 115, 36), 'lion-light': (242, 220, 191), 'peacock': (70, 180, 176), 'peacock-dark': (0, 109, 112), 'peacock-light': (184, 224, 229), 'turtle': (0, 151, 112), 'turtle-dark': (0, 106, 77), 'turtle-light': (125, 196, 181), 'whale': (54, 107, 161), 'whale-dark': (28, 69, 121), 'whale-light': (149, 194, 240)}¶
Pyrocko palette as integer
(R, G, B)tuples, likeg_tango_colors.
- parse_color(s)[source]¶
Translate color string into rgba tuple.
- Parameters:
s (str) – Color definition.
- Returns:
Color value in
rgbaform.- 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:
SObjectColor with red, green, blue and alpha values.
The color can be specified as a color string or by giving the component values in
intorfloatformat.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.- 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>)'.