[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] easy way to check pygame.Color() equality?
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] easy way to check pygame.Color() equality?
- From: "René Dudfield" <renesd@xxxxxxxxx>
- Date: Mon, 12 Jan 2009 19:36:53 +1100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 12 Jan 2009 03:36:57 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=EzNQIuZMvYl8ajEoyWaz3f7LelnaqiikiWv2p05pTyo=; b=QErFU1hRevrlrAGqD9ngI6S/C3LdcIrAi4pMIyMtKCQNcN+vZectwyTdbmt+a74Eja BbEEj89+zl+qE5h7Xjd0VLwEdvgfDA5EMkR8xUYm/YGZu2Veww17G+TXxOzH88syIh+s TXQyKm5EcXK4ibXdKfGrI1qbgXKrLaYaDklNg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=pH/pNdPsdSCuErhJEVg4jusUl+qqC+Tz0ekMJN0smFkcn8LvwXe8vA8AE/r8CNVKIP uSl95l42ez9vVdKH+FobgGs7dQvG5GJ2h8p58I4fYpicp1JF7ANY4w7YkM/F1yAAn2Hq oiNmJBEzXLH7xp/uYiGsScCFS5KgFtfiJ0U3I=
- In-reply-to: <dc44bb3e0901112324q282b5f40hea232a975bc2e424@xxxxxxxxxxxxxx>
- References: <dc44bb3e0901112324q282b5f40hea232a975bc2e424@xxxxxxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
hi,
I think that should work... and does in fact work for me...
>>> r = pygame.Color("red")
>>> r == pygame.Color("red")
True
Maybe it is your pygame version? What version do you have? I'm using
pygame 1.9.0pre (from subversion). The color class changed in pygame
1.8.1.
>>> import pygame
>>> print pygame.version.ver
Also, note that you might want to compare to color thresholds, or
weights... which is what the pygame.transform.threshold and
pygame.PixelArray.compare functions are for. If you don't want to
compare exact colors, but colors within a certain range.
cheers,
On Mon, Jan 12, 2009 at 6:24 PM, Jake b <ninmonkeys@xxxxxxxxx> wrote:
> How do I check for color equality?
>
>>>> r = pygame.Color("red")
>>>> r == pygame.Color("red")
> returns False # expected True, since I don't care if they are the same
> instance of a Color() class
>
> I thought it would be an equality test., like this: [ The print out has
> equivalent values. ]
>
> def ceq(c1,c2):
> return c1.r == c2.r and c1.g == c2.g and c1.b == c2.b and c1.a == c2.a
> --
> Jake
>