ColorMap

class compas.colors.ColorMap(colors)[source]

Bases: object

Class providing a map for colors of a specific color palette.

Parameters

colors (sequence[tuple[float, float, float]]) – A sequence of colors forming the map.

Attributes

colors (list[compas.colors.Color]) – The colors of the map.

Examples

>>> import random
>>> cmap = ColorMap.from_palette('bamako')
>>> for i in range(100):
...     color = cmap(random.random())
...
>>> cmap = ColorMap.from_mpl('viridis')
>>> n = 100
>>> for i in range(n):
...     color = cmap(i, 0, n - 1)
...
>>> cmap = ColorMap.from_color(Color.red(), rangetype='light')
>>> cmap.plot()    

Methods

from_color

Construct a color map from a single color by varying luminance.

from_mpl

Construct a color map from matplotlib.

from_palette

Construct a color map from a named palette.

from_rgb

Construct a color map from the complete rgb color space.

from_three_colors

Construct a color map from three colors.

from_two_colors

Create a color map from two colors.

plot

Visualize the current map with the plotter.