Python turtle 模块,left() 实例源码

我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用turtle.left()

项目:L-Systems-Compiler-And-Renderer    作者:Mizzlr    | 项目源码 | 文件源码
def draw(self):
        "draws the lsystem on the screen"
        stack = []
        tt.penup()
        tt.setpos(0, -200)
        tt.seth(90)
        tt.pendown()

        print "Drawing the lsystem ..."
        for i, codebit in enumerate(self.generation[-1]):

            if codebit in ['F', 'A', 'B']:
                tt.forward(self.length)
                print '[ FRWD ] ', codebit
            elif codebit == '+':
                tt.right(self.angle)
                print '[ RGHT ] ', codebit
            elif codebit == '-':
                tt.left(self.angle)
                print '[ LEFT ] ', codebit
            elif codebit == '[':
                stack.append((tt.pos(), tt.heading()))
                print '[ PUSH ] ', (tt.pos(), tt.heading())
            elif codebit == ']':
                position,heading = stack.pop()
                print '[ POP  ] ', (position, heading)
                tt.penup()
                tt.goto(position)
                tt.seth(heading)
                tt.pendown()
            else:
                print '[ NOP  ] ', codebit

            if self.save_every_frame:
                self.save(frame=i)

        print "Done drawing"
        print "Saving file as %s.jpg" % self.name,
        self.save()
        print "Done"
项目:tp10    作者:electronut    | 项目源码 | 文件源码
def drawStar(N, R):
    turtle.reset()
    a = 360/N
    for i in range(N):
        turtle.fd(R)
        turtle.bk(R)
        turtle.left(a)
项目:tp10    作者:electronut    | 项目源码 | 文件源码
def drawSootSprite(N, R):
    # reset direction
    turtle.reset()
    # draw star
    drawStar(N, R)
    # draw body
    turtle.dot(0.8*2*R)
    # draw right eyeball
    turtle.fd(0.2*R)
    turtle.dot(0.3*R, 'white')
    # draw right pupil
    turtle.pu()
    turtle.bk(0.1*R)
    turtle.pd()
    turtle.dot(0.05*R)
    turtle.pu()
    # centre
    turtle.setpos(0, 0)
    # draw left eyeball
    turtle.bk(0.2*R)
    turtle.pd()
    turtle.dot(0.3*R, 'white')
    # draw left pupil
    turtle.pu()
    turtle.fd(0.1*R)
    turtle.pd()
    turtle.dot(0.05*R)

    turtle.hideturtle()

#drawStar(5, 200)
项目:nautical-combat    作者:horstjens    | 项目源码 | 文件源码
def zweig(laenge = 10, winkel=30, divisor=2):
    if laenge < 2:
        return
    turtle.forward(laenge)
    turtle.left(winkel)
    zweig(laenge//divisor, winkel, divisor)
    turtle.right(winkel*2)
    zweig(laenge//divisor, winkel, divisor)
    turtle.left(winkel)
    turtle.penup()
    turtle.forward(-laenge)
    turtle.pendown()
项目:IPC_2017-1    作者:jucimarjr    | 项目源码 | 文件源码
def draw_star(x, y, side):
    star_angle = 360.0/6
    left_angle = star_angle * 2
    tu.penup()
    tu.goto(x, y)
    tu.pendown()
    for i in range(6):
        tu.forward(side)
        tu.right(star_angle)
        tu.forward(side)
        tu.left(left_angle)
项目:Scheme    作者:StephenK1998    | 项目源码 | 文件源码
def tscheme_left(n):
    """Rotate the turtle's heading N degrees counterclockwise."""
    _check_nums(n)
    _tscheme_prep()
    turtle.left(n)
    return okay
项目:Scheme    作者:StephenK1998    | 项目源码 | 文件源码
def tscheme_circle(r, extent=None):
    """Draw a circle with center R units to the left of the turtle (i.e.,
    right if N is negative.  If EXTENT is not None, then draw EXTENT degrees
    of the circle only.  Draws in the clockwise direction if R is negative,
    and otherwise counterclockwise, leaving the turtle facing along the
    arc at its end."""
    if extent is None:
        _check_nums(r)
    else:
        _check_nums(r, extent)
    _tscheme_prep()
    turtle.circle(r, extent and extent)
    return okay
项目:Charon    作者:forrestchang    | 项目源码 | 文件源码
def tscheme_left(n):
    """Rotate the turtle's heading N degrees counterclockwise."""
    _check_nums(n)
    _tscheme_prep()
    turtle.left(n)
    return okay
项目:Charon    作者:forrestchang    | 项目源码 | 文件源码
def tscheme_circle(r, extent = None):
    """Draw a circle with center R units to the left of the turtle (i.e.,
    right if N is negative.  If EXTENT is not None, then draw EXTENT degrees
    of the circle only.  Draws in the clockwise direction if R is negative,
    and otherwise counterclockwise, leaving the turtle facing along the
    arc at its end."""
    if extent is None:
        _check_nums(r)
    else:
        _check_nums(r, extent)
    _tscheme_prep()
    turtle.circle(r, extent and extent)
    return okay
项目:monty    作者:shoeffner    | 项目源码 | 文件源码
def draw_tree(h):
    if h == 0:
        return
    turtle.forward(LENGTH * h)
    turtle.left(ANGLE)
    draw_tree(h - 1)
    turtle.right(2 * ANGLE)
    draw_tree(h - 1)
    turtle.left(ANGLE)
    turtle.backward(LENGTH * h)
项目:monty    作者:shoeffner    | 项目源码 | 文件源码
def draw_house():
    height = 5
    width = 7
    roofside = (width ** 2 / 2) ** (1 / 2)
    turtle.forward(LENGTH * height)  # left wall
    turtle.right(45)  # roof
    turtle.forward(LENGTH * roofside)
    turtle.right(90)
    turtle.forward(LENGTH * roofside)
    turtle.right(45)
    turtle.forward(LENGTH * height)  # right wall
    turtle.right(90)
    turtle.forward(LENGTH * width)  # bottom line
    turtle.right(90)
项目:monty    作者:shoeffner    | 项目源码 | 文件源码
def prepare_drawing():
    turtle.down()
    turtle.left(90)
项目:thinkcspy-studios    作者:LaunchCodeEducation    | 项目源码 | 文件源码
def draw_square(length, turtle):
    for side in range(4):
        turtle.forward(length)
        turtle.left(90)
项目:thinkcspy-studios    作者:LaunchCodeEducation    | 项目源码 | 文件源码
def draw_grid(length, angle, turtle):
    turtle.left(angle)
    for side in range(4):
        draw_square(length, turtle)
        turtle.left(90)
项目:SchemeInterpreter    作者:GrantHiggins16    | 项目源码 | 文件源码
def tscheme_left(n):
    """Rotate the turtle's heading N degrees counterclockwise."""
    _check_nums(n)
    _tscheme_prep()
    turtle.left(n)
    return okay
项目:SchemeInterpreter    作者:GrantHiggins16    | 项目源码 | 文件源码
def tscheme_circle(r, extent = None):
    """Draw a circle with center R units to the left of the turtle (i.e.,
    right if N is negative.  If EXTENT is not None, then draw EXTENT degrees
    of the circle only.  Draws in the clockwise direction if R is negative,
    and otherwise counterclockwise, leaving the turtle facing along the
    arc at its end."""
    if extent is None:
        _check_nums(r)
    else:
        _check_nums(r, extent)
    _tscheme_prep()
    turtle.circle(r, extent and extent)
    return okay