Coloring
segmentColor
Returns colors for segmentation. These are handpicked colors for good contrast and limited in number. The following are currently available. You can get the maximum from NUM_SEGMENT_COLORS.
gradientColor
A method to obtain a color gradient value for a given value in the range min (default 0) to max (default 1). The following methods are available: (Default = Turbo)
Python
These methods can also be used from python (note the different naming convention):
import hector_math.coloring as coloring
# Get a color for a segment
color = coloring.segment_color( 3 )
# Get a color for a value in a range
color = coloring.gradient_color( 0.5, 0, 1, coloring.GradientMethod.Turbo )
# Get a color for a value in a range with default min and max
color = coloring.gradient_color( 0.5, coloring.GradientMethod.Civides )
# Get a color for a value in a range with default min and max and default method
color = coloring.gradient_color( 0.5 )
API
-
inline RGB hector_math::coloring::segmentColor(int index)
Get a distinct color for a color segment. See NUM_SEGMENT_COLORS for the number of available colors.
- Parameters:
index – The index of the color segment. Must be in the range [0, NUM_SEGMENT_COLORS).
- Returns:
RGB Color of the segment.
-
inline RGB hector_math::coloring::gradientColor(float value, float min = 0, float max = 1, GradientMethod method = GradientMethod::Turbo)
Obtain a color from a color gradient using the given method.
- Parameters:
value – The value to colorize. Values outside of [min, max] are bound to the range [min, max].
min – The minimum value of the range.
max – The maximum value of the range.
method – The method to use for coloring. See GradientMethod for available methods. Default: Turbo
- Returns:
RGB The gradient color for the given value.
-
inline RGB hector_math::coloring::gradientColor(float value, GradientMethod method = GradientMethod::Turbo)
See gradientColor( float value, float min, float max, GradientMethod method ) This method uses the default range [0, 1].