# The homework I failed

**URL:** <https://discourse.processing.org/t/the-homework-i-failed/26006>\
**Category:** Coding Questions\
**Created:** [December 6, 2020, 10:16pm UTC](https://discourse.processing.org/t/the-homework-i-failed/26006 "2020-12-06T22:16:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![duruko](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/duruko/32/11307_2.png) [@duruko](https://discourse.processing.org/u/duruko)\
**Post date:** [December 6, 2020, 10:16pm UTC](https://discourse.processing.org/t/the-homework-i-failed/26006/1 "2020-12-06T22:16:49Z")

</div>

![hj](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7f2d769905d1480e04901a5f22917705bed19b61.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![ErraticGenerator](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/erraticgenerator/32/11304_2.png) [@ErraticGenerator](https://discourse.processing.org/u/ErraticGenerator)\
**Post date:** [December 7, 2020, 5:29pm UTC](https://discourse.processing.org/t/the-homework-i-failed/26006/2 "2020-12-07T17:29:53Z")

</div>

something like this?

```java
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);
  }
}

```

---

<div class="post-metadata">

**Author:** ![duruko](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/duruko/32/11307_2.png) [@duruko](https://discourse.processing.org/u/duruko)\
**Post date:** [December 7, 2020, 5:39pm UTC](https://discourse.processing.org/t/the-homework-i-failed/26006/3 "2020-12-07T17:39:15Z")

</div>

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);  
> }  
> }\<

---

<div class="post-metadata">

**Author:** ![ErraticGenerator](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/erraticgenerator/32/11304_2.png) [@ErraticGenerator](https://discourse.processing.org/u/ErraticGenerator)\
**Post date:** [December 7, 2020, 5:44pm UTC](https://discourse.processing.org/t/the-homework-i-failed/26006/4 "2020-12-07T17:44:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![duruko](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/duruko/32/11307_2.png) [@duruko](https://discourse.processing.org/u/duruko)\
**Post date:** [December 7, 2020, 5:50pm UTC](https://discourse.processing.org/t/the-homework-i-failed/26006/5 "2020-12-07T17:50:55Z")

</div>

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