It just maps pixels (lighter: #cccc77, darker: #aaaa55). You can achieve the same (and faster) with a shader I guess; but here I just do something like:
```
for(var i=0; i<data.length; i+=4) {
data[i+0] = replaceColor[0];
data[i+1] = replaceColor[1];
data[i+2] = replaceColor[2];
}
```
(where components are red, blue and green colors and the 4th one would be alpha)