I have a problem and need a solution after thinking about it the whole day. I want to generate a canvas which changes his color by using a range. Sound simple.
The colors are in (HSB). There are 6 colors.
- blue (230, S,B)
- green (130, S,B)
- yellow (55, S,B)
- orange (40, S,B)
- red (0(or 360), S,B)
- violette (315, S,B)
The saturation and brightness are insignificant (can be the same all the time).
the color has to change in this range
- blue 0 - 2.9 green
- green 3 - 5.9 yellow
- yellow 6 - 8.9 orange
- orange 9 - 11.9 red
- red 12 - 14.9 violette
so if i've get some data like this
var sample Data = new Array(0.1,0.2,0.3,0.4,3.4,5.9,9.3,9.4,9.5,9.6,...);
the canvas has to change the hue between slow from blue to green and then there should be a "color-cut" because of the "big jump" from 0.4 to 3.4 (something between green and yellow).
I'm looking for the "logic" behind this problem. I have already the HTML with canvas. For canvas and colors I'm using Paper.js
hope someone understand my problem!
thanks
I don't know Paper.js, so I can't help getting the colors on the canvas, but I can help to convert the data into a color. Since your five hue ranges havn't same size we have to do a separate calculation for each.
Now
sampleColors
contains the hsb color strings that belong to the items insampleData
.If the color notation doesn't fit your needs, please post critique.