Class: Anchor

Anchor(x, y)

An Anchor is a mutable 2D point that is used to locate pieces and pieces inserts

Constructor

new Anchor(x, y)

Parameters:
Name Type Description
x number
y number
Source:

Methods

(static) atRandom(maxX, maxY) → {Anchor}

Parameters:
Name Type Description
maxX number
maxY number
Source:
Returns:
Type
Anchor

(static) import(vector) → {Anchor}

Parameters:
Name Type Description
vector Vector
Source:
Returns:
Type
Anchor

asPair() → {Pair}

Converts this anchor into a point
Source:
Returns:
Type
Pair

asVector() → {Vector}

Converts this anchor into a vector
Source:
Returns:
Type
Vector

closeTo(other, tolerance) → {boolean}

Answers whether this Anchor is near to another given a tolerance
Parameters:
Name Type Description
other Anchor
tolerance number the max distance within its radius is considered to be "close"
Source:
Returns:
Type
boolean

copy() → {Anchor}

Source:
Returns:
Type
Anchor

diff(other) → {Pair}

Calculates the difference between this anchor and another
Parameters:
Name Type Description
other Anchor
Source:
Returns:
Type
Pair

equal(other) → {boolean}

Parameters:
Name Type Description
other Anchor
Source:
Returns:
Type
boolean

export() → {Vector}

Source:
Returns:
Type
Vector

isAt(x, y) → {boolean}

Parameters:
Name Type Description
x number
y number
Source:
Returns:
Type
boolean

translate(dx, dy)

Translates this anchor given to a vector
Parameters:
Name Type Description
dx number
dy number
Source:

translated(dx, dy) → {Anchor}

Creates a translated copy of this Anchor according to a vector
Parameters:
Name Type Description
dx number
dy number
Source:
Returns:
Type
Anchor