Skip to content

Instantly share code, notes, and snippets.

@prerakmody
Created July 20, 2018 04:49
Show Gist options
  • Save prerakmody/505d6d41618eaf7b1d84a07c3336d149 to your computer and use it in GitHub Desktop.
Save prerakmody/505d6d41618eaf7b1d84a07c3336d149 to your computer and use it in GitHub Desktop.
Code Snipets on Colors in python
import random
import colorsys
def get_random_color():
h,s,l = random.random(), 0.5 + random.random()/2.0, 0.4 + random.random()/5.0
r,g,b = [int(256*i) for i in colorsys.hls_to_rgb(h,l,s)]
person_color1 = '#%02x%02x%02x' % (r,g,b)
person_color2 = "#" + "%06x" % random.randint(0, 0xFFFFFF)
return [(r,g,b), person_color1], person_color2
if __name__ == __main__:
print (get_random_color())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment