本文整理汇总了Python中turtle.backward函数的典型用法代码示例。如果您正苦于以下问题:Python backward函数的具体用法?Python backward怎么用?Python backward使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了backward函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: turtle_init
def turtle_init():
turtle.ht()
turtle.up()
turtle.speed(0)
turtle.left(90)
turtle.backward(350)
turtle.down()
开发者ID:TravisWhitaker,项目名称:lsystems,代码行数:7,代码来源:stupid_tree.py
示例2: basaDon
def basaDon():
turtle.penup()
turtle.backward(200)
turtle.right(90)
turtle.forward(100)
turtle.left(90)
turtle.pendown()
开发者ID:FikretPythonLesson,项目名称:Lecture4_Functions,代码行数:7,代码来源:BuyuyenIsim.py
示例3: main
def main():
turtle.left(90)
turtle.up()
turtle.backward(120)
turtle.down()
drawTree(60)
turtle.exitonclick()
开发者ID:sfilata,项目名称:gitskills,代码行数:7,代码来源:treeBranch.py
示例4: backward
def backward(seconds):
turtle.backward(seconds * 100)
motor_on(LEFT_BACKWARD)
motor_on(RIGHT_BACKWARD)
sleep(seconds)
motor_off(LEFT_BACKWARD)
motor_off(RIGHT_BACKWARD)
开发者ID:ryanteck,项目名称:turtlebot,代码行数:7,代码来源:turtlebot.py
示例5: player1_symbol
def player1_symbol(jogada):
if jogada == 1:
go_to(-200,200,45)
elif jogada==2:
go_to(0,200,45)
elif jogada==3:
go_to(200,200,45)
elif jogada==4:
go_to(-200,0,45)
elif jogada==5:
go_to(0,0,45)
elif jogada==6:
go_to(200,0,45)
elif jogada==7:
go_to(-200,-200,45)
elif jogada==8:
go_to(0,-200,45)
elif jogada==9:
go_to(200,-200,45)
turtle.pencolor('green')
for i in range(4):
turtle.forward(75)
turtle.backward(75)
turtle.right(90)
开发者ID:joaomiguelsa,项目名称:Jogo-do-Galo,代码行数:25,代码来源:3+em+linha.py
示例6: drawTree
def drawTree(tree, angle, length, width):
turtle.width(width)
if tree[0] == "ancestor":
# left branch
turtle.left(angle)
turtle.forward(length)
turtle.right(angle)
drawTree(tree[1], angle - 0.2 * angle, length - 0.2 * length, width - 0.3 * width)
turtle.width(width)
turtle.left(angle)
turtle.backward(length)
turtle.right(angle)
# right branch
turtle.right(angle)
turtle.forward(length)
turtle.left(angle)
drawTree(tree[2], angle - 0.2 * angle, length - 0.2 * length, width - 0.3 * width)
turtle.width(width)
turtle.right(angle)
turtle.backward(length)
turtle.left(angle)
else:
# draw the ending node
turtle.pencolor("red")
turtle.write(tree[0], font=("Monospace", 14, "bold"))
turtle.pencolor("black")
开发者ID:gorgitko,项目名称:bioinformatics-chemoinformatics,代码行数:28,代码来源:phylogenetic-tree.py
示例7: pezzo
def pezzo(color, colors = colors, unit = unit, alfa = alfa, depth = depth):
turtle.pencolor(colors[color])
turtle.fillcolor(color)
turtle.begin_fill()
for i in range(2):
turtle.forward(unit)
turtle.left(90)
turtle.forward(unit)
turtle.left(90)
turtle.forward(unit)
for i in range(2):
turtle.left(alfa)
turtle.forward(depth)
turtle.left(alfa)
turtle.forward(unit)
turtle.left(90)
turtle.backward(unit)
turtle.left(90)
turtle.forward(unit)
turtle.right(90)
for i in range(2):
turtle.forward(unit)
turtle.left(alfa)
turtle.forward(depth)
turtle.left(180-alfa)
turtle.end_fill()
turtle.right(90)
turtle.forward(unit)
turtle.left(90)
开发者ID:pennal,项目名称:USI10YearPython,代码行数:29,代码来源:lego.py
示例8: pythagoras_tree
def pythagoras_tree(size, n):
turtle.begin_fill()
for _ in range(4):
turtle.forward(size)
turtle.left(90)
turtle.end_fill()
if n > 0:
roof = .5 * math.sqrt(2) * size
turtle.left(90)
turtle.forward(size)
turtle.right(45)
pythagoras_tree(roof, n - 1)
turtle.forward(roof)
turtle.right(90)
pythagoras_tree(roof, n - 1)
turtle.left(90)
turtle.backward(roof)
turtle.left(45)
turtle.backward(size)
turtle.right(90)
开发者ID:greut,项目名称:turtle-and-l-system,代码行数:26,代码来源:10_01_pythagoras_tree.py
示例9: tscm_backward
def tscm_backward(n):
"""Move the turtle backward a distance N units on the current heading,
without changing direction."""
_check_nums(n)
_tscm_prep()
turtle.backward(n.num_val)
return UNSPEC
开发者ID:UCBpetersoncheng,项目名称:sample,代码行数:7,代码来源:scheme_primitives.py
示例10: render
def render(tree, length, width):
"Draws a given phylogenetic tree constrained by dimensions of"
"length and width."
root = tree[0]
leftTree = tree[1]
rightTree = tree[2]
if leftTree == ():
turtle.dot(10)
turtle.write(root , font=("Arial", 20, "normal"))
return
else:
turtle.dot(10)
turtle.write(root, font=("Arial", 20, "normal"))
turtle.left(90)
turtle.forward(width)
turtle.right(90)
turtle.forward(length)
render(leftTree, 0.5*length, 0.5*width)
turtle.back(length)
turtle.left(90)
turtle.backward(2*width)
turtle.right(90)
turtle.forward(length)
render(rightTree, 0.5*length, 0.5*width)
turtle.back(length)
turtle.right(90)
turtle.back(width)
turtle.left(90)
return
开发者ID:brianconroy,项目名称:Bioinformatics,代码行数:29,代码来源:parsimony.py
示例11: 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
示例12: draw_tree
def draw_tree(length=200):
"""
A recursive function that uses the turtle external library to
draw a binary tree in the size of the user input (or default: 200).
The flow of the function that it first draw a straight line,
the right side branches and then left side branches.
"""
# length is number of pixel
deg = 30 # degrees of each branch (left, right)
if not length < 10:
# Base is when the length is lower then 10,
# otherwise, continue with the iteration.
turtle.forward(length) # Draw straight line forward size length
turtle.right(deg) # Turn right 30 degrees
draw_tree(length*0.6) # Call the recursion to draw the right
# side branches
turtle.left(deg*2) # Then turn left (30 degrees center,
# 30 degrees more to the left)
draw_tree(length*0.6) # Draw inner left side branches
turtle.right(deg) # Turn to center
turtle.backward(length) # Go backwards length size
开发者ID:yochze,项目名称:intro2cs,代码行数:26,代码来源:y_tree.py
示例13: draw_arrow
def draw_arrow():
'''Draw an arrow toward the turtle's current heading, then return to
position and heading.'''
arrow_length = 7 # pixels
arrow_width = 10 # pixels
arrow_end = tt.position()
old_heading = tt.heading()
# move to back end of upper line
tt.penup()
tt.backward(arrow_length)
tt.left(90)
tt.forward(arrow_width)
# draw upper line
tt.pendown()
tt.setposition(arrow_end)
tt.setheading(old_heading)
# move to back end of lower line
tt.penup()
tt.backward(arrow_length)
tt.right(90)
tt.forward(arrow_width)
# draw lower line
tt.pendown()
tt.setposition(arrow_end)
tt.setheading(old_heading)
tt.penup()
开发者ID:xerebus,项目名称:nedm,代码行数:28,代码来源:fieldpic.py
示例14: house
def house(length):
"""
Draw a nice house where the base is length long and put the turtle
back to its original position at the end.
"""
inside = SQRT2 * length
roof = inside / 2.
turtle.forward(length)
turtle.left(90)
turtle.forward(length)
# roof
turtle.left(45)
turtle.forward(roof)
turtle.left(90)
turtle.forward(roof)
turtle.left(45)
# interior
turtle.forward(length)
turtle.left(135)
turtle.forward(inside)
turtle.left(135)
turtle.forward(length)
turtle.left(135)
turtle.forward(inside)
# back into position
turtle.left(45)
turtle.backward(length)
开发者ID:greut,项目名称:turtle-and-l-system,代码行数:31,代码来源:01_00_houses.py
示例15: plot_a_face
def plot_a_face(angle, pencolor, fillcolors, dimension):
t.down()
def plot_a_row(angle, pencolor, fillcolors,dimension):
for i in range(len(fillcolors)):
t.color(pencolor, fillcolors[i])
t.begin_fill()
t.forward(50*3/dimension)
t.right(angle)
t.forward(50*3/dimension)
t.right(180 - angle)
t.forward(50*3/dimension)
t.right(angle)
t.forward(50*3/dimension)
t.right(180 - angle)
t.end_fill()
t.forward(50*3/dimension)
n = int(len(fillcolors)/dimension)
for i in range(n):
plot_a_row(angle,pencolor,fillcolors[dimension*i:dimension*(i+1)],dimension)
t.up()
t.backward(150)
t.right(angle)
t.forward(50*3/dimension)
t.left(angle)
t.down()
开发者ID:BohaoTang,项目名称:Rubik-s-Cube,代码行数:27,代码来源:RubikCube.py
示例16: tscheme_backward
def tscheme_backward(n):
"""Move the turtle backward a distance N units on the current heading,
without changing direction."""
_check_nums(n)
_tscheme_prep()
turtle.backward(n)
return okay
开发者ID:61a-su15-website,项目名称:61a-su15-website.github.io,代码行数:7,代码来源:scheme_primitives.py
示例17: test_same_function_names_work
def test_same_function_names_work(self):
# draw some things using the english commands in tortuga
tortuga.forward(50)
tortuga.left(90)
tortuga.forward(50)
tortuga.right(45)
tortuga.backward(50)
tortuga.left(45)
tortuga.pensize(5)
for c in (english_colors):
tortuga.color(c)
tortuga.forward(10)
# now draw the same things using turtle
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.right(45)
turtle.backward(50)
turtle.left(45)
turtle.pensize(5)
for c in (english_colors):
turtle.color(c)
turtle.forward(10)
# and make sure they both resulted in the same output
self.assert_same()
开发者ID:asweigart,项目名称:tortuga,代码行数:27,代码来源:turtleTest.py
示例18: test_equivalent_spanish_names_work
def test_equivalent_spanish_names_work(self):
# draw some things using the english commands in tortuga
tortuga.adelante(50)
tortuga.izquierda(90)
tortuga.adelante(50)
tortuga.derecho(45)
tortuga.atras(50)
tortuga.izquierda(45)
tortuga.tamano_lapiz(5)
for c in (english_colors):
tortuga.color(c)
tortuga.adelante(10)
for c in (spanish_colors):
tortuga.color(c)
tortuga.adelante(10)
# now draw the same things using turtle
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.right(45)
turtle.backward(50)
turtle.left(45)
turtle.pensize(5)
for c in (english_colors):
turtle.color(c)
turtle.forward(10)
for c in (english_colors):
turtle.color(c)
turtle.forward(10)
# and make sure they both resulted in the same output
self.assert_same()
开发者ID:asweigart,项目名称:tortuga,代码行数:33,代码来源:turtleTest.py
示例19: 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
示例20: backward
def backward(quantity):
"""Turtle animation function.
Moves the turtle backwards by the amount of the passed quantity (converted
from a string to a floating-point value).
"""
convertedQuantity = convertfloat(quantity)
turtle.backward(convertedQuantity)
开发者ID:dan-may,项目名称:turtle,代码行数:8,代码来源:turtledraw.py
注:本文中的turtle.backward函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论