Class: Position

Position

Abstract parent class for Point and Coordinate

(abstract) new Position() [source]


Members

  • x

  • Properties:
    Name Type Description
    x Number x value
    Source:

  • y

  • Properties:
    Name Type Description
    y Number y value
    Source:

    Methods

  • abs() [source]

  • Return abs value of the point
    Returns:
    Coordinate|Point: abs point
  • round() [source]

  • Like math.round, rounding the point's xy.
    Returns:
    Coordinate|Point: rounded point
  • copy() [source]

  • Returns a copy of the coordinate
    Returns:
    Coordinate|Point: copy
  • add(x, yopt) [source]

  • Returns the result of addition of another coordinate.
    Parameter Type Description
    x Coordinate | Point | Array | Number coordinate to add
    y opt Number optional, coordinate to add
    Returns:
    Coordinate|Point: result
  • sub(x, yopt) [source]

  • Returns the result of subtraction of another coordinate.
    Parameter Type Description
    x Coordinate | Point | Array | Number coordinate to add
    y opt Number optional, coordinate to add
    Returns:
    Coordinate|Point: result
  • substract(x, yopt) [source]

  • Alias for sub
    Parameter Type Description
    x Coordinate | Point | Array | Number coordinate to add
    y opt Number optional, coordinate to add
    Returns:
    Coordinate|Point: result
  • multi(ratio) [source]

  • Returns the result of multiplication of the current coordinate by the given number.
    Parameter Type Description
    ratio Number ratio to multi
    Returns:
    Coordinate|Point: result
  • div(n) [source]

  • Returns the result of division of the current point by the given number.
    Parameter Type Description
    n Number number to div
    Returns:
    Coordinate|Point: result
  • equals(c) [source]

  • Compare with another coordinate to see whether they are equal.
    Parameter Type Description
    c Coordinate | Point coordinate to compare
    Returns:
    Boolean:
  • isZero() [source]

  • Whether the coordinate/point is zero

  • toArray() [source]

  • Convert to a number array [x, y]
    Returns:
    Array.<Number>: number array
  • toFixed(n) [source]

  • Formats coordinate number using fixed-point notation.
    Parameter Type Description
    n Number The number of digits to appear after the decimal point
    Returns:
    Coordinate: fixed coordinate
  • toJSON() [source]

  • Convert to a json object {x : .., y : ..}
    Returns:
    Object: json