Lan's World 兰兰想世界 - 2020年10月
type: channel
link: https://blog.lanhaoo.club/index.php/2020/10/
description: Think and explore！
items: git just output all your commit messages
items: pygame with gif(image sequence) and control play speed（code）

git just output all your commit messages
type: item
date: 2020-10-17T18:52:00+08:00
description: git shortlog --no-merges >1.txtwindows run this ???? ????

pygame with gif(image sequence) and control play speed（code）
type: item
date: 2020-10-07T18:07:00+08:00
description: _：） Ideasthe pygame redraw map in a while loop, so we just need calculate time and then using different image path.so we use image sequence to simulate gif.useimgGif = Gif('./gif/talks/')write your own image sequence folder in the code.use function build_gif(screen, x, y, gif, million_seconds) in the while loop of pygame.for example:build_gif(screen, x, y, imgGif, 500)and this is the source file.Gif.pyimport time import os import pygame class Gif: def __init__(self, gif_path): self.current_index = 0 self.sync_time = int(round(time.time() * 1000)) self.gif_path = gif_path self.image_path_arr = os.listdir(gif_path) imgGif = Gif('./gif/talks/') # first input Gif folder path here ux = 25 uy = 25 # use this funtion in 'creation_niveau' to build gif def build_gif(screen, x, y, gif, million_seconds): img = pygame.image.load(get_gif_sequence(gif, million_seconds)) img = pygame.transform.scale(img, (ux, uy)) screen.blit(img, (x * ux, y * uy)) def get_gif_sequence(gif, time_between_gifs): current_index = gif.current_index sync_time = gif.sync_time gif_path = gif.gif_path image_path_arr = gif.image_path_arr all_length = len(image_path_arr) img_path = gif_path + image_path_arr[current_index] new_time = int(round(time.time() * 1000)) if new_time - sync_time > time_between_gifs: gif.sync_time = new_time if current_index < all_length - 1: gif.current_index += 1 else: gif.current_index = 0 else: pass return img_path