This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jwcub
committed
May 2, 2024
1 parent
78a802c
commit d1021b9
Showing
7 changed files
with
198 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export const R = 30; | ||
|
||
export const TEXT_SIZE = 15; | ||
export const TEXT_COLOR = 0xffffff; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Formats a large number. | ||
*/ | ||
export function formatLargeNumber(n: number): string { | ||
let text; | ||
|
||
if (n < 0) { | ||
return "-" + formatLargeNumber(-n); | ||
} else if (n === 0) { | ||
return ""; | ||
} else if (n < 1000) { | ||
text = String(n); | ||
} else if (n < 10000) { | ||
text = String(Math.round(n / 100) / 10) + "k"; | ||
} else if (n < 100000) { | ||
text = String(Math.round(n / 1000)) + "k"; | ||
} else if (n < 10000000) { | ||
const millions = Math.round(n / 100000) / 10; | ||
text = | ||
(millions < 1 ? millions.toString().substring(1) : millions.toString()) + | ||
"m"; | ||
} else if (n < 100000000) { | ||
text = String(Math.round(n / 1000000)) + "m"; | ||
} else { | ||
const power = Math.round(Math.log10(n)); | ||
text = `${Math.round(n / Math.pow(10, power))}e${power}`; | ||
} | ||
|
||
return text; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters