當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


p5.js getURL()用法及代碼示例

p5.j​​s中的getURL()函數用於返回當前URL。

用法:

getURL()

參數:該函數不接受任何參數。


返回值:它返回當前的URL字符串。

以下示例程序旨在說明p5.js中的getURL()函數:

例:

// Declare a URL variable 
let url; 
  
// Function to set the height and 
// width of window 
function setup() { 
    createCanvas(350, 200); 
      
    // Use getURL() function to 
    // get the current URL 
    url = getURL(); 
} 
   
function draw() { 
    
    // Set the background color 
    background(0, 200, 0); 
      
    // Set the font-size 
    textSize(30); 
    
    // Set the text alignment 
    textAlign(LEFT); 
    
    text(url, 100, height / 2); 
}

輸出:

參考: https://p5js.org/reference/#/p5/getURL



相關用法


注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 p5.js | getURL() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。