Table of contents

Public class

Signature
class Box2d {}
Source

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


Constructor

Public constructor

Constructs a new instance of the Box2d 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(): Vec2d

set center(v: Vec2d)
References

Vec2d


Collides

Public static property

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

Box2d


Common

Public static property

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

Box2d


Contains

Public static property

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

Box2d


ContainsPoint

Public static property

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

Box2d, VecLike


corners

Public readonly property

Signature
get corners(): Vec2d[]
References

Vec2d


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: Box2d, B: Box2d) => boolean
References

Box2d


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(): Vec2d

set point(val: Vec2d)
References

Vec2d


sides

Public readonly property

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

Vec2d


Sides

Public static property

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

Box2d, Vec2d


size

Public readonly property

Signature
get size(): Vec2d
References

Vec2d


snapPoints

Public readonly property

Signature
get snapPoints(): Vec2d[]
References

Vec2d


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(): Box2d
References

Box2d


collides()

Public method

Signature
collides(B: Box2d): boolean
Parameters
NameDescription

B

Box2d
Returns
boolean
References

Box2d


contains()

Public method

Signature
contains(B: Box2d): boolean
Parameters
NameDescription

B

Box2d
Returns
boolean
References

Box2d


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: Box2d | Box2dModel): boolean
Parameters
NameDescription

other

Box2d | Box2dModel
Returns
boolean
References

Box2d, Box2dModel


Equals()

Public static method

Signature
static Equals(a: Box2d | Box2dModel, b: Box2d | Box2dModel): boolean
Parameters
NameDescription

a

Box2d | Box2dModel

b

Box2d | Box2dModel
Returns
boolean
References

Box2d, Box2dModel


expand()

Public method

Signature
expand(A: Box2d): this
Parameters
NameDescription

A

Box2d
Returns
this
References

Box2d


Expand()

Public static method

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

A

Box2d

B

Box2d
Returns
Box2d
References

Box2d


expandBy()

Public method

Signature
expandBy(n: number): this
Parameters
NameDescription

n

number
Returns
this

ExpandBy()

Public static method

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

A

Box2d

n

number
Returns
Box2d
References

Box2d


From()

Public static method

Signature
static From(box: Box2dModel): Box2d
Parameters
NameDescription

box

Box2dModel
Returns
Box2d
References

Box2dModel, Box2d


FromPoints()

Public static method

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

points

VecLike[]
Returns
Box2d
References

VecLike, Box2d


getHandlePoint()

Public method

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

handle

SelectionCorner | SelectionEdge
Returns
Vec2d
References

SelectionCorner, SelectionEdge, Vec2d


includes()

Public method

Signature
includes(B: Box2d): boolean
Parameters
NameDescription

B

Box2d
Returns
boolean
References

Box2d


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: Box2d,
  handle: SelectionCorner | SelectionEdge | string,
  dx: number,
  dy: number,
  isAspectRatioLocked?: boolean
): {
  box: Box2d
  scaleX: number
  scaleY: number
}
Parameters
NameDescription

box

Box2d

handle

SelectionCorner | SelectionEdge | string

dx

number

dy

number

isAspectRatioLocked

boolean
Returns
{
  box: Box2d
  scaleX: number
  scaleY: number
}
References

Box2d, 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: Box2d): this
Parameters
NameDescription

B

Box2d
Returns
this
References

Box2d


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(): Box2dModel
References

Box2dModel


translate()

Public method

Signature
translate(delta: VecLike): this
Parameters
NameDescription

delta

VecLike
Returns
this
References

VecLike


union()

Public method

Signature
union(box: Box2dModel): this
Parameters
NameDescription

box

Box2dModel
Returns
this
References

Box2dModel


zeroFix()

Public method

Signature
zeroFix(): this

ZeroFix()

Public static method

Signature
static ZeroFix(other: Box2d | Box2dModel): Box2d
Parameters
NameDescription

other

Box2d | Box2dModel
Returns
Box2d
References

Box2d, Box2dModel


BaseBoxShapeUtilcanonicalizeRotation