# Object changing colour over time

**URL:** <https://discourse.processing.org/t/object-changing-colour-over-time/29377>\
**Category:** Coding Questions\
**Created:** [April 15, 2021, 1:16pm UTC](https://discourse.processing.org/t/object-changing-colour-over-time/29377 "2021-04-15T13:16:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 15, 2021, 1:56pm UTC](https://discourse.processing.org/t/object-changing-colour-over-time/29377/2 "2021-04-15T13:56:57Z")

</div>

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](https://discourse.processing.org/t/linear-color-lerp-with-three-colors/29269))

---

_[View the full topic](https://discourse.processing.org/t/object-changing-colour-over-time/29377)._
