Created
March 16, 2023 15:43
-
-
Save devded/a565cc2271e2821c398576b9dd85b5df 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
def rgba_to_hex(rgba_color): | |
# Convert the RGBA color value to a 32-bit integer | |
hex_value = (int(rgba_color[3] * 255) << 24) | (rgba_color[0] << 16) | (rgba_color[1] << 8) | rgba_color[2] | |
# Convert the 32-bit integer to a hexadecimal string | |
hex_string = hex(hex_value) | |
# Return the result | |
return hex_string | |
rgba_color = (112, 121, 138, 0.1); | |
hex_value = rgba_to_hex(rgba_color) | |
print(hex_value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment