Skip to content

Instantly share code, notes, and snippets.

@RonjaPonja
Created April 5, 2015 13:58
Show Gist options
  • Select an option

  • Save RonjaPonja/0270fc61124cfc85c024 to your computer and use it in GitHub Desktop.

Select an option

Save RonjaPonja/0270fc61124cfc85c024 to your computer and use it in GitHub Desktop.
rgbToHex
def rgbToHex(r, g, b):
rHex = hex(r)[2:]
gHex = hex(g)[2:]
bHex = hex(b)[2:]
colour = ""
for subColour in [rHex,gHex,bHex]:
if len(subColour) < 2:
colour += "0" + subColour
else:
colour += subColour
return colour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment