本文整理汇总了Python中turtle.left函数的典型用法代码示例。如果您正苦于以下问题:Python left函数的具体用法?Python left怎么用?Python left使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了left函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 )
示例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
示例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()
示例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()
示例5: theStem
def theStem(stemLength=100):
turtle.home()
turtle.forward(25)
turtle.left(90)
turtle.pensize(4)
turtle.color("green")
turtle.forward(stemLength)
示例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()
示例7: at
def at(x, y):
turtle.penup()
turtle.home()
turtle.forward(x)
turtle.left(90)
turtle.forward(y)
turtle.pendown()
示例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)
示例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)
示例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))
示例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)
示例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()
示例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()
示例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
示例15: draw_triangle
def draw_triangle(l):
i=0
while(i<3):
turtle.forward(l)
turtle.left(120)
i=i+1
turtle.done()