Friday, September 5, 2025
HomeLanguagesJavascriptp5.js Constants TWO_PI

p5.js Constants TWO_PI

The TWO_PI is a mathematical constant with the value 6.28318530717958647693. It is twice the ratio of the circumference of a circle to its diameter.

Syntax:

TWO_PI

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

Example:




function setup() {
      
    // Create Canvas of size 880*300  
    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);
   
    // Draw Arc
    // Use of constant TWO_PI
    arc(180, 50, 280, 280, 0, TWO_PI/2);
   
    // Unset the stroke
    noStroke();
   
    // Set the text size
    textSize(20);
      
    // Display output
    text("Value of TWO_PI is "+ TWO_PI, 30, 230);
}


Output:

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS