Skip to content
Related Articles
Open in App
Not now

Related Articles

p5.js | Constants | PI

Improve Article
Save Article
  • Last Updated : 10 Apr, 2019
Improve Article
Save Article

The PI is a mathematical constant with the value 3.14159265358979323846. It is the circumference’s ratio of a circle to its diameter.
Syntax

PI

Below program illustrates the usage of PI in p5.js:

Example:




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);
}


Output:

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!