Get() returns one number in RGB mode?

Hello everyone.

I do not understand why get does not return R, G, B values instead of 1 single signed number. I am trying to get the background color and then create a rect() with the same color (fill(R,G,B)) as the background. My code is:

int backgroundColor;
void setup()
{
  orientation(LANDSCAPE); 
  size(displayWidth, displayHeight);
  background(random(0,255),random(0,255),random(0,255));
  backgroundColor=get((int)displayWidth/2, (int)displayHeight/2);
}
void draw()
{
  println(backgroundColor);
  fill(backgroundColor);
  rect(displayWidth/2,)displayHeight/2, displayWidth*0.6, )displayHeight*0.6)
}

Could you please help to get the RGB values correctly??

1 Like

The documentation may seem a bit obscure https://www.processing.org/reference/color_datatype.html color is not a datatype at all, the processing pre-processor converts color to a signed int. There are convenience methods red(value), green(value), blue(value), that extract those values from the signed int.

1 Like

could you set your color values to variable and use the same variables on your RECT as your BACKGROUND?