API Docs for: 1.4.0
Show:

Kiwi.Geom.Point Class

Defined in: src\geom\Point.ts:9
Module: Geom
Parent Module: Kiwi

Represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.

Constructor

Kiwi.Geom.Point

(
  • [x=0]
  • [y=0]
)

Defined in src\geom\Point.ts:9

Parameters:

  • [x=0] Number optional

    Position of this point on the x-axis.

  • [y=0] Number optional

    Position of this point on the y-axis.

Methods

add

(
  • toAdd
  • output
)
Kiwi.Geom.Point public

Adds the coordinates of another point to the coordinates of this point to create a new point.

Parameters:

Returns:

Kiwi.Geom.Point:

The new Point object.

addTo

(
  • x
  • y
)
Kiwi.Geom.Point public

Adds the given values to the coordinates of this point and returns it

Parameters:

  • x Number

    The amount to add to the x value of the point

  • y Number

    The amount to add to the x value of the point

Returns:

Kiwi.Geom.Point:

This Point object.

angleTo

(
  • target
)
Number public

Get the angle from this Point object to given Point object.

Parameters:

Returns:

Number:

angle to point

angleToXY

(
  • x
  • y
)
Number

Get the angle from this Point object to given X,Y coordinates.

Parameters:

  • x Number

    x value.

  • y Number

    y value.

Returns:

Number:

angle to point.

clamp

(
  • min
  • max
)
Kiwi.Geom.Point public

Clamps this Point object to be between the given min and max.

Parameters:

  • min Number

    The minimum value to clamp this Point to.

  • max Number

    The maximum value to clamp this Point to.

Returns:

Kiwi.Geom.Point:

This Point object.

clampX

(
  • min
  • max
)
Kiwi.Geom.Point public

Clamps the x value of this Point object to be between the given min and max

Parameters:

  • min Number

    The minimum value to clamp this Point to

  • max Number

    The maximum value to clamp this Point to

Returns:

Kiwi.Geom.Point:

This Point object.

clampY

(
  • min
  • max
)
Kiwi.Geom.Point public

Clamps the y value of this Point object to be between the given min and max

Parameters:

  • min Number

    The minimum value to clamp this Point to

  • max Number

    The maximum value to clamp this Point to

Returns:

Kiwi.Geom.Point:

This Point object.

clone

(
  • [output]
)
Kiwi.Geom.Point public

Creates a copy of this Point.

Parameters:

  • [output] Kiwi.Geom.Point optional

    Optional Point object. If given the values will be set into this object, otherwise a new Point object will be created.

Returns:

copyFrom

(
  • source
)
Kiwi.Geom.Point public

Copies the point data from the source Point object into this Point object.

Parameters:

Returns:

Kiwi.Geom.Point:

This Point object. Useful for chaining method calls.

copyTo

(
  • target
)
Kiwi.Geom.Point public

Copies the point data from this Point object to the given target Point object.

Parameters:

Returns:

Kiwi.Geom.Point:

The target Point object.

distanceBetween

(
  • pointA
  • pointB
  • [round=false]
)
Number public

Returns the distance between the two Point objects.

Parameters:

  • pointA Kiwi.Geom.Point

    The first Point object.

  • pointB Kiwi.Geom.Point

    The second Point object.

  • [round=false] Boolean optional

    Round the distance to the nearest integer (default false)

Returns:

Number:

The distance between the two Point objects.

distanceCompare

(
  • target
  • distance
)
Boolean public

Returns true if the distance between this point and a target point is greater than or equal a specified distance. This avoids using a costly square root operation

Parameters:

  • target Kiwi.Geom.Point

    The Point object to use for comparison.

  • distance Number

    The distance to use for comparison.

Returns:

Boolean:

True if distance is >= specified distance.

distanceTo

(
  • target
  • round
)
Number public

Returns the distance from this Point object to the given Point object.

Parameters:

  • target Kiwi.Geom.Point

    The destination Point object.

  • round Boolean

    Round the distance to the nearest integer (default false)

Returns:

Number:

The distance between this Point object and the destination Point object.

distanceToXY

(
  • x
  • y
  • [round=false]
)
Number public

Returns the distance from this Point object to the given Point object.

Parameters:

  • x Number

    The x value.

  • y Number

    The y value.

  • [round=false] Boolean optional

    Round the distance to the nearest integer (default false)

Returns:

Number:

The distance between this Point object and the x/y values.

equals

(
  • point
)
Boolean public

Determines whether this Point object and the given point object are equal. They are equal if they have the same x and y values.

Parameters:

Returns:

Boolean:

A value of true if the object is equal to this Point object; false if it is not equal.

interpolate

(
  • pointA
  • pointB
  • f
)
Kiwi.Geom.Point public

Determines a point between two specified points. The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2.

The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2).

Parameters:

  • pointA Kiwi.Geom.Point

    The first Point object.

  • pointB Kiwi.Geom.Point

    The second Point object.

  • f Number

    The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned.

Returns:

Kiwi.Geom.Point:

The new interpolated Point object.

invert

() Kiwi.Geom.Point public

Inverts the x and y values of this point

Returns:

Kiwi.Geom.Point:

This Point object.

objType

() String public

The type of this object.

Returns:

String:

"Point"

offset

(
  • dx
  • dy
)
Kiwi.Geom.Point public

Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value.

Parameters:

  • dx Number

    The amount by which to offset the horizontal coordinate, x.

  • dy Number

    The amount by which to offset the vertical coordinate, y.

Returns:

Kiwi.Geom.Point:

This Point object. Useful for chaining method calls.

polar

(
  • length
  • angle
)
Kiwi.Geom.Point public

Creates a new point with cartesian coordinates from a pair of polar coordinates

Parameters:

  • length Number

    The length coordinate of the polar pair.

  • angle Number

    The angle, in radians, of the polar pair.

Returns:

Kiwi.Geom.Point:

The new Cartesian Point object.

polar

(
  • length
  • angle
)
Kiwi.Geom.Point public

Converts a pair of polar coordinates to a Cartesian point coordinate and sets them on the point instance.

Parameters:

  • length Number

    The length coordinate of the polar pair.

  • angle Number

    The angle, in radians, of the polar pair.

Returns:

Kiwi.Geom.Point:

The new Cartesian Point object.

setTo

(
  • x
  • y
)
Kiwi.Geom.Point public

Sets the x and y values of this Point object to the given coordinates.

Parameters:

  • x Number

    The horizontal position of this point.

  • y Number

    The vertical position of this point.

Returns:

Kiwi.Geom.Point:

This Point object. Useful for chaining method calls.

subtract

(
  • point
  • output
)
Kiwi.Geom.Point public

Subtracts the coordinates of another point from the coordinates of this point to create a new point.

Parameters:

  • point Kiwi.Geom.Point

    The point to be subtracted.

  • output Kiwi.Geom.Point

    Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.

Returns:

Kiwi.Geom.Point:

The new Point object.

subtractFrom

(
  • x
  • y
)
Kiwi.Geom.Point public

Adds the given values to the coordinates of this point and returns it

Parameters:

  • x Number

    The amount to subtract from the x value of the point

  • y Number

    The amount to subtract from the x value of the point

Returns:

Kiwi.Geom.Point:

This Point object.

toString

() String public

Returns a string representation of this object.

Returns:

String:

a string representation of the instance.

Properties

x

Number public

The horizontal position of this point.

y

Number public

The vertical position of this point.