# The homework I failed

Hello, my Processing skills are as bad as my English. I consult you here with my teacher’s suggestion.
I showed the work I tried to do from Processing with sample pictures. I want a spring to multiply by moving to the right, and likewise I want it to disappear one by one when it comes to its starting point. I’ll be happy if you can help me.

1 Like

something like this?

``````void setup() {
size(500, 500);
}

void draw() {
background(200);

int spacing = 30;
for (int x = 0; x < mouseX; x+=30) {
ellipse(x, height/2, 50, 50);
}
}
``````

First of all thank you for the code.It should be this way, but I want it to be three-dimensional and work spontaneously. Three-dimensional springs that continue towards the back.

void setup() {
size(800, 800);
}
void draw() {
background(0);
strokeWeight(5);
stroke(255);
noFill();
ellipse(400, 400, 500, 500);
if (mouseX>190) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 420, 500, HALF_PI, PI+HALF_PI);
}
if (mouseX>230) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 340, 500, HALF_PI, PI+HALF_PI);
}
if (mouseX>270) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 260, 500, HALF_PI, PI+HALF_PI);
}
if (mouseX>310) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 180, 500, HALF_PI, PI+HALF_PI);
}
if (mouseX>350) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 100, 500, HALF_PI, PI+HALF_PI);
}
if (mouseX>390) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 20, 500, HALF_PI, PI+HALF_PI);
}
if (mouseX>410) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 20, 500, PI+HALF_PI, HALF_PI+TWO_PI);
}
if (mouseX>450) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 100, 500, PI+HALF_PI, HALF_PI+TWO_PI);
}
if (mouseX>490) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 180, 500, PI+HALF_PI, HALF_PI+TWO_PI);
}
if (mouseX>530) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 260, 500, PI+HALF_PI, HALF_PI+TWO_PI);
}
if (mouseX>570) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 340, 500, PI+HALF_PI, HALF_PI+TWO_PI);
}
if (mouseX>610) {
strokeWeight(5);
stroke(random(255),0,255);
noFill();
arc(400, 400, 420, 500, PI+HALF_PI, HALF_PI+TWO_PI);
}
}<

I think you are almost there. if you look at your code, you see many repetitions of the if statements. The only things that are different in each if statement is the condition itself and the 3rd parameter of `arc()` function. These values can be updated within a for loop like the for-loop code that I gave you.

The key is to be able to extract a pattern and apply it as a for loop.

It’s true,i understand what you said. Thank youu 1 Like