Class Point

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(x: number, y: number, round?: boolean): Point

Creates a Point object with the given x and y coordinates. If optional round is set to true, rounds the x and y values.

Parameters

  • x: number
  • y: number
  • round?: boolean optional

Returns

Point

Properties

public x: number

The x coordinate.

public y: number

The y coordinate.

Methods

public add(otherPoint: Point): Point

Returns the result of addition of the current and the given points.

Parameters

Returns

Point

public clone(): Point

Returns a copy of the current point.

Returns

Point

public distanceTo(otherPoint: Point): number

Returns the distance between the current and the given points.

Parameters

Returns

number

public divideBy(number: number, round?: boolean): Point

Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result.

Parameters

  • number: number
  • round?: boolean optional

Returns

Point

public equals(otherPoint: Point): boolean

Returns true if the given point has the same coordinates.

Parameters

Returns

boolean

public multiplyBy(number: number): Point

Returns the result of multiplication of the current point by the given number.

Parameters

  • number: number

Returns

Point

public round(): Point

Returns a copy of the current point with rounded coordinates.

Returns

Point

public subtract(otherPoint: Point): Point

Returns the result of subtraction of the given point from the current.

Parameters

Returns

Point

public toString(): string

Returns a string representation of the point for debugging purposes.

Returns

string