Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptp5.js fullscreen() function

p5.js fullscreen() function

The fullscreen() function in p5.js is used to get the current fullscreen state of the user’s browser window. If an argument is given, sets the sketch to fullscreen or not based on the value of the argument. If no argument is given, returns the current fullscreen state. Note that due to browser restrictions this can only be called on user input.

Syntax:

fullscreen()

Parameters: The function does not accept any parameters.

Below program illustrates the fullscreen() function in p5.js:

Example:




function setup() {
      
    // Set the background color
    background(200);
}
function mousePressed() {
      
    // Set the value of fullscreen
    // into the variable
    let fs = fullscreen();
      
    // Call to fullscreen function
    fullscreen(!fs); 
}


Output:
Before Clicking the screen:

After Clicking the screen:

Reference: https://p5js.org/reference/#/p5/fullscreen

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments