Class: Point

Point()

Point class. Represents a point defined by its X and Y coordinates.

Constructor

new Point()

Properties:
Name Type Description
x number

X coordinate

y number

Y coordinate

Source:

Classes

Point

Methods

(static) average(…points) → {Point}

Calculates average position of multiple points

Parameters:
Name Type Attributes Description
points Point <repeatable>

Points to average

Source:
Returns:

Average point

Type
Point

add(other) → {Point}

Returns new point resulting from addition of this and other point.

Parameters:
Name Type Description
other Point

Other point

Source:
Returns:

Resulting Point from addition

Type
Point

asArray() → {Array.<number>}

Returns coordinates in array format

Source:
Returns:

Array in format [x,y]

Type
Array.<number>

asString() → {string}

Returns coordinates in string format

Source:
Returns:

Coordinates of the point

Type
string

copy() → {Point}

Returns a copy of this instance

Source:
Returns:

New instance of Point

Type
Point

distanceTo(other) → {number}

Returns distance between the two points

Parameters:
Name Type Description
other Point

2nd Point

Source:
Returns:

Distance between the points

Type
number

rotateAround(origin, angle) → {Point}

Returns new Point resulting from rotating this point around a point of origin by angle

Parameters:
Name Type Description
origin Point

Origin point (around which is this one rotated)

angle number

Angle in radians

Source:
Returns:

New instance of Point resulting from the rotation

Type
Point

subtract(other) → {Point}

Returns new point resulting from subtraction of this and other point.

Parameters:
Name Type Description
other Point

Other point

Source:
Returns:

Resulting Point from subtraction

Type
Point

xWithin(left, right) → {boolean}

Checks if point is between 2 values on X axis

Parameters:
Name Type Description
left number

Lower value

right number

Higher value

Source:
Returns:

Is within values

Type
boolean

yWithin(top, bottom) → {boolean}

Checks if point is between 2 values on Y axis

Parameters:
Name Type Description
top number

Lower value

bottom number

Higher value

Source:
Returns:

Is within values

Type
boolean