ellipse()

Ellipse - Draws an Ellipse with the given inputs

Example

ellipse(200, 200, 300, 150)

Syntax

ellipse(x, y, width, height)
InputDescription

x

x co-ordinate of the center

y

y co-ordinate of the center

width

width of the ellipse (length in x direction)

height

height of the ellipse (length in y direction)

Description

ellipse() draws an ellipse on the canvas, using the inputs to determine the position and dimension of the shape. The width and height of the ellipse must always be parallel to the x-axis and y-axis respectively - this can only be changed separately with a rotation.

Modes

By default, the x and y inputs refer to the center of the ellipse.

This can be changed using ellipseMode(), with an input of CENTER, CORNERS, CORNER, or RADIUS.

ellipseMode(CENTER)

This is the default mode. The code:

ellipse(x, y, width, height)

will use (x,y) as the center coordinates and width and height as the dimensions.

ellipseMode(CORNERS)

This mode is for specifying the coordinates of opposite corners of the ellipse's bounding box. The code:

ellipse(x1, y2, x2, y2)

ellipseMode(CORNER)

This mode is for specifying the corner of the ellipse's bounding box together with the width and height. The code:

ellipse(x, y, width, height)

will use (x,y) as the bottom left corner of the ellipse's bounding box and width and height as the dimensions.

ellipseMode(RADIUS)

This mode is for specifying the center of the ellipse together with half the width and half the height. The code:

ellipse(x, y, wRadius, hRadius)

will use (x,y) as the center coordinates and wRadius * 2 and hRadius * 2 as the dimensions.

Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!

We'd love to hear your Feedback/Comments here.

Last updated