A student wrote the following code (comments are mine):
//set noseColor to a random color
var noseColor = rgb(randomNumber(0, 255), randomNumber(0, 255), randomNumber(0, 255));
//use noseColor for the nose
fill(rgb(noseColor, noseColor, noseColor);
ellipse(200,200,50,50);
My understanding is that when r = g = b, the color will be a shade of gray. So looking at this code, I expected the nose to be somewhere on the monochrome scale from black (0, 0, 0) to white (255, 255, 255). I was surprised to see the nose appear in different colors.
My undetstanding is the correct way to write this code would be to change the fill command to this:
fell(noseColor);
As expected, this results in a random color.
I have this demo code that shows that in fact both versions of the fill() command result in the same color (see lines 22 & 29).
Another thing that confuses me is that line 29 in the demo code does not result in a partially transparent fill color (note the alpha = 0.7). If I change all 3 ‘randomColor’ in line 29 to 50 (or any other number 0 to 255), the color is transparent.
Anyone understand what is going on?
Thanks,
John