Thursday, September 4, 2025
HomeLanguagesJavascriptp5.js ellipsoid() function

p5.js ellipsoid() function

The ellipsoid() function in p5.js is used to draw an ellipsoid with given radius.

Syntax:

ellipsoid( radiusX, radiusY, radiusZ, detailX, detailY )

Parameters: This function accepts five parameters as mentioned above and described below:

  • radiusX: This parameter stores the x-radius of the ellipsoid.
  • radiusY: This parameter stores the y-radius of the ellipsoid.
  • radiusZ: This parameter stores the z-radius of the ellipsoid.
  • detailX: This parameter stores the number of segments in x-dimension.
  • detailY: This parameter stores the number of segments in y-dimension.
  • Below programs illustrate the ellipsoid() function in p5.js:

    Example 1: This example uses ellipsoid() function to draw an ellipsoid with given radius.




    function setup() {
        
        // Create Canvas of size 600*600
        createCanvas(600, 600, WEBGL);
    }
       
    function draw() {
          
        // Set background color
        background(200);
         
        // Set fill color of ellipsoid
        fill('green');
         
        // Call to ellipsoid function
        ellipsoid(90, 75, 32, 12, 12);
    }

    
    

    Output:

    Example 2: This example uses ellipsoid() function to draw an ellipsoid with given radius.




    function setup() {
        
        // Create Canvas of size 600*600
        createCanvas(600, 600, WEBGL);
    }
       
    function draw() {
          
        // Set background color
        background(200);
         
        // Set fill color of ellipsoid
        fill('yellow');
         
        // Rotate 
        rotateX(frameCount * 0.01);
        rotate(frameCount*0.03);
         
        // Call to ellipsoid function
        ellipsoid(190, 135, 130);
    }

    
    

    Output:

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

    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
    6629 POSTS0 COMMENTS
    Nicole Veronica
    11799 POSTS0 COMMENTS
    Nokonwaba Nkukhwana
    11859 POSTS0 COMMENTS
    Shaida Kate Naidoo
    6749 POSTS0 COMMENTS
    Ted Musemwa
    7025 POSTS0 COMMENTS
    Thapelo Manthata
    6698 POSTS0 COMMENTS
    Umr Jansen
    6717 POSTS0 COMMENTS