Class: Rectangle

PIXI.Rectangle

Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its width and its height.

new PIXI.Rectangle (x, y, width, height)

Rectangle.ts:30
Name Type Attributes Default Description
x number <optional>
0

The X coordinate of the upper-left corner of the rectangle

y number <optional>
0

The Y coordinate of the upper-left corner of the rectangle

width number <optional>
0

The overall width of this rectangle

height number <optional>
0

The overall height of this rectangle

Members

PIXI.Rectangle.EMPTY PIXI.Rectangle static

A constant empty rectangle.

bottom number

returns the bottom edge of the rectangle

height number

Default Value:
  • 0

left number

returns the left edge of the rectangle

returns the right edge of the rectangle

top number

returns the top edge of the rectangle

type number readonly

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

Default Value:
  • PIXI.SHAPES.RECT
See:

width number

Default Value:
  • 0

x number

Default Value:
  • 0

y number

Default Value:
  • 0

Methods

ceil (resolution, eps) PIXI.Rectangle

Rectangle.ts:233

Enlarges rectangle that way its corners lie on grid

Name Type Attributes Default Description
resolution number <optional>
1

resolution

eps number <optional>
0.001

precision

Returns:
Type Description
PIXI.Rectangle Returns itself.

clone () PIXI.Rectangle

Rectangle.ts:126

Creates a clone of this Rectangle

Returns:
Type Description
PIXI.Rectangle a copy of the rectangle

contains (x, y) boolean

Rectangle.ts:168

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

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 coordinates are within this Rectangle

containsRect (other) boolean

rectangleExtras.ts:32

Determines whether the other Rectangle is contained within this Rectangle object. Rectangles that occupy the same space are considered to be containing each other. Rectangles without area (width or height equal to zero) can't contain anything, not even other arealess rectangles.

Note: Only available with @pixi/math-extras.

Name Type Description
other Rectangle

The Rectangle to fit inside this.

Returns:
Type Description
boolean A value of true if this Rectangle contains other; otherwise false.

copyFrom (rectangle) PIXI.Rectangle

Rectangle.ts:136

Copies another rectangle to this one.

Name Type Description
rectangle PIXI.Rectangle

The rectangle to copy from.

Returns:
Type Description
PIXI.Rectangle Returns itself.

copyTo (rectangle) PIXI.Rectangle

Rectangle.ts:152

Copies this rectangle to another one.

Name Type Description
rectangle PIXI.Rectangle

The rectangle to copy to.

Returns:
Type Description
PIXI.Rectangle Returns given parameter.

enlarge (rectangle) PIXI.Rectangle

Rectangle.ts:254

Enlarges this rectangle to include the passed rectangle.

Name Type Description
rectangle PIXI.Rectangle

The rectangle to include.

Returns:
Type Description
PIXI.Rectangle Returns itself.

equals (other) boolean

rectangleExtras.ts:55

Accepts other Rectangle and returns true if the given Rectangle is equal to this Rectangle.

Note: Only available with @pixi/math-extras.

Name Type Description
other Rectangle

The Rectangle to compare with this

Returns:
Type Description
boolean Returns true if all x, y, width, and height are equal.

fit (rectangle) PIXI.Rectangle

Rectangle.ts:212

Fits this rectangle around the passed one.

Name Type Description
rectangle PIXI.Rectangle

The rectangle to fit.

Returns:
Type Description
PIXI.Rectangle Returns itself.

intersects (other) boolean

rectangleExtras.ts:3

Determines whether the other Rectangle intersects with this Rectangle object. Returns true only if the area of the intersection is >0, this means that Rectangles sharing a side are not overlapping. Another side effect is that an arealess rectangle (width or height equal to zero) can't intersect any other rectangle.

Note: Only available with @pixi/math-extras.

Name Type Description
other Rectangle

The Rectangle to intersect with this.

Returns:
Type Description
boolean A value of true if the other Rectangle intersects with this; otherwise false.

intersects (other, outRect) Rectangle

rectangleExtras.ts:75

If the area of the intersection between the Rectangles other and this is not zero, returns the area of intersection as a Rectangle object. Otherwise, return an empty Rectangle with its properties set to zero. Rectangles without area (width or height equal to zero) can't intersect or be intersected and will always return an empty rectangle with its properties set to zero.

Note: Only available with @pixi/math-extras.

Name Type Attributes Description
other Rectangle

The Rectangle to intersect with this.

outRect Rectangle <optional>

A Rectangle object in which to store the value, optional (otherwise will create a new Rectangle).

Returns:
Type Description
Rectangle The intersection of this and other.

intersects (other, outRect) Rectangle

rectangleExtras.ts:126

Adds this and other Rectangles together to create a new Rectangle object filling the horizontal and vertical space between the two rectangles.

Note: Only available with @pixi/math-extras.

Name Type Attributes Description
other Rectangle

The Rectangle to unite with this.

outRect Rectangle <optional>

A Rectangle object in which to store the value, optional (otherwise will create a new Rectangle).

Returns:
Type Description
Rectangle The union of this and other.

pad (paddingX, paddingY) PIXI.Rectangle

Rectangle.ts:193

Pads the rectangle making it grow in all directions. If paddingY is omitted, both paddingX and paddingY will be set to paddingX.

Name Type Attributes Default Description
paddingX number <optional>
0

The horizontal padding amount.

paddingY number <optional>
0

The vertical padding amount.

Returns:
Type Description
PIXI.Rectangle Returns itself.