Geometry~ Point

A point in 2D space

Constructor

new Point(x, y)

Creates a new Point
Parameters:
NameTypeDescription
xnumberThe x coordinate. (Can be any number from 0 to process.stdout.columns)
ynumberThe y coordinate. (Can be any number from 0 to process.stdout.rows)
Throws:
If the arguments are invalid or out of bounds
Type
Error
Example
// Create a new point at (10, 10)
const point = new Point(10, 10);

Members

x :number

The x coordinate
Type:
  • number

y :number

The y coordinate
Type:
  • number

Methods

equals(x, yopt) → {boolean}

Determines whether or not the point is equal to another point
Parameters:
NameTypeAttributesDescription
xPointLikeThe point to compare to, or the x coordinate
ynumber<optional>
The y coordinate
Returns:
Whether or not the points are equal
Type: 
boolean

transform(matrix)

Transforms the point by the given matrix
Parameters:
NameTypeDescription
matrixMatrixThe matrix to transform the point by

(static) center() → {Point}

Creates a new point at the center of the terminal
Returns:
The center point
Type: 
Point

(static) centerFor(x, yopt) → {Point}

Parameters:
NameTypeAttributesDescription
xPointLikeThe point or size to center, or the x coordinate
ynumber<optional>
The y coordinate
Returns:
Type: 
Point

(static) inBounds(px, yopt) → {boolean}

Determines whether or not the given point is within the bounds of the terminal
Parameters:
NameTypeAttributesDescription
pxPointLikeThe point or size to check, or the x coordinate
ynumber<optional>
The y coordinate
Throws:
If the arguments are invalid
Type
Error
Returns:
Whether or not the point is within the bounds of the terminal
Type: 
boolean

(static) of(psx, yopt) → {Point}

Creates a new point from the given point, size, array, or coordinates
Parameters:
NameTypeAttributesDescription
psxPoint | Size | number | Array.<number> | ObjectThe point or size to create a new point from, or the x coordinate
ynumber<optional>
The y coordinate
Returns:
The new point
Type: 
Point

(static) zero() → {Point}

Creates a new point at (0, 0)
Returns:
A new point at (0, 0)
Type: 
Point