# Can Mouse Coordinates Change with Translate and Rotate?

**URL:** <https://discourse.processing.org/t/can-mouse-coordinates-change-with-translate-and-rotate/5580>\
**Category:** Coding Questions\
**Created:** [November 16, 2018, 3:25am UTC](https://discourse.processing.org/t/can-mouse-coordinates-change-with-translate-and-rotate/5580 "2018-11-16T03:25:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erit1566](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@Erit1566](https://discourse.processing.org/u/Erit1566)\
**Post date:** [November 16, 2018, 3:25am UTC](https://discourse.processing.org/t/can-mouse-coordinates-change-with-translate-and-rotate/5580/1 "2018-11-16T03:25:18Z")

</div>

Hi, I am trying to be able to change where the mouse cursor is so it would be easier to see if I am hovering over one of my objects without looking at every pixel by pixel.  
Thanks in advance,

Eric

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [November 16, 2018, 6:14am UTC](https://discourse.processing.org/t/can-mouse-coordinates-change-with-translate-and-rotate/5580/2 "2018-11-16T06:14:56Z")

</div>

good question,  
may i fill it with a example:

```auto

// https://discourse.processing.org/t/can-mouse-coordinates-change-with-translate-and-rotate/5580?u=kll
// or ? does a moved object know where it is ?

MySquare here;

// ________________________________________________________
public class MySquare {
  int posX, posY, wide;

  public MySquare(int posX, int posY, int wide ) {
    this.posX = posX;
    this.posY = posY;
    this.wide = wide;
  }

  public void draw() {
    stroke(0, 200, 0);
    if (over(mouseX, mouseY)) fill(200, 200, 200);
    else fill(0, 0, 0);
    rect(posX, posY, wide, wide);
  }

  boolean over(int mx, int my) {
    if ((mx > (posX)) & (mx < (posX+ wide))) {
      if ((my > (posY)) & (my < (posY+ wide))) {
        return true;
      }
    }
    return false;
  }
}

// ________________________________________________________
void setup() {
  size(500, 500);
  here = new MySquare(10, 10, 100); // MySquare(x,y,wide);
}

// ________________________________________________________
void draw() {
  background(200, 200, 0);
  noStroke();
  fill(150, 150, 150);
  rect(10, 10, 100, 100); // mouse dummy

  pushMatrix();
  translate(width/2, height/2);
  rotate(PI/4);
  stroke(200, 0, 0);
  line(-200, 0, 200, 0);
  stroke(0, 0, 200);
  line(0, -200, 0, 200);
  here.draw();
  popMatrix();
}

```
