本文整理汇总了Python中turtle.update函数的典型用法代码示例。如果您正苦于以下问题:Python update函数的具体用法?Python update怎么用?Python update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display
def display(self):
turtle.clear()
# draws all live cells from grid.state
for i in range(self.xspan):
for j in range(self.yspan):
self.draw(i, j)
turtle.update()
示例2: show_robot
def show_robot(self, robot):
turtle.color("blue")
turtle.shape('square')
turtle.setposition(*robot.xy)
turtle.setheading(math.degrees(robot.h))
turtle.stamp()
turtle.update()
示例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: show_shark
def show_shark(self, shark):
turtle.color(shark.color)
turtle.shape('turtle')
turtle.setposition(*shark.xy)
turtle.setheading(math.degrees(shark.h))
turtle.stamp()
turtle.update()
示例5: rysuj
def rysuj():
turtle.tracer(0, 0) # wylaczenie animacji co KROK, w celu przyspieszenia
turtle.hideturtle() # ukrycie glowki zolwika
turtle.penup() # podnosimy zolwia, zeby nie mazal nam linii podczas ruchu
ostatnie_rysowanie = 0 # ile kropek temu zostal odrysowany rysunek
for i in xrange(ILE_KROPEK):
# losujemy wierzcholek do ktorego bedziemy zmierzac
do = random.choice(WIERZCHOLKI)
# bierzemy nasza aktualna pozycje
teraz = turtle.position()
# ustawiamy sie w polowie drogi do wierzcholka, ktorego wczesniej obralismy
turtle.setpos(w_polowie_drogi(teraz, do))
# stawiamy kropke w nowym miejscu
turtle.dot(1)
ostatnie_rysowanie += 1
if ostatnie_rysowanie == OKRES_ODSWIEZENIA:
# postawilismy na tyle duzo kropek, zeby odswiezyc rysunek
turtle.update()
ostatnie_rysowanie = 0
pozdrowienia()
turtle.update()
示例6: drawPattern
def drawPattern(turt, offx, offy, radius, step):
# Points is the number of points per side, NOT including the corner points
# Draw lines between the points around teh box in the given pattern
# drawRect(turt, offx, offy, sizex, sizey) # Basic rectangle to outline the shape
pointsl = drawCricle(turt, offx, offy, radius, step)
turtle.tracer(1)
for p in range(len(pointsl)):
turt.color(getRandColor(cols))
for p2 in range(len(pointsl)-3):
if not p+p2+2 > len(pointsl)-1:
drawLine(turt, pointsl[p][0], pointsl[p][1], pointsl[p+p2+2][0], pointsl[p+p2+2][1])
else:
drawLine(turt, pointsl[p][0], pointsl[p][1], pointsl[p+p2+2 - len(pointsl)][0], pointsl[p+p2+2 - len(pointsl)][1])
turtle.update()
# Draw a nice looking border around the rectangle
# turt.pensize(10) # Make it thick
# drawRect(turt, offx, offy, sizex, sizey)
# turt.pensize(1) # Reset pen size
turt.penup()
turt.setpos(offx, offy) #Sit in the centre of the circle at the end
turtle.update()
示例7: draw
def draw(self, x, y, width, height, max_length=None, force_fields=None):
"""Draw the string. The grammar-system axiom is extended to
the specified depth"""
self.reset()
turtle.setup(width,height,None,None)
turtle.tracer(200,0)
self.penup()
self.setposition(x,y)
self.origin = x, y
self.max_length = max_length
while not self.grammar_system.done and \
self.grammar_system.generation < self.depth:
self.grammar_system.step()
if (self.max_length is not None and
len(self.grammar_system.string) > self.max_length):
self.hideturtle()
print("Drawing exceeded maximum length")
return False
print(self.grammar_system.string)
if force_fields:
for force_field in force_fields:
self.force_fields.append(Attractor(force_field['type'], force_field['effect'], force_field['x'], force_field['y'], force_field['size']))
non_null = self._draw(self.grammar_system.string, self._rules)
self.hideturtle()
turtle.update()
return non_null
示例8: draw
def draw(self, w, h, dot = False):
norm = CoordinateNormalizer(self, w, h)
window = turtle.Screen()
cursor = turtle.Turtle()
window.setup(w, h)
window.setworldcoordinates(0, 0, w, h)
window.delay(0)
cursor.ht()
turtle.tracer(0)
cursor.up()
for way in self.getWays():
tags = self.ways[way].tags
line = self.getPolyline(way)
for (x, y) in line:
cursor.pencolor('black')
x, y = norm(x, y)
cursor.setpos(x, y)
if dot:
cursor.dot()
if not cursor.isdown():
cursor.down()
cursor.up()
turtle.update()
window.exitonclick()
示例9: Run
def Run():
#bounds
nearRange = [0, 50]
farRange = [50, 200]
frusHL = 100
#Logic
nearDist = random.uniform(nearRange[0], nearRange[1])
farDist = random.uniform(farRange[0], farRange[1])
d = frusHL * 2
an = nearDist
af = farDist
b = (d*d + af*af - an*an) / (2 * d)
radius = math.sqrt(b*b + an*an)
originY = -frusHL + b
#text.insert('end', 'Origin: %d\n' % originY)
#Render
turtle.clear()
turtle.hideturtle()
turtle.tracer(0, 0)
turtle.penup()
turtle.goto(-farDist, frusHL)
turtle.pendown()
turtle.goto(-nearDist, -frusHL)
turtle.goto(nearDist, -frusHL)
turtle.goto(farDist, frusHL)
turtle.goto(-farDist, frusHL)
turtle.penup()
DrawCircle(0, originY, radius);
turtle.update()
示例10: tree2
def tree2(argv, x, y):
lsys_filename2 = argv[2]
lsys2 = ls.createLsystemFromFile( lsys_filename2 )
print lsys2
num_iter2 = int( 3 )
dist = float( 5 )
angle2 = float( 30 )
s2 = ls.buildString( lsys2, num_iter2 )
#draw lsystem2
'''this is my second lsystem
with filename mysystem2.txt
with 5 iterations and
with angle = 120 dist = 10'''
turtle.up()
turtle.goto(0,0)
turtle.goto(x,y)
turtle.down()
turtle.setheading(0)
turtle.left(90)
turtle.pencolor('White')
it.drawString( s2, dist, angle2 )
# wait and update
turtle.update()
示例11: sun
def sun(argv):
lsys_filename3 = argv[3]
lsys3 = ls.createLsystemFromFile( lsys_filename3 )
print lsys3
num_iter3 = int( 3 )
dist = 5
angle3 = float( 120 )
s3 = ls.buildString( lsys3, num_iter3 )
#draw lsystem3
'''this is my third lsystem
with filename mysystem3.txt
with 3 iterations and
with angle = 45 dist = 10'''
turtle.up()
turtle.goto(0,0)
turtle.goto(300, 200)
turtle.down()
turtle.setheading(0)
turtle.left(90)
turtle.pencolor('Red')
it.drawString( s3, dist, angle3 )
# wait and update
turtle.update()
示例12: s
def s(n, l):
if n == 0: # stop conditions
# draw filled rectangle
turtle.color('black')
turtle.begin_fill()
for _ in range (4):
turtle.forward(l)
turtle.left(90)
turtle.end_fill()
else: # recursion
# around center point create 8 smalles rectangles.
# create two rectangles on every side
# so you have to repeat it four times
for _ in range(4):
# first rectangle
s(n-1, l/3)
turtle.forward(l/3)
# second rectangle
s(n-1, l/3)
turtle.forward(l/3)
# go to next corner
turtle.forward(l/3)
turtle.left(90)
# update screen
turtle.update()
示例13: show_robot
def show_robot(self, robot):
turtle.color("green")
turtle.shape('turtle')
turtle.setposition([robot.x + self.width / 2, robot.y + self.height / 2])
turtle.setheading(robot.theta / pi * 180.0)
turtle.stamp()
turtle.update()
示例14: show_goal_posts
def show_goal_posts(self, goal_posts):
for p in goal_posts:
turtle.color("#FFFF00")
turtle.setposition(p[0], p[1])
turtle.shape("circle")
turtle.stamp()
turtle.update()
示例15: draw
def draw(self, size, step, colors = 0, so_fast = False, turtl = None):
if not turtl:
turtl = franklinBegin()
base = self.get_step(step, colors = colors)
angle = self.angle
ls = []
turtl.setheading(self.head)
for char in base:
if char in self.fd:
turtl.forward(size)
elif char == '+':
turtl.left(angle)
elif char == '-':
turtl.right(angle)
elif char == '[':
ls.append(turtl.clone())
elif char == ']':
turtl = ls.pop()
elif char == 'R':
turtl.right(360*random.random())
elif char == 'c':
newcolor = (0.3 + 0.7*random.random(),
0.3 + 0.7*random.random(),
0.3 + 0.7*random.random())
turtl.color(newcolor, newcolor)
if not so_fast:
turtle.update()
turtle.update()