p5.js | cursor() Function
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 16×16 or 32×32 pixels. The values for parameters x and y must be less than the dimensions of the image.
Syntax:
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.
Below program illustrates the cursor() function in p5.js:
Example: This example uses cursor() function to display 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() { } |
Output:

Reference: https://p5js.org/reference/#/p5/cursor
Recommended Posts:
- CSS | cursor property
- JavaScript | Cursor property
- Hide the cursor in a webpage using CSS and JavaScript
- HTML | DOM Style cursor Property
- How to change cursor style using jQuery ?
- How to set cursor style to pointer for links without href ?
- How to change cursor to waiting state in JavaScript/jQuery ?
- How to make the cursor to hand when a user hovers over a list item using CSS?
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- PHP | Ds\Map put() Function
- PHP | pi( ) Function
- PHP | Ds\Map xor() Function
- D3.js | d3.map.set() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai



