-
Notifications
You must be signed in to change notification settings - Fork 0
/
generating-shapes-from-numbers.py
57 lines (51 loc) · 1.42 KB
/
generating-shapes-from-numbers.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
'''
In this script I tried to implement the algorithm described in this tweet
https://twitter.com/matthen2/status/1433081884402233347?lang=de
The shapes generated by this algorithm are fascinating.
'''
from decimal import Decimal, getcontext
import numpy as np
import math
from turtle import Turtle, speed, tracer, update, delay, ht, done
decimals = 10001
getcontext().prec = decimals
number = Decimal(1).exp()
print(number)
digitsArray= []
for i in range(2, decimals+1):
digitsArray.append(int((str(number))[i]))
anglesArray = []
for i in range(0, 10):
anglesArray.append(np.multiply((np.divide(i,10)),360))
t = Turtle()
tracer(0, 0)
delay(0)
ht()
speed(speed=0)
for i in range(0, len(digitsArray)):
if digitsArray[i] == 0:
angle = anglesArray[0]
elif digitsArray[i] == 1:
angle = anglesArray[1]
elif digitsArray[i] == 2:
angle = anglesArray[2]
elif digitsArray[i] == 3:
angle = anglesArray[3]
elif digitsArray[i] == 4:
angle = anglesArray[4]
elif digitsArray[i] == 5:
angle = anglesArray[5]
elif digitsArray[i] == 6:
angle = anglesArray[6]
elif digitsArray[i] == 7:
angle = anglesArray[7]
elif digitsArray[i] == 8:
angle = anglesArray[8]
else:
angle = anglesArray[9]
steps = 3
t.right(angle)
t.fd(steps)
update()
t.screen.mainloop()
done()