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)

None
copy
Meta Data
filepath_exists True
path distances
filepath distances.js
clean_files ()

  • ClassDeclaration
    class comments:
    Track the distances between given points. const d = new Distances; d.addPoints(...points); const near = d.closest(Point.mouse.position) --- {% load content %}
    {% code_content "events/mypoint-stage.js" %}
    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)
    • constructor

      constructor

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

      addPoints

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

      removePoints

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

      setPoints

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

      closest

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

      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 class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
          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 class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])

      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 class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])

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

      if(distance == undefined) {

    • method

      each

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

      keep

      (
      caller
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
    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'])