# How to make the ellipse size change when the ellipse locates toward the center??

**URL:** <https://discourse.processing.org/t/how-to-make-the-ellipse-size-change-when-the-ellipse-locates-toward-the-center/35805>\
**Category:** Beginners\
**Created:** [March 18, 2022, 12:57am UTC](https://discourse.processing.org/t/how-to-make-the-ellipse-size-change-when-the-ellipse-locates-toward-the-center/35805 "2022-03-18T00:57:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anson565](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@Anson565](https://discourse.processing.org/u/Anson565)\
**Post date:** [March 18, 2022, 12:57am UTC](https://discourse.processing.org/t/how-to-make-the-ellipse-size-change-when-the-ellipse-locates-toward-the-center/35805/1 "2022-03-18T00:57:41Z")

</div>

How to make the ellipse size change when the ellipse locates toward the center??

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 18, 2022, 2:16am UTC](https://discourse.processing.org/t/how-to-make-the-ellipse-size-change-when-the-ellipse-locates-toward-the-center/35805/2 "2022-03-18T02:16:42Z")

</div>

hi and welcome

try this and play with this line  
ellipse(33+move, 255, 55+move, move+55);

```auto
int c = 1;
int move=0; 
void setup() { 
  size(600, 600);
} 
void draw() { 
  background(1,255,1); 
  move= move + c; 
 fill(0,0,266);
  ellipse(33+move, 255, 55+move, move+55); 
  if (move>= width || move <= 0 ) { 
    c= c * -1;
  }
}

```

---

<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:** [March 18, 2022, 5:52am UTC](https://discourse.processing.org/t/how-to-make-the-ellipse-size-change-when-the-ellipse-locates-toward-the-center/35805/3 "2022-03-18T05:52:09Z")

</div>

You can calculate the distance to the center with

`float d=dist(x,y,width/2,height/2);`

and then use map() command

`float diam = map(d,0,width,1,55);`

use diam as 3rd and 4th parameters for ellipse
