Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devded/a565cc2271e2821c398576b9dd85b5df to your computer and use it in GitHub Desktop.
Save devded/a565cc2271e2821c398576b9dd85b5df to your computer and use it in GitHub Desktop.
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