# Background colour change

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

``````///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);
}
``````
1 Like

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

Thanks again 