# How do i add colour to each one of the 10 boxes i made

**URL:** <https://discourse.processing.org/t/how-do-i-add-colour-to-each-one-of-the-10-boxes-i-made/25739>\
**Category:** Coding Questions\
**Created:** [November 26, 2020, 8:46pm UTC](https://discourse.processing.org/t/how-do-i-add-colour-to-each-one-of-the-10-boxes-i-made/25739 "2020-11-26T20:46:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DijaAngel](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@DijaAngel](https://discourse.processing.org/u/DijaAngel)\
**Post date:** [November 26, 2020, 8:46pm UTC](https://discourse.processing.org/t/how-do-i-add-colour-to-each-one-of-the-10-boxes-i-made/25739/1 "2020-11-26T20:46:26Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

void setup(){  
size(500,500);  
}  
void draw(){  
for(int i=0;i\<=450;i+=50){  
rect(0,i,50,50);  
}  
}

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [November 26, 2020, 9:05pm UTC](https://discourse.processing.org/t/how-do-i-add-colour-to-each-one-of-the-10-boxes-i-made/25739/2 "2020-11-26T21:05:57Z")

</div>

Hi, just use fill() above the rect() with a variable.  
Like: fill(i/2, i/4, 0);

---

<div class="post-metadata">

**Author:** ![DijaAngel](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@DijaAngel](https://discourse.processing.org/u/DijaAngel)\
**Post date:** [November 27, 2020, 2:05pm UTC](https://discourse.processing.org/t/how-do-i-add-colour-to-each-one-of-the-10-boxes-i-made/25739/3 "2020-11-27T14:05:55Z")

</div>

Thanks but I want each box to have a different colour not a range like box 1 black box 2 red and so on using the colour selector.

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [November 27, 2020, 2:25pm UTC](https://discourse.processing.org/t/how-do-i-add-colour-to-each-one-of-the-10-boxes-i-made/25739/4 "2020-11-27T14:25:27Z")

</div>

Make an array of colors and access the color as fill parameter like

```auto
for(int i = 0; i <= 450; i += 50){
  int index = int(map(i, 0, 450, 0, myColoArray.length));
  fill(myColorArray[index];
  rect(0,i,50,50);
}

```
