# How do I change the size of an object with mouse

**URL:** <https://discourse.processing.org/t/how-do-i-change-the-size-of-an-object-with-mouse/30540>\
**Category:** Coding Questions\
**Created:** [June 6, 2021, 9:06pm UTC](https://discourse.processing.org/t/how-do-i-change-the-size-of-an-object-with-mouse/30540 "2021-06-06T21:06:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hisoka](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hisoka/32/13534_2.png) [@Hisoka](https://discourse.processing.org/u/Hisoka)\
**Post date:** [June 6, 2021, 9:06pm UTC](https://discourse.processing.org/t/how-do-i-change-the-size-of-an-object-with-mouse/30540/1 "2021-06-06T21:06:52Z")

</div>

How do I change the size of an object, when the mouse is getting farther than the center of the canvas, the object gets bigger and when the mouse is getting closer to the center of the canvas, the object gets smaller

I did this Toyoya Logo and I want it to get bigger if the mouse is far form the center, and smaller if the mouse is close to the center, can someone give me a hint please

```auto
int dragX, dragY, moveX, moveY;

void setup() {
  size(500, 500);
  noStroke();
}

void draw() {
  
  if (mousePressed){
   dragX=mouseX;
   dragY=mouseY;
   noLoop();
  } else {
    dragX=pmouseX;
    dragY=pmouseY;
  }
  background(255);
  stroke(0);
  strokeWeight(20);
  noFill();
  ellipse(dragX,dragY,380,250);
  ellipse(dragX,dragY,100,250);
  ellipse(dragX,dragY-80,230,90);
}

```

---

<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:** [June 7, 2021, 1:22pm UTC](https://discourse.processing.org/t/how-do-i-change-the-size-of-an-object-with-mouse/30540/2 "2021-06-07T13:22:31Z")

</div>

Hello,

Check this out:  
[https://processing.org/reference/map\_.html](https://processing.org/reference/map_.html)  
[https://processing.org/reference/mouseX.html](https://processing.org/reference/mouseX.html)

The Processing website has resources (tutorials, examples, references, etc):  
_[www.processing.org](http://www.processing.org)_

I use them all the time!

`:)`
