本文整理汇总了Python中turtle.speed函数的典型用法代码示例。如果您正苦于以下问题:Python speed函数的具体用法?Python speed怎么用?Python speed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了speed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: turtle_init
def turtle_init():
turtle.ht()
turtle.up()
turtle.speed(0)
turtle.left(90)
turtle.backward(350)
turtle.down()
示例2: draw_starrows
def draw_starrows(row):
color2 = 1
color = get_color(color2)
x = -160
y = 150
## This for loop draws 10 stars for each row above (5 total x 10 = 50).
for z in range(10):
x += 15
turtle.up()
turtle.color(color)
turtle.speed(100)
turtle.setpos(x,row)
turtle.begin_fill()
turtle.down()
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.end_fill()
示例3: draw_walk
def draw_walk(x, y, speed = 'slowest', scale = 20):
''' Animate a two-dimensional random walk.
Args:
x x positions
y y positions
speed speed of the animation
scale scale of the drawing
'''
# Reset the turtle.
turtle.reset()
turtle.speed(speed)
# Combine the x and y coordinates.
walk = zip(x * scale, y * scale)
start = next(walk)
# Move the turtle to the starting point.
turtle.penup()
turtle.goto(*start)
# Draw the random walk.
turtle.pendown()
for _x, _y in walk:
turtle.goto(_x, _y)
示例4: __init__
def __init__(self, length=10, angle=90, colors=None, lsystem=None):
import turtle
self.length = length
self.angle = angle
if colors is None:
self.colors = ['red', 'green', 'blue', 'orange', 'yellow', 'brown']
if lsystem is not None:
self.lsystem(lsystem)
# draw number
self.ith_draw = 0
# origin of next draw
self.origin = [0, 0]
# bounding_box
self._box = 0, 0, 0, 0
# turtle head north and positive angles is clockwise
turtle.mode('world')
turtle.setheading(90)
turtle.speed(0) # fastest
turtle.hideturtle()
turtle.tracer(0, 1)
# set pencolor
self.pencolor()
示例5: rectangle
def rectangle(length = 50, width = 30, x = 0, y = 0, color = 'black', fill = False):
turtle.pensize(3)
turtle.speed('fastest')
turtle.hideturtle()
if fill == True:
turtle.color(color)
for i in range(width):
turtle.setposition(x, (y+i))
turtle.pendown()
turtle.setposition((x+length), (y+i))
turtle.penup()
else:
turtle.penup()
turtle.goto(x,y)
turtle.color(color)
turtle.pendown()
turtle.forward(length)
turtle.left(90)
turtle.forward(width)
turtle.left(90)
turtle.forward(length)
turtle.left(90)
turtle.forward(width)
turtle.left(90)
turtle.penup()
return
示例6: main
def main():
while True:
side = input("Please enter the total length of the figure: ")
try:
side = int(side)
except:
print('Please enter a valid number.\n')
continue
break
while True:
id = input("Please enter MSU ID (including the starting letter): ")
if len(id) == 9 and id[0].isalpha() and all(d.isdigit() for d in id[1:]):
break
else:
print('Please enter a valid MSU ID.\n')
continue
turtle.colormode(1.0)
turtle.speed(0)
drawQ1(id, side/2)
drawQ2(id, side/2)
drawQ3(id, side/2)
drawQ4(id, side/2)
time.sleep(20)
turtle.bye()
示例7: init_turtle
def init_turtle():
"""
Стартовые настройки для рисования
"""
turtle.colormode(255)
turtle.speed(10)
turtle.pensize(3)
示例8: 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
示例9: tree1
def tree1(argv, x, y):
lsys_filename1 = argv[1]
lsys1 = ls.createLsystemFromFile( lsys_filename1 )
print lsys1
num_iter1 = int( 3 )
dist = float( 5 )
angle1 = float( 22 )
s1 = ls.buildString( lsys1, num_iter1 )
#draw lsystem1
'''this is my first lsystem
with filename mysystem1.txt
with 3 iterations and
with angle = 45 dist = 10'''
turtle.tracer(False)
turtle.speed(50000000)
turtle.up()
turtle.goto(0,0)
turtle.goto(x, y)
turtle.down()
turtle.pencolor('White')
it.drawString( s1, dist, angle1 )
# wait and update
turtle.update()
示例10: turtleProgram
def turtleProgram():
import turtle
import random
global length
turtle.title("CPSC 1301 Assignment 4 MBowen") #Makes the title of the graphic box
turtle.speed(0) #Makes the turtle go rather fast
for x in range(1,(numHex+1)): #For loop for creating the hexagons, and filling them up
turtle.color(random.random(),random.random(),random.random()) #Defines a random color
turtle.begin_fill()
turtle.forward(length)
turtle.left(60)
turtle.forward(length)
turtle.left(60)
turtle.forward(length)
turtle.left(60)
turtle.forward(length)
turtle.left(60)
turtle.forward(length)
turtle.left(60)
turtle.forward(length)
turtle.left(60)
turtle.end_fill()
turtle.left(2160/(numHex))
length = length - (length/numHex) #Shrinks the hexagons by a small ratio in order to create a more impressive shape
turtle.penup()
turtle.goto(5*length1/2, 0) #Sends turtle to a blank spot
turtle.color("Black")
turtle.hideturtle()
turtle.write("You have drawn %d hexagons in this pattern." %numHex) #Captions the turtle graphic
turtle.mainloop()
示例11: draw_flower
def draw_flower():
window = turtle.Screen()
window.bgcolor('blue')
bobie = turtle.Turtle()
turtle.speed('0')
bobie.shape('classic')
bobie.color('pink')
anny = turtle.Turtle()
anny.color('pink')
for i in range(1,73):
bobie.forward(100)
bobie.right(30)
bobie.forward(100)
bobie.right(150)
bobie.forward(100)
bobie.right(30)
bobie.forward(100)
bobie.right(5)
anny.right(90)
anny.forward(300)
window.exitonclick
示例12: __init__
def __init__(self):
# Janela sobre
self.janSobre = None
# Cor de fundo
self.corFundo = "gray"
turtle.screensize(1000, 700, self.corFundo)
turtle.setup(width=1000, height=700)
turtle.title("cidadeBela - Janela de desenho")
turtle.speed(0)
turtle.tracer(4)
# Definindo variáveis globais
self._tamPadrao = ""
# Listas de prédios
self.predios = ['Casa', 'Hotel']
self.prediosProc = [ 'hotel', 'hotelInv', 'casa', 'casaInv' ]
# Sorteando elementos
self.sorteioPredios = [["casa", 1], ["hotel", 1]]
self.sorteioPrediosInv = [["casaInv", 1], ["hotelInv", 1]]
# Cores dos prédios
self.coresHotel = ["076080190", "255255255", "167064057", "153204255", "000090245",
"201232098", "255058123", "010056150", "130255255", "255255000",
"255000000", "255127042", "000255000", "255170255", "000255170",
"212000255", "170255127", "127212255", "255127127", "255212085",
"212212255", "255255127", "222202144" ]
self.coresCasa = ['209187103', '115155225', '130047006', '255137111', '203229057',
'017130100', '025195159', '204057065', '194082255', '092221159',
'167045055', '238243030', '069241248', '000156228', '159094040',
'048033253', '040209239', '138164253', '190042177', '000122159',
'255255255', '253208201', '245228133']
self.coresLoja = ['255255255', '253208201', '245228133' ]
# Janelas dos prédios
self.janelasHotel = janelas.janelasHotel
self.janelasCasa = janelas.janelasCasa
self.janelasLoja = janelas.janelasLoja
self.janelasTodas = janelas.janelasTodas
# Tetos dos prédios
self.tetosHotel = tetos.tetosHotel
self.tetosCasa = tetos.tetosCasa
self.tetosLoja = tetos.tetosLoja
self.tetosTodas = tetos.tetosTodas
# Portas dos prédios
self.portasHotel = portas.portasHotel
self.portasCasa = portas.portasCasa
self.portasLoja = portas.portasLoja
self.portasTodas = portas.portasTodas
示例13: turtlePrint
def turtlePrint(board, width, height):
turtle.hideturtle()
turtle.speed(0)
turtle.penup()
turtle.goto(-210, -60)
turtle.pendown()
turtle.goto(20*width-210, -60)
turtle.goto(20*width-210, 20*height-60)
turtle.goto(-210, 20*height-60)
turtle.goto(-210, -60)
turtle.penup()
for y in xrange(height):
for x in xrange(width):
turtle.penup()
turtle.goto(20*x-200,20*y-50)
turtle.pendown()
if board[x][y] is 1:
turtle.pencolor("green")
turtle.dot(10)
turtle.pencolor("black")
elif board[x][y] is 2:
turtle.dot(20)
elif board[x][y] is 3:
turtle.pencolor("red")
turtle.dot(10)
turtle.pencolor("black")
elif board[x][y] is 8:
turtle.pencolor("blue")
turtle.dot()
turtle.pencolor("black")
turtle.exitonclick()
示例14: plot
def plot(self, node1, node2, debug=False):
"""Plots wires and intersection points with python turtle"""
tu.setup(width=800, height=800, startx=0, starty=0)
tu.setworldcoordinates(-self.lav, -self.lav, self.sample_dimension+self.lav, self.sample_dimension+self.lav)
tu.speed(0)
tu.hideturtle()
for i in self.index:
if debug:
time.sleep(2) # Debug only
tu.penup()
tu.goto(self.startcoords[i][0], self.startcoords[i][1])
tu.pendown()
tu.goto(self.endcoords[i][0], self.endcoords[i][1])
tu.penup()
if self.list_of_nodes is None:
intersect = self.intersections(noprint=True)
else:
intersect = self.list_of_nodes
tu.goto(intersect[node1][0], intersect[node1][1])
tu.dot(10, "blue")
tu.goto(intersect[node2][0], intersect[node2][1])
tu.dot(10, "blue")
for i in intersect:
tu.goto(i[0], i[1])
tu.dot(4, "red")
tu.done()
return "Plot complete"
示例15: main
def main():
path_data = open('path.txt').read()
print turtle.position()
turtle.penup()
turtle.setposition(-400,200)
turtle.pendown()
turtle.speed(0)
turtle.delay(0)
for c in path_data:
if c in 'NSEW*':
if c == 'N':
turtle.setheading(90)
turtle.forward(1)
if c == 'S':
turtle.setheading(270)
turtle.forward(1)
if c == 'E':
turtle.setheading(0)
turtle.forward(1)
if c == 'W':
turtle.setheading(180)
turtle.forward(1)
if c == '*':
if turtle.isdown():
turtle.penup()
else:
turtle.pendown()