34 lines
784 B
Python
Executable File
34 lines
784 B
Python
Executable File
#!/usr/bin/env nix-script
|
|
#!>python
|
|
#! python | pillow
|
|
|
|
## Fun with PIL during boring lesson. Generate DNA microarray-like images.
|
|
|
|
from PIL import Image
|
|
from threading import Thread
|
|
import math
|
|
import random
|
|
|
|
def color():
|
|
a = (random.randint(0, 255), random.randint(0, 255), 0)
|
|
b = (0, 0, 0)
|
|
return random.choice((a, b))
|
|
|
|
def draw(image, x, y, c, d, color):
|
|
for i in range(d):
|
|
for k in range(d):
|
|
if abs(complex(x+i, y+k) - complex(c[0], c[1])) <= d/3:
|
|
image.putpixel((x + i, y + k), color)
|
|
|
|
def main():
|
|
d = 16
|
|
img = Image.new('RGB', (2528, 2528), '#000')
|
|
|
|
for i in range(0, img.size[0], d):
|
|
for k in range(0, img.size[1], d):
|
|
Thread(draw(img, i, k, (i + d/2, k + d/2), d, color())).start()
|
|
img.show()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|