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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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);
     

chevron_right


Output:

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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);
     

chevron_right


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



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.