There is a color selection service for interior and exterior. It selects an image and you can repaint part of the image in the selected color (see how the color will look).
I am engaged in the creation of similar functionality. Initially I wanted to enclose SVG under the texture, but without the blend mode it doesn’t look very much.
There are several canvas layers on the service:
- layer with the main image, it is slightly lightened - with transparency
- layer with the mask of the object, initially the mask is black
Dug in obfustsirovannogo code and get about the following algorithm.
- User chooses color to repaint object
- Make a list of opaque pixels (based on the mask)
- Cycle through each pixel of the main image and blend the selected color for recoloring to the pixel color of the main image.
- Save the value from the previous item to canvas with mask
The algorithm is simple, but maybe I forgot some function or missed a simpler implementation.