diff options
author | Walter Bender <walter@sugarlabs.org> | 2014-01-24 00:06:43 (GMT) |
---|---|---|
committer | Walter Bender <walter@sugarlabs.org> | 2014-01-24 00:06:43 (GMT) |
commit | 30ff5e89db6ac91b6bc49d15f4d2e7984fc0bc0a (patch) | |
tree | 77e1ded186bd89cc89c5a6b9da3e94a4d7cdc409 /TurtleArt/taconstants.py | |
parent | e07c9f11f03e239e56345ea05bd34b31716b52f9 (diff) |
fix to color constant block
Diffstat (limited to 'TurtleArt/taconstants.py')
-rw-r--r-- | TurtleArt/taconstants.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py index a8fc046..0a3cc23 100644 --- a/TurtleArt/taconstants.py +++ b/TurtleArt/taconstants.py @@ -151,6 +151,26 @@ REVERSE_KEY_DICT = { } +class ColorObj(object): + def __init__(self, color): + self.color = color + + def __int__(self): + if self.color.color is None: + return int(self.color.shade) + else: + return int(self.color.color) + + def __float__(self): + return float(int(self)) + + def __str__(self): + return str(self.color.name) + + def __repr__(self): + return str(self.color.name) + + class Color(object): """ A color used in block programs (e.g., as pen color). """ @@ -176,6 +196,9 @@ class Color(object): def get_number_string(self): return str(int(self)) + def get_number_name(self): + return str(self.name) + def __str__(self): return str(self.name) |