Data, Ecology, Art

Code Blog

Rainbow Colors from a single value

At times we have a wide range of data values which we want to colorize. Mapping a value range to a color is not easy because we are mapping from one parameter (the input value) to three parameters (the red, green and blue color values). What’s more, the colors are a result of how the three dimensions of the parameters interact. We can use the sine wave to map the input value to shifted sine wave outputs for each color.

screenCapture41.png

But of course, we don’t want just cycle through the rainbow, because we want the highest and the lowest values to map to different colors. We may also want to pick the range of colors, and where we start and end.

It’s also interesting to see what happens when we decouple the three colors: We get a complex sequence of shiny color shifts. Someone could build an art career out of that simple concept.

To that effect, we need to introduce two additional parameters to our simple equation, which offset the color cycle and determine the range of the color cycle. The code linked here gives us options for all this control.