distances
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 | () |
-
ClassDeclarationclass
Distances
extends None-
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) pointReturn 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', '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 pointUseful if the intersection point has a radius:
> intersect(mouse, mouse.radius) // add 10px around the perimeterThis 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', '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) pointFor a list of points, use
near.near(point, distance=point.radius) [point, ...]Each distance is tested against the curent low. If the distance
vis less thanlow, storep.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'])ExpressionStatement:
dict_keys(['type', 'expression', 'pos'])ExpressionStatement:
dict_keys(['type', 'expression', 'pos'])
The
Distancesclass helps with tracking many points and discovering the distance to or within the given points.