In the above gif, the colors of the sprite are changed. This is easy to do if one maps the colors from the original palette to the desired palette and then iterates over each pixel of the original image and changes the color accordingly. For example, one can define a map like this:
My question is, how can one define the new palette programmatically ? For example, if the original palette is Green, and I want to create a new palette in Red, then rather than having to create a mapping of each color in the green palette to the equivalent red color in the new palette, is there a way to automatically generate the entire red palette mapping by specifying just ONE color, and computing the others based on the hue,saturation or luminance or something (I don't know the right technical terms)? I imagine there is some relationship between the colors on the source palette, so if one defines one of the colors in the destination palette, then using the same relationship one can generate the entire palette from a single color.
Don't know enough about colors to know the right terms to define my problem, but I am sure that the calculations would be simple enough. Is my idea correct ? Solution can be in any programming language. I don't mind.