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:
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