11 lines
517 B
JavaScript
11 lines
517 B
JavaScript
"use strict";
|
|
const rand = (min, max) => min + Math.random() * (max - min);
|
|
const randi = (min, max) => Math.floor(rand(min, max + 1));
|
|
const pick = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
|
const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
|
|
const lerp = (a, b, t) => a + (b - a) * t;
|
|
const dist = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
const distXY = (ax, ay, bx, by) => Math.hypot(ax - bx, ay - by);
|
|
const nowSec = () => performance.now() / 1000;
|
|
const fmt = (v) => Math.round(v).toString();
|
|
|