-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiso-cubes.py
executable file
·63 lines (56 loc) · 1.39 KB
/
iso-cubes.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
from turtle import *
screen_width, screen_height = screensize()
scale = 1.2
columns = int(20 // scale)
rows = int(20 // scale) - 1
red_factor = 0.2
green_factor = 0.4
blue_factor = 0.5
bgcolor("black")
hideturtle()
pensize(2)
pd()
left(90)
tracer(12,0)
goto(screen_width,-screen_height)
stroke_color = "black"
for row in range(rows):
for column in range(columns if row % 2 == 0 else columns -1 ):
for diamond in range(3):
diamond = ((diamond + 2) % 3) + 1
red = min(1, red_factor * diamond + (column / 100))
green = min(1, (green_factor * diamond + (column / 50)))
blue = min(1, (blue_factor * diamond + (row / 100)))
color(stroke_color, (red, green, blue))
begin_fill()
left(60)
forward(25 * scale)
right(120)
forward(25 * scale)
right(60)
forward(25 * scale)
right(120)
forward(25 * scale)
end_fill()
pu()
left(60)
forward(25 * scale)
left(60)
forward(25 * scale)
right(120)
pd()
pu()
right(60)
for step_back in range(columns - 1):
right(60)
forward(25 * scale)
left(60)
forward(25 * scale)
left(60)
forward(25 * scale)
right(60)
forward(25 * scale)
left(60)
pd()
done()