ellipseMode()

Examples

ellipseMode() example
void draw() {
  background(255);
  stroke(0);

  ellipseMode(RADIUS);  // Set ellipseMode to RADIUS
  fill(255);  // Set fill to white
  ellipse(50, 50, 30, 30);  // Draw white ellipse using RADIUS mode

  ellipseMode(CENTER);  // Set ellipseMode to CENTER
  fill(0);  // Set fill to black
  ellipse(50, 50, 30, 30);  // Draw black ellipse using CENTER mode

  ellipseMode(CORNER);  // Set ellipseMode is CORNER
  fill(255);  // Set fill to white
  ellipse(50, 50, 50, 50);  // Draw white ellipse using CORNER mode

  line(50, 0, 50, sketchHeight);
  line(0, 50, sketchWidth, 50);
}

Description

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

The default mode is ellipseMode(CENTER), which interprets the first two parameters of ellipse() or circle() 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() or circle() 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() or circle() as the upper-left corner of the shape, while the third and fourth parameters are its width and height.

With Pebcessing, it's not possible to use CORNERS unlike Processing.

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

Syntax

ellipseMode(mode)

Parameters

mode int: either CENTER, RADIUS, CORNER

Returns

void

Related

circle()
ellipse()

Back to index