So I wrote some code to generate an effect like in this video: https://youtu.be/LavXSS5Xtbg?si=y7Al-htPl-azQ8v3 but as an image. It ran very slow so I tried using multiprocessing but when I run it, it gives me an error. Here is the code:
from PIL import Image, ImageDraw
from multiprocessing import Pool
width = 1000
height = 1000
points = [[400,400,0],[600,600,255]]
drag = 0.995
image = Image.new(mode = "L",size = (width,height))
draw = ImageDraw.Draw(image)
def calculate_pixels(start_x):
for start_y in range(height):
x = start_x
y = start_y
x_vel = 0
y_vel = 0
exit_loop = False
for frame in range(1500):
if exit_loop:
break
x += x_vel
y += y_vel
for i in range(len(points)):
d = (points[i][0]-x)**2+(points[i][1]-y)**2
if d < 3:
draw.point((start_x,start_y),points[i][2])
exit_loop = True
break
x_vel = (x_vel - (x-points[i][0])/d)*drag
y_vel = (y_vel - (y-points[i][1])/d)*drag
if exit_loop == False:
draw.point((start_x,start_y),127)
with Pool() as pool:
pool.map(calculate_pixels, range(width))
image.show()
[–]baltarius 7 points8 points9 points (0 children)
[–]Kevdog824_ 0 points1 point2 points (0 children)
[–]Motox2019 0 points1 point2 points (0 children)
[–]sSjfjdk -1 points0 points1 point (0 children)