# Trying to do an animation, how can I make the mushroom go from closed to open?

**URL:** <https://discourse.processing.org/t/trying-to-do-an-animation-how-can-i-make-the-mushroom-go-from-closed-to-open/10614>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [April 24, 2019, 11:52pm UTC](https://discourse.processing.org/t/trying-to-do-an-animation-how-can-i-make-the-mushroom-go-from-closed-to-open/10614 "2019-04-24T23:52:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [April 25, 2019, 2:02am UTC](https://discourse.processing.org/t/trying-to-do-an-animation-how-can-i-make-the-mushroom-go-from-closed-to-open/10614/2 "2019-04-25T02:02:01Z")

</div>

pls repair above code posting,

- by using in processing IDE [ctrl][t]
- and here at the forum editor use for code the

```auto
</> code tag

```

* * *

so it might look like

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

void draw() {
  my_background();
  my_mushroom();
}

void my_background() { //BACKGROUND GRADIENT START
  int r=0, g=0, b=0;
  for (int i = 0; i< height; i++) {
    stroke(r, i, b);
    line(0, i, width, i);
  }
} //BACKGROUND GRADIENT END

void my_mushroom() {
  fill(#4d3300); //dirt floor
  rect(-1, 360, 500, 500);
  fill(#ffffe6); //mushroom stalk
  noStroke();
  rect(225, 120, 50, 330);
  ellipse(250, 450, 50, 10);
  fill(#c2c2a3); //mushroom head
  bezier(180, 270, 210, -50, 290, -50, 320, 270);
}

```

* * *

ok to your question,  
the head of the mushroom is your

```auto
bezier(180,270,210,-50,290,-50,320,270);

```

if you know already that the idea is to make that variable,  
how you can draw that hard coded?  
a very variable version would use

```auto
int mx, my, mw, mh;

```

like for the outer rectangle of the head.  
after you have that running we talk about the animation.

? is it your idea to use  
[https://processing.org/reference/bezier\_.html](https://processing.org/reference/bezier_.html)  
for the head?

---

_[View the full topic](https://discourse.processing.org/t/trying-to-do-an-animation-how-can-i-make-the-mushroom-go-from-closed-to-open/10614)._
