Created
July 20, 2018 04:49
-
-
Save prerakmody/505d6d41618eaf7b1d84a07c3336d149 to your computer and use it in GitHub Desktop.
Code Snipets on Colors in python
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
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