• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python turtle.left函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中turtle.left函数的典型用法代码示例。如果您正苦于以下问题:Python left函数的具体用法?Python left怎么用?Python left使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了left函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: vlocka

def vlocka(velikost=100, pstran=6, rev=False):
    for _ in range(pstran):
        troj(velikost / 3, 3)
        if rev:
            t.left( 360 / pstran )
        else:
            t.right( 360 / pstran )
开发者ID:tlapicka,项目名称:2014-2015.3A,代码行数:7,代码来源:trojuhelnik.py


示例2: polygon

def polygon(side = 50, angle = None, xstart = None, ystart = None, numberSides = 3, color = 'black', fill = False):
    turtle.pensize(3)
    turtle.speed('fastest')
    turtle.hideturtle()
    if angle != None:
        turtle.left(angle)
    
    turtle.penup()
    if fill == True:
        if xstart != None or ystart != None:
            turtle.goto(xstart, ystart)
        else:
            turtle.goto(0, 0)
        turtle.color(color)
        turtle.pendown()
        turtle.begin_fill()
        turtle.circle(side, 360, numberSides)
        turtle.end_fill()
        turtle.penup()
        
    else:
        turtle.goto(xstart, ystart)
        turtle.color(color)
        turtle.pendown()
        turtle.circle(side, 360, numberSides)
        turtle.penup()
    
    return
开发者ID:JakenHerman,项目名称:python-homework,代码行数:28,代码来源:GraphicsAndPatternLibrary.py


示例3: draw

def draw(cmds, size=2): #output tree
    stack = []
    for cmd in cmds:
        if cmd=='F':
            turtle.forward(size)
        elif cmd=='-':
            t = random.randrange(0,7,1)
            p = ["Red","Green","Blue","Grey","Yellow","Pink","Brown"]
            turtle.color(p[t])
            turtle.left(15) #slope left
        elif cmd=='+':
            turtle.right(15) #slope right
            t = random.randrange(0,7,1) #рандомная пер. для цвета
            p = ["Red","Green","Blue","Grey","Yellow","Pink","Brown"] #ряд цветов
            turtle.color(p[t]) #выбор цвета из ряда
        elif cmd=='X':
            pass
        elif cmd=='[':
            stack.append((turtle.position(), turtle.heading()))
        elif cmd==']':
            position, heading = stack.pop()
            turtle.penup()
            turtle.setposition(position)
            turtle.setheading(heading)  
            turtle.pendown()
    turtle.update()
开发者ID:Papapashu,项目名称:main,代码行数:26,代码来源:python_three.py


示例4: draw_star

def draw_star(size, color):

    turtle.pendown()
    turtle.begin_fill()
    turtle.color(1,1,1)
    turtle.forward(2.5) 
    turtle.left(size)
    turtle.forward(2.5)
    turtle.right(144)
    turtle.forward(2.5)
    turtle.left(size)
    turtle.forward(2.5)
    turtle.right(144)
    turtle.forward(2.5)
    turtle.left(size)
    turtle.forward(2.5)
    turtle.right(144)
    turtle.forward(2.5)
    turtle.left(size)
    turtle.forward(2.5)
    turtle.right(144)
    turtle.forward(2.5)
    turtle.left(size)
    turtle.forward(2.5)
    turtle.right(144)
    turtle.end_fill()
    turtle.penup()
开发者ID:mukasama,项目名称:portfolio,代码行数:27,代码来源:Project++04.py


示例5: theStem

def theStem(stemLength=100):
	turtle.home()
	turtle.forward(25)
	turtle.left(90)
	turtle.pensize(4)
	turtle.color("green")
	turtle.forward(stemLength)
开发者ID:KrbAlmryde,项目名称:Homework,代码行数:7,代码来源:ISTA130_HW1b.py


示例6: draw

 def draw(self):
     for i in range(0,2):
         turtle.forward(self.length)
         turtle.left(90)
         turtle.forward(self.width)
         turtle.left(90)
     turtle.done()
开发者ID:ddamuliram,项目名称:Mahadi-Ddamulira,代码行数:7,代码来源:shapes.py


示例7: at

def at(x, y):
    turtle.penup()
    turtle.home()
    turtle.forward(x)
    turtle.left(90)
    turtle.forward(y)
    turtle.pendown()
开发者ID:michaelmp,项目名称:python-lab,代码行数:7,代码来源:lab2.py


示例8: draw_tree

def draw_tree(depth, height, branches, leafs, angle):
    """
    Draws the tree using recursion
    :pre: pos(0,0), heading east, up
    :post: pos(0,0), heading east, up
    :param depth: number of layers of sub branches (recursion depth)
    :param height: height of tree
    :param branches: number of branches
    :param leafs: number of leafs
    :param angle: angle between branches
    :return: None
    """
    if depth == 0:
        leafs = random.randint(0, leafs)
        draw_leaf(leafs)
        t.down()
        pass

    else:
        t.color('brown')
        t.forward(height)
        for i in range(1, branches+1):
            t.left(90 - i * angle)
            #random branches
            branches = random.randint(branches-1,branches+5)
            draw_tree(depth - 1, height * HEIGHT_FACTOR, branches, leafs, angle)
            t.right(90 - i * angle)
            #random angle
            angle = random.randint(angle-1, angle+1)
            if depth == 1:
                break
        t.color('brown')
        t.backward(height)
开发者ID:AnushaBalusu,项目名称:PythonCodes,代码行数:33,代码来源:enhanced_tree.py


示例9: Minkovskiy

def Minkovskiy(l, n):
	if n == 0:
		turtle.forward(l)
	else:
		for angle in [90, -90, -90, 0, 90, 90, -90, 0]:
			Minkovskiy(l/4, n-1)
			turtle.left(angle)
开发者ID:gunther-on-fire,项目名称:boris-the-parselmouth,代码行数:7,代码来源:minkovskiy1.py


示例10: drawHouse

def drawHouse(wallSize):

    """
    This is the function for drawing house which takes
    wall size as a input.
    :pre: (relative) pos (0,0), heading (east), right
    :post: (relative) pos (wallSize,0), heading (north), up
    :return: total wood required to built the house.
    """
    turtle.down()
    turtle.forward(wallSize)
    turtle.left(90)
    turtle.forward(wallSize)
    maxX = turtle.xcor()
    turtle.left(45)
    turtle.forward(wallSize / math.sqrt(2))
    maxY = turtle.ycor()
    turtle.left(90)
    turtle.forward(wallSize / math.sqrt(2))
    turtle.left(45)
    turtle.forward(wallSize)
    turtle.left(90)
    turtle.forward(wallSize)
    turtle.up()
    return 2 * (wallSize + wallSize / math.sqrt(2))
开发者ID:RIT-2015,项目名称:CPS,代码行数:25,代码来源:new_draw.py


示例11: robber_move

def robber_move(turtle):
    fifty_fifty = random.randrange(0, 2)
    if fifty_fifty == 0:
        turtle.right(90)
    else:
        turtle.left(90)
    turtle.forward(10)
开发者ID:guardhunt,项目名称:all_projects,代码行数:7,代码来源:Cop+Robber+Game.py


示例12: drawFins

def drawFins(size):
    
    turtle.fillcolor("red")    
    turtle.setheading(90)
    turtle.begin_fill()
    turtle.forward(0.2*size)
    turtle.left(120)
    turtle.forward(0.6*size) 
    turtle.right(120)
    turtle.forward(0.3*size) 
    turtle.right(40)
    turtle.forward(0.8*size)
    turtle.end_fill()    
    
    turtle.setheading(0)
    
    turtle.begin_fill()

    turtle.penup()
    turtle.forward(size)
    turtle.pendown()
    turtle.begin_fill()
    turtle.right(50)
    turtle.forward(0.8*size) 
    turtle.right(40)
    turtle.forward(0.3*size) 
    turtle.right(120)
    turtle.forward(0.6*size)
    turtle.end_fill()
开发者ID:rckc,项目名称:CoderDojoUWA2016,代码行数:29,代码来源:Peter+-+Space+Rocket.py


示例13: drawY

def drawY(length):
    """
    Draw English character 'Y'
    :pre: (relative) pos (X,Y), heading (east), up
    :post: (relative) pos (X+length,Y), heading (east), up
    :return: None
    """
    turtle.up()
    turtle.left(90)
    turtle.forward(length)
    turtle.right(90)
    turtle.down()
    turtle.right(45)
    turtle.forward(math.sqrt((2 * math.pow((length / 2), 2))))
    # moving at 45 degree angle for length sqrt(((math.pow((length/2)+(math.pow((length/2)),2)))
    # calculated using pythagorean theorem.
    turtle.right(45)
    turtle.forward(length / 2)
    turtle.right(180)
    turtle.forward(length / 2)
    turtle.right(45)
    turtle.forward(math.sqrt((2 * math.pow((length / 2), 2))))
    turtle.right(45)
    turtle.up()
    turtle.right(90)
    turtle.forward(length)
    turtle.left(90)
    turtle.up()
开发者ID:deepaksharma36,项目名称:Python-Assignements,代码行数:28,代码来源:typography.py


示例14: y_tree

