# Trouble with homework

**URL:** <https://discourse.processing.org/t/trouble-with-homework/41647>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [April 8, 2023, 12:22am UTC](https://discourse.processing.org/t/trouble-with-homework/41647 "2023-04-08T00:22:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Computerscience](https://avatars.discourse-cdn.com/v4/letter/c/3da27b/32.png) [@Computerscience](https://discourse.processing.org/u/Computerscience)\
**Post date:** [April 8, 2023, 12:22am UTC](https://discourse.processing.org/t/trouble-with-homework/41647/1 "2023-04-08T00:22:38Z")

</div>

Question: Modify your solution to Q1 such that the diameter of the circle grows and shrinks depending on the distance of the mouse pointer to the center of the circle. Hints: You’ll need the dist() function and the multiplication \* operator for this one.

Code:  
\<  
let growthDistance= 0 \* 0

function setup() {  
createCanvas(400,400);  
}

function draw() {  
background(220);

//Change growth of Ellipse by mouse pointer  
ellipse(200,200,mouseX +50,mouseY+50);  
growthDistance= dist(200,200,mouseX +50,mouseY +50)  
}

> 

Problem: I cannot figure out how to change the ellipse size with the mouse cursor without making the ellipse change size in both directions rather than just having the size change without it moving like crazy

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [April 8, 2023, 12:30am UTC](https://discourse.processing.org/t/trouble-with-homework/41647/2 "2023-04-08T00:30:14Z")

</div>

> [@Computerscience](#):
>
> `growthDistance = dist(200, 200, mouseX + 50, mouseY + 50);`

You call **dist()** & then update the current value of variable _growthDistance_.  
However, you never use variable _growthDistance_ for **ellipse()** or anything else!

---

<div class="post-metadata">

**Author:** ![Computerscience](https://avatars.discourse-cdn.com/v4/letter/c/3da27b/32.png) [@Computerscience](https://discourse.processing.org/u/Computerscience)\
**Post date:** [April 8, 2023, 12:48am UTC](https://discourse.processing.org/t/trouble-with-homework/41647/3 "2023-04-08T00:48:53Z")

</div>

Sorry, I don’t understand what you’re implying

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [April 8, 2023, 1:14am UTC](https://discourse.processing.org/t/trouble-with-homework/41647/4 "2023-04-08T01:14:45Z")

</div>

You have a variable _growthDistance_ which you don’t use for anything.

---

<div class="post-metadata">

**Author:** ![Computerscience](https://avatars.discourse-cdn.com/v4/letter/c/3da27b/32.png) [@Computerscience](https://discourse.processing.org/u/Computerscience)\
**Post date:** [April 8, 2023, 1:28am UTC](https://discourse.processing.org/t/trouble-with-homework/41647/5 "2023-04-08T01:28:27Z")

</div>

I’m sorry but this didn’t help me at all… I do get what you are saying but your solution does not help me from my understanding

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [April 8, 2023, 2:38am UTC](https://discourse.processing.org/t/trouble-with-homework/41647/6 "2023-04-08T02:38:57Z")

</div>

Calculate `growthDistance` before you draw the ellipse and use that variable instead of `mouseX` and `mouseY` to size your ellipse.
