Bug with color variable type

image

size(400,200);
color clr = 255, clr2 = color(255,255,255);
noStroke();
fill(red(clr),green(clr),blue(clr));
rect(0,0,200,200);
fill(red(clr2),green(clr2),blue(clr2));
rect(200,0,200,200);

I know color is stored as a weird integer (like -1 for white). But it should at least work the same way as fill(255);

1 Like

color(255) and 255 are very different values.

In this example, I’ve fixed clr to actually be a color.

size(400,200);
color clr = color(255); // <<< NOTE THE CHANGE HERE
color clr2 = color(255,255,255);
noStroke();
fill(red(clr),green(clr),blue(clr));
rect(0,0,200,200);
fill(red(clr2),green(clr2),blue(clr2));
rect(200,0,200,200);
1 Like

I know but still : P

It’s best to just store the color as a color() variable. Also, instead of the red green blue, you don’t have to put that with processing.

1 Like