-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcubesSquished.py
45 lines (41 loc) · 1.58 KB
/
cubesSquished.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from PIL import Image
import numpy as np
img = Image.new( 'RGB', (1080,1080), "white") # create a new black image
pixels = img.load() # create the pixel map
for i in range(0, img.size[0], 60):
for j in range(0, img.size[1], 30):
a = np.array([i,j+30])
b = np.array([i+60,j])
x = np.array([i+60,j+30])
if (i/60) % 2 == 0:
orientation = (j/30) % 4;
else :
if (j / 30) % 4 == 0:
orientation = 2
if (j / 30) % 4 == 1 :
orientation = 3
if (j / 30) % 4 == 2:
orientation = 0
if (j / 30) % 4 == 3:
orientation = 1
for k in range(0,60) :
for l in range(0,30) :
if orientation == 0 :
if (((i+k)%60)/2 >= (l+j)%30) :
pixels[i + k, l + j] = (1,(i + k)/4,(l + j)/4)
if orientation == 1 :
if (((i+k)%60)/2 < (l+j)%30) :
pixels[i + k, l + j] = (1,(i + k)/4,(l + j)/4)
y = np.array([i+k,j+l])
cp1 = np.cross(b-a,x-a)
cp2 = np.cross(b-a,y-a)
if np.dot(cp1,cp2) <= 0 :
if orientation == 2 :
pixels[i + k, l + j] = (1,(i + k)/4,(l + j)/4)
else :
if orientation == 3 :
pixels[i + k, l + j] = (1,(i + k)/4,(l + j)/4)
if k== 0 :
pixels[i + k, l + j] = (1,(i + k)/4,(l + j)/4)
img.show()
img.save('Squished3.jpeg','jpeg')