Skip to content

colors

Colors

Tool class to work with colors.

Allows to build color maps and return color values.

__init__()

build_lookup_table(x_min, x_max, cmap='hsv', number_of_colors=256) staticmethod

Create lookup table for cmap.

Parameters:

Name Type Description Default
x_min float

lower limit of coloring data range.

required
x_max float

upper limit of coloring data range.

required
cmap str

color map name.

'hsv'
number_of_colors int

number of RGB values in lookup table.

256

Returns:

Name Type Description
vtkLookupTable vtkLookupTable

lookup table object.

build_rgb_array_from_cmap(cmap, number_of_colors=256) staticmethod

Return color map based on its name.

Parameters:

Name Type Description Default
cmap str

Color map name.

required
number_of_colors int

Number of RGB values in color map.

256

Returns:

Name Type Description
list list

list of RGB values.

get_rgb_from_cmap(val, cmap, val_min=0, val_max=1) staticmethod

Return RGB color values from color map.

Parameters:

Name Type Description Default
val float

If val_min and val_max not provided a val must be in range 0 <= val <= 1.

required
cmap str

color map name.

required
val_min float

Values less than val_min give the same color.

0
val_max float

Values more than val_max give the same color.

1

Returns:

Name Type Description
list list

list of RGB values.

get_rgb_list_from_cmap(vals, cmap, val_min=None, val_max=None) staticmethod

Return RGB color values from color map.

Parameters:

Name Type Description Default
vals list

List of values

required
cmap str

color map name.

required
val_min float

Values less than val_min give the same color.

None
val_max float

Values more than val_max give the same color.

None

Returns:

Name Type Description
list list

list of RGB values for each value.

to_rgb(color) staticmethod

Return RGB color values based on their names.

Parameters:

Name Type Description Default
color (str, list)

color name or RGB(A) values.

required

Returns:

Name Type Description
list list

list of RGB values.