ColorMap
- class compas.colors.ColorMap[source]
Bases:
object
Class providing a map for 256 distinct colors of a specific color palette.
- Parameters:
- colorssequence[tuple[float, float, float]]
A sequence of colors forming the map. The number of colors in the sequence should be 256.
- Attributes:
- colorslist[
compas.colors.Color
] The colors of the map.
- colorslist[
- Raises:
- ValueError
If the number of colors in the sequence is not 256.
See also
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, minval=0, maxval=n - 1)
Methods
Construct a color map from a single color by varying luminance.
Construct a color map from matplotlib.
Construct a color map from a named palette.
Construct a color map from the complete rgb color space.
Construct a color map from three colors.
Create a color map from two colors.