Skip to content

Instantly share code, notes, and snippets.

@nomelif
Created December 8, 2016 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomelif/fb00c9b3efa244447b8c915445a265cd to your computer and use it in GitHub Desktop.
Save nomelif/fb00c9b3efa244447b8c915445a265cd to your computer and use it in GitHub Desktop.
from PIL import Image
import numpy as np
import random
w = h = 1024
data = np.zeros((h, w, 3), dtype=np.uint8)
parallellism = 2048
point = np.random.rand(parallellism).reshape((parallellism//2,2))
targets = np.array([[0,0],[1,0],[1.5, 0.5*np.sqrt(3)],[0, np.sqrt(3)], [1, np.sqrt(3)], [-0.5, np.sqrt(3)*0.5]])
maxI = 1600
for iteration in range(maxI):
print(iteration / maxI)
target = np.array([random.choice(targets) for x in range(parallellism//2)])
point = point + (target - point)*(1/2)
coords = 200 * (point + np.array([1, 1]))
for x in range(parallellism//2):
data[int(coords[x][1]), int(coords[x][0])] = data[int(coords[x][1]), int(coords[x][0])] + [4, 4, 4]
img = Image.fromarray(data, "RGB")
img.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment