p5.js Constants PI
Last Updated :
16 Aug, 2023
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() {
createCanvas(880, 300);
}
function draw() {
background(220);
stroke(255, 204, 0);
strokeWeight(4);
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...