Class: Ellipse

Ellipse

The Ellipse object is used to help draw graphics and can also be used to specify a hit area for containers.

import { Ellipse } from 'pixi.js';

const ellipse = new Ellipse(0, 0, 20, 10); // 40x20 rectangle
const isPointInEllipse = ellipse.contains(0, 0); // true

new Ellipse (x, y, halfWidth, halfHeight)

Name Type Default Description
x number 0

The X coordinate of the center of this ellipse

y number 0

The Y coordinate of the center of this ellipse

halfWidth number 0

The half width of this ellipse

halfHeight number 0

The half height of this ellipse

Implements

Members

halfHeight number

The half height of this ellipse

Default Value:
  • 0

halfWidth number

The half width of this ellipse

Default Value:
  • 0

type string readonly

The type of the object, mainly used to avoid instanceof checks

Default Value:
  • 'ellipse'

x number

The X coordinate of the center of this ellipse

Default Value:
  • 0

y number

The Y coordinate of the center of this ellipse

Default Value:
  • 0

Methods

clone () Ellipse

Creates a clone of this Ellipse instance

Returns:
Type Description
Ellipse A copy of the ellipse

contains (x, y) boolean

Checks whether the x and y coordinates given are contained within this ellipse

Name Type Description
x number

The X coordinate of the point to test

y number

The Y coordinate of the point to test

Returns:
Type Description
boolean Whether the x/y coords are within this ellipse

copyFrom (ellipse) this

Copies another ellipse to this one.

Name Type Description
ellipse Ellipse

The ellipse to copy from.

Returns:
Type Description
this Returns itself.

copyTo (ellipse) Ellipse

Copies this ellipse to another one.

Name Type Description
ellipse Ellipse

The ellipse to copy to.

Returns:
Type Description
Ellipse Returns given parameter.

getBounds (out) Rectangle

Returns the framing rectangle of the ellipse as a Rectangle object

Name Type Attributes Description
out Rectangle <optional>
Returns:
Type Description
Rectangle The framing rectangle

strokeContains (x, y, strokeWidth, alignment) boolean

Checks whether the x and y coordinates given are contained within this ellipse including stroke

Name Type Default Description
x number

The X coordinate of the point to test

y number

The Y coordinate of the point to test

strokeWidth number

The width of the line to check

alignment number 0.5

The alignment of the stroke

Returns:
Type Description
boolean Whether the x/y coords are within this ellipse