telva-vec
v1.1.1
Published
2D vector utilities for telva and maybe you, too.
Downloads
400
Maintainers
Readme
telva-vec
Tiny, fast 2D vector math utilities for editors, geometry tooling, and canvas apps.
Install
npm i telva-vecTypical use cases
- Vector arithmetic (
add,sub,mul,div,neg). - Metrics (
dist,len, projections, dot/cross products). - Geometry helpers for transforms, nearest points, and angle/slope operations.
Quick example
import { Vec } from 'telva-vec'
const a = [10, 20]
const b = [25, 12]
const delta = Vec.sub(b, a)
const distance = Vec.dist(a, b)
const unit = Vec.uni(delta)How it works internally
- Exposes a single static
Vecclass with focused, composable methods. - Uses plain tuple-like number arrays (
number[]) to stay lightweight and interoperable. - Designed as a zero-framework utility layer with no React/editor coupling.
- Serves as the base dependency for
telva-intersect,telva-core, andtelvageometry paths.
Workspace scripts
yarn dev
yarn build
yarn lintLicense
AGPL-3.0-only
