getPiecewiseValue

fun getPiecewiseValue(sourceColorHct: Hct, hueBreakpoints: DoubleArray, hues: DoubleArray): Double

Returns a new hue based on a piecewise function and input color hue.

For example, for the following function:

result = 26, if 0 <= hue < 101;
result = 39, if 101 <= hue < 210;
result = 28, if 210 <= hue < 360.

Call the function as:

val hueBreakpoints = listOf(0, 101, 210, 360)
val hues = listOf(26, 39, 28)
val result = scheme.piecewise(sourceColor, hueBreakpoints, hues)

Parameters

sourceColorHct

The input value.

hueBreakpoints

The breakpoints, in sorted order. No default lower or upper bounds are assumed.

hues

The hues that should be applied when source color's hue is >= the same index in hueBreakpoints array, and < the hue at the next index in hueBreakpoints array. Otherwise, the source color's hue is returned.