p5.js ellipsoid() function
Last Updated :
11 Aug, 2023
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() {
createCanvas(600, 600, WEBGL);
}
function draw() {
background(200);
fill( 'green' );
ellipsoid(90, 75, 32, 12, 12);
}
|
Output:
Example 2: This example uses ellipsoid() function to draw an ellipsoid with given radius.
function setup() {
createCanvas(600, 600, WEBGL);
}
function draw() {
background(200);
fill( 'yellow' );
rotateX(frameCount * 0.01);
rotate(frameCount*0.03);
ellipsoid(190, 135, 130);
}
|
Output:
Reference: https://p5js.org/reference/#/p5/ellipsoid
Share your thoughts in the comments
Please Login to comment...