# HG changeset patch
# User poeschko <jan.poeschko@gmail.com>
# Date 1333515956 -7200
# Node ID e69edfbce5078648184b6e12459a76066da708f7
# Parent  638055501d7553a8f91383ffa97d3262202932db
#11383: added Color.__eq__ and Color.__hash__ to use __rgb

diff --git a/sage/plot/colors.py b/sage/plot/colors.py
--- a/sage/plot/colors.py
+++ b/sage/plot/colors.py
@@ -479,6 +479,48 @@
                                    for a, b in zip(self.__rgb, color)]))
         raise TypeError("%s must be a Color or float-convertible 3-tuple/list" % (color, ))
 
+    def __eq__(self, right):
+        """
+        Compare two Color objects to determine whether they refer to the same color.
+
+        INPUT:
+
+        - ``right`` - a :class:`Color` instance
+
+        OUTPUT:
+
+        - boolean: True if the two colors are the same, False if different
+
+        EXAMPLES::
+
+            sage: Color('red') == Color((1,0,0))
+            True
+            sage: Color('blue') == Color((0,1,0))
+            False
+            sage: Color('blue') + Color((0,1,0)) == Color((0,0.5,0.5))
+            True
+        """
+        if isinstance(right, Color):
+            return self.__rgb == right.__rgb
+        raise TypeError("%s must be a Color" % (right, ))
+    
+    def __hash__(self):
+        """
+        Return the hash value of a color. Equal colors return equal hash values.
+
+        OUTPUT:
+
+        - a hash value
+
+        EXAMPLES::
+
+            sage: hash(Color('red')) # random
+            873150856
+            sage: hash(Color('red')) == hash(Color((1,0,0)))
+            True
+        """
+        return hash(self.__rgb)
+
     def __add__(self, right):
         """
         Return a color "added" on the right to another color, with