def y_tree(length = 200):
    """
    This function receives a length and draws a tree according to the length
    in an angle 60 between the branches always reducing the next length by
    0.6. The drawing ends when the length is smaller than 10
    :param length: The length of the branch to draw, default 200
    :return: None
    """
    ANGLE_BETWEEN_BRANCHES = 60
    LENGTH_REDUCTION = 0.6
    MIN_LENGTH = 10


    if length <= MIN_LENGTH:
        return
    else:
        turtle.forward(length)                  # draws the branch
        turtle.left(ANGLE_BETWEEN_BRANCHES / 2)
        y_tree(LENGTH_REDUCTION * length)       # draws the left branch

        turtle.right(ANGLE_BETWEEN_BRANCHES)
        y_tree(LENGTH_REDUCTION * length)       # draws the right branch

        turtle.left(ANGLE_BETWEEN_BRANCHES / 2)
        turtle.backward(length)                 # returns back to draw next
开发者ID:Metushelah,项目名称:Python_Intro2cs_exercises,代码行数:25,代码来源:y_tree.py


示例15: draw_triangle

def draw_triangle(l):
    i=0
    while(i<3):
        turtle.forward(l)
        turtle.left(120)
        i=i+1
    turtle.done()
开发者ID:gesesew,项目名称:Gesesew-Reta,代码行数:7,代码来源:matplot.py


示例16: dragon

def dragon(level=1, remove_plus_minus=False, width=5):

    a = 'FX'

    rule = {
        'X': 'X+YF+',
        'Y': '-FX-Y',
        '-': '-',
        '+': '+',
        'F': 'F',
    }

    for _ in range(level):
        a = ''.join(rule[x] for x in a)

    print('len:', len(a))

    a = a.replace('X', '').replace('Y','')
    print('len without X, Y:', len(a))
    
    if remove_plus_minus:
        a = a.replace('+-', '').replace('-+', '')
        print('len without -+, +-:', len(a))
            
    for x in a:
        if x == 'F':
            turtle.forward(width)
        elif x == '+':        
            turtle.right(90)
            turtle.color('red')
        elif x == '-':
            turtle.left(90)
            turtle.color('green')

    print('OK')
开发者ID:furas,项目名称:my-python-codes,代码行数:35,代码来源:main.py


示例17: draw_regular_hexagon

def draw_regular_hexagon(l):
    i=0
    while(i<6):
        turtle.forward(l)
        turtle.left(60)
        i=i+1
    turtle.done()
开发者ID:gesesew,项目名称:Gesesew-Reta,代码行数:7,代码来源:matplot.py


示例18: hexagon

def hexagon(sidelen,turtle):
   # turtle.begin_fill()
    for x in range(0, 6):
        #move forward sidelen
        turtle.forward(sidelen)
        #rotate 90 degrees to the left
        turtle.left(60)
开发者ID:laura-james,项目名称:test-repository-for-a-level-demo,代码行数:7,代码来源:turtle+second+function.py


示例19: treeType

def treeType(type):
    """
    This function draws a tree randomly
    :param type: type is any integer between 1-3
    :pre: pos (0,0), heading (east), up
    :post: pos (100,0), heading (east), up
    :return: wood used to make the tree
    """
    global maxheight
    randvalue = 0
    if type == 1:
        randvalue = random.randint(50, 200)
        makeTrunk(randvalue)
        makePolygon(3, 50)
    if type == 2:
        randvalue = random.randint(50, 150)
        makeTrunk(randvalue)
        makePolygon(4, 50)
    if type == 3:
        randvalue = random.randint(50, 150)
        makeTrunk(randvalue)
        makePolygon(0, 25)

    t.right(90)
    t.forward(randvalue)
    t.left(90)
    t.forward(100)
    if randvalue + 50 > maxheight:
        maxheight = randvalue + 50
    return randvalue
开发者ID:lokesh91a,项目名称:Python-Codes,代码行数:30,代码来源:forest.py


示例20: tree

def tree( x, y, scale ):
	'''draws a leaf given location and scale'''
	goto( x, y )
	turtle.setheading(0)
	turtle.begin_fill()
	turtle.color('dark green')
	turtle.forward(25*scale)
	turtle.left(150)
	turtle.forward(25*scale)
	turtle.right(150)
	turtle.forward(20*scale)
	turtle.left(150)
	turtle.forward(30*scale)
	turtle.left(60)
	turtle.forward(30*scale)
	turtle.left(150)
	turtle.forward(20*scale)
	turtle.right(150)
	turtle.forward(25*scale)
	turtle.left(150)
	turtle.end_fill()
	turtle.forward(30*scale)
	goto( x, y )
	turtle.begin_fill()
	turtle.color('brown')
	turtle.right(90)
	turtle.forward(15*scale)
	turtle.right(90)
	turtle.forward(5*scale)
	turtle.right(90)
	turtle.forward(15*scale)
	turtle.right(90)
	turtle.end_fill()
	turtle.forward(5*scale)
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:34,代码来源:shapelib.py



注:本文中的turtle.left函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python turtle.listen函数代码示例发布时间:2022-05-27
下一篇:
Python turtle.ht函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap