How to Change Image RBG value when image hits x or y axis

Hi so I’m brand new to coding, just started maybe a week ago for a class. I’m trying to code the “dvd logo.png” image to hit a random RGB value when it hits the x and y borders of the window. So far it will load a random color when the program is started, but it stays the same until the program is closed. Is there any way to execute the random color value code each time it hits a side?

int R;

int G;

int B;

PImage img;

float xpos = 0;

float ypos = 0;

float speedx = 10;

float speedy= 15;

PImage screen;

void setup(){

   screen= loadImage("wp6985856.jpg");
   img = loadImage("dvd logo.png");
   int R = (int)random(0,255);
   int G = (int)random(0,255);
   int B = (int)random(0,255);



  void draw(){
   image(img, xpos, ypos);  
  if (((xpos+10)< 0) || (xpos>width-60))
   speedx=speedx* -1;
   if (((ypos+10)< 0) || (ypos>height-28))

   speedy = speedy * -1;

Hi and welcome to the coding world lol.

You already have the RGB as global variables so theres no need to declare them as ints in setup aswell, but what you want instead is to generate new values for them in your if statements in draw(), then add the tint() above the image in draw() aswell, setup is only called at the beginning of the program, draw is called every frame which is 60 times a second as default

Hope that makes sense

Hey, yeah that definitely makes sense, thank you!