Python turtle.update() Examples
The following are 15
code examples of turtle.update().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
turtle
, or try the search function
.
Example #1
Source File: main.py From pattern.logo.py with Apache License 2.0 | 7 votes |
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)
Example #2
Source File: main.py From pattern.logo.py with Apache License 2.0 | 6 votes |
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()
Example #3
Source File: maze.py From Particle_Filter with MIT License | 6 votes |
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()
Example #4
Source File: maze.py From Particle_Filter with MIT License | 6 votes |
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()
Example #5
Source File: maze.py From Particle_Filter with MIT License | 6 votes |
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()
Example #6
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 6 votes |
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()
Example #7
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 6 votes |
def update_screen(self): while time.time() < self.time + (1.0 / self.fps): pass turtle.update() self.time = time.time()
Example #8
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 6 votes |
def update(self, text): self.text = text self.tick()
Example #9
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 6 votes |
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()
Example #10
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 6 votes |
def update_screen(self): while time.time() < self.time + (1.0 / self.FPS): pass turtle.update() self.time = time.time()
Example #11
Source File: spgl.py From Projects with GNU General Public License v3.0 | 6 votes |
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()
Example #12
Source File: spgl.py From Projects with GNU General Public License v3.0 | 6 votes |
def update_screen(self): while time.time() < self.time + (1.0 / self.FPS): pass turtle.update() self.time = time.time()
Example #13
Source File: spgl.py From Projects with GNU General Public License v3.0 | 6 votes |
def update(self, text): self.text = text self.tick()
Example #14
Source File: main.py From python-examples with MIT License | 6 votes |
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)
Example #15
Source File: maze.py From Particle_Filter with MIT License | 5 votes |
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()