Created
February 19, 2012 20:30
-
-
Save jtauber/1865616 to your computer and use it in GitHub Desktop.
This file contains 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 colorsys | |
VALUE = 0.8 | |
def to_hex(h, s, v): | |
return "#%02X%02X%02X" % tuple(int(255 * i) for i in colorsys.hsv_to_rgb(h, s, v)) | |
def generate_colour(): | |
a = 1 | |
while True: | |
b = 2 ** a | |
if a > 1: | |
l = range(1, b, 2) | |
else: | |
l = range(0, b) | |
for h in l: | |
for s in [0.2, 0.5, 1]: | |
yield to_hex(1. * h / b, s, VALUE) | |
a += 1 | |
colours = generate_colour() | |
for i in range(100): | |
rgb = colours.next() | |
# print rgb | |
print "<div style='background: %s; height: 100px; width: 100px;'>%s</div>" % (rgb, rgb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment