Generating a rainbow?
Neil Hodgson
nyamatongwe+thunder at gmail.com
Thu Apr 8 18:14:50 EDT 2010
Me:
> You should use different variables for the two loops.
Actually it is closing the divs that makes it work in FireFox:
import colorsys
sat = 1
value = 1
length = 1000
for h in range(0, length + 1):
hue = h / float(length)
color = list(colorsys.hsv_to_rgb(hue, sat, value))
for x in range(3):
color[x] = int(color[x] * 255)
hexval = ("#%02x%02x%02x" % tuple(color)).upper()
print(
"<div style='height: 1; width: 500; background-color: %s'>"
"</div>" % hexval)
More information about the Python-list
mailing list