Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TurtleArt/taconstants.py2
-rw-r--r--TurtleArt/taturtle.py25
2 files changed, 21 insertions, 6 deletions
diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py
index b20948d..8c7eac9 100644
--- a/TurtleArt/taconstants.py
+++ b/TurtleArt/taconstants.py
@@ -168,7 +168,7 @@ SELECTED_STROKE_WIDTH = 1.0
STANDARD_STROKE_WIDTH = 1.0
BLOCK_SCALE = 2.0
PALETTE_SCALE = 1.5
-DEFAULT_TURTLE = 1
+DEFAULT_TURTLE = 'Yertle'
HORIZONTAL_PALETTE = 0
VERTICAL_PALETTE = 1
BLACK = -9999
diff --git a/TurtleArt/taturtle.py b/TurtleArt/taturtle.py
index abfb415..f5e2c5e 100644
--- a/TurtleArt/taturtle.py
+++ b/TurtleArt/taturtle.py
@@ -21,6 +21,7 @@
from taconstants import TURTLE_LAYER
from tasprite_factory import SVG, svg_str_to_pixbuf
+from tacanvas import wrap100, color_table
from sprites import Sprite
def generate_turtle_pixbufs(colors):
@@ -102,7 +103,7 @@ class Turtles:
# A class for the individual turtles
#
class Turtle:
- def __init__(self, turtles, key, colors=None):
+ def __init__(self, turtles, key, turtle_colors=None):
""" The turtle is not a block, just a sprite with an orientation """
self.x = 0
self.y = 0
@@ -116,11 +117,25 @@ class Turtle:
self.pen_size = 5
self.pen_state = True
- if colors is None:
- self.shapes = turtles.get_pixbufs()
- else:
- self.colors = colors[:]
+ # If the turtle key is an int, we'll use a palette color as the
+ # turtle color
+ try:
+ int_key = int(key)
+ use_color_table = True
+ except ValueError:
+ use_color_table = False
+
+ if turtle_colors is not None:
+ self.colors = turtle_colors[:]
self.shapes = generate_turtle_pixbufs(self.colors)
+ elif use_color_table:
+ fill = wrap100(int_key)
+ stroke = wrap100(fill + 10)
+ self.colors = ['#%06x' % (color_table[fill]),
+ '#%06x' % (color_table[stroke])]
+ self.shapes = generate_turtle_pixbufs(self.colors)
+ else:
+ self.shapes = turtles.get_pixbufs()
if turtles.sprite_list is not None:
self.spr = Sprite(turtles.sprite_list, 0, 0, self.shapes[0])