Table of contents
class Box {}

Constructor

Constructs a new instance of the Box class

Parameters
NameDescription

x

number

y

number

w

number

h

number

Properties

Collides

static Collides: (A: Box, B: Box) => boolean

Common

static Common: (boxes: Box[]) => Box

Contains

static Contains: (A: Box, B: Box) => boolean

ContainsPoint

static ContainsPoint: (A: Box, B: VecLike, margin?: number) => boolean

Includes

static Includes: (A: Box, B: Box) => boolean

Sides

static Sides: (A: Box, inset?: number) => Vec[][]

aspectRatio

get aspectRatio(): number

center

get center(): Vec

set center(v: Vec)

corners

get corners(): Vec[]

cornersAndCenter

get cornersAndCenter(): Vec[]

h

h: number

height

get height(): number

set height(n: number)

maxX

get maxX(): number

maxY

get maxY(): number

midX

get midX(): number

midY

get midY(): number

minX

get minX(): number

set minX(n: number)

minY

get minY(): number

set minY(n: number)

point

get point(): Vec

set point(val: Vec)

sides

get sides(): Array<[Vec, Vec]>

size

get size(): Vec

w

w: number

width

get width(): number

set width(n: number)

x

x: number

y

y: number

Methods

Equals()

static Equals(a: Box | BoxModel, b: Box | BoxModel): boolean
Parameters
NameDescription

a

Box | BoxModel

b

Box | BoxModel
Returns
boolean

Expand()

static Expand(A: Box, B: Box): Box
Parameters
NameDescription

A

Box

B

Box
Returns
Box

ExpandBy()

static ExpandBy(A: Box, n: number): Box
Parameters
NameDescription

A

Box

n

number
Returns
Box

From()

static From(box: BoxModel): Box
Parameters
NameDescription

box

BoxModel
Returns
Box

FromCenter()

static FromCenter(center: VecLike, size: VecLike): Box
Parameters
NameDescription

center

VecLike

size

VecLike
Returns
Box

FromPoints()

static FromPoints(points: VecLike[]): Box
Parameters
NameDescription

points

VecLike[]
Returns
Box

Resize()

static Resize(
  box: Box,
  handle: SelectionCorner | SelectionEdge | string,
  dx: number,
  dy: number,
  isAspectRatioLocked?: boolean
): {
  box: Box
  scaleX: number
  scaleY: number
}
Parameters
NameDescription

box

Box

handle

SelectionCorner | SelectionEdge | string

dx

number

dy

number

isAspectRatioLocked

boolean
Returns
{
  box: Box
  scaleX: number
  scaleY: number
}

ZeroFix()

static ZeroFix(other: Box | BoxModel): Box
Parameters
NameDescription

other

Box | BoxModel
Returns
Box

clone()

clone(): Box

collides()

collides(B: Box): boolean
Parameters
NameDescription

B

Box
Returns
boolean

contains()

contains(B: Box): boolean
Parameters
NameDescription

B

Box
Returns
boolean

containsPoint()

containsPoint(V: VecLike, margin?: number): boolean
Parameters
NameDescription

V

VecLike

margin

number
Returns
boolean

equals()

equals(other: Box | BoxModel): boolean
Parameters
NameDescription

other

Box | BoxModel
Returns
boolean

expand()

expand(A: Box): this
Parameters
NameDescription

A

Box
Returns
this

expandBy()

expandBy(n: number): this
Parameters
NameDescription

n

number
Returns
this

getHandlePoint()

getHandlePoint(handle: SelectionCorner | SelectionEdge): Vec
Parameters
NameDescription

handle

SelectionCorner | SelectionEdge
Returns
Vec

includes()

includes(B: Box): boolean
Parameters
NameDescription

B

Box
Returns
boolean

resize()

resize(
  handle: SelectionCorner | SelectionEdge | string,
  dx: number,
  dy: number
): void
Parameters
NameDescription

handle

SelectionCorner | SelectionEdge | string

dx

number

dy

number
Returns
void

scale()

scale(n: number): this
Parameters
NameDescription

n

number
Returns
this

set()

set(x?: number, y?: number, w?: number, h?: number): this
Parameters
NameDescription

x

number

y

number

w

number

h

number
Returns
this

setTo()

setTo(B: Box): this
Parameters
NameDescription

B

Box
Returns
this

snapToGrid()

snapToGrid(size: number): void
Parameters
NameDescription

size

number
Returns
void

toFixed()

toFixed(): this

toJson()

toJson(): BoxModel

translate()

translate(delta: VecLike): this
Parameters
NameDescription

delta

VecLike
Returns
this

union()

union(box: BoxModel): this
Parameters
NameDescription

box

BoxModel
Returns
this

zeroFix()

zeroFix(): this

BoundsSnapsCircle2d