This is some proof of concept code for a function to allow players to customise their sprites. This one is based on 8px sprites, but the original ones I was thinking of were 16px.
There is a central sprite tilesheet, and the individual customisable colours are in easily-referrably primary colours on that. Each sprite also has a shadow map, which is the same size and contains black pixels at a certain alpha value.
The code, which activates when you type in any of the input boxes, takes the appropriate colour values from the boxes then runs through each pixel, swapping the colours as appropriate, drawing a larger rectangle on the canvas then applying the same pixel from the shadow map to draw a box with an alpha value over the top. It could quite easily create a new 8px sprite instead, but it would be a little small to see.