p5.js中的hour()函數用於從係統時鍾返回當前小時。它返回一個介於0到23之間的整數值。
用法:
hour()
參數:該函數不接受任何參數。
返回值:此函數返回代表當前小時的整數值。
以下示例程序旨在說明p5.js中的hour()函數:
例:本示例使用hour()函數從係統時鍾返回當前小時。
function setup() {
// Create Canvas of size 270*80
createCanvas(270, 80);
}
function draw() {
// Set the background color
background(220);
// Initialize the parameter with
// current hour
let h = hour();
// Set the font size
textSize(16);
// Set the font color
fill(color('red'));
// Display result
text("Current hour is : " + h, 50, 30);
}
輸出:
參考: https://p5js.org/reference/#/p5/hour
相關用法
- PHP exp()用法及代碼示例
- d3.js d3.rgb()用法及代碼示例
- PHP ord()用法及代碼示例
- PHP Ds\Set add()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- p5.js arc()用法及代碼示例
- PHP Ds\Set first()用法及代碼示例
- PHP Ds\Set contains()用法及代碼示例
- p5.js pan()用法及代碼示例
- CSS rgb()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 p5.js | hour() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。