Violin animation made out of many tiny notes. Frames rendered in parallel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import random | |
import multiprocessing | |
background = Image.new('RGBA', (2048, 2048), (255, 255, 255, 255)) | |
image = Image.open(r"violin.jpg").convert('RGBA').load() | |
note = Image.open(r"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)) | |
background.save(f'out/{frame}.png') | |
if __name__ == '__main__': | |
pool = multiprocessing.Pool() | |
pool.map(gen_frame, range(60)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment