Generating a rainbow?

Chris Colbert sccolbert at gmail.com
Thu Apr 8 13:06:53 EDT 2010


On Thu, Apr 8, 2010 at 12:46 PM, Tobiah <toby at rcsreg.com> wrote:
> I'm having a difficult time with this.  I want
> to display a continuous range of hues using HTML
> hex representation (#RRGGBB).  How would I go
> about scanning through the hues in order to
> make a rainbow?
>
> Thanks,
>
> Toby
> --
> http://mail.python.org/mailman/listinfo/python-list
>

In [43]: possible = []

In [44]: for i in range(2**8):
   ....:     h = hex(i).lstrip('0x')
   ....:     while len(h) < 2:
   ....:         h = '0' + h
   ....:     possible.append(h)
   ....:
   ....:

In [45]: full = [r + g + b for r in possible for g in possible for b
in possible]

In [46]: len(full)
Out[46]: 16777216

In [47]: 2**24
Out[47]: 16777216



More information about the Python-list mailing list