createCanvas(windowWidth, windowHeight);
function mouseClicked() {
for(let i=0; i < n; i++) {
base = RGB2HSV(lastColor);
base.hue = HueShift(base.hue,180);
base.value = random(70,100);
base.saturation = random(50,100);
base = {r: random(255), g: random(255), b: random(255)};
base.saturation = constrain(base.saturation, 50, 100);
base.saturation = random(50,100);
base.value = random(70,100);
nb.saturation -= settings.tintDrop;
nb.saturation = constrain(nb.saturation, 50, 100);
nb.value = random(60,100);
nc.hue = HueShift(nc.hue,180);
nc.saturation = random(50,100);
nc.value = random(70,100);
nct.saturation -= settings.tintDrop;
nct.saturation = constrain(nct.saturation, 50, 100);
nct.value = random(70,100);
rect(width/2, height/2, 400, 400);
let w = 390 / colors.length;
translate(width/2-195,height/2-195);
for(let i = 0; i < colors.length ; i++) {
fill(color(colors[i].r, colors[i].g, colors[i].b));
max=max3(rgb.r,rgb.g,rgb.b);
dif=max-min3(rgb.r,rgb.g,rgb.b);
hsv.saturation=(max==0.0)?0:(100*dif/max);
if (hsv.saturation==0) hsv.hue=0;
else if (rgb.r==max) hsv.hue=60.0*(rgb.g-rgb.b)/dif;
else if (rgb.g==max) hsv.hue=120.0+60.0*(rgb.b-rgb.r)/dif;
else if (rgb.b==max) hsv.hue=240.0+60.0*(rgb.r-rgb.g)/dif;
if (hsv.hue<0.0) hsv.hue+=360.0;
hsv.value=Math.round(max*100/255);
hsv.hue=Math.round(hsv.hue);
hsv.saturation=Math.round(hsv.saturation);
rgb.r=rgb.g=rgb.b=Math.round(hsv.value*2.55);
p=hsv.value*(1-hsv.saturation);
q=hsv.value*(1-hsv.saturation*f);
t=hsv.value*(1-hsv.saturation*(1-f));
case 0: rgb.r=hsv.value; rgb.g=t; rgb.b=p; break;
case 1: rgb.r=q; rgb.g=hsv.value; rgb.b=p; break;
case 2: rgb.r=p; rgb.g=hsv.value; rgb.b=t; break;
case 3: rgb.r=p; rgb.g=q; rgb.b=hsv.value; break;
case 4: rgb.r=t; rgb.g=p; rgb.b=hsv.value; break;
default: rgb.r=hsv.value; rgb.g=p; rgb.b=q;
rgb.r=Math.round(rgb.r*255);
rgb.g=Math.round(rgb.g*255);
rgb.b=Math.round(rgb.b*255);
h+=s; while (h>=360.0) h-=360.0; while (h<0.0) h+=360.0; return h;
return (a<b)?((a<c)?a:c):((b<c)?b:c);
return (a>b)?((a>c)?a:c):((b>c)?b:c);