Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TurtleArt/taconstants.py18
-rw-r--r--TurtleArt/taprimitive.py20
2 files changed, 30 insertions, 8 deletions
diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py
index 0a3cc23..469f5d3 100644
--- a/TurtleArt/taconstants.py
+++ b/TurtleArt/taconstants.py
@@ -156,18 +156,28 @@ class ColorObj(object):
self.color = color
def __int__(self):
- if self.color.color is None:
- return int(self.color.shade)
+ if hasattr(self.color, 'color'):
+ if self.color.color is None:
+ return int(self.color.shade)
+ else:
+ return int(self.color.color)
else:
- return int(self.color.color)
+ return int(self.color)
def __float__(self):
- return float(int(self))
+ if hasattr(self.color, 'color'):
+ return float(int(self))
+ else:
+ return float(self.color)
def __str__(self):
+ if isinstance(self.color, (float, int, bool)):
+ return str(self.color)
return str(self.color.name)
def __repr__(self):
+ if isinstance(self.color, (float, int, bool)):
+ return str(self.color)
return str(self.color.name)
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index 197a8d8..e840d92 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -28,7 +28,7 @@ import traceback
from tablock import Media
from tacanvas import TurtleGraphics
-from taconstants import (Color, CONSTANTS)
+from taconstants import (Color, CONSTANTS, ColorObj)
from talogo import (LogoCode, logoerror, NegativeRootError)
from taturtle import (Turtle, Turtles)
from TurtleArt.tatype import (TYPE_CHAR, TYPE_INT, TYPE_FLOAT, TYPE_OBJECT,
@@ -761,17 +761,29 @@ class Primitive(object):
@staticmethod
def equals(arg1, arg2):
""" Return arg1 == arg2 """
- return arg1 == arg2
+ # See comment in tatype.py TYPE_BOX -> TYPE_COLOR
+ if isinstance(arg1, ColorObj) or isinstance(arg2, ColorObj):
+ return str(arg1) == str(arg2)
+ else:
+ return arg1 == arg2
@staticmethod
def less(arg1, arg2):
""" Return arg1 < arg2 """
- return arg1 < arg2
+ # See comment in tatype.py TYPE_BOX -> TYPE_COLOR
+ if isinstance(arg1, ColorObj) or isinstance(arg2, ColorObj):
+ return float(arg1) < float(arg2)
+ else:
+ return arg1 < arg2
@staticmethod
def greater(arg1, arg2):
""" Return arg1 > arg2 """
- return arg1 > arg2
+ # See comment in tatype.py TYPE_BOX -> TYPE_COLOR
+ if isinstance(arg1, ColorObj) or isinstance(arg2, ColorObj):
+ return float(arg1) > float(arg2)
+ else:
+ return arg1 > arg2
@staticmethod
def comment(text):