telva-intersect
v1.1.1
Published
2D intersection utilities for Telva and maybe you, too.
Maintainers
Readme
telva-intersect
2D intersection and hit-testing toolkit for geometry-heavy editors and visual apps.
Install
npm i telva-intersectDependency
- Uses
telva-vecfor vector operations and geometric primitives.
Typical use cases
- Hit testing against bounds, polylines, and shape silhouettes.
- Segment/ray/line intersections for interaction and snapping logic.
- Overlap checks for selection models and collision workflows.
Quick example
import { intersectBoundsPolyline, intersectLineSegmentLineSegment } from 'telva-intersect'
const hit = intersectLineSegmentLineSegment([0, 0], [100, 100], [0, 100], [100, 0])
const crossings = intersectBoundsPolyline(
{ minX: 0, minY: 0, maxX: 80, maxY: 80, width: 80, height: 80 },
[
[0, 0],
[40, 120],
[100, 20],
]
)How it works internally
- Centralizes algorithms in a functional API over point arrays and bounds objects.
- Standardizes outcomes via
TLIntersection(didIntersect,message,points). - Covers broad primitive combinations (line, segment, ray, bounds, ellipse, polyline).
- Keeps math deterministic and side-effect free for reliable tool pipelines.
Workspace scripts
yarn dev
yarn build
yarn lintLicense
AGPL-3.0-only
