p5.js cursor() Function
Last Updated :
10 Aug, 2023
Improve
The cursor() function in p5.js is used to set the cursor to a predefined symbol or an image or it makes visible if already hidden. To set an image as the cursor, the recommended size is 16x16 or 32x32 pixels. The values for parameters x and y must be less than the dimensions of the image.
Syntax:
javascript
Output:
Reference: https://p5js.org/reference/#/p5/cursor
cursor(type, x, y)Parameters: This function accepts three parameters as mentioned above and described below:
- type: This parameter stores the type of cursor like ARROW, CROSS, HAND, MOVE, TEXT and WAIT Native CSS properties: 'grab', 'progress', 'cell' etc. External: path for cursor's images (Allowed File extensions: .cur, .gif, .jpg, .jpeg, .png).
- x: This parameter stores the horizontal active spot of the cursor.
- y: This parameter stores the vertical active spot of the cursor.
function setup() {
// Create canvas
createCanvas(400, 400);
// Set the text size
textSize(40);
// Set the text alignment
// to center
textAlign(CENTER);
}
function draw() {
cursor('https://s3.amazonaws.com/mupublicdata/cursor.cur');
}
