distances

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

Track the distances between given points.

const d = new Distances;
d.addPoints(...points);

const near = d.closest(Point.mouse.position)
Meta Data
filepath_exists True
path distances
filepath distances.js
clean_files ()

  • ClassDeclaration
    class comments:

    The Distances class helps with tracking many points and discovering the distance to or within the given points.

    const d = new Distances;
    d.addPoints(...points);
    
    • constructor

      constructor

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

      addPoints

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

      removePoints

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

      setPoints

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

      closest

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

      Return the closest point to the given point, for example the nearest point to the mouse.

      Return the most near point at any distance:

      > distances.closest(mouse.position)
      point
      

      Return the most near point, also within 100px radius distance:

      > distances.closest(mouse.position, 100)
      

      Of which is the same as:

      // within 100px of the mouse position
      > distances.within(100, mouse.position)
      
    • method

      intersect

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

      Check if a point intersects another point, returning the interecting top point.

      > intersect(mouse)
      point  // a point under the mouse.
      

      To pad the overlap distance, provide an addition padding value:

      > intersect(mouse, 10) // add 10px around the perimeter
      point
      

      Useful if the intersection point has a radius:

      > intersect(mouse, mouse.radius) // add 10px around the perimeter
      

      This is the same as calling closest(), with the second arg as a function for radius testing.

    • method

      within

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

      Return a point within the max distance set

      // return the closest point within 100px (radius) from the mouse position
      > distances.within(100, this.mouse.position)
      point
      

      For a list of points, use near.

      near(point, distance=point.radius)
      [point, ...]
      

      Each distance is tested against the curent low. If the distance v is less than low, store p.

      In the first iteration, setterFunc, does not do a test, and replaces itself, with a testing function.

      This ensures we don't need to check for the first undefined .

    • method

      near

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

      Return a list of points near the the given point at a given distance.

      if(distance == undefined) {

    • method

      each

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

      keep

      (
      caller
      )
      from Distances
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos', 'class_name'])
    dict_keys(['kind', 'word', 'parentName', 'type', 'body', 'comments', 'pos'])
  • EmptyStatement
    ; (empty statement)
  • ExpressionStatement

    :

    dict_keys(['type', 'expression', 'pos'])
  • FunctionDeclaration
    function

    distance

    (
    xy1 , xy2
    )
    dict_keys(['kind', 'word', 'generator', 'expression', 'async', 'params', 'id', 'pos', 'type'])
  • FunctionDeclaration
    function

    distance2D

    (
    xy1 , xy2
    )
    dict_keys(['kind', 'word', 'generator', 'expression', 'async', 'params', 'id', 'pos', 'type'])
  • ExpressionStatement

    :

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

    :

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