[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] easy way to check pygame.Color() equality?



High Marcus,

I agree that comparing a color to a string was not a good idea. That can go as 1.9.0 is still pre-alpha. For backwards compatibility comparison with a tuple will remain valid in Pygame 1.9.

Lenard


Marcus von Appen wrote:
On, Wed Jan 14, 2009, Jake b wrote:

How so, or what do I need to watch? Meaning is it safe for now to do?:

if self.color == pygame.Color("red"): print 'same color!'

In the recent pygame versions you can do something like:

if color == "0xff0000": print "it's red!"

Comparing a color to a string however is something that should not give
a valid result, just as other type comparisions:

"1" == 1
False

In pgreloaded you only can compare a Color object with a another Color
object.


--
Lenard Lindstrom
<len-l@xxxxxxxxx>