📜  p5.js |常数 | PI

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

p5.js |常数 | PI

PI是一个数学常数,值为 3.14159265358979323846。它是圆周与其直径的比值。
句法

PI

下面的程序说明了 PI 在 p5.js 中的用法:

例子:

function setup() {
    
    //create Canvas of size 880*200  
    createCanvas(880, 300);
}
  
function draw() {
    
    //Set the background Color
    background(220);
    
    //Set the stroke color
    stroke(255, 204, 0);
    
    //Set the stroke weight
    strokeWeight(4);
    
    //Use of constant PI
    arc(50, 50, 280, 280, 0, PI / 2); 
    noStroke();
    textSize(20);
    text("Value of PI is " + PI, 30, 250);
}

输出:

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