# I am completely lost - changing size according to Mouse position

**URL:** https://discourse.processing.org/t/i-am-completely-lost-changing-size-according-to-mouse-position/682
**Category:** Coding Questions
**Tags:** homework
**Created:** [June 3, 2018, 6:49pm UTC](https://discourse.processing.org/t/i-am-completely-lost-changing-size-according-to-mouse-position/682 "2018-06-03T18:49:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![the-junk](https://avatars.discourse-cdn.com/v4/letter/t/d07c76/32.png) [@the-junk](https://discourse.processing.org/u/the-junk)
#### Post date: [June 3, 2018, 6:49pm UTC](https://discourse.processing.org/t/i-am-completely-lost-changing-size-according-to-mouse-position/682/1 "2018-06-03T18:49:47Z")

</div>

Hello, I need some serious help…

I want my tennis racquet in this code to change size according to the mouse position. When my mouse is at the bottom of the canvas, I want it to be double the size and when the mouse is at the top of the canvas I want it to be half the size.

Can anybody point me in the right direction?

Here is my code…

```auto
/ **************
 * INFO
 ************** /

//declare some constants
float RACQUET_HEIGHT = mouseY; //this controls the length of the tennis racquet shaft (0 is default)
float RACQUET_X = 250; //move the raquet left ot right
float RACQUET_Y = 250; //move the raquet up or down
 
void setup(){
  //set canvas size
  size (500, 500);
}

void draw(){
  background(250);
  
if (mouseY == height){
    RACQUET_HEIGHT = 50;}
  
		//draw the racquet shaft
  fill(0, 0, 255); //the racquet shat will be the colour blue
  rect(RACQUET_X-10, RACQUET_Y-RACQUET_HEIGHT, 20, RACQUET_HEIGHT+100); //this is the middle section that attatches the face to the handle

  //complete the shaft by adding the handle
  fill(150); //set the colour to light grey
  rect(RACQUET_X-15, RACQUET_Y+100, 30, 75); //this is the actual handle
  
  //the grip tape on the handle will be made of three triangles
  fill (100); //set the colour to dark grey
  triangle(RACQUET_X-15, RACQUET_Y+100, RACQUET_X+15, RACQUET_Y+125, RACQUET_X-15, RACQUET_Y+125); //represents the grip tape on the handle
  triangle(RACQUET_X-15, RACQUET_Y+125, RACQUET_X+15, RACQUET_Y+150, RACQUET_X-15, RACQUET_Y+150); //represents the grip tape on the handle
  triangle(RACQUET_X-15, RACQUET_Y+150, RACQUET_X+15, RACQUET_Y+175, RACQUET_X-15, RACQUET_Y+175); //represents the grip tape on the handle
  
  //draw the racquet face last so that it overlaps the shaft
  fill(0,0,255); //the colour blue will be used for the outside portion of the face
  ellipse(RACQUET_X, RACQUET_Y-75-RACQUET_HEIGHT, 125, 175); //this is the outside of the portion
  fill(255); //the colour white will be used for the inner section of the racquet face
  ellipse(RACQUET_X, RACQUET_Y-75-RACQUET_HEIGHT, 115, 165); //this represents the strings of the racquet face
}

```

---

<div class="post-metadata">

### Author: ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)
#### Post date: [June 3, 2018, 7:28pm UTC](https://discourse.processing.org/t/i-am-completely-lost-changing-size-according-to-mouse-position/682/2 "2018-06-03T19:28:11Z")

</div>

```auto
//declare some constants
float RACQUET_HEIGHT = mouseY; //this controls the length of the tennis racquet shaft (0 is default)
float RACQUET_X = 250; //move the raquet left ot right
float RACQUET_Y = 250; //move the raquet up or down

void setup() {
  //set canvas size
  size (500, 500);
}

void draw() {
  background(250);

  scale(map(mouseY,0,height,.5,2));

  //draw the racquet shaft
  fill(0, 0, 255); //the racquet shat will be the colour blue
  rect(RACQUET_X-10, RACQUET_Y-RACQUET_HEIGHT, 20, RACQUET_HEIGHT+100); //this is the middle section that attatches the face to the handle

  //complete the shaft by adding the handle
  fill(150); //set the colour to light grey
  rect(RACQUET_X-15, RACQUET_Y+100, 30, 75); //this is the actual handle

  //the grip tape on the handle will be made of three triangles
  fill (100); //set the colour to dark grey
  triangle(RACQUET_X-15, RACQUET_Y+100, RACQUET_X+15, RACQUET_Y+125, RACQUET_X-15, RACQUET_Y+125); //represents the grip tape on the handle
  triangle(RACQUET_X-15, RACQUET_Y+125, RACQUET_X+15, RACQUET_Y+150, RACQUET_X-15, RACQUET_Y+150); //represents the grip tape on the handle
  triangle(RACQUET_X-15, RACQUET_Y+150, RACQUET_X+15, RACQUET_Y+175, RACQUET_X-15, RACQUET_Y+175); //represents the grip tape on the handle

  //draw the racquet face last so that it overlaps the shaft
  fill(0, 0, 255); //the colour blue will be used for the outside portion of the face
  ellipse(RACQUET_X, RACQUET_Y-75-RACQUET_HEIGHT, 125, 175); //this is the outside of the portion
  fill(255); //the colour white will be used for the inner section of the racquet face
  ellipse(RACQUET_X, RACQUET_Y-75-RACQUET_HEIGHT, 115, 165); //this represents the strings of the racquet face
}

```
