当前位置: 首页>>代码示例>>Python>>正文


Python turtle.update方法代码示例

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


在下文中一共展示了turtle.update方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: click

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import update [as 别名]
def click(x, y):
    # draw dot
    pos = t.position()
    t.penup()
    t.goto(x, y)
    t.dot()
    t.goto(*pos)
    t.pendown()

    # draw pattern
    pattern.append((x, y))
    if len(pattern) % 4 == 0:
        save(pattern_path, pattern)
        start, end, p1, p2 = pattern[-4:]
        draw_bezier(t, bezier_steps, start, end, p1, p2)
        turtle.update()


# set background image
# img = '/Users/gua/Desktop/heart.gif'
# turtle.bgpic(img) 
开发者ID:guaxiao,项目名称:pattern.logo.py,代码行数:23,代码来源:main.py

示例2: draw_pattern

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import update [as 别名]
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:guaxiao,项目名称:pattern.logo.py,代码行数:9,代码来源:main.py

示例3: update_screen

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import update [as 别名]
def update_screen(self):
        while time.time() < self.time + (1.0 / self.fps):
            pass
        turtle.update()
        self.time = time.time() 
开发者ID:wynand1004,项目名称:SPGL,代码行数:7,代码来源:spgl.py

示例4: update_screen

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import update [as 别名]
def update_screen(self):
        while time.time() < self.time + (1.0 / self.FPS):
            pass
        turtle.update()
        self.time = time.time() 
开发者ID:wynand1004,项目名称:SPGL,代码行数:7,代码来源:spgl.py

示例5: show_particles

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import update [as 别名]
def show_particles(self, particles, show_frequency = 10):

        turtle.shape('tri')

        for i, particle in enumerate(particles):
            if i % show_frequency == 0:
                turtle.setposition((particle.x, particle.y))
                turtle.setheading(90 - particle.heading)
                turtle.color(self.weight_to_color(particle.weight))
                turtle.stamp()
        
        turtle.update() 
开发者ID:leimao,项目名称:Particle_Filter,代码行数:14,代码来源:maze.py

示例6: show_estimated_location

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import update [as 别名]
def show_estimated_location(self, particles):
        '''
        Show average weighted mean location of the particles.
        '''

        x_accum = 0
        y_accum = 0
        heading_accum = 0
        weight_accum = 0

        num_particles = len(particles)

        for particle in particles:

            weight_accum += particle.weight
            x_accum += particle.x * particle.weight
            y_accum += particle.y * particle.weight
            heading_accum += particle.heading * particle.weight

        if weight_accum == 0:

            return False

        x_estimate = x_accum / weight_accum
        y_estimate = y_accum / weight_accum
        heading_estimate = heading_accum / weight_accum

        turtle.color('orange')
        turtle.setposition(x_estimate, y_estimate)
        turtle.setheading(90 - heading_estimate)
        turtle.shape('turtle')
        turtle.stamp()
        turtle.update() 
开发者ID:leimao,项目名称:Particle_Filter,代码行数:35,代码来源:maze.py

示例7: show_robot

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import update [as 别名]
def show_robot(self, robot):

        turtle.color('green')
        turtle.shape('turtle')
        turtle.shapesize(0.7, 0.7)
        turtle.setposition((robot.x, robot.y))
        turtle.setheading(90 - robot.heading)
        turtle.stamp()
        turtle.update() 
开发者ID:leimao,项目名称:Particle_Filter,代码行数:11,代码来源:maze.py

示例8: tick

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import update [as 别名]
def tick(self):
        # Check the game state
        # showsplash, running, gameover, paused

        if self.state == "showsplash":
            self.show_splash(self.splash_time)

        elif self.state == "paused":
            pass

        elif self.state == "gameover":
            pass

        else:
            # Iterate through all sprites and call their tick method
            for sprite in Game.sprites:
                if sprite.state:
                    sprite.tick()

            # Iterate through all labels and call their update method
            for label in Game.labels:
                if label.text != "":
                    label.tick()

        # Update the screen
        self.update_screen() 
开发者ID:wynand1004,项目名称:SPGL,代码行数:28,代码来源:spgl.py

示例9: update

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import update [as 别名]
def update(self, text):
        self.text = text
        self.tick() 
开发者ID:wynand1004,项目名称:SPGL,代码行数:5,代码来源:spgl.py

示例10: s

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import update [as 别名]
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()

# --- main ---    

# stop updating screen (to make it faster) 
开发者ID:furas,项目名称:python-examples,代码行数:40,代码来源:main.py

示例11: show_maze

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import update [as 别名]
def show_maze(self):

        turtle.setworldcoordinates(0, 0, self.width * 1.005, self.height * 1.005)

        wally = turtle.Turtle()
        wally.speed(0)
        wally.width(1.5)
        wally.hideturtle()
        turtle.tracer(0, 0)

        for i in range(self.num_rows):
            for j in range(self.num_cols):
                permissibilities = self.permissibilities(cell = (i,j))
                turtle.up()
                wally.setposition((j * self.grid_width, i * self.grid_height))
                # Set turtle heading orientation
                # 0 - east, 90 - north, 180 - west, 270 - south
                wally.setheading(0)
                if not permissibilities[0]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_width)
                wally.setheading(90)
                wally.up()
                if not permissibilities[1]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_height)
                wally.setheading(180)
                wally.up()
                if not permissibilities[2]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_width)
                wally.setheading(270)
                wally.up()
                if not permissibilities[3]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_height)
                wally.up()

        turtle.update() 
开发者ID:leimao,项目名称:Particle_Filter,代码行数:49,代码来源:maze.py


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