# Ellipse diameter depending on mouse position

**URL:** <https://discourse.processing.org/t/ellipse-diameter-depending-on-mouse-position/24678>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [October 18, 2020, 2:03pm UTC](https://discourse.processing.org/t/ellipse-diameter-depending-on-mouse-position/24678 "2020-10-18T14:03:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdhasan6230](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@mdhasan6230](https://discourse.processing.org/u/mdhasan6230)\
**Post date:** [October 18, 2020, 2:03pm UTC](https://discourse.processing.org/t/ellipse-diameter-depending-on-mouse-position/24678/1 "2020-10-18T14:03:18Z")

</div>

i need help drawing an ellipse that’s diameter will depend on the mouse moving position…  
like when the y position increase and the x position decrease the diameter will in increase and vise versa… plus the ellipse should stay on a still position when the mouse pressed is released …

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 18, 2020, 2:06pm UTC](https://discourse.processing.org/t/ellipse-diameter-depending-on-mouse-position/24678/2 "2020-10-18T14:06:15Z")

</div>

Hello,

I would start by exploring the resources on the Processing website:

_[https://processing.org/](https://processing.org/)_

`:)`

References:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/119a3a3635298965f0f04342b2c7c120f502312f.png)

Examples:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/33a67143534629a0ac151a8a227813201894deea.png)

Check out the Tutorials!

Coordinate System and Shapes:

_[https://processing.org/tutorials/drawing/](https://processing.org/tutorials/drawing/)_

Interactivity:

_[https://processing.org/tutorials/interactivity/](https://processing.org/tutorials/interactivity/)_

---

<div class="post-metadata">

**Author:** ![mdhasan6230](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@mdhasan6230](https://discourse.processing.org/u/mdhasan6230)\
**Post date:** [October 18, 2020, 2:13pm UTC](https://discourse.processing.org/t/ellipse-diameter-depending-on-mouse-position/24678/4 "2020-10-18T14:13:32Z")

</div>

i did look there but cant find the function that will keep the ellipse on a certain position when mousepressed is released

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 18, 2020, 2:23pm UTC](https://discourse.processing.org/t/ellipse-diameter-depending-on-mouse-position/24678/5 "2020-10-18T14:23:43Z")

</div>

look at map() to map mouseX to a diameter

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 18, 2020, 2:24pm UTC](https://discourse.processing.org/t/ellipse-diameter-depending-on-mouse-position/24678/6 "2020-10-18T14:24:14Z")

</div>

Hello,

The map() function may be helpful.

Do some exploration on the website.

`:)`

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 18, 2020, 4:04pm UTC](https://discourse.processing.org/t/ellipse-diameter-depending-on-mouse-position/24678/7 "2020-10-18T16:04:57Z")

</div>

> [@mdhasan6230](#):
>
> keep the ellipse on a certain position when mousepressed is released

When you get rid of background the ellipse will stay

---

<div class="post-metadata">

**Author:** ![raron](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/raron/32/13651_2.png) [@raron](https://discourse.processing.org/u/raron)\
**Post date:** [October 18, 2020, 8:51pm UTC](https://discourse.processing.org/t/ellipse-diameter-depending-on-mouse-position/24678/8 "2020-10-18T20:51:20Z")

</div>

Welcome to the forum!

It sounds like you (@mdhasan6230) also asks about how to [calculate the ellipse radius](https://math.stackexchange.com/questions/432902/how-to-get-the-radius-of-an-ellipse-at-a-specific-angle-by-knowing-its-semi-majo) (or diameter)?  
Or maybe you just wanted to draw an [ellipse](https://processing.org/reference/ellipse_.html)?
