Using println to show a random color that's picked

Hi, I have set println for some different number variables and I have it working just fine. But I have a color picker set up as such;
<
int selected = (int)random(0, 20);
int choicesR[] = {51, 12, 25, 18, 33, 5, 15, 7, 8, 251, 252, 254, 255, 245, 254, 233, 100, 142, 239, 5};
int choicesG[] = {52, 13, 26, 21, 33, 5, 15, 8, 8, 252, 252, 255, 255, 245, 255, 255, 194, 255, 124, 255};
int choicesB[] = {50, 6, 20, 0, 33, 0, 15, 3, 8, 242, 250, 242, 255, 245, 245, 38, 255, 235, 255, 52};
color r2 = color(choicesR[selected], choicesG[selected], choicesB[selected]);
/>
And the println(r2) for this example gives me a big negative number output. What would be the move to get it show me the rgb value?

Also, is this the best way to have the metadata for an image?

I appreciate the help.

Color variables are really just numbers. Try printing the values of red(r2), green(r2), and blue(r2) instead.

1 Like

That’s what I needed. Thank you

Hello,

You can also print the hexadecimal representation:

color col = color(0, 128, 255);
println(hex(col));

Reference:

:)

Hi, so I was able to get the println how I was thinking.

But I maybe should have asked a different question.

Is there a way to print those values into a json file when a png is generated?

That’s possible

Maybe this is a starting point for you: Reference / Processing.org