Skip to content

Commit

Permalink
Add helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
AB1908 committed Mar 16, 2022
1 parent 00ad8e6 commit 23ca702
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions util.ts
Original file line number Diff line number Diff line change
@@ -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)}`;
}

0 comments on commit 23ca702

Please sign in to comment.