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

aspectRatio

readonly
get aspectRatio(): number

center

get center(): Vec

set center(v: Vec)

corners

readonly
get corners(): Vec[]

cornersAndCenter

readonly
get cornersAndCenter(): Vec[]

h

h: number

height

get height(): number

set height(n: number)

maxX

readonly
get maxX(): number

maxY

readonly
get maxY(): number

midX

readonly
get midX(): number

midY

readonly
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

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

size

readonly
get size(): Vec

w

w: number

width

get width(): number

set width(n: number)

x

x: number

y

y: number

Methods

Collides()

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

Parameters

NameDescription

A

B

Returns

boolean

Common()

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

Parameters

NameDescription

boxes

Box[]

Returns


Contains()

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

Parameters

NameDescription

A

B

Returns

boolean

ContainsPoint()

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

Parameters

NameDescription

A

B

margin

number

Returns

boolean

Equals()

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

Parameters

NameDescription

a

b

Returns

boolean

Expand()

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

Parameters

NameDescription

A

B

Returns


ExpandBy()

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

Parameters

NameDescription

A

n

number

Returns


From()

static
static From(box: BoxModel): Box

Parameters

NameDescription

box

Returns


FromCenter()

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

Parameters

NameDescription

center

size

Returns


FromPoints()

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

Parameters

NameDescription

points

Returns


Includes()

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

Parameters

NameDescription

A

B

Returns

boolean

Resize()

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

Parameters

NameDescription

box

handle

dx

number

dy

number

isAspectRatioLocked

boolean

Returns

{
  box: Box
  scaleX: number
  scaleY: number
}

Sides()

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

Parameters

NameDescription

A

inset

number

Returns

Vec[][]

ZeroFix()

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

Parameters

NameDescription

other

Returns


clone()

clone(): Box

collides()

collides(B: Box): boolean

Parameters

NameDescription

B

Returns

boolean

contains()

contains(B: Box): boolean

Parameters

NameDescription

B

Returns

boolean

containsPoint()

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

Parameters

NameDescription

V

margin

number

Returns

boolean

equals()

equals(other: Box | BoxModel): boolean

Parameters

NameDescription

other

Returns

boolean

expand()

expand(A: Box): this

Parameters

NameDescription

A

Returns

this

expandBy()

expandBy(n: number): this

Parameters

NameDescription

n

number

Returns

this

getHandlePoint()

getHandlePoint(handle: SelectionCorner | SelectionEdge): Vec

Parameters

NameDescription

handle

Returns


includes()

includes(B: Box): boolean

Parameters

NameDescription

B

Returns

boolean

resize()

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

Parameters

NameDescription

handle

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

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

Returns

this

union()

union(box: BoxModel): this

Parameters

NameDescription

box

Returns

this

zeroFix()

zeroFix(): this

Prev
BoundsSnaps
Next
Circle2d