Table of contents

Public class

Signature
class Box {}
Source

packages/editor/src/lib/primitives/Box.ts


Constructor

Public constructor

Constructs a new instance of the Box class

Parameters
NameDescription

x

number

y

number

w

number

h

number

Properties

aspectRatio

Public readonly property

Signature
get aspectRatio(): number

center

Public property

Signature
get center(): Vec

set center(v: Vec)
References

Vec


Collides

Public static property

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

Box


Common

Public static property

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

Box


Contains

Public static property

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

Box


ContainsPoint

Public static property

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

Box, VecLike


corners

Public readonly property

Signature
get corners(): Vec[]
References

Vec


cornersAndCenter

Public readonly property

Signature
get cornersAndCenter(): Vec[]
References

Vec


h

Public property

Signature
h: number

height

Public property

Signature
get height(): number

set height(n: number)

Includes

Public static property

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

Box


maxX

Public readonly property

Signature
get maxX(): number

maxY

Public readonly property

Signature
get maxY(): number

midX

Public readonly property

Signature
get midX(): number

midY

Public readonly property

Signature
get midY(): number

minX

Public property

Signature
get minX(): number

set minX(n: number)

minY

Public property

Signature
get minY(): number

set minY(n: number)

point

Public property

Signature
get point(): Vec

set point(val: Vec)
References

Vec


sides

Public readonly property

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

Vec


Sides

Public static property

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

Box, Vec


size

Public readonly property

Signature
get size(): Vec
References

Vec


w

Public property

Signature
w: number

width

Public property

Signature
get width(): number

set width(n: number)

x

Public property

Signature
x: number

y

Public property

Signature
y: number

Methods

clone()

Public method

Signature
clone(): Box
References

Box


collides()

Public method

Signature
collides(B: Box): boolean
Parameters
NameDescription

B

Box
Returns
boolean
References

Box


contains()

Public method

Signature
contains(B: Box): boolean
Parameters
NameDescription

B

Box
Returns
boolean
References

Box


containsPoint()

Public method

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

V

VecLike

margin

number
Returns
boolean
References

VecLike


equals()

Public method

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

other

Box | BoxModel
Returns
boolean
References

Box, BoxModel


Equals()

Public static method

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

a

Box | BoxModel

b

Box | BoxModel
Returns
boolean
References

Box, BoxModel


expand()

Public method

Signature
expand(A: Box): this
Parameters
NameDescription

A

Box
Returns
this
References

Box


Expand()

Public static method

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

A

Box

B

Box
Returns
Box
References

Box


expandBy()

Public method

Signature
expandBy(n: number): this
Parameters
NameDescription

n

number
Returns
this

ExpandBy()

Public static method

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

A

Box

n

number
Returns
Box
References

Box


From()

Public static method

Signature
static From(box: BoxModel): Box
Parameters
NameDescription

box

BoxModel
Returns
Box
References

BoxModel, Box


FromCenter()

Public static method

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

center

VecLike

size

VecLike
Returns
Box
References

VecLike, Box


FromPoints()

Public static method

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

points

VecLike[]
Returns
Box
References

VecLike, Box


getHandlePoint()

Public method

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

handle

SelectionCorner | SelectionEdge
Returns
Vec
References

SelectionCorner, SelectionEdge, Vec


includes()

Public method

Signature
includes(B: Box): boolean
Parameters
NameDescription

B

Box
Returns
boolean
References

Box


resize()

Public method

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

handle

SelectionCorner | SelectionEdge | string

dx

number

dy

number
Returns
void
References

SelectionCorner, SelectionEdge


Resize()

Public static method

Signature
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
}
References

Box, SelectionCorner, SelectionEdge


scale()

Public method

Signature
scale(n: number): this
Parameters
NameDescription

n

number
Returns
this

set()

Public method

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

x

number

y

number

w

number

h

number
Returns
this

setTo()

Public method

Signature
setTo(B: Box): this
Parameters
NameDescription

B

Box
Returns
this
References

Box


snapToGrid()

Public method

Signature
snapToGrid(size: number): void
Parameters
NameDescription

size

number
Returns
void

toFixed()

Public method

Signature
toFixed(): this

toJson()

Public method

Signature
toJson(): BoxModel
References

BoxModel


translate()

Public method

Signature
translate(delta: VecLike): this
Parameters
NameDescription

delta

VecLike
Returns
this
References

VecLike


union()

Public method

Signature
union(box: BoxModel): this
Parameters
NameDescription

box

BoxModel
Returns
this
References

BoxModel


zeroFix()

Public method

Signature
zeroFix(): this

ZeroFix()

Public static method

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

other

Box | BoxModel
Returns
Box
References

Box, BoxModel


BoundsSnapPointBoxLike