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)

Name Type Default Description
x number 0 optional

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

y number 0 optional

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

width number 0 optional

The overall width of this rectangle

height number 0 optional

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)

Enlarges rectangle that way its corners lie on grid

Name Type Default Description
resolution number 1 optional

resolution

eps number 0.001 optional

precision

Creates a clone of this Rectangle

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

contains (x, y)boolean

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

copy () Deprecated : since 5.0.0

See:

copyFrom (rectangle)PIXI.Rectangle

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

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)

Enlarges this rectangle to include the passed rectangle.

Name Type Description
rectangle PIXI.Rectangle

The rectangle to include.

fit (rectangle)

Fits this rectangle around the passed one.

Name Type Description
rectangle PIXI.Rectangle

The rectangle to fit.

pad (paddingX, paddingY)

Pads the rectangle making it grow in all directions.

Name Type Description
paddingX number

The horizontal padding amount.

paddingY number

The vertical padding amount.