Example #1
0
    def __init__(self, x=0, y=0, angle=0,
        visible=True, pen_down=True,
        shell_color='DarkGreen', shell_radius=20,
        head_color='Tan', head_radius=8, head_dist=25,
        legs_color='Tan', legs_radius=8, legs_dist=22,
        eyes_color='DarkGreen', eyes_radius=2, size_scaling=1 ):
        # line_drawings will include all the javascript instructions assigned
        # up to the time a new drawing is required, so that it can redraw
        # the entire set of lines, circles, etc.
        self.line_drawings = []
        CTurtle.__init__(self, x, y, angle, visible)
        self.default_colors()
        self.uid = plugin['get_uid']() # determining to which canvas it will be drawn
        if self.uid in _turtles:
            _turtles[self.uid].append(self)
        else:
            _turtles[self.uid] = [self]

        # physical appearance
        self.shell_color = shell_color
        self.shell_radius = shell_radius * size_scaling
        self.head_color = head_color
        self.head_radius = head_radius * size_scaling
        self.head_dist = head_dist * size_scaling
        self.legs_color = legs_color
        self.legs_radius = legs_radius * size_scaling
        self.legs_dist = legs_dist * size_scaling
        self.eyes_color = eyes_color
        self.eyes_radius = eyes_radius *size_scaling
        self.eyes_dist = self.head_dist + self.head_radius/2.
        self.eyes_angle = 0.75 * _math.degrees(
                            _math.atan(1.0*self.head_radius/self.head_dist))
        if self._visible:
            _update_drawing()
Example #2
0
 def goto(self, x, y):  # tested
     '''Moves turtle to specified coordinates, without changing its
     orientation'''
     # draw line then move...
     if self._drawing:
         self.draw_line((self._x, self._y), (x, y))
     CTurtle.goto(self, x, y)
     _update_drawing()
Example #3
0
 def goto(self, x, y): # tested
     '''Moves turtle to specified coordinates, without changing its
     orientation'''
     # draw line then move...
     if self._drawing:
         self.draw_line((self._x, self._y), (x, y))
     CTurtle.goto(self, x, y)
     _update_drawing()
Example #4
0
    def __init__(self,
                 x=0,
                 y=0,
                 angle=0,
                 visible=True,
                 pen_down=True,
                 shell_color='DarkGreen',
                 shell_radius=20,
                 head_color='Tan',
                 head_radius=8,
                 head_dist=25,
                 legs_color='Tan',
                 legs_radius=8,
                 legs_dist=22,
                 eyes_color='DarkGreen',
                 eyes_radius=2,
                 size_scaling=1):
        # line_drawings will include all the javascript instructions assigned
        # up to the time a new drawing is required, so that it can redraw
        # the entire set of lines, circles, etc.
        self.line_drawings = []
        CTurtle.__init__(self, x, y, angle, visible)
        self.default_colors()
        self.uid = plugin['get_uid'](
        )  # determining to which canvas it will be drawn
        if self.uid in _turtles:
            _turtles[self.uid].append(self)
        else:
            _turtles[self.uid] = [self]

        # physical appearance
        self.shell_color = shell_color
        self.shell_radius = shell_radius * size_scaling
        self.head_color = head_color
        self.head_radius = head_radius * size_scaling
        self.head_dist = head_dist * size_scaling
        self.legs_color = legs_color
        self.legs_radius = legs_radius * size_scaling
        self.legs_dist = legs_dist * size_scaling
        self.eyes_color = eyes_color
        self.eyes_radius = eyes_radius * size_scaling
        self.eyes_dist = self.head_dist + self.head_radius / 2.
        self.eyes_angle = 0.75 * _math.degrees(
            _math.atan(1.0 * self.head_radius / self.head_dist))
        if self._visible:
            _update_drawing()
Example #5
0
 def left(self, angle):  # tested
     CTurtle.left(self, angle)
     _update_drawing()
Example #6
0
 def home(self):  # tested
     if self._drawing:
         self.draw_line((self._x, self._y), (0, 0))
     CTurtle.home(self)
     _update_drawing()
Example #7
0
 def default_colors(self):
     """sets the default line color and fill color"""
     CTurtle.default_colors(self)
     self.color(self._line_color)
     self.fill_color(self._fill_color)
Example #8
0
 def color(self, col):
     CTurtle.color(self, col)
     self.line_drawings.append(_set_line_colour(self._line_color))
Example #9
0
 def setheading(self, angle):  # tested
     CTurtle.setheading(self, angle)
     _update_drawing()
Example #10
0
 def right(self, angle):  # tested
     CTurtle.right(self, angle)
     _update_drawing()
Example #11
0
 def setheading(self, angle): # tested
     CTurtle.setheading(self, angle)
     _update_drawing()
Example #12
0
 def right(self, angle): # tested
     CTurtle.right(self, angle)
     _update_drawing()
Example #13
0
 def left(self, angle): # tested
     CTurtle.left(self, angle)
     _update_drawing()
Example #14
0
 def home(self): # tested
     if self._drawing:
         self.draw_line((self._x, self._y), (0, 0))
     CTurtle.home(self)
     _update_drawing()
Example #15
0
 def default_colors(self):
     """sets the default line color and fill color"""
     CTurtle.default_colors(self)
     self.color(self._line_color)
     self.fill_color(self._fill_color)
Example #16
0
 def color(self, col):
     CTurtle.color(self, col)
     self.line_drawings.append(_set_line_colour(self._line_color))