Interpolators
Interpolators
Interpolators are functions that use the current zoom level to get you a value. The following interpolators are currently supported:
Step
{ "step": [output0, Stops[]] }: Computes discrete results by evaluating a piecewise-constant function defined by stops on a given input. Returns the output value of the stop with a stop input value just less than the input one. If the input value is less than the input of the first stop, output0 is returned.
Stops are defined as pairs of [zoom, value] where zoom is the minimum zoom level where value is returned and value can be number | string | boolean. Note that stops need to be defined by increasing zoom level.
{ "step": ["hsl(50,5%,72%)", [[9, "hsl(10,75%,75%)"]] }
// If zoom level is less than 9, "hsl(50,5%,72%)" will be returned
// If zoom level is equal or higher than 9, "hsl(10,75%,75%)" will be returned
The following image shows the behavior of this definition:
{ "step": [0, [[0, 0], [100, 100]]]} // Blue
{ "step": [0, [[0, 0], [50, 50], [100, 100]]]} // Red
{ "step": [0, [[0, 0], [25, 25], [50, 50], [75, 75], [100, 100]]]} // Yellow

Linear
{ "linear": Stops[] }: Linearly interpolates between stop values less than or equal and greater than the input value
The following image shows the behaviour of this definitions

{ "linear": [number, number] }: Expands to { "linear": [[minZoom, number], [maxZoom, number] }
Color linear interpolation is done in the HCL color-space
Exponential
{ "exp": [number, Stops[]] }: Exponentially interpolates between output stop values less than or equal and greater than the input value. The base parameter controls the rate at which output increases where higher values increase the output value towards the end of the range, lower values increase the output value towards the start of the range, and a base 1 interpolates linearly.
The used value is computed as follows : (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1)
The following images shows the behaviour of this definition






Cubic Bezier
{ "cubicbezier": [number, number, number, number, Stops[]] }: Interpolates using the bezier curve defined by the curve control points.
The following images shows the behaviour of this definition

Default values
Last updated
Was this helpful?