Class: Point

Point

new Point(x, y)

This object represents a single point in an abstract 2-dimensional matrix.

The unit of measure is typically pixels. (If used to model computer graphics, vertical coordinates are typically measured downwards from the top of the window. This convention however is not inherent in this object.)

Note: This object should be instantiated with the new keyword.

Parameters:
Name Type Description
x number

the new point's x property

y number

the new point's y property

Members

(abstract) x :number

This point's horizontal coordinate.

Created upon instantiation by the constructor.

Type:
  • number

(abstract) y :number

This point's vertical coordinate.

Created upon instantiation by the constructor.

Type:
  • number

Methods

distance(point) → {number}

Parameters:
Name Type Description
point Point

A point from which to compute the distance to this point.

Returns:

Distance between given point and this point using Pythagorean Theorem formula.

Type
number

equals(point) → {boolean}

(Formerly: equal.)

Parameters:
Name Type Description
point Point

A point to compare to this point.

Returns:

true iff both coordinates of this point are exactly equal to those of given point.

Type
boolean

greaterThan(point) → {boolean}

Parameters:
Name Type Description
point Point

A point to compare to this point

Returns:

true iff both coordinates of this point are greater than those of given point.

Type
boolean

greaterThanOrEqualTo(point) → {boolean}

(Formerly greaterThanEqualTo.)

Parameters:
Name Type Description
point Point

A point to compare to this point

Returns:

true iff both coordinates of this point are greater than or equal to those of given point.

Type
boolean

lessThan(point) → {boolean}

Parameters:
Name Type Description
point Point

A point to compare to this point

Returns:

true iff both coordinates of this point are less than those of given point.

Type
boolean

lessThanOrEqualTo(point) → {boolean}

(Formerly lessThanEqualTo.)

Parameters:
Name Type Description
point Point

A point to compare to this point.

Returns:

true iff both coordinates of this point are less than or equal to those of given point.

Type
boolean

max(point) → {Point}

Parameters:
Name Type Description
point Point

A point to compare to this point.

Returns:

A new Point positioned to greatest x and greatest y of this point and given point.

Type
Point

min(point) → {Point}

Parameters:
Name Type Description
point Point

A point to compare to this point.

Returns:

A new Point positioned to least x and least y of this point and given offset.

Type
Point

minus(offset) → {Point}

Parameters:
Name Type Description
offset Point

Horizontal and vertical values to subtract from this point's coordinates.

Returns:

A new point which is this point's position decreased by coordinates of given offset.

Type
Point

plus(offset) → {Point}

Parameters:
Name Type Description
offset Point

Horizontal and vertical values to add to this point's coordinates.

Returns:

A new point which is this point's position increased by coordinates of given offset.

Type
Point

plusXY(offsetXopt, offsetYopt) → {Point}

Parameters:
Name Type Attributes Default Description
offsetX number <optional>
0

Value to add to this point's horizontal coordinate.

offsetY number <optional>
0

Value to add to this point's horizontal coordinate.

Returns:

A new point which is this point's position increased by given offsets.

Type
Point

within(rect) → {boolean}

(Formerly isContainedWithinRectangle.)

Parameters:
Name Type Description
rect Rectangle

Rectangle to test this point against.

Returns:

true iff this point is within given rect.

Type
boolean