colorRemapLayer = {
class ColorRemapBitmapLayer extends deck.BitmapLayer {
getShaders() {
return {
...super.getShaders(),
inject: {
'fs:#decl': `
uniform vec4 fromColor;
uniform vec4 toColor;`,
'fs:DECKGL_FILTER_COLOR': `
float grayscale = (color.r + color.g + color.b) / 3.0;
color = mix(fromColor, toColor, grayscale);`
}
}
}
draw(opts) {
const {colorRange} = this.props;
opts.uniforms.fromColor = colorRange[0].map(x => x / 255);
opts.uniforms.toColor = colorRange[1].map(x => x / 255);
super.draw(opts);
}
}
return new ColorRemapBitmapLayer({
id: `BitmapLayer with color remapping#${Math.random()}`,
pickable: true,
image: IMAGE_URL,
bounds: [440, 100, 640, -100],
colorRange: [[235, 0, 0, 255], [0, 255, 125, 255]]
});
}