geometry-kit
v0.0.1
Published
Framework-agnostic 2D vector geometry primitives for interactive interfaces.
Maintainers
Readme
Geometry Kit
Framework-agnostic 2D vector geometry primitives for interactive interfaces.
geometry-kit is the small maths layer underneath interactive interfaces. It provides framework-agnostic 2D vector and geometry primitives that can be shared by artboards, gesture recognition, and motion/path tooling.
The package is intentionally boring at the boundary: plain objects, numbers, and pure functions. Geometry can be calculated during rendering, on the server, or in a worker without bringing a browser into the equation.
Scope
type Vec2 = { x: number; y: number };
add(a, b);
subtract(a, b);
scale(v, n);
normalize(v);
length(v);
distance(a, b);
dot(a, b);
lerp(a, b, t);
angle(a, b);
rotate(v, radians);
project(point, line);
closestPoint(...args);
bounds(points);
centroid(points);
transform(...args);The primitives should remain composable and predictable: no hidden state, no implicit coordinate system, and no mutation of input vectors.
License
MIT
