Name

ellipseMode()

Description

Modifies the location from which ellipses are drawn by changing the way in which parameters given to ellipse() are interpreted.

The default mode is ellipseMode(CENTER), which interprets the first two parameters of ellipse() as the shape's center point, while the third and fourth parameters are its width and height.

ellipseMode(RADIUS) also uses the first two parameters of ellipse() as the shape's center point, but uses the third and fourth parameters to specify half of the shape's width and height.

ellipseMode(CORNER) interprets the first two parameters of ellipse() as the upper-left corner of the shape, while the third and fourth parameters are its width and height.

ellipseMode(CORNERS) interprets the first two parameters of ellipse() as the location of one corner of the ellipse's bounding box, and the third and fourth parameters as the location of the opposite corner.

The parameter must be written in ALL CAPS because Processing is a case-sensitive language.

Examples

  • size(400, 400);
    
    ellipseMode(RADIUS);  // Set ellipseMode to RADIUS
    fill(255);  // Set fill to white
    ellipse(200, 200, 120, 120);  // Draw white ellipse using RADIUS mode
    
    ellipseMode(CENTER);  // Set ellipseMode to CENTER
    fill(100);  // Set fill to gray
    ellipse(200, 200, 120, 120);  // Draw gray ellipse using CENTER mode
    Image output for example 1
  • size(400, 400);
    
    ellipseMode(CORNER);  // Set ellipseMode is CORNER
    fill(255);  // Set fill to white
    ellipse(100, 100, 200, 200);  // Draw white ellipse using CORNER mode
    
    ellipseMode(CORNERS);  // Set ellipseMode to CORNERS
    fill(100);  // Set fill to gray
    ellipse(100, 100, 200, 200);  // Draw gray ellipse using CORNERS mode
    Image output for example 2

Syntax

  • ellipseMode(mode)

Parameters

  • mode(int)either CENTER, RADIUS, CORNER, or CORNERS

Return

  • void
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.