From: Chris Colbert on 8 Apr 2010 13:23 On Thu, Apr 8, 2010 at 1:14 PM, Tobiah <toby(a)rcsreg.com> wrote: >> Look at the colorsys module. >> >> http://docs.python.org/library/colorsys.html?highlight=colorsys#module- > colorsys > > That so rocks. Thanks! > -- > http://mail.python.org/mailman/listinfo/python-list > How does that answer your original question?
From: Tobiah on 8 Apr 2010 14:34 > How does that answer your original question? I was able to do this: import colorsys sat = 1 value = 1 length = 1000 for x in range(0, length + 1): hue = x / 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'>" % hexval http://tobiah.org/rainbow.html
From: Peter Parker on 8 Apr 2010 16:39 Tobiah wrote: >> How does that answer your original question? > > I was able to do this: > > import colorsys > > sat = 1 > value = 1 > length = 1000 > for x in range(0, length + 1): > hue = x / 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'>" > % hexval > > > http://tobiah.org/rainbow.html Roy G. Biv would like you to order the colors according to their wavelength. He would also like to see Orange and Yellow appear in your rainbow.
From: Neil Hodgson on 8 Apr 2010 18:02 Tobiah: > for x in range(0, length + 1): > ... > for x in range(3): You should use different variables for the two loops. Neil
From: Neil Hodgson on 8 Apr 2010 18:14 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)
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: catch clipboard status in gnome Next: Pythonic list reordering |