📜  p5.js |毫秒()函数

📅  最后修改于: 2022-05-13 01:56:25.512000             🧑  作者: Mango

p5.js |毫秒()函数

p5.js 中的millis()函数用于返回从启动程序开始的毫秒数。该函数主要用于定时事件和动画序列。

句法:

millis()

参数:该函数不接受任何参数。

返回值:返回程序启动后的毫秒数。

下面的程序说明了 p5.js 中的 millis()函数:

示例:此示例使用 millis()函数返回从启动程序开始的毫秒数。

function setup() {
      
    // Create Canvas of size 450*80 
    createCanvas(450, 80);
}
  
function draw() {
      
    // Set the background color
    background(220);
      
    // Initialize the parameter with
    // current milliseconds
    let ml = millis();
      
    // Set the font size
    textSize(16);
      
    // Set the font color
    fill(color('red'));
      
    // Display result
    text("Current Milli Seconds is : "
                    + ml, 50, 30);
}                    

输出:

参考: https://p5js.org/reference/#/p5/millis