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:
{ "linear": Stops[] }: Linearly interpolates between stop values less than or equal and greater than the input value
{"linear": [ [8,10], [14,15], [20,21] ]}// If zoom level is less than 8, 10 is returned// If zoom level is greater or equal than 8 but less than 14, a value linearly interpolated// between 10 and 15 is returned// If zoom level is greater or equal than 14 but less than 20, a value linearly interpolated // between 15 and 21 is returned// If zoom level is greater or equal than 20, 21 is returned
The following image shows the behaviour of this definitions
{ "linear": [8,10] }// If minZoom is defined as 3 and maxZoom is defined as 20:// If zoom level is less than 3, 8 is returned// If zoom level is between 3 and 20, a value linearly interpolated between 8 and 10 is// returned// If zoom level is greater or equal than 20, 10 is returned
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)
{"exp": [0.25, [ [0,25], [10,100] ] ]}// If zoom level is less than 0, 25 is returned// If zoom level z is between 0 and 10, an interpolation factor is computed between 0 and 10// and then it's used to interpolate between 25 and 100// If zoom level is equal or higher than 10, 100 will be returned
The following images shows the behaviour of this definition