The resizeCanvas() function is used to resize the canvas to the height and width given as parameters. The canvas is immediately redrawn after the resize takes place unless the optional ‘noRedraw’ parameter is set to true.
resizeCanvas(w, h, [noRedraw])
Parameters: This function accepts three parameters as mentioned above and described below:
- w: It is a number representing the width of the new canvas.
- h: It is a number representing the height of the new canvas.
- noRedraw: It is a boolean value which specifies if the canvas is immediately redrawn when resized.
Below example illustrates the resizeCanvas() function in p5.js:
Example 1: In this example, we fixed the increase size.
Example 2: In this example, size depends on the click position.
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
- How to get the function name inside a function in PHP ?
- D3.js | d3.set.add() Function
- D3.js | d3.min() function
- PHP | pi( ) Function
- CSS | rgb() Function
- D3.js | d3.max() function
- PHP | key() Function
- PHP | Ds\Set contains() Function
- PHP | pos() Function
- p5.js | hex() function
- CSS | url() Function
- PHP | max( ) 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 email@example.com. 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.