The pmouseY variable in p5.js is used to store the vertical position of the mouse cursor in the frame previous to the current active frame, relative to the origin of the canvas.
Syntax:
pmouseY
Below programs illustrate the pmouseY variable in p5.js:
Example 1: This example uses pmouseY variable to draw mouse pointer as circle.
function setup() {
createCanvas(1000, 400);
}
function draw() {
background(244, 248, 252);
fill(pmouseX%255, pmouseY%255, mouseY%255);
circle(mouseX, pmouseY, pmouseX%100);
}
|
Output:
Example 2: This example uses pmouseY variable to display the position of mouse pointer.
function setup() {
createCanvas(1000, 400);
textSize(20);
}
function draw() {
background(200);
text( "Position of pmouseY is "
+ pmouseY, 30, 40);
}
|
Output:
Reference: https://p5js.org/reference/#/p5/pmouseY
Last Updated :
22 Apr, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...