本文整理汇总了Python中turtle.back函数的典型用法代码示例。如果您正苦于以下问题:Python back函数的具体用法?Python back怎么用?Python back使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了back函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:donkirkby,项目名称:donimoes,代码行数:25,代码来源:diagram.py
示例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)
开发者ID:hehe3301,项目名称:Recursion_Training,代码行数:7,代码来源:mystuff.py
示例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)
开发者ID:hehe3301,项目名称:Recursion_Training,代码行数:33,代码来源:mystuff.py
示例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
开发者ID:wish343,项目名称:Python,代码行数:32,代码来源:SnowFlake.py
示例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)
开发者ID:gorgitko,项目名称:bioinformatics-chemoinformatics,代码行数:25,代码来源:recursive-tree.py
示例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)
开发者ID:deepaksharma36,项目名称:Python-Assignements,代码行数:25,代码来源:typography.py
示例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)
开发者ID:donkirkby,项目名称:donimoes,代码行数:28,代码来源:diagram.py
示例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)
开发者ID:Azelor,项目名称:pythons,代码行数:25,代码来源:10-recursive_tree.py
示例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
开发者ID:wish343,项目名称:Python,代码行数:32,代码来源:enhanced_tree.py
示例10: nextSlice
def nextSlice():
"""
Moves the turtle to the next slice.
"""
turtle.back(100)
turtle.right(90)
turtle.forward(1)
turtle.left(90)
开发者ID:Yash3667,项目名称:GeigerToKML,代码行数:8,代码来源:ColorTest.py
示例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)
开发者ID:donkirkby,项目名称:donimoes,代码行数:58,代码来源:diagram.py
示例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)
开发者ID:aadeshnpn,项目名称:timepass,代码行数:57,代码来源:radar_chart.py
示例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()
开发者ID:nyep,项目名称:learning-prog,代码行数:9,代码来源:turtleTree+[WIP].py
示例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)
开发者ID:towardsRevolution,项目名称:Aditya-s-Python-Codes,代码行数:9,代码来源:tree.py
示例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)
开发者ID:siddhi,项目名称:playful_python,代码行数:9,代码来源:util.py
示例16: draw_tree
def draw_tree(size, angle, min_size, scale_factor):
if size > min_size:
turtle.forward(size)
turtle.right(angle)
draw_tree(size * scale_factor, angle, min_size, scale_factor)
turtle.left(angle*2)
draw_tree(size * scale_factor, angle, min_size, scale_factor)
turtle.right(angle)
turtle.back(size)
开发者ID:NickChapman,项目名称:Nick-Chapman,代码行数:9,代码来源:draw_tree.py
示例17: draw_star
def draw_star(xcor, ycor):
turtle.up()
turtle.setposition(xcor, ycor + 40)
turtle.down()
for x in range(0, 8):
turtle.forward(30)
turtle.back(30)
turtle.left(45)
turtle.up()
开发者ID:RIT-2015,项目名称:CPS,代码行数:9,代码来源:drawImage.py
示例18: draw_star
def draw_star(ycor):
turtle.up()
turtle.left(90)
turtle.forward(ycor+40)
turtle.down()
for x in range(0, 8):
turtle.forward(30)
turtle.back(30)
turtle.left(45)
turtle.up()
开发者ID:RIT-2015,项目名称:CPS,代码行数:10,代码来源:draw_image.py
示例19: render
def render(self):
turtle.up()
w=turtle.window_width()
self.dist=w/len(self.string)
turtle.back(w/2)
turtle.shape("turtle")
for c in self.string:
self.draw(c)
turtle.hideturtle()
turtle.exitonclick()
开发者ID:weka511,项目名称:fractals,代码行数:10,代码来源:Lindenmayer.py
示例20: main
def main():
"""
:pre:(relative) pos (0,0), heading (east), up
:post:(relative) pos (X,0), heading (east), up
:return: none
"""
numberOfTree=int(raw_input("How many trees in your forest ?"))
treeHome=["Mapel","Pine","bodhiTree"]
dummy_house=raw_input("Is there a house in the forest (y/n)?")
highestHeight=50
treeHomeRandom=[treeHome[r.randint(0,2)] for n in range(numberOfTree) ]
if dummy_house in ['Y','y']:
if numberOfTree>2:
treeHomeRandom.insert(r.randint(1,numberOfTree-2),"House")
elif numberOfTree<=2:
treeHomeRandom.insert(1,"House")
if numberOfTree <= 11:
if dummy_house in ['Y','y']:
init(-(numberOfTree+1)*100/2,-100)
else:
init(-(numberOfTree)*100/2,-100)
else:
init(-600,-100)
#print(treeHomeRandom)
totalWood=0
for myTree in treeHomeRandom:
(length,totalWood)=treeAndHouse(myTree,totalWood)
if length>highestHeight:
highestHeight=length
t.up()
t.forward(100)
t.down()
t.up()
t.back(100)
star2(highestHeight+10)
raw_input("Night is done Press Enter for day")
t.reset()
print("We have " + str(totalWood) +" units of lumber for building." )
print ("We will build a house with walls " + str((totalWood)/(2+math.sqrt(2)))+ " tall.")
init(0,-300)
house((totalWood)/(2+math.sqrt(2)))
t.left(90)
t.forward(3*abs((totalWood)/(2+math.sqrt(2)))/2+30)
t.right(90)
maple_shape(30)
t.right(90)
t.up()
t.back(3*abs((totalWood)/(2+math.sqrt(2)))/2+30)
t.right(90)
raw_input("Day is done, house is build, Press enter to quit")
开发者ID:deepaksharma36,项目名称:Python-Assignements,代码行数:55,代码来源:forest.py
注:本文中的turtle.back函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论