Hi all,
I wrote this code for my students to demonstrate the HSB color mode, unfortunately the output is buggy. (It will occasionally take a few runs before the bug appears, so give it a few chances to fail!) If colorMode(HSB, 360) is called in setup, sometimes it will not stick, and the sketch runs in the default colorspace. It runs properly only if the colorMode is set inside draw().
[Mac OS X 10.5.2, 0153 Beta]
Code:
color frontColor, backColor;
int hueValue, compHueValue;
void setup() {
size(500, 500);
colorMode(HSB, 360);
frameRate(15);
hueValue = 0;
compHueValue = hueValue + 180;
smooth();
}
void draw() {
frontColor = color(hueValue, 359, 359);
backColor = color (compHueValue, 359, 359);
background(backColor);
fill(frontColor);
noStroke();
ellipse(width/2, height/2, 500, 500);
hueValue+=1;
if (hueValue == 360)
hueValue = 0;
compHueValue = hueValue + 180;
if (compHueValue >= 360)
compHueValue -= 360;
}