# Background colour change

**URL:** <https://discourse.processing.org/t/background-colour-change/20855>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [May 14, 2020, 6:49am UTC](https://discourse.processing.org/t/background-colour-change/20855 "2020-05-14T06:49:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ree311](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ree311/32/9206_2.png) [@ree311](https://discourse.processing.org/u/ree311)\
**Post date:** [May 14, 2020, 6:49am UTC](https://discourse.processing.org/t/background-colour-change/20855/1 "2020-05-14T06:49:19Z")

</div>

Hello,

I am a beginner trying to create a real-time art for an assignment in processing with true or false conditions and a mouse press.

So far I have been able to play around and gain understanding with some code I found on the processing website to look and function the way I would like, but every time I add new code from tutorials and the processing website for colour changes or mouse pressed, I am getting errors of active and static and other code errors that I don’t understand.

What else I would like in the code:

- Background random colour change with mouse press
- Star collision changes when the stars hit each other.

Here is my code; any help with some explanation would be appreciated and some points in the right direction would be appreciated.

I look forward to a reply.

Sheree

```auto
///canvas setup varibles
void setup() {
  size(1280, 720);
  stroke (4);

}

/// spinning stars

void draw() {
  background(218,251,255);
  
  /// left star moves clockwise
  pushMatrix();
  translate(width*0.3, height*0.5);
  rotate(frameCount / 200.0);
  star(0, 0, 60, 140, 10); 
  fill(240,21,240);
  popMatrix();
  
 
  /// middle star spin anticlockwise
  
  pushMatrix();
  translate(width*0.5, height*0.5);
  rotate(frameCount / -100.0);
  star(0, 0, 60, 140, 10); 
  popMatrix();
  

  /// right star moves anticlockwise 
  pushMatrix();
  translate(width*0.7, height*0.5);
  rotate(frameCount / 200.0);
  star(0, 0, 60, 140, 10); 
  popMatrix();

}

void star(float x, float y, float radius1, float radius2, int npoints) {
  float angle = TWO_PI / npoints;
  float halfAngle = angle/2.0;
  beginShape();
  for (float a = 0; a < TWO_PI; a += angle) {
    float sx = x + cos(a) * radius2;
    float sy = y + sin(a) * radius2;
    vertex(sx, sy);
    sx = x + cos(a+halfAngle) * radius1;
    sy = y + sin(a+halfAngle) * radius1;
    vertex(sx, sy);
  }
  endShape(CLOSE);
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 14, 2020, 10:09pm UTC](https://discourse.processing.org/t/background-colour-change/20855/2 "2020-05-14T22:09:59Z")

</div>

> [@ree311](#):
>
> errors of active and static

This sounds like you may not understand the difference between active and static modes.

Read the overview tutorial:

> **[Processing Overview](https://processing.org/tutorials/overview/)**
>
> A little more detailed introduction to the different features of Processing than the Getting Started tutorial.

> A program written as a list of statements (like the previous examples) is called a _static_ sketch. In a static sketch, a series of functions are used to perform tasks or create a single image without any animation or interaction. Interactive programs are drawn as a series of frames, which you can create by adding functions titled setup() and draw() as shown in the code below.

So, you can do certain things with no setup and no draw. But you want animation, so you need exactly one draw and (optionally) one setup, and the commands should go inside them. You can’t have more than one setup or draw.

---

<div class="post-metadata">

**Author:** ![ree311](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ree311/32/9206_2.png) [@ree311](https://discourse.processing.org/u/ree311)\
**Post date:** [May 15, 2020, 4:13am UTC](https://discourse.processing.org/t/background-colour-change/20855/3 "2020-05-15T04:13:19Z")

</div>

Hi @jeremydouglass  
Thank you for your reply.  
Ohhh now I understand.  
Thanks again 🙂
