p5.js | Mouse | mouseX
The mouseX variable in p5.js is used to store the current horizontal position of the mouse, relative to (0, 0) of the canvas. If touch is used instead of mouse input, mouseX will hold the x value of the most recent touch point.
Below programs illustrate the mouseX variable in p5.js:
Example 1: This example uses mouseX variable to display position.
Example 2: This example uses mouseX variable to display position.