point

<script src="./point_src/point"></script>

Meta Data
dependencies ()
unused_keys ('title',)
unknown_keys ('categories', 'doc_imports', 'doc_loader', 'doc_readme', 'doc_content', 'files')
categories ['primary', 'point']
doc_imports ['point']
doc_loader ['loadDocInfo']
doc_readme ['point/readme.md']
doc_content ['point/*.md']
files ['', 'relative-xy.js', 'pointcast.js']
filepath_exists True
path point
filepath point.js
clean_files ('relative-xy.js', 'pointcast.js')

The entire library is focused upon the single 2D Point.

Getting Started

A Point accepts many properties, or an object.

Default properties:
// accepts: (x, y, radius, rotation)
new Point(100, 200, 20, 90)
Or array of the same four attributes
// accepts: (x, y, radius, rotation)
new Point([100, 200, 20, 90])
The same properties may be applied through an object:
new Point({
    x: 100
    , y: 200
    , radius: 20
    , rotation: 90
})
Anything can be applied to the point instance directly:
let point = new Point

point.x = 100
point.y = 200
point.radius = 20
point.rotation = 90
  • VariableDeclaration
    const

    isPoint

    =
    function ( value )
  • VariableDeclaration
    const

    isFunction

    =
    function ( value )
  • VariableDeclaration
    const

    point

    =
    function ( p , b )
  • ExpressionStatement

    :

    dict_keys(['type', 'expression', 'pos'])
  • ClassDeclaration
    class comments:

    The base Positionable class provides functionality for plotting the X and Y of an entity. This includes any fundamental methods such as multiply().

    • set

      x

      (
      value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      ABOVE X method

      Multiline - touching.

      Set the X (horizontal | latitude | across) value of the positionable. From cooridinate top left `(0,0)``

      point.x = 100
      

      If the given value is a function, the function is called immediately, with this positionable as the first argument.

      stage.center.x = (p)=>200
      
    • set

      y

      (
      value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Set the Y (vertical | height | longtitude) value of the positionable. From cooridinate top left `(0,0)``

      point.x = 100
      

      If the given value is a function, the function is called immediately, with this positionable as the first argument.

      stage.center.x = (p)=>200
      
    • get

      x

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      const _x = this._opts.x;

    • get

      y

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      const _y = this._opts.y;

    • set

      radius

      (
      v
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      this._opts.radius = isFunction(v)? v(this, 'radius'): v

    • get

      radius

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the radius of this point in base units (pixels)

      const point = new Point(100,300, 20)
      point.radius == 20
      
    • method

      setSpecial

      (
      key , value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Set the given key, value, assuming the given key is a "special" string, such as "radius". This method is called by the special getters and setters for this point:

      const point = new Point(100,300, 20)
      point.setSpecial('radius', 55)
      

      Synonymous to:

      point.radius = 55
      
    • method

      onSpecialSet

      (
      key , value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      A callback executed by setSpecial when a "special" property is called.

      If a method on this point exists matching the set method pattern, the method is called with the given value:

      class MyPoint extends Point {
          radiusSet(value) {
              console.log('New Radius value is', value)
          }
      }
      
    • method

      getSpecial

      (
      key , relIndex = undefined , defaultValue
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return a stored special value given a key.

      If the relIndex property is not None, the relative value found at the index (within this points relative data Array), add the stashed relative value to the result.

      const point = new Point(100,300, 20)
      point.getSpecial('radius', 2)
      // 20
      

      if a default value is given, and the internal key value does not exist, return the default value:

      point.getSpecial('banana', 'yellow')
      'yellow'
      
    • method

      set

      (
      x , y , radius , rotation
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      set(x, y, radius, rotation) set(100) => x,y set([]) => [x,y,radius, rotation] set({}) => *

    • method

      _cast

      (
      other , _2 = other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      subtract

      (
      other , _2 = other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "subtract" this point to the other point, returning a new point.

    • method

      add

      (
      other , _b
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Add" this point to the other point, returning a new point.

    • method

      divide

      (
      other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Divide" this point to the other point, returning a new point.

    • method

      multiply

      (
      other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Multiply" this point to the other point, returning a new point.

    • method

      midpoint

      (
      other , offset = 0.5
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Returns a new point, with the XY set at the point that is offset times the distance from the current point to the other point.

      this function is also lerp for linear interpolation

    • property

      lerp

      from Positionable
      dict_keys(['kind', 'word', 'computed', 'static', 'value', 'type', 'pos', 'class_name'])
    dict_keys(['kind', 'word', 'parentName', 'type', 'body', 'comments', 'pos'])
  • ClassDeclaration
    class comments:

    Set the rotation in degrees (0 to 360). If this.modulusRotate is true (default), the given value is fixed through modulus 360

    point.rotation = 600
    // 240
    point.rotation += 1
    // 241
    

    To set the rotation (degrees) whilst accounting for the UP vector, consider the rotate() method.

    • set

      rotation

      (
      value
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Set the rotation in degrees (0 to 360). If this.modulusRotate is true (default), the given value is fixed through modulus 360

      point.rotation = 600
      // 240
      point.rotation += 1
      // 241
      

      To set the rotation (degrees) whilst accounting for the UP vector, consider the rotate() method.

    • method

      rotate

      (
      degrees
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • get

      rotation

      (
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • get

      radians

      (
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the radians of the current rotation, where _rotation returns the degrees

    • set

      radians

      (
      angle
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      by pushing through the existing rotations, we account for the up vector.

    • method

      lookAt

      (
      otherPoint , add , rotationMultiplier = undefined
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Rotate the point such that the angle relative to the otherPoint is 0, essentially looking at the other point.

      point.lookAt(otherPoint)
      

      Return the angle in radians.

    • method

      directionTo

      (
      otherPoint , rotationMultiplier = undefined , addRad
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Calculate the differences in x and y coordinates

    • method

      _normalizedRadians

      (
      otherPoint , rotationMultiplier , addRad
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Normalize the angle difference to be within the range -PI to PI

    • method

      turnTo

      (
      otherPoint , rotationMultiplier = 1
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      getTheta

      (
      other , direction = undefined
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the calculated theta value through atan2 and built to offload some of the boring. The direction denotes the "gravity" pull. Generally this is DOWN.

      Synonymous to:

      let theta = Math.atan2(point.y,
                             point.x);
      
      let theta = Math.atan2(point.y - other.y,
                             point.x - other.x);
      
      let theta = Math.atan2(point.y - other.y,
                             point.x - other.x) - DOWN;
      
    • set

      x

      (
      value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      ABOVE X method

      Multiline - touching.

      Set the X (horizontal | latitude | across) value of the positionable. From cooridinate top left `(0,0)``

      point.x = 100
      

      If the given value is a function, the function is called immediately, with this positionable as the first argument.

      stage.center.x = (p)=>200
      
    • set

      y

      (
      value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Set the Y (vertical | height | longtitude) value of the positionable. From cooridinate top left `(0,0)``

      point.x = 100
      

      If the given value is a function, the function is called immediately, with this positionable as the first argument.

      stage.center.x = (p)=>200
      
    • get

      x

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      const _x = this._opts.x;

    • get

      y

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      const _y = this._opts.y;

    • set

      radius

      (
      v
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      this._opts.radius = isFunction(v)? v(this, 'radius'): v

    • get

      radius

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the radius of this point in base units (pixels)

      const point = new Point(100,300, 20)
      point.radius == 20
      
    • method

      setSpecial

      (
      key , value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Set the given key, value, assuming the given key is a "special" string, such as "radius". This method is called by the special getters and setters for this point:

      const point = new Point(100,300, 20)
      point.setSpecial('radius', 55)
      

      Synonymous to:

      point.radius = 55
      
    • method

      onSpecialSet

      (
      key , value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      A callback executed by setSpecial when a "special" property is called.

      If a method on this point exists matching the set method pattern, the method is called with the given value:

      class MyPoint extends Point {
          radiusSet(value) {
              console.log('New Radius value is', value)
          }
      }
      
    • method

      getSpecial

      (
      key , relIndex = undefined , defaultValue
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return a stored special value given a key.

      If the relIndex property is not None, the relative value found at the index (within this points relative data Array), add the stashed relative value to the result.

      const point = new Point(100,300, 20)
      point.getSpecial('radius', 2)
      // 20
      

      if a default value is given, and the internal key value does not exist, return the default value:

      point.getSpecial('banana', 'yellow')
      'yellow'
      
    • method

      set

      (
      x , y , radius , rotation
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      set(x, y, radius, rotation) set(100) => x,y set([]) => [x,y,radius, rotation] set({}) => *

    • method

      _cast

      (
      other , _2 = other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      subtract

      (
      other , _2 = other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "subtract" this point to the other point, returning a new point.

    • method

      add

      (
      other , _b
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Add" this point to the other point, returning a new point.

    • method

      divide

      (
      other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Divide" this point to the other point, returning a new point.

    • method

      multiply

      (
      other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Multiply" this point to the other point, returning a new point.

    • method

      midpoint

      (
      other , offset = 0.5
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Returns a new point, with the XY set at the point that is offset times the distance from the current point to the other point.

      this function is also lerp for linear interpolation

    • property

      lerp

      from Positionable
      dict_keys(['kind', 'word', 'computed', 'static', 'value', 'type', 'pos', 'class_name'])
    dict_keys(['kind', 'word', 'parentName', 'type', 'body', 'comments', 'pos'])
  • ClassDeclaration
    class comments:

    str such as this["rotation"]

    • method

      resolveStringOrFunction

      (
      direction , defaultValue
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      str such as this["rotation"]

    • method

      atan2

      (
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the theta value through the atan2 function for this point.

    • method

      project

      (
      distance , rotation , relative = True
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      copy

      (
      position , deep
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Given another point, replicate the value into this node. Else, return a new node with the same information as this point.

    • method

      magnitude

      (
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      normalized

      (
      magnitude
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Synonymous to:

      {
          x: AB.x / magnitudeAB,
          y: AB.y / magnitudeAB
      };
      
    • method

      interpolateTo

      (
      other , offset , pointIndex
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      return a point relative from this point towards the other, offset by the given number offset value. The pointIndex (default 0) identifies from which point [this, other] to offset.

    • method

      interpolateFrom

      (
      other , offset , pointIndex
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      distance

      (
      a , b
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      quantize

      (
      amount = 1
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      protractorAngleTo

      (
      other , referencePoint
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      lerpPixel

      (
      other , pixelDistance
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Returns a new point, offset by pixelDistance pixels in the direction from this point to the other point.

    • set

      rotation

      (
      value
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Set the rotation in degrees (0 to 360). If this.modulusRotate is true (default), the given value is fixed through modulus 360

      point.rotation = 600
      // 240
      point.rotation += 1
      // 241
      

      To set the rotation (degrees) whilst accounting for the UP vector, consider the rotate() method.

    • method

      rotate

      (
      degrees
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • get

      rotation

      (
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • get

      radians

      (
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the radians of the current rotation, where _rotation returns the degrees

    • set

      radians

      (
      angle
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      by pushing through the existing rotations, we account for the up vector.

    • method

      lookAt

      (
      otherPoint , add , rotationMultiplier = undefined
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Rotate the point such that the angle relative to the otherPoint is 0, essentially looking at the other point.

      point.lookAt(otherPoint)
      

      Return the angle in radians.

    • method

      directionTo

      (
      otherPoint , rotationMultiplier = undefined , addRad
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Calculate the differences in x and y coordinates

    • method

      _normalizedRadians

      (
      otherPoint , rotationMultiplier , addRad
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Normalize the angle difference to be within the range -PI to PI

    • method

      turnTo

      (
      otherPoint , rotationMultiplier = 1
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      getTheta

      (
      other , direction = undefined
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the calculated theta value through atan2 and built to offload some of the boring. The direction denotes the "gravity" pull. Generally this is DOWN.

      Synonymous to:

      let theta = Math.atan2(point.y,
                             point.x);
      
      let theta = Math.atan2(point.y - other.y,
                             point.x - other.x);
      
      let theta = Math.atan2(point.y - other.y,
                             point.x - other.x) - DOWN;
      
    • set

      x

      (
      value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      ABOVE X method

      Multiline - touching.

      Set the X (horizontal | latitude | across) value of the positionable. From cooridinate top left `(0,0)``

      point.x = 100
      

      If the given value is a function, the function is called immediately, with this positionable as the first argument.

      stage.center.x = (p)=>200
      
    • set

      y

      (
      value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Set the Y (vertical | height | longtitude) value of the positionable. From cooridinate top left `(0,0)``

      point.x = 100
      

      If the given value is a function, the function is called immediately, with this positionable as the first argument.

      stage.center.x = (p)=>200
      
    • get

      x

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      const _x = this._opts.x;

    • get

      y

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      const _y = this._opts.y;

    • set

      radius

      (
      v
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      this._opts.radius = isFunction(v)? v(this, 'radius'): v

    • get

      radius

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the radius of this point in base units (pixels)

      const point = new Point(100,300, 20)
      point.radius == 20
      
    • method

      setSpecial

      (
      key , value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Set the given key, value, assuming the given key is a "special" string, such as "radius". This method is called by the special getters and setters for this point:

      const point = new Point(100,300, 20)
      point.setSpecial('radius', 55)
      

      Synonymous to:

      point.radius = 55
      
    • method

      onSpecialSet

      (
      key , value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      A callback executed by setSpecial when a "special" property is called.

      If a method on this point exists matching the set method pattern, the method is called with the given value:

      class MyPoint extends Point {
          radiusSet(value) {
              console.log('New Radius value is', value)
          }
      }
      
    • method

      getSpecial

      (
      key , relIndex = undefined , defaultValue
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return a stored special value given a key.

      If the relIndex property is not None, the relative value found at the index (within this points relative data Array), add the stashed relative value to the result.

      const point = new Point(100,300, 20)
      point.getSpecial('radius', 2)
      // 20
      

      if a default value is given, and the internal key value does not exist, return the default value:

      point.getSpecial('banana', 'yellow')
      'yellow'
      
    • method

      set

      (
      x , y , radius , rotation
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      set(x, y, radius, rotation) set(100) => x,y set([]) => [x,y,radius, rotation] set({}) => *

    • method

      _cast

      (
      other , _2 = other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      subtract

      (
      other , _2 = other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "subtract" this point to the other point, returning a new point.

    • method

      add

      (
      other , _b
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Add" this point to the other point, returning a new point.

    • method

      divide

      (
      other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Divide" this point to the other point, returning a new point.

    • method

      multiply

      (
      other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Multiply" this point to the other point, returning a new point.

    • method

      midpoint

      (
      other , offset = 0.5
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Returns a new point, with the XY set at the point that is offset times the distance from the current point to the other point.

      this function is also lerp for linear interpolation

    • property

      lerp

      from Positionable
      dict_keys(['kind', 'word', 'computed', 'static', 'value', 'type', 'pos', 'class_name'])
    dict_keys(['kind', 'word', 'parentName', 'type', 'body', 'comments', 'pos'])
  • ClassDeclaration
    class comments:

    The Point is the primary class for manipulating XY 2D points.

    Arguments:

    new Point(100, 200)
    

    Object | Array:

    new Point({x: 100, y: 200})
    new Point([100, 200])
    

    Properties:

    point = new Point
    point.x = 100
    point.y = 200
    
    • property

      UP

      from Point
      dict_keys(['kind', 'word', 'computed', 'static', 'value', 'type', 'pos', 'class_name'])
    • property

      _rotationDegrees

      from Point
      dict_keys(['kind', 'word', 'computed', 'static', 'value', 'type', 'pos', 'class_name'])
    • constructor

      constructor

      (
      opts = {}
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      A new point accepts arguments, an object, or an array.

      By default the Point accepts up to four arguments

      new Point(x, y, radius, rotation)
      

      The same properties may be supplied as a single Array:

      new Point([x, y, radius, rotation])
      

      If the given object is an object, we can assign properties immediately:

      point = new Point({x, y, radius, rotation, other:100})
      point.other
      // 100
      
    • method

      created

      (
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      api hook for life.

    • method

      update

      (
      data
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Perform an update given a dictionary of other properties.

      point.update({ x: 200, color: 'red' })
      
    • get

      uuid

      (
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Get or create the random _id for this point. Return a unique string.

    • set

      uuid

      (
      v
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • get

      [[computed_Literal]]

      (
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      return the X value of the point:

      point[0]
      

      Note:

      point[0] == point.x
      
    • set

      [[computed_Literal]]

      (
      value
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Sugar function to apply this.x:

      point[0] = 100
      point.x == 100
      
    • get

      [[computed_Literal]]

      (
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      return the Y value of the point:

      point[0]
      

      Note:

      point[0] == point.y
      
    • set

      [[computed_Literal]]

      (
      value
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Sugar function to apply this.y:

      point[0] = 300
      point.y == 300
      
    • get

      [Symbol.toStringTag]

      (
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      [Symbol.toPrimitive]

      (
      hint
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      return Reflect.apply(...arguments)

    • method

      toString

      (
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • get

      _liveProps

      (
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      asArray

      (
      fix
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return this point as an Array of 4 values:

      const point = new Point(1,2,3,4);
      point.asArray();
      // [1,2,3,4]
      

      Keys:

      • x
      • y
      • radius
      • rotation
    • method

      asObject

      (
      )
      from Point
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the important information about this node, used for save or copy methods.

    • method

      resolveStringOrFunction

      (
      direction , defaultValue
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      str such as this["rotation"]

    • method

      atan2

      (
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the theta value through the atan2 function for this point.

    • method

      project

      (
      distance , rotation , relative = True
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      copy

      (
      position , deep
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Given another point, replicate the value into this node. Else, return a new node with the same information as this point.

    • method

      magnitude

      (
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      normalized

      (
      magnitude
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Synonymous to:

      {
          x: AB.x / magnitudeAB,
          y: AB.y / magnitudeAB
      };
      
    • method

      interpolateTo

      (
      other , offset , pointIndex
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      return a point relative from this point towards the other, offset by the given number offset value. The pointIndex (default 0) identifies from which point [this, other] to offset.

    • method

      interpolateFrom

      (
      other , offset , pointIndex
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      distance

      (
      a , b
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      quantize

      (
      amount = 1
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      protractorAngleTo

      (
      other , referencePoint
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      lerpPixel

      (
      other , pixelDistance
      )
      from Tooling
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Returns a new point, offset by pixelDistance pixels in the direction from this point to the other point.

    • set

      rotation

      (
      value
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Set the rotation in degrees (0 to 360). If this.modulusRotate is true (default), the given value is fixed through modulus 360

      point.rotation = 600
      // 240
      point.rotation += 1
      // 241
      

      To set the rotation (degrees) whilst accounting for the UP vector, consider the rotate() method.

    • method

      rotate

      (
      degrees
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • get

      rotation

      (
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • get

      radians

      (
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the radians of the current rotation, where _rotation returns the degrees

    • set

      radians

      (
      angle
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      by pushing through the existing rotations, we account for the up vector.

    • method

      lookAt

      (
      otherPoint , add , rotationMultiplier = undefined
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Rotate the point such that the angle relative to the otherPoint is 0, essentially looking at the other point.

      point.lookAt(otherPoint)
      

      Return the angle in radians.

    • method

      directionTo

      (
      otherPoint , rotationMultiplier = undefined , addRad
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Calculate the differences in x and y coordinates

    • method

      _normalizedRadians

      (
      otherPoint , rotationMultiplier , addRad
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Normalize the angle difference to be within the range -PI to PI

    • method

      turnTo

      (
      otherPoint , rotationMultiplier = 1
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      getTheta

      (
      other , direction = undefined
      )
      from Rotation
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the calculated theta value through atan2 and built to offload some of the boring. The direction denotes the "gravity" pull. Generally this is DOWN.

      Synonymous to:

      let theta = Math.atan2(point.y,
                             point.x);
      
      let theta = Math.atan2(point.y - other.y,
                             point.x - other.x);
      
      let theta = Math.atan2(point.y - other.y,
                             point.x - other.x) - DOWN;
      
    • set

      x

      (
      value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      ABOVE X method

      Multiline - touching.

      Set the X (horizontal | latitude | across) value of the positionable. From cooridinate top left `(0,0)``

      point.x = 100
      

      If the given value is a function, the function is called immediately, with this positionable as the first argument.

      stage.center.x = (p)=>200
      
    • set

      y

      (
      value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Set the Y (vertical | height | longtitude) value of the positionable. From cooridinate top left `(0,0)``

      point.x = 100
      

      If the given value is a function, the function is called immediately, with this positionable as the first argument.

      stage.center.x = (p)=>200
      
    • get

      x

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      const _x = this._opts.x;

    • get

      y

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      const _y = this._opts.y;

    • set

      radius

      (
      v
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      this._opts.radius = isFunction(v)? v(this, 'radius'): v

    • get

      radius

      (
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return the radius of this point in base units (pixels)

      const point = new Point(100,300, 20)
      point.radius == 20
      
    • method

      setSpecial

      (
      key , value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Set the given key, value, assuming the given key is a "special" string, such as "radius". This method is called by the special getters and setters for this point:

      const point = new Point(100,300, 20)
      point.setSpecial('radius', 55)
      

      Synonymous to:

      point.radius = 55
      
    • method

      onSpecialSet

      (
      key , value
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      A callback executed by setSpecial when a "special" property is called.

      If a method on this point exists matching the set method pattern, the method is called with the given value:

      class MyPoint extends Point {
          radiusSet(value) {
              console.log('New Radius value is', value)
          }
      }
      
    • method

      getSpecial

      (
      key , relIndex = undefined , defaultValue
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Return a stored special value given a key.

      If the relIndex property is not None, the relative value found at the index (within this points relative data Array), add the stashed relative value to the result.

      const point = new Point(100,300, 20)
      point.getSpecial('radius', 2)
      // 20
      

      if a default value is given, and the internal key value does not exist, return the default value:

      point.getSpecial('banana', 'yellow')
      'yellow'
      
    • method

      set

      (
      x , y , radius , rotation
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      set(x, y, radius, rotation) set(100) => x,y set([]) => [x,y,radius, rotation] set({}) => *

    • method

      _cast

      (
      other , _2 = other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    • method

      subtract

      (
      other , _2 = other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "subtract" this point to the other point, returning a new point.

    • method

      add

      (
      other , _b
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Add" this point to the other point, returning a new point.

    • method

      divide

      (
      other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Divide" this point to the other point, returning a new point.

    • method

      multiply

      (
      other
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      "Multiply" this point to the other point, returning a new point.

    • method

      midpoint

      (
      other , offset = 0.5
      )
      from Positionable
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])

      Returns a new point, with the XY set at the point that is offset times the distance from the current point to the other point.

      this function is also lerp for linear interpolation

    • property

      lerp

      from Positionable
      dict_keys(['kind', 'word', 'computed', 'static', 'value', 'type', 'pos', 'class_name'])
    dict_keys(['kind', 'word', 'parentName', 'type', 'body', 'comments', 'pos'])
  • ExpressionStatement

    :

    dict_keys(['type', 'expression', 'pos'])
  • ExpressionStatement

    :

    dict_keys(['type', 'expression', 'pos'])
  • ExpressionStatement

    :

    dict_keys(['type', 'expression', 'pos'])

lerp()

Point

The lerp() method accepts a Point and a float. The float value 0 to 1 is a represents a percent amount along the distance to the other point.

point.lerp(other, .5)