Constricting shape movement in p5js

Hi, I’m a beginner with p5js and I’ve run into some trouble with some code I’m writing. I have three circles of decreasing size, with the smallest and middle circles mapped to mouseX and mouseY. My issue is that I want to make it so that the smallest circle cannot move outside the boundaries of the middle circle, while the middle circle cannot move outside the boundaries of the largest circle, the position of which is fixed. How do I do this?

Hey,

I think the constrain() function is what you are looking for: