Saturday, October 11, 2025
HomeLanguagesJavascriptp5.js Constants HALF_PI

p5.js Constants HALF_PI

The HALF_PI is a mathematical constant and its value is 1.57079632679489661923. The HALF_PI is the half ratio of the circumference of a circle to its diameter.

Syntax:

HALF_PI

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

Example:




function setup() {
  
    // Create Canvas of size 300*200
    createCanvas(300, 200);
}
  
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 HALF_PI
    arc(50, 50, 280, 280, 0, HALF_PI/2); 
      
    noStroke();
      
    // Set the font size
    textSize(20);
      
    // Display result
    text("Value of HALF_PI is "
            + HALF_PI, 30, 180);
}


Output:

Reference: https://p5js.org/reference/#/p5/HALF_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
32352 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6720 POSTS0 COMMENTS
Nicole Veronica
11885 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6840 POSTS0 COMMENTS
Ted Musemwa
7103 POSTS0 COMMENTS
Thapelo Manthata
6794 POSTS0 COMMENTS
Umr Jansen
6794 POSTS0 COMMENTS