linear

Calculates an RgbColor by interpolating between from and to, given value. The interpolation is linear. If value falls outside the range from..to, the colors at the bounds will be used.

Very useful if you want the text-, or background color to correspond to the value of a cell, for instance.

For example:

df.format { temperature }.with { value ->
background(linear(value, -20 to blue, 40 to red)) and
textColor(black)
}

For more information: See format on the documentation website.

Return

An RgbColor that corresponds to the interpolation.

Parameters

value

The value to interpolate the color for.

from

The lower bound of the interpolation range and the color that will be returned when value touches this bound.

to

The upper bound of the interpolation range and the color that will be returned when value touches this bound.

See also