Monday, November 18, 2024
Google search engine
HomeLanguagesJavascriptp5.js second() function

p5.js second() function

The second() function in p5.js is used to return the current second of the system clock. The value of second() function lies between 0 to 59.

Syntax:

second()

Parameters: The function does not accept any parameter.

Return Value: This function returns an integer value which represents the current second.

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

Example: This example uses second() function to return the current second.




function setup() {
  
    // Create Canvas of size 270*80
    createCanvas(270, 80);
}
  
function draw() {
      
    // Set the background color
    background(220);
      
    // Store value of second() function
    // to the variable
    let s = second();
      
    // Set the font size
    textSize(16);
      
    // Set the font color
    fill(color('red'));
      
    // Display result 
    text("Current Second is : " + s, 50, 30);
}


Output:

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

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!

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments