[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Further standardizations



Jan Ekholm wrote:
> 
> Personally I'd like more to use (r,g,b,a) tuples. The color index is not
> intuitive, as most places elsewhere use RGB[A]. If possible and without a
> performance hit I'd suggest abandoning the color index thing. But it may
> be there for a good reason in SDL, so it may be worth being sure about
> this?
> 

In an RGB type color mode, converting the tuple to a pixel value
takes very little time, but in a color-indexed mode it has to search
a table for the closest match. If you do a lot of color lookups
the performance will suffer, which is why SDL uses pixel values for
most operations, and has a lookup function to retrieve them - you can
cache the retrieved values.

I think the lookup function overhead will be lost in the noise of the
python parameter parsing anyway, so it's probably not a big deal to
pass in a color tuple to the python functions. Perhaps some benchmarking
would help here.

However, consistancy is important, and we have a means to do direct 
pixel manipulation, which requires pixel values instead of color tuples.
Maybe that's the way to go.

-Ray
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org