Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Compare equality for colors
  • Loading branch information
mattrobenolt committed May 16, 2012
1 parent 7625f26 commit 065a8c9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/colors.py
Expand Up @@ -45,6 +45,16 @@ def rgb(self):
def hsv(self):
raise NotImplemented

def __eq__(self, other):
self_rgb = self.rgb
other_rgb = other.rgb
return self_rgb.red == other_rgb.red \
and self_rgb.green == other_rgb.green \
and self_rgb.blue == other_rgb.blue

def __ne__(self, other):
return not self.__eq__(other)

def __iter__(self):
""" Treat the color object as an iterable to iterate over color values
Allows mapping such as:
Expand Down

0 comments on commit 065a8c9

Please sign in to comment.