# Help changing colours in my animation

**URL:** <https://discourse.processing.org/t/help-changing-colours-in-my-animation/4799>\
**Category:** Coding Questions\
**Created:** [October 24, 2018, 9:28am UTC](https://discourse.processing.org/t/help-changing-colours-in-my-animation/4799 "2018-10-24T09:28:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe891](https://avatars.discourse-cdn.com/v4/letter/j/e495f1/32.png) [@joe891](https://discourse.processing.org/u/joe891)\
**Post date:** [October 24, 2018, 9:28am UTC](https://discourse.processing.org/t/help-changing-colours-in-my-animation/4799/1 "2018-10-24T09:28:44Z")

</div>

Hi! I want my 3 triangle to randomly be changing colours throughout the whole animation. I’m a little stuck on where to go next but this is what I have so far.

```auto
float x = 0;
float speed = 1;
float r = random(255);
float g = random(255);
float b = random(255);

void setup()
{
  size(700,500);

}

void draw()
{
  background(255);
      
  x = x + speed;
  translate( x,0);
  if ( x > width) x = -50;
  if (mousePressed) x = 0;
  
 
    
 { 
   fill(0);
line(0,200,700,200);
line(0,300,700,300);
line(0,400,700,400);
   
noStroke();  
fill(#958585); 
rect(50,430,50,30);
triangle(100,425,150,443,100,465);
fill(#0FD2F2);
ellipse(100,445,20,20);
fill(0);
ellipse(63,445,5,5);
ellipse(78,445,5,5);
strokeWeight(255);
fill(#F20F0F);
triangle(30,410,50,430,100,430);
triangle(30,480,50,460,100,460);
fill(r,g,b);
triangle(7,425,50,430,50,460);
triangle(23,437,0,443,50,460);
triangle(30,450,7,462,50,460);
fill(#F74D0A);
triangle(20,430,50,438,50,450);
triangle(35,438,10,443,50,450);
triangle(20,457,35,445,50,450);

  }
    

}

```

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 24, 2018, 9:44am UTC](https://discourse.processing.org/t/help-changing-colours-in-my-animation/4799/2 "2018-10-24T09:44:48Z")

</div>

you can repeat the  
color random inside the

```auto
void draw(){
// ...
  r = random(255);
  g = random(255);
  b = random(255);
// ...
}

```

and your rocket is on fire

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [October 24, 2018, 12:26pm UTC](https://discourse.processing.org/t/help-changing-colours-in-my-animation/4799/3 "2018-10-24T12:26:22Z")

</div>

HSB mode allows you to use one variable (hue) to cycle through colors, and you don’t need to store it, since it is calculated on the fly.  
setup

```java
 colorMode(HSB, 1.0);

```

draw

```java
fill(random(1.0), 1.0, 1.0);

```

```auto

```
