Skip to content

Instantly share code, notes, and snippets.

@dimazest
Created January 31, 2015 15:11
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 dimazest/2717e2c2730fc44bf450 to your computer and use it in GitHub Desktop.
Save dimazest/2717e2c2730fc44bf450 to your computer and use it in GitHub Desktop.
random, yet matching colors
from colorsys import rgb_to_hls, hls_to_rgb
import random
def colors():
r, g, b = 1, 0, 0
h, l, s = rgb_to_hls(r, g, b)
while True:
h += 30./360
if h > 1.0:
h -= 1
l = random.random()
s = random.random()
yield hls_to_rgb(h, s, l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment