Skip to content

Instantly share code, notes, and snippets.

Last active February 9, 2022 23:16
What would you like to do?
Violin animation made out of many tiny notes. Frames rendered in parallel.
from PIL import Image
import random
import multiprocessing
background ='RGBA', (2048, 2048), (255, 255, 255, 255))
image ="violin.jpg").convert('RGBA').load()
note ="note.png").convert('RGBA')
def gen_frame(frame):
for x in range(2048):
for y in range(2048):
if random.random() < 0.04 and image[x, y][0] / 255. < random.random():
background.alpha_composite(note, (x, y))'out/{frame}.png')
if __name__ == '__main__':
pool = multiprocessing.Pool(), range(60))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment