From 8aa6645f2311de78f74b35f804cc45c7fcf38f57 Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 30 May 2022 18:19:02 -0500 Subject: add brushes --- src/modules/Geometry.js | 6 +++++- src/modules/Util.js | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/Geometry.js b/src/modules/Geometry.js index 628512b..43f277f 100644 --- a/src/modules/Geometry.js +++ b/src/modules/Geometry.js @@ -1,5 +1,9 @@ 'use strict'; +function dist(a, b) { + return Math.sqrt((a.x - b.x)**2 + (a.y - b.y)**2); +} + /* AABB - axis-aligned bounding box */ class AABB { /* create a new AABB */ @@ -226,4 +230,4 @@ class QuadTree { } } -export { AABB, QTNode, QuadTree }; +export { dist, AABB, QTNode, QuadTree }; diff --git a/src/modules/Util.js b/src/modules/Util.js index 2375f10..165d1d0 100644 --- a/src/modules/Util.js +++ b/src/modules/Util.js @@ -14,4 +14,7 @@ function clamp(value, min, max) { return Math.min(Math.max(value, min), max); } -export { useAverage, clamp }; +function lerp(a, b, alpha) { + return ((1-alpha)*a) + (alpha*b); +} +export { useAverage, clamp, lerp }; -- cgit v1.2.1