summaryrefslogtreecommitdiff
path: root/core/src/com/ilotterytea/maxoning/utils
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2022-08-26 18:23:43 +0600
committerilotterytea <iltsu@alright.party>2022-08-26 18:23:43 +0600
commit6377ee262c95537355801ee28149b87eb6d9cb9e (patch)
tree092283abb8f8a3aee43c365421bc820e5a307ceb /core/src/com/ilotterytea/maxoning/utils
Initial commit
Diffstat (limited to 'core/src/com/ilotterytea/maxoning/utils')
-rw-r--r--core/src/com/ilotterytea/maxoning/utils/colors/HexToARGB.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/src/com/ilotterytea/maxoning/utils/colors/HexToARGB.java b/core/src/com/ilotterytea/maxoning/utils/colors/HexToARGB.java
new file mode 100644
index 0000000..5db8f1d
--- /dev/null
+++ b/core/src/com/ilotterytea/maxoning/utils/colors/HexToARGB.java
@@ -0,0 +1,14 @@
+package com.ilotterytea.maxoning.utils.colors;
+
+import com.badlogic.gdx.graphics.Color;
+
+public final class HexToARGB {
+ public static Color convert(String hex) {
+ hex = hex.charAt(0) == '#' ? hex.substring(1) : hex;
+ int r = Integer.valueOf(hex.substring(0, 2), 16);
+ int g = Integer.valueOf(hex.substring(2, 4), 16);
+ int b = Integer.valueOf(hex.substring(4, 6), 16);
+ int a = hex.length() != 8 ? 255 : Integer.valueOf(hex.substring(6, 8), 16);
+ return new Color(r / 255f, g / 255f, b / 255f, a / 255f);
+ }
+}