distances
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 | () |
-
ClassDeclarationclass
Distances
extends None-
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)
-
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.
-
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` .
EmptyStatement; (empty statement)ExpressionStatement:
dict_keys(['type', 'expression', 'pos'])FunctionDeclarationFunctionDeclarationExpressionStatement:
dict_keys(['type', 'expression', 'pos'])ExpressionStatement:
dict_keys(['type', 'expression', 'pos'])
{% code_content "events/mypoint-stage.js" %}