You could split your image into multiple images, with the areas that are to be coloured being their own separate images. Colour them white for the image file and then just use
setColor() to change the colour for the sprite that belongs to what is being coloured.
If you really needed to use
setPixel, you could also investigate creating bindings. Create a class with the C++ code you found and then create a binding to be able to call it from JS. Might even be more efficient than doing it in JS.