Trouble with homework

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

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

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

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

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

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

1 Like