🚀
Lightweight & Fast
Zero dependencies with a minimal footprint. All operations are optimized for performance.
A lightweight, immutable library for 2D geometry operations with TypeScript support
import { Vec2, Rect, Transform } from 'paintvec'
// Create vectors
const pos = new Vec2(100, 200)
const pos2 = pos.add(new Vec2(50, 30)).mul(new Vec2(10, 20))
// Work with rectangles
const rect = new Rect(new Vec2(0), new Vec2(100, 200))
const rect2 = new Rect(new Vec2(50, 50), new Vec2(100, 200))
const intersection = Rect.intersection(rect, rect2)
// Apply transforms
const transform = Transform.translate(new Vec2(100, 200))
.merge(Transform.scale(new Vec2(2)))
.merge(Transform.rotate(Math.PI / 4))
const transformed = pos.transform(transform)
npm install paintvec
yarn add paintvec
pnpm add paintvec