Friday, September 19, 2025
HomeLanguagesJavascriptp5.js ellipseMode() Function

p5.js ellipseMode() Function

The ellipseMode() function is an inbuilt function in p5.js which is used to set the location where the ellipses are drawn by changing the way. The default mode of this function is ellipseMode(CENTER).

Syntax:

ellipseMode( mode )

Parameters: This function accepts single parameter as mentioned above and described below:

  • mode: This parameter contains different mode constant those are case sensitive so must use it in capital letter.The modes are CENTER, RADIUS, CORNER or CORNERS.

Example 1:




function setup() { 
       
    // Create Canvas of given size 
    createCanvas(300, 300); 
   
} 
   
function draw() { 
       
    background(220);
       
    // Set ellipseMode to RADIUS
    ellipseMode(CORNER);
      
    // Fill color
    fill('green');
    
    // Draw the ellipse
    ellipse(150, 150, 100, 100);
  
    // Set ellipseMode to CENTER
    ellipseMode(CONRNERS); 
      
    // Fill color
    fill("white");
      
    // Draw the ellipse
    ellipse(50, 50, 50, 50);
     
} 


Output:

Example 2:




function setup() { 
       
    // Create Canvas of given size 
    createCanvas(300, 300); 
   
} 
   
function draw() { 
       
    background(220);
       
    // Set ellipseMode to RADIUS
    ellipseMode(RADIUS);
      
    // Fill color
    fill('green');
    
    // Draw the ellipse
    ellipse(150, 150, 100, 100);
  
    // Set ellipseMode to CENTER
    ellipseMode(CENTER); 
      
    // Fill color
    fill("white");
      
    // Draw the ellipse
    ellipse(150, 150, 50, 50);
     
} 


Output:

Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/

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

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
32301 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6666 POSTS0 COMMENTS
Nicole Veronica
11840 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11898 POSTS0 COMMENTS
Shaida Kate Naidoo
6781 POSTS0 COMMENTS
Ted Musemwa
7056 POSTS0 COMMENTS
Thapelo Manthata
6739 POSTS0 COMMENTS
Umr Jansen
6745 POSTS0 COMMENTS