制作gif图一例_合成gif_制作gif

制作gif图一例_合成gif_制作gif

python制作gif合成gif

python制作gif合成gif

"""
   制作gif图一例
"""
from PIL import Image, ImageDraw

images = []

width = 200
center = width // 2
color_1 = (0, 110, 110)
color_2 = (0, 255, 0)
max_radius = int(center * 1.5)
step = 8

for i in range(0, max_radius, step):
    im = Image.new('RGB', (width, width), color_1)
    draw = ImageDraw.Draw(im)
    draw.ellipse((center - i, center - i, center + i, center + i), fill=color_2)
    images.append(im)

for i in range(0, max_radius, step):
    im = Image.new('RGB', (width, width), color_2)
    draw = ImageDraw.Draw(im)
    draw.ellipse((center - i, center - i, center + i, center + i), fill=color_1)
    images.append(im)

images[0].save('合成.gif',save_all=True, append_images=images[1:],
               optimize=False, duration=40, loop=0)

李兴球

李兴球的博客是Python创意编程原创博客