aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-05-20 14:03:12 -0400
committerbobzel <zzzman@gmail.com>2024-05-20 14:03:12 -0400
commit4ad0dfca6a48b88a53e3add295d41cd0a223b722 (patch)
tree3651e9dee039eb197840591c5e09ec7d3c1be2f7 /src/Utils.ts
parent01eb7a85292122bd0702453923a9a34569bee531 (diff)
parenta5aa41e60dc72881e1aa2f14743b9f00c1160eed (diff)
Merge branch 'restoringEslint' into alyssa-starter
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index 3af057d82..23ae38bdb 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -3,6 +3,11 @@ import * as uuid from 'uuid';
export function clamp(n: number, lower: number, upper: number) {
return Math.max(lower, Math.min(upper, n));
}
+
+export function ptDistance(p1: { x: number; y: number }, p2: { x: number; y: number }) {
+ return Math.sqrt((p2.x - p1.x) ** 2 + (p2.y - p1.y) ** 2);
+}
+
export namespace Utils {
export function GuestID() {
return '__guest__';
@@ -206,6 +211,11 @@ export type Without<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type Predicate<K, V> = (entry: [K, V]) => boolean;
+/**
+ * creates a list of numbers ordered from 0 to 'num'
+ * @param num range of numbers
+ * @returns list of values from 0 to num -1
+ */
export function numberRange(num: number) {
return num > 0 && num < 1000 ? Array.from(Array(num)).map((v, i) => i) : [];
}