Auto color selection PIL

Leif K-Brooks eurleif at ecritters.biz
Thu Sep 28 12:04:47 CEST 2006


Gabriel Genellina wrote:
> Try this. It first chooses 0, 1/2, then 1/4, 3/4, then */8...
> It's the best I could make if you don't know the number of colors 
> beforehand. If you *do* know how many colors, your previous response is OK.

Um, that's the same thing my second suggestion does:

  >>> h = hues()
  >>> h.next()
  0.0
  >>> h.next()
  0.5
  >>> h.next()
  0.25
  >>> h.next()
  0.75
  >>> h.next()
  0.125

Your implementation is less terse than mine, though. And I suspect it 
runs faster, though I haven't checked that.



More information about the Python-list mailing list