Object changing colour over time

Hi! I would break the task to two phases. First try to make the color change from gray to white (in grayscale). This would be easier than changing the speed and direction. You would need a variable for the grayscale color (int or float) and increment it if mousePressed == false.

Then if that is done, map the value to green-yellow-… For this second task, you can either hardcode RGB values or make it generic by lerping (reference: Linear color lerp with three colors)