# Question about mouseX and mouseY

**URL:** <https://discourse.processing.org/t/question-about-mousex-and-mousey/34620>\
**Category:** Libraries\
**Created:** [January 14, 2022, 9:54am UTC](https://discourse.processing.org/t/question-about-mousex-and-mousey/34620 "2022-01-14T09:54:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasco](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@vasco](https://discourse.processing.org/u/vasco)\
**Post date:** [January 14, 2022, 9:54am UTC](https://discourse.processing.org/t/question-about-mousex-and-mousey/34620/1 "2022-01-14T09:54:34Z")

</div>

hello guys

Working on a project with p5js and getting a curious result with mouseX and mouseY

So I have this code:

```auto
 if(tx > 0 && tx < 500 && ty > 0 && ty < 500 && myp5.mouseIsPressed && (pty != ty || ptx != tx)){
            socket.emit('message',{x : tx, y : ty, pen: 1});
            pendown = true;
            console.log(myp5.mouseX + "---" + myp5.mouseY);
    
    }else{
           if(pendown){
               pendown = false;
               socket.emit('message',{x : tx, y : ty, pen: 0});
               console.log(tx + "---" + ty + "---up" );
            }
    }

```

and returns me this :

402.578125—436.5—up  
java.js:14 392.578125—442.5  
java.js:14 386.578125—445.5  
java.js:20 386.578125—445.5—up  
java.js:14 380.578125—447.5  
java.js:14 373.578125—448.5  
java.js:20 373.578125—448.5—up  
java.js:14 365.578125—450.5  
java.js:20 365.578125—450.5—up  
java.js:14 358.578125—452.5  
java.js:20 358.578125—452.5—up  
java.js:14 352.578125—452.5  
java.js:20 352.578125—452.5—up  
java.js:14 347.578125—452.5  
java.js:20 347.578125—452.5—up

why is the X with much more resolution and Y ? is this normal ?

thanks

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [January 16, 2022, 6:24am UTC](https://discourse.processing.org/t/question-about-mousex-and-mousey/34620/2 "2022-01-16T06:24:39Z")

</div>

Is your canvas square or rectangular?

---

<div class="post-metadata">

**Author:** ![vasco](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@vasco](https://discourse.processing.org/u/vasco)\
**Post date:** [January 17, 2022, 10:15pm UTC](https://discourse.processing.org/t/question-about-mousex-and-mousey/34620/3 "2022-01-17T22:15:21Z")

</div>

Hello

thanks for taking the time to reply this

it’s square, 500x500 on a retina display ( don’t know if this matters )

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [January 18, 2022, 1:24am UTC](https://discourse.processing.org/t/question-about-mousex-and-mousey/34620/4 "2022-01-18T01:24:08Z")

</div>

Do you have more code? Difficult to say otherwise.

---

<div class="post-metadata">

**Author:** ![Crysp](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Crysp](https://discourse.processing.org/u/Crysp)\
**Post date:** [January 18, 2022, 2:04am UTC](https://discourse.processing.org/t/question-about-mousex-and-mousey/34620/5 "2022-01-18T02:04:13Z")

</div>

Yeah we might need more code (maybe where ty or y is modified). This just prints it, the issue you are asking about probably happens before this code runs.

It looks like the decimal place of both x and y are the same for every value; each value only changes in whole-number amounts, with the unchanging decimal amount added on (x’s being .578125 and y’s being .5). Because of this I honestly don’t think it’s an issue, but if it is giving you problems, then yes, please post more code.
