diff options
author | Walter Bender <walter.bender@gmail.com> | 2013-01-17 19:25:06 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2013-01-17 19:25:06 (GMT) |
commit | 4e1b79276d531133263857317e09013d5ab0c72e (patch) | |
tree | 14a25a75c35871c8717ca6f080eaf51e73764cec /TurtleArt/tacanvas.py | |
parent | ba5775ed0ba8f213ed4a56f9c7a5df3966af3c64 (diff) |
refactoring of color constants
Diffstat (limited to 'TurtleArt/tacanvas.py')
-rw-r--r-- | TurtleArt/tacanvas.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/TurtleArt/tacanvas.py b/TurtleArt/tacanvas.py index e1e229e..41aaa75 100644 --- a/TurtleArt/tacanvas.py +++ b/TurtleArt/tacanvas.py @@ -34,7 +34,7 @@ from sprites import Sprite from tasprite_factory import SVG from tautils import image_to_base64, get_path, data_to_string, round_int, \ debug_output -from taconstants import BLACK, WHITE +from taconstants import CONSTANTS, COLORDICT, BLACK, WHITE def wrap100(n): @@ -423,6 +423,17 @@ class TurtleGraphics: def setcolor(self, c, share=True): ''' Set the pen color ''' + + # Special case for color blocks + if c in CONSTANTS: + self.setshade(COLORDICT[c][1], share) + self.setgray(COLORDICT[c][2], share) + if COLORDICT[c][0] is not None: + self.setcolor(COLORDICT[c][0], share) + c = COLORDICT[c][0] + else: + c = self.color + try: self.color = c except TypeError, ValueError: |