Weird behaviour with mouseX and mouseY

Whenever i retrieve mouseX and mouseY , mouseX returns as long decimal number and mouseY returns as a integer. (ex. [340.32472970811324, 350]).

This is quite annoying as it broke one of my functions.
Does anyone have any idea why it is doing this?

1 Like

Which OS?

Do you have a new mouse driver or mouse?

You can int() the value of course

1 Like

Which OS?

Ubuntu 18.04 , using chromium

Do you have a new mouse driver or mouse?

mouse is the same one it has always been , the OS might have updated driver i am not sure.
I did fix my issue with int() but it is just puzzling me why its a float for one and interger with the other.

1 Like

Hello,

Can you provide a small example of code to demonstrate this?

I will try it here.

:)

I can just type [mouseX,mouseY] into the developer console, and i would get that result, it isnt limited to any part of the code

p5.js uses the underlying web API:s to calculate the value of mouseX and mouseY. Those API:s returns a double floating-point value. In other words: this is expected behavior and works as intended.

A double floating point value, as redefined by the CSSOM View Module. Originally, this property was defined as a long integer.

2 Likes