# Changing color according to the y variable

**URL:** https://discourse.processing.org/t/changing-color-according-to-the-y-variable/17315
**Category:** Coding Questions
**Created:** [January 24, 2020, 1:54pm UTC](https://discourse.processing.org/t/changing-color-according-to-the-y-variable/17315 "2020-01-24T13:54:48Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![PhilRandom](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@PhilRandom](https://discourse.processing.org/u/PhilRandom)
#### Post date: [January 24, 2020, 1:54pm UTC](https://discourse.processing.org/t/changing-color-according-to-the-y-variable/17315/1 "2020-01-24T13:54:48Z")

</div>

How should one go about changing the color according to the y variable, an ombré of sorts?  
Please and Thank You  
Best,  
Phil

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [January 24, 2020, 1:58pm UTC](https://discourse.processing.org/t/changing-color-according-to-the-y-variable/17315/2 "2020-01-24T13:58:46Z")

</div>

Hello,

[https://processing.org/](https://processing.org/) is a good place to start and has tutorials, references, examples and lists books available.

YouTube:

> **[The Coding Train](https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw)**
>
> All aboard! The Coding Train is on its way with creative coding video tutorials on subjects ranging from the basics of programming languages like JavaScript to algorithmic art, machine learning, simulation, generative poetry, and more. Choo choo!

🙂

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [January 24, 2020, 2:04pm UTC](https://discourse.processing.org/t/changing-color-according-to-the-y-variable/17315/3 "2020-01-24T14:04:37Z")

</div>

[Processing.org/reference/colorMode\_.html](http://Processing.org/reference/colorMode_.html)

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [January 24, 2020, 2:10pm UTC](https://discourse.processing.org/t/changing-color-according-to-the-y-variable/17315/4 "2020-01-24T14:10:32Z")

</div>

> [@PhilRandom](#):
>
> ombré

There is a color selector in Menu tools

---

<div class="post-metadata">

### Author: ![PhilRandom](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@PhilRandom](https://discourse.processing.org/u/PhilRandom)
#### Post date: [January 24, 2020, 2:14pm UTC](https://discourse.processing.org/t/changing-color-according-to-the-y-variable/17315/5 "2020-01-24T14:14:28Z")

</div>

Thank you all for your quick responses, much appreciated.  
Our new question is as follows:  
How does one alternate colors in a pattern vís-a-vís a modulus with an if statement?  
Thank you again  
Best,  
Phil

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [January 24, 2020, 2:51pm UTC](https://discourse.processing.org/t/changing-color-according-to-the-y-variable/17315/6 "2020-01-24T14:51:38Z")

</div>

if(i%2 == 0)  
fill(255,0,0);  
else  
fill(0,255,0);

i++;

---

<div class="post-metadata">

### Author: ![PhilRandom](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@PhilRandom](https://discourse.processing.org/u/PhilRandom)
#### Post date: [January 24, 2020, 7:20pm UTC](https://discourse.processing.org/t/changing-color-according-to-the-y-variable/17315/7 "2020-01-24T19:20:37Z")

</div>

Very helpful, thank you.  
Much appreciated.  
Best,  
Phil
