Skip to content

Instantly share code, notes, and snippets.

@wbrgss
Forked from matthewkremer/hex_to_rgb.py
Created July 8, 2019 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wbrgss/ac5bdc2cede114b4a4d3d291ce44d665 to your computer and use it in GitHub Desktop.
Save wbrgss/ac5bdc2cede114b4a4d3d291ce44d665 to your computer and use it in GitHub Desktop.
Python Hex Code to RGB Value
def hex_to_rgba(hex, alpha=1):
hex = hex.lstrip('#')
hlen = len(hex)
return tuple(int(hex[i:i+hlen//3], 16) for i in range(0, hlen, hlen//3)) + (alpha,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment