Skip to content

Instantly share code, notes, and snippets.

@joemilbourn
Last active January 25, 2021 21:24
Show Gist options
  • Save joemilbourn/a97e6826003c3c06b0fbd897dbea8ca6 to your computer and use it in GitHub Desktop.
Save joemilbourn/a97e6826003c3c06b0fbd897dbea8ca6 to your computer and use it in GitHub Desktop.
test2
from math import *
from random import *
from kandinsky import *
n = 200
nx = 320
ny = 222
maxd = sqrt(nx**2 + ny**2)
fill_rect(0, 0, nx, ny, (0, 0, 0))
r = [(randint(0, nx), randint(0, ny)) for i in range(n)]
c = [(randint(0, 255), randint(0, 255), randint(0, 255)) for i in range(n)]
for x in range(nx):
for y in range(ny):
mind = maxd
ci = 0
for i in range(n):
d = sqrt((x-r[i][0])**2 + (y-r[i][1])**2)
if d < mind:
ci = i
mind = d
set_pixel(x, y, c[ci])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment