From 6377ee262c95537355801ee28149b87eb6d9cb9e Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Fri, 26 Aug 2022 18:23:43 +0600 Subject: Initial commit --- .../com/ilotterytea/maxoning/utils/colors/HexToARGB.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 core/src/com/ilotterytea/maxoning/utils/colors/HexToARGB.java (limited to 'core/src/com/ilotterytea/maxoning/utils') 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); + } +} -- cgit v1.2.3