How To Create A Color Template?


I am new to color manipulation and thought i would experiment with Cinder’s surface manipulation by trying to create a template from a texture. I have attached the texture i am trying to use. By template i mean that i would like to be able to use this texture to make identical textures but in different colors. For example a yellow version that has dark yellow where there is dark blue and so on.

As you can see the texture i am using has blue, dark blue, transparent white and transparent blue patches.

My first idea was to iterate through each pixel, record its color and its (color’s) relative distance from its neighbouring pixel’s color. If that makes sense.

Another way is to group pixels by their base color (blue and white in this case but how to write code in Cinder that detects base color?), calculate each pixels (color) relative distance from this base color.

By “relative distance” i mean the RGB difference between one color and another.

But i am thinking that this kind of thing has already been solved or thought of before?


I would recommend to simply change the HUE of the color. So, iterate over the pixels to obtain the base color, then:

// Convert to HSV.
auto hsv = rgbToHsv( color );

// Obtain hue.
auto &hue = hsv[0];

// Shift the hue a bit, while making sure it stays valid.
hue = glm::fract( hue + 0.5f );

// Convert back to RGB.
color = hsvToRgb( hsv );

Don’t forget to write the result back into the surface.


1 Like

Was side tracked by another project but working on this now. Thanks for advice. I will try that out.