p5.js | resizeCanvas() Function
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/
My Personal Notes arrow_drop_up
Please Login to comment...