UNPKG

@selenite/commons

Version:

This typescript package provides a set of frequently used utilities, types and svelte actions for building projects with Typescript and Svelte.

15 lines (14 loc) 427 B
export function lerp(start, end, alpha) { return start + (end - start) * alpha; } export function affineFromPoints(p1, p2) { const a = (p2.y - p1.y) / (p2.x - p1.x); const b = p2.y - a * p2.x; return (x) => a * x + b; } export function distance(a, b) { return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2); } export function getDistance(a, b) { return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2); }