本文整理汇总了Python中turtle.back函数的典型用法代码示例。如果您正苦于以下问题:Python back函数的具体用法?Python back怎么用?Python back使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了back函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_demo
def draw_demo(turtle):
width = turtle.window_width()
height = turtle.window_height()
cell_size = min(width/8.5, height/7)
turtle.up()
turtle.back(width*.475)
turtle.left(90)
turtle.forward(height*0.4)
turtle.right(90)
turtle.down()
state1 = """\
3|6 2|0 2
-
5 3 1|2 3
- -
3 1 4|3 6
-
5|5 6|6 1
"""
draw_diagram(turtle, state1, cell_size, solution=True)
turtle.right(90)
turtle.forward(cell_size*7)
turtle.left(90)
示例2: B
def B(distance):
'''
This function defines a function B(distance) that moves the turtle backwards "distance"
Inputs: Distance
Distance: can be any float
'''
turtle.back(distance)
示例3: sig
def sig(x,y):
'''
This function adds my signiture to the turtle drawing in a location x,y
pre-conditions: the turtle is somwhere on the board
post-conditions: the turtle is at the base fo my signiture
'''
turtle.up()
turtle.goto(x,y)
turtle.down()
turtle.setheading(0)
turtle.left(90)
turtle.forward(20)
turtle.left(90)
turtle.left(60)
turtle.forward(23)
turtle.left(180)
turtle.forward(23)
turtle.right(60)
turtle.right(90)
turtle.left(45)
turtle.forward(27)
turtle.left(135)
turtle.forward(20)
turtle.up()
turtle.right(90)
turtle.forward(15)
turtle.down()
turtle.right(90)
turtle.forward(20)
turtle.forward(-10)
turtle.right(90)
turtle.back(5)
turtle.forward(60)
示例4: newSnow
def newSnow(size,n):
x=size/2
y=.4
if n<=0 or size<10:
return
else:
for i in range(2):
if n%2==0:
turtle.color("#0099CC")
elif n%3==0:
turtle.color("#B2DFEE")
else:
turtle.color("#00B2EE")
turtle.forward(y*size/2)
turtle.left(60)
newSnow(x,n-1)
turtle.right(120)
newSnow(x,n-1)
turtle.left(60)
x/=2
y+=.2
if n%2==0:
turtle.color("#0099CC")
elif n%3==0:
turtle.color("#B2DFEE")
else:
turtle.color("#00B2EE")
turtle.forward(.4*size/2)
turtle.up()
turtle.back(1.4*size/2)
turtle.down()
return
示例5: treeSimpleVerbose
def treeSimpleVerbose(length, angle, minlength=10, level=0):
recursionPrint("level: {} | length: {} | angle: {}".format(level, length, angle), level)
if length < minlength:
recursionPrint("length < {}, returning\n".format(minlength), level)
return
recursionPrint("forward({})".format(length), level)
t.forward(length)
recursionPrint("left({})".format(angle), level)
t.left(angle)
recursionPrint("calling first tree({}, {}, {})\n".format(length * 0.75, angle, level+1), level)
treeSimpleVerbose(length * 0.75, angle, minlength=minlength, level=level+1)
recursionPrint("right({})".format(2 * angle), level)
t.right(2 * angle)
recursionPrint("calling second tree({}, {}, {})\n".format(length * 0.75, angle, level+1), level)
treeSimpleVerbose(length * 0.75, angle, minlength=minlength, level=level+1)
recursionPrint("left({})".format(angle), level)
t.left(angle)
recursionPrint("back({})".format(length), level)
t.back(length)
示例6: drawA
def drawA(length):
"""
Draw A.
:pre: (relative) pos (0,0), heading (east), up
:post: (relative) pos (length,0), heading (east), up
:return: None
"""
turtle.down()
turtle.left(90)
turtle.forward(length)
turtle.right(90)
turtle.forward(length)
turtle.right(90)
turtle.forward(length)
turtle.up()
turtle.back(length/2)
turtle.right(90)
turtle.down()
turtle.forward(length)
turtle.up()
turtle.back(length)
turtle.left(90)
turtle.forward(length/2)
turtle.left(90)
示例7: draw_arrow
def draw_arrow(turtle, cell_size, rotation=0):
pos = turtle.pos()
turtle.left(rotation)
turtle.back(cell_size*.2)
turtle.down()
turtle.left(90)
turtle.begin_fill()
turtle.forward(cell_size*.05)
turtle.right(90)
turtle.forward(cell_size*.3)
turtle.left(90)
turtle.forward(cell_size*.1)
turtle.right(120)
turtle.forward(cell_size*.3)
turtle.right(120)
turtle.forward(cell_size*.3)
turtle.right(120)
turtle.forward(cell_size*.1)
turtle.left(90)
turtle.forward(cell_size*.3)
turtle.right(90)
turtle.forward(cell_size*.05)
turtle.right(90)
turtle.forward(cell_size*.2)
turtle.end_fill()
turtle.up()
turtle.setpos(pos)
turtle.right(rotation)
示例8: joonista_puu
def joonista_puu(tyve_pikkus, min_haru_pikkus):
"""
Joonistab puu.
Puu on fraktaalne/rekursiivne kujund,
mille tüve küljes on kaks lühema tüvega alampuud:
puu haru. Kui tyve_pikkus < min_haru_pikkus,
siis puu koosneb ainult tüvest.
Funktsioon taastab kilpkonna algse oleku.
"""
# Joonista tüvi
turtle.forward(tyve_pikkus)
# Kui tyve_pikkus > min_haru pikkus
if tyve_pikkus > min_haru_pikkus:
# Keera kilpkonna 45 kraadi vasakule
turtle.left(45)
# Joonista esimene alampuu 0.6*tyve_pikkus
joonista_puu(0.6*tyve_pikkus, min_haru_pikkus)
# Keera kilpkonna 90 kraadi paremale
turtle.right(90)
# Joonista teine alampuu
joonista_puu(0.6*tyve_pikkus, min_haru_pikkus)
# Taasta algne suund
turtle.left(45)
# Taasta algne olek
turtle.back(tyve_pikkus)
示例9: draw_tree
def draw_tree(n, b, l, size):
if n < 0: #base-case
return
elif n == 0: #Draw Leaves
turtle.color("green") #Color of leaves
turtle.width(1)
numberOfLeaves = random.randint(5, 15) #Random number of leaves ranging from 5 to 15
angle = int(270 / numberOfLeaves) #Angle Range between leaves determined by number of leaves
for i in range(numberOfLeaves):
if (randomB(l)):
angle2 = random.randint(0 + (i * angle), 0 + ((i + 1) * angle)) #Angle between different leaves can be different given the Angle Range
angle2-=135
turtle.right(angle2)
turtle.forward(5)
turtle.back(5)
turtle.left(angle2)
return
else: #Draw Tree
turtle.color("brown") #Color of Tree
turtle.forward(size)
b1 = math.floor(5 * b) #Using Bushiness to calculate number of branches: Max branchess are 5
angle = int(270 / b1); #Angle Range between branches determined by Number of Branches
for i in range(b1):
if randomB(b1):
angle2 = random.randint(0 + (i * angle), 0 + ((i + 1) * angle)) #Angle between different branches can be different given the Angle Range
angle2-=135
turtle.right(angle2)
draw_tree(n - 1, b, l, size * random.uniform(0.4, 0.7)) #Recursion step: size of sub-tree is random
turtle.left(angle2)
turtle.color("brown")
turtle.back(size)
return
示例10: nextSlice
def nextSlice():
"""
Moves the turtle to the next slice.
"""
turtle.back(100)
turtle.right(90)
turtle.forward(1)
turtle.left(90)
示例11: draw_pips
def draw_pips(turtle, pips, cell_size):
PIP_PATTERNS = """\
---+
|
|
|
---+
|
O |
|
---+
O |
|
O|
---+
O |
O |
O|
---+
O O|
|
O O|
---+
O O|
O |
O O|
---+
OOO|
|
OOO|
---+
"""
pip_pattern = PIP_PATTERNS.splitlines()[pips*4+1:pips*4+4]
pip_radius = cell_size*0.09
turtle.up()
pos = turtle.pos()
turtle.back(pip_radius*5)
turtle.left(90)
turtle.forward(pip_radius*5)
turtle.right(90)
for i in range(3):
turtle.forward(pip_radius*2)
turtle.right(90)
turtle.forward(pip_radius)
turtle.left(90)
for j in range(3):
if pip_pattern[i][j] == 'O':
turtle.down()
turtle.begin_fill()
turtle.circle(-pip_radius)
turtle.end_fill()
turtle.up()
turtle.forward(pip_radius*3)
turtle.back(pip_radius*11)
turtle.right(90)
turtle.forward(pip_radius*2)
turtle.left(90)
turtle.setpos(pos)
示例12: radar_chart
def radar_chart(data):
# Some "typical" test data
#print "Hello"
length=len(data) # stores the length of the data provided
turtle.home() # Sets the turtle to position (0,0)
division=360/length #what angle is needed for invidual lines
poslist=[] #list to store current position
valpos=[] #list to store position
j=0
turtle.hideturtle() #hides the arrow
#Draw the foundation of the Radar Chart
for i in range(length): # Loop until all the given data is plotted
turtle.forward(200) #move turtle forward
turtle.dot(10,"black") # Draw the black dot at the end of each data
nowpos=turtle.pos() # store the current position
poslist.append(nowpos) #append the current position to list
#turtle.hideturtle()
turtle.setpos(nowpos[0]+10,nowpos[1]) #get the turtle to new postion to write data
turtle.write(data[i], True, align="center") # Write the label of data
turtle.setpos(nowpos[0],nowpos[1]) #return to the previous position
turtle.back(200) #return home
turtle.left(division) # rotate by the specific angle
turtle.home() # return to turtle home
#Connect the ends points of the radar chart
for i in poslist: #
turtle.setpos(i[0],i[1])
#turtle.setpos(i[j],i[j+1])
#turtle.forward(100)
#turtle.home()
#turtle.degree(division)
#turtle.heading()
#turtle.forward(100)
turtle.setpos(poslist[0][0],poslist[0][1])
turtle.home()
#Draw green Dots
for i in range(length):
incval=data[i]
turtle.forward(incval*2)
turtle.dot(15,"green")
nowpos=turtle.pos()
valpos.append(nowpos)
turtle.back(incval*2)
turtle.left(division)
turtle.begin_poly()
turtle.fill(True)
#Fill the green Dots
for i in valpos:
turtle.setpos(int(i[0]),int(i[1]))
turtle.setpos(valpos[0][0],valpos[0][1])
turtle.end_poly()
p = turtle.get_poly()
turtle.register_shape("jpt", p)
turtle.color("Green", "Green")
turtle.begin_fill()
#turtle.p(80)
turtle.end_fill()
turtle.fill(False)
示例13: draw_whole_tree
def draw_whole_tree(x,y):
size = 10
draw_tree(x,y)
draw_star(size,x,y)
for i in coords:
turtle.goto(i)
#draw_bauble()
turtle.back(100)
draw_pot()
示例14: drawTree
def drawTree(n,size):
if(n>0):
turtle.forward(size)
turtle.left(45)
drawTree(n-1,size/2)
turtle.right(90)
drawTree(n-1,size/2)
turtle.left(45)
turtle.back(size)
示例15: draw_wall
def draw_wall(x, y):
goto(x, y)
turtle.color("red")
if y % 2 == 0:
turtle.seth(0)
else:
turtle.seth(90)
turtle.forward(5)
turtle.back(10)