Generating a rainbow?

Peter Parker parkerp at example.net
Thu Apr 8 22:39:17 CEST 2010


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.



More information about the Python-list mailing list