# Calculation for variables in D. Shiffman book "Learning Processing"

**URL:** <https://discourse.processing.org/t/calculation-for-variables-in-d-shiffman-book-learning-processing/11286>\
**Category:** Beginners\
**Created:** [May 15, 2019, 7:59pm UTC](https://discourse.processing.org/t/calculation-for-variables-in-d-shiffman-book-learning-processing/11286 "2019-05-15T19:59:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [May 15, 2019, 7:59pm UTC](https://discourse.processing.org/t/calculation-for-variables-in-d-shiffman-book-learning-processing/11286/1 "2019-05-15T19:59:39Z")

</div>

I’m trying to get a better understanding on how Dan Shiffman drew his raindrop shape via the variables below **AND** the starting y position.

Any help is most appreciated!

**Text in bold placed next to the 3 areas in question.**

```auto
class Drop{
  float x, y;
  float speed;
  color c;
  float r;
  
  Drop(){
    r = 8;
    x = random(width);
    y = -r*4;

```

**for y above, does this mean -8\*4 is: y = -32?**

```auto
    speed = random(1, 5);
    c = color(50, 100, 150);
  }
  
  void move(){
    y += speed;
  }

```

**In the move() function, with the y set at -32 that becomes -32 += speed?**  
**I think my interpretation of y must be wrong?**  
**```**

```auto
void display(){
    fill(c);
    noStroke();
    for (int i = 2; i < r; i++){
      ellipse(x, y+i*4, i*2, i*2);
    }
  }

```

\*\*And finally, in ellipse, for y position and w, h: \*\*  
\*\*1/ how do you get the raindrop shape if both w and h are the same variable \*\*  
**2/ i’m not fully understanding the y position calculation**

---

<div class="post-metadata">

**Author:** ![humayung](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/humayung/32/6089_2.png) [@humayung](https://discourse.processing.org/u/humayung)\
**Post date:** [May 15, 2019, 8:50pm UTC](https://discourse.processing.org/t/calculation-for-variables-in-d-shiffman-book-learning-processing/11286/2 "2019-05-15T20:50:50Z")

</div>

try to change 2 and 4 in the ellipse and 4 at the constructor with something bigger, you will start to understand how it works. plus, give it some alpha to the circle

 ![Screenshot%20from%202019-05-16%2003-49-06](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/758cabd79fda32ee5ceb90600fc22b9c0b1fd9fc.png)

> [@debxyz](#):
>
> for y above, does this mean -8\*4 is: y = -32?

you wouldnt want the drop instantly shown on the screen, so you should start to draw the drop at **minus y axis**

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [May 15, 2019, 9:29pm UTC](https://discourse.processing.org/t/calculation-for-variables-in-d-shiffman-book-learning-processing/11286/3 "2019-05-15T21:29:35Z")

</div>

Thank you @humayung! That was helpful changing the alpha and numbers in ellipse to better visualize.  
And I understand the y position now! 🙂
