Use the colorBlend
method:colorBlend(inputValue, indexArray, outputValueArray)
The returned value is interpolated between the two consecutive values in outputValueArray
(which represent RGB colors normalized to [0,1], e.g. pure red is [1,0,0]) based on the inputValue’s location in the indexArray
.
Note the indexArray
and outputValueArray
must be the same size. For example: return colorBlend(B04, [0, 0.2, 0.4, 0.6, 0.8, 1], [[0,0,0], [0.1,0.2,0.5], [0.25,0.4,0.5], [0.4,0.6,0.5], [0.75,0.8,0.5], [1,1,0.5]]); If B04 is 0.25 it will interpolate between [0.1,0.2,0.5] and [0.25,0.4,0.5] since they are the corresponding colors to the 0.2 and 0.4 indices in the indexArray nearest to B04.