Created
March 29, 2024 15:59
-
-
Save hariedo/0c0a7f2bc72da70f53a6bff18f28fe66 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public static Color HexRGB(uint hexcode) | |
{ | |
// e.g., 0xFF0033 | |
float b = (hexcode & 0xFF) / 255f; | |
float g = ((hexcode >> 8) & 0xFF) / 255f; | |
float r = ((hexcode >> 16) & 0xFF) / 255f; | |
return new Color(r, g, b); | |
} | |
public static Color HexRGBA(uint hexcode) | |
{ | |
// e.g., 0xFF003380 | |
float a = (hexcode & 0xFF) / 255f; | |
float b = ((hexcode >> 8) & 0xFF) / 255f; | |
float g = ((hexcode >> 16) & 0xFF) / 255f; | |
float r = ((hexcode >> 24) & 0xFF) / 255f; | |
return new Color(r, g, b, a); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment