p5.js windowHeight
Last Updated :
10 Aug, 2023
The windowHeight in p5.js is a system variable that is used to store the height of the inner window and it maps to window.innerHeight.
Syntax
windowHeight
Parameters: This function does not accept any parameter.
Below program illustrates the windowHeight variable in p5.js:
Example-1:
function setup() {
createCanvas(1000, 400);
textSize(20);
}
function draw() {
background(200);
rect(mouseX, mouseY, 30, 30);
text( "Window Height is " + windowHeight, 30, 40);
}
|
Output:
Example-2:
function setup() {
height = windowHeight;
createCanvas(380, height);
}
function draw() {
background(220);
textSize(16);
textAlign(CENTER);
fill(color( 'Green' ));
text( "windowHeight of Canvas is : "
+ height, 180, height / 2);
}
|
Output:
Reference: https://p5js.org/reference/#/p5/windowHeight
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...