vispy.color.color_array.
Color
Bases: vispy.color.color_array.ColorArray
vispy.color.color_array.ColorArray
A single color
If str, can be any of the names in vispy.color.get_color_names. Can also be a hex value if it starts with '#' as '#ff0000'. If array-like, it must be an 1-dimensional array with 3 or 4 elements.
vispy.color.get_color_names
'#'
'#ff0000'
If no alpha is not supplied in color entry and alpha is None, then this will default to 1.0 (opaque). If float, it will override the alpha value in color, if provided.
color
alpha
If True, clip the color values.
RGB
Nx3 array of RGBA uint8s
RGBA
Nx4 array of RGBA uint8s
Length-N array of alpha floats
hex
Numpy array with N elements, each one a hex triplet string
hsv
Nx3 array of HSV floats
is_blank
Boolean indicating whether the color is invisible.
lab
rgb
Nx3 array of RGB floats
rgba
Nx4 array of RGBA floats
value
Length-N array of color HSV values
ColorArray
Bases: object
object
An array of colors
If str, can be any of the names in vispy.color.get_color_names. Can also be a hex value if it starts with '#' as '#ff0000'. If array-like, it must be an Nx3 or Nx4 array-like object. Can also be a list of colors, such as ['red', '#00ff00', ColorArray('blue')].
['red', '#00ff00', ColorArray('blue')]
If no alpha is not supplied in color entry and alpha is None, then this will default to 1.0 (opaque). If float, it will override any alpha values in color, if provided.
Clip the color value.
‘rgb’ (default) : color tuples are interpreted as (r, g, b) components. ‘hsv’ : color tuples are interpreted as (h, s, v) components.
Notes
Under the hood, this class stores data in RGBA format suitable for use on the GPU.
Examples
There are many ways to define colors. Here are some basic cases:
>>> from vispy.color import ColorArray >>> r = ColorArray('red') # using string name >>> r <ColorArray: 1 color ((1.0, 0.0, 0.0, 1.0))> >>> g = ColorArray((0, 1, 0, 1)) # RGBA tuple >>> b = ColorArray('#0000ff') # hex color >>> w = ColorArray() # defaults to black >>> w.rgb = r.rgb + g.rgb + b.rgb >>>hsv_color = ColorArray(color_space="hsv", color=(0, 0, 0.5)) >>>hsv_color <ColorArray: 1 color ((0.5, 0.5, 0.5, 1.0))> >>> w == ColorArray('white') True >>> w.alpha = 0 >>> w <ColorArray: 1 color ((1.0, 1.0, 1.0, 0.0))> >>> rgb = ColorArray(['r', (0, 1, 0), '#0000FFFF']) >>> rgb <ColorArray: 3 colors ((1.0, 0.0, 0.0, 1.0) ... (1.0, 0.0, 0.0, 1.0))> >>> rgb == ColorArray(['red', '#00ff00', ColorArray('blue')]) True
copy
Return a copy
darker
Produce a darker color (if possible)
Amount to decrease the color value by.
If False, operation will be carried out in-place.
The darkened Color.
extend
Extend a ColorArray with new colors
The new colors.
lighter
Produce a lighter color (if possible)
Amount to increase the color value by.
The lightened Color.