'Manages the correct rendering of the turtle with respect to
its shape, resizemode, stretch and tilt etc.'

def _drawturtle(self):

    screen = self.screen
    shape = screen._shapes[self.turtle.shapeIndex]
    ttype = shape._type
    titem = self.turtle._item
    if (self._shown and (screen._updatecounter == 0) and (screen._tracing > 0)):
        self._hidden_from_screen = False
        tshape = shape._data
        if (ttype == 'polygon'):
            if (self._resizemode == 'noresize'):
                w = 1
                shape = tshape
            else:
                if (self._resizemode == 'auto'):
                    lx = ly = max(1, (self._pensize / 5.0))
                    w = self._pensize
                    tiltangle = 0
                elif (self._resizemode == 'user'):
                    (lx, ly) = self._stretchfactor
                    w = self._outlinewidth
                    tiltangle = self._tilt
                shape = [((lx * x), (ly * y)) for (x, y) in tshape]
                (t0, t1) = (math.sin(tiltangle), math.cos(tiltangle))
                shape = [(((t1 * x) + (t0 * y)), (((- t0) * x) + (t1 * y))) for (x, y) in shape]
            shape = self._polytrafo(shape)
            (fc, oc) = (self._fillcolor, self._pencolor)
            screen._drawpoly(titem, shape, fill=fc, outline=oc, width=w, top=True)
        elif (ttype == 'image'):
            screen._drawimage(titem, self._position, tshape)
        elif (ttype == 'compound'):
            (lx, ly) = self._stretchfactor
            w = self._outlinewidth
            for (item, (poly, fc, oc)) in zip(titem, tshape):
                poly = [((lx * x), (ly * y)) for (x, y) in poly]
                poly = self._polytrafo(poly)
                screen._drawpoly(item, poly, fill=self._cc(fc), outline=self._cc(oc), width=w, top=True)
    else:
        if self._hidden_from_screen:
            return
        if (ttype == 'polygon'):
            screen._drawpoly(titem, ((0, 0), (0, 0), (0, 0)), '', '')
        elif (ttype == 'image'):
            screen._drawimage(titem, self._position, screen._shapes['blank']._data)
        elif (ttype == 'compound'):
            for item in titem:
                screen._drawpoly(item, ((0, 0), (0, 0), (0, 0)), '', '')
        self._hidden_from_screen = True
