Skip to content

Instantly share code, notes, and snippets.

@showyou
Created December 21, 2020 13:13
Show Gist options
  • Save showyou/cb52c1588dd53675e7a54c09f8ea5c7b to your computer and use it in GitHub Desktop.
Save showyou/cb52c1588dd53675e7a54c09f8ea5c7b to your computer and use it in GitHub Desktop.
gen_image.py
from PIL import Image, ImageDraw
images = []
before = 20
frames = 30 + 1
after = 20
s = (0xff, 0xff)
e = (0x8e, 0x00)
w = ((s[0] - e[0])//frames, (s[1] - e[1])//frames)
for i in range(before):
img = Image.new('RGBA', (200, 200), 'white')
images.append(img)
for i in range(frames):
img = Image.new('RGBA', (200, 200), (0xff, s[0] - w[0] * i, s[1] - w[1] * i))
images.append(img)
for i in range(after):
img = Image.new('RGBA', (200, 200), (0xff, e[0], e[1]))
images.append(img)
images[0].save('white2orange.gif', save_all=True, append_images=images[1:], optimize=False, duration=50, loop=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment