Move the slider to change the relative widths of the primary (red, green, blue) vs secondary (yellow, cyan, magenta) colors. Notice that at a slider setting of 0 the secondary color regions are very narrow. At a setting of 16, they are very wide.
A fork of HSV to RGB - Conversion by Richard Bourne
xxxxxxxxxx
/*
This sketch shows how to equalize the primary and secondary color region widths of the spectrum.
it works only for colorMode(HSB) and its equivalent, colorMode(HSB, 360, 255, 255).
For a formula that smooths the color regions of colorMode(HSB) or its equivalent
colorMode(HSB, 360, 255, 255), see this sketch:
https://https://openprocessing.org/sketch/2345954
*/
let hu = 0;
OPC.slider('fvalue', 6); // this slider sets spectrum linearity correction
function setup() {
createCanvas(windowWidth, windowWidth*.75);
colorMode(HSB, 255);
background(255);
}
function draw() {
for (let t=0; t<765; t+=10){
//let hu = hsv2Rgb(t/765, 1, 1)
hu = t/765*255;
let h = hu + fvalue * sin(3 * hu / 40.53); // linearity corrected for 256 degrees
fill(h, 255, 255);
rect(t*1.53, 0, 16, height);
}
}
let lapse = 0; // mouse timer
function mousePressed(){
// prevents mouse press from registering twice
if (millis() - lapse > 400){
save("img_" + month() + '-' + day() + '_' + hour() + '-' + minute() + '-' + second() + ".jpg");
lapse = millis();
}
}