• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python turtle.update函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中turtle.update函数的典型用法代码示例。如果您正苦于以下问题:Python update函数的具体用法?Python update怎么用?Python update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了update函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:Nagoogin,项目名称:game-of-life,代码行数:7,代码来源:gameOfLife.py


示例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()
开发者ID:hmc-lair,项目名称:multitarget_state_estimator,代码行数:7,代码来源:draw.py


示例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()
开发者ID:Papapashu,项目名称:main,代码行数:26,代码来源:python_three.py


示例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()
开发者ID:hmc-lair,项目名称:multitarget_state_estimator,代码行数:7,代码来源:draw.py


示例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()
开发者ID:samorajp,项目名称:kompresja_fraktalna,代码行数:25,代码来源:w_polowie_drogi.py


示例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()
开发者ID:LaurenceGA,项目名称:programmingProjects,代码行数:25,代码来源:CircleCurveStitch.py


示例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
开发者ID:ElliotGluck,项目名称:ponyge,代码行数:28,代码来源:drawing.py


示例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()
开发者ID:SmashMouthFanClub,项目名称:ai-project-2014,代码行数:30,代码来源:osm.py


示例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()
开发者ID:int-Frank,项目名称:DgLib,代码行数:32,代码来源:FrustumMinBoungingSphere.py


示例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()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:26,代码来源:scene.py


示例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()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:27,代码来源:scene.py


示例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()
开发者ID:golubaca,项目名称:python-examples,代码行数:34,代码来源:main.py


示例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()
开发者ID:shreeshga,项目名称:gaussian_particlefilter,代码行数:7,代码来源:draw.py


示例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()
开发者ID:hendrikvgl,项目名称:RoboCup-Spielererkennung,代码行数:7,代码来源:draw.py


示例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()
开发者ID:pbialas,项目名称:lsystem,代码行数:28,代码来源:Lsystem.py


示例16: drawString

def drawString( dstring, distance, angle ):
    """ Interpret the characters in string dstring as a series
    of turtle commands. Distance specifies the distance
    to travel for each forward command. Angle specifies the
    angle (in degrees) for each right or left command. The list of 
    turtle supported turtle commands is:
    F : forward
    - : turn right
    + : turn left
    [ : save position, heading
    ] : restore position, heading
    """
    stack = []
    for c in dstring:
		if c == 'F':
			turtle.forward(distance)
		elif c == '-':
			turtle.right(angle)
		elif c == '+':
			turtle.left(angle)
		elif c == '[':
			stack.append(turtle.position())
			stack.append(turtle.heading())
		elif c == ']':
			turtle.up()
			turtle.setheading(stack.pop())
			turtle.goto(stack.pop())
			turtle.down()
		turtle.update()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:29,代码来源:turtle_interpreter.py


示例17: animate_fw

def animate_fw(slide1, slide2):
    for i in range(100):
        turtle.clear()
        draw_slide(slide1[0],slide1[1],-885+(i*8.85),0)
        draw_slide(slide2[0],slide2[1],i*8.85,0)
        turtle.update()
    return
开发者ID:nitros12,项目名称:slideshow_py,代码行数:7,代码来源:python+slideshow.py


示例18: 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()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:26,代码来源:project7extension.py


示例19: display

 def display(self):
     """Draw the whole board"""
     turtle.clear()
     for i in range(self.xsize):
         for j in range(self.ysize):
             self.draw(i, j)
     turtle.update()
开发者ID:MattRijk,项目名称:algorithms,代码行数:7,代码来源:conway_game_of_life.py


示例20: draw_pattern

def draw_pattern(pattern):
    n = len(pattern) // 4
    for i in range(n):
        s, e = i * 4, i * 4 + 4
        start, end, p1, p2 = pattern[s:e]
        draw_bezier(t, bezier_steps, start, end, p1, p2)
        turtle.update()
开发者ID:AugustLONG,项目名称:pattern.logo.py,代码行数:7,代码来源:main.py



注:本文中的turtle.update函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python turtle.width函数代码示例发布时间:2022-05-27
下一篇:
Python turtle.up函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap