From 23ca702ad3c205195987fd1132405d8f9b773d3e Mon Sep 17 00:00:00 2001 From: AB1908 <14124383+AB1908@users.noreply.github.com> Date: Wed, 16 Mar 2022 19:17:17 +0530 Subject: [PATCH] Add helper function --- util.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 util.ts diff --git a/util.ts b/util.ts new file mode 100644 index 0000000..d539929 --- /dev/null +++ b/util.ts @@ -0,0 +1,11 @@ +export default function integerToRGBA( + number: number +): string { + if (number < 0) + { + number = 0xFFFFFFFF + number + 1; + } + const ARGB = number.toString(16).toUpperCase(); + + return `#${ARGB.slice(2,)}${ARGB.slice(0,2)}`; +} \ No newline at end of file