-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy paththoth.py
367 lines (337 loc) · 15.8 KB
/
thoth.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
import turtle
import math
from time import strftime
from random import *
### Setting up Osiris' Window
wn = turtle.Screen()
osiris = turtle.Turtle()
wn.screensize(1000, 1000)
### SCREENSHOT COMMAND ON 'A' KEYBOARD PRESS ###
def ihy():
ts = osiris.getscreen()
osiris.hideturtle()
ts.getcanvas().postscript(file="thoth/thoth - " + djet +
".eps", width=1000, height=1000)
osiris.showturtle()
print ('screenshot taken')
turtle.onkey(ihy,"a")
turtle.listen()
### CENTRE DOT COMMAND ON 'D' KEYBOARD PRESS ###
def yam():
osiris.penup()
osiris.goto(0,0)
osiris.dot(3,'#0000FF')
turtle.onkey(yam,"d")
turtle.listen()
### MATH DEFINITIONS ###
def pythag(sidea, sideb):
csquare = (sidea ** 2) + (sideb ** 2)
sidec = math.sqrt(csquare)
return sidec
def work_acos(A,B,C):
X = math.degrees(math.acos(((C ** 2) + (A ** 2) - (B ** 2))/(2.0 * C * A))) # bottom angle
return X
'''
#############################################################
################## GEOMETRIC DEFINITIONS ####################
################## START ####################
#############################################################
'''
#######################################################
### Thoth = Randomly generated tile ###
### God of Knowledge, the Moon, Measurement, Wisdom ###
#######################################################
########### Developed using
##thoth_y=1,thoth_height=500,thoth_ray_no_min = 1,
##thoth_ray_no_max = 4,thoth_ray_reverse_no_min = 1,
##thoth_ray_reverse_no_max = 4,thoth_stripe_no_min = 1,
##thoth_stripe_no_max = 4,thoth_stripe_reverse_no_min = 1,
##thoth_stripe_reverse_no_max = 4,thoth_halo_no_min = 1,
##thoth_halo_no_max = 4,thoth_circle_no_min = 1,
##thoth_circle_no_max = 4,
##thoth_ray_pensize = 2,thoth_ray_color = '#990000',
##thoth_ray_reverse_pensize = 2,thoth_ray_reverse_color = '#990000',
##thoth_stripe_pensize = 2,thoth_stripe_color = '#990000',
##thoth_stripe_reverse_pensize = 2,thoth_stripe_reverse_color = '#990000',
##thoth_halo_pensize = 2,thoth_halo_color = '#990000',
##thoth_circle_pensize = 2,thoth_circle_color = '#990000'
def thoth(
thoth_y=1,thoth_height=600,
thoth_ray_no_min = 1,thoth_ray_no_max = 5,
thoth_ray_reverse_no_min = 1,thoth_ray_reverse_no_max = 5,
thoth_stripe_no_min = 1,thoth_stripe_no_max = 5,
thoth_stripe_reverse_no_min = 1,thoth_stripe_reverse_no_max = 5,
thoth_halo_no_min = 1,thoth_halo_no_max = 5,
thoth_circle_no_min = 1,thoth_circle_no_max = 5,
thoth_ray_pensize = 2,thoth_ray_color = '#990000',
thoth_ray_reverse_pensize = 2,thoth_ray_reverse_color = '#990000',
thoth_stripe_pensize = 2,thoth_stripe_color = '#990000',
thoth_stripe_reverse_pensize = 2,thoth_stripe_reverse_color = '#990000',
thoth_halo_pensize = 2,thoth_halo_color = '#990000',
thoth_circle_pensize = 2,thoth_circle_color = '#990000'
):
if thoth_y == 1:
thoth_ray_y = (randint(0,1))
thoth_ray_reverse_y = (randint(0,1))
thoth_stripe_y = (randint(0,1))
thoth_stripe_reverse_y = (randint(0,1))
thoth_halo_y = (randint(0,1))
thoth_circle_y = (randint(0,1))
thoth_ray_no = (randint(thoth_ray_no_min,thoth_ray_no_max))
thoth_ray_reverse_no = (randint(thoth_ray_reverse_no_min,thoth_ray_reverse_no_max))
thoth_stripe_no = (randint(thoth_stripe_no_min,thoth_stripe_no_max))
thoth_stripe_reverse_no = (randint(thoth_stripe_reverse_no_min,thoth_stripe_reverse_no_max))
thoth_halo_no = (randint(thoth_halo_no_min,thoth_halo_no_max))
thoth_circle_no = (randint(thoth_circle_no_min,thoth_circle_no_max))
thoth_cell_height = thoth_height / 2
thoth_ray_height = thoth_cell_height / thoth_ray_no
thoth_ray_reverse_height = thoth_cell_height / thoth_ray_reverse_no
thoth_stripe_height = thoth_cell_height / thoth_stripe_no
thoth_stripe_reverse_height = thoth_cell_height / thoth_stripe_reverse_no
thoth_halo_size = thoth_cell_height / thoth_halo_no
thoth_circle_size = thoth_cell_height / thoth_circle_no
# Outer Stroke
osiris.goto(-thoth_cell_height,thoth_cell_height)
osiris.setheading(270)
osiris.pensize(thoth_circle_pensize)
osiris.color(thoth_circle_color)
for thoth_box_range in range(1,5):
osiris.pendown()
osiris.forward(thoth_height)
osiris.left(90)
osiris.penup()
### Inner Circles
if thoth_circle_y == 1:
osiris.pensize(thoth_circle_pensize)
osiris.color(thoth_circle_color)
for thoth_circle_a in range(1,(thoth_circle_no+1)):
osiris.goto(0,0)
osiris.setheading(90)
osiris.forward(thoth_circle_size*thoth_circle_a)
osiris.left(90)
thoth_circle_on_off = (randint(0,1))
if thoth_circle_on_off == 1:
osiris.pendown()
osiris.circle((thoth_circle_size*thoth_circle_a),360)
osiris.penup()
### Outer Circles
if thoth_halo_y == 1:
osiris.pensize(thoth_halo_pensize)
osiris.color(thoth_halo_color)
for thoth_halo_range in range(1,(thoth_halo_no+1)):
thoth_halo_on_off = (randint(0,1))
thoth_halo_start_heading = 0
for thoth_halo_a in [(-thoth_cell_height,thoth_cell_height),
(-thoth_cell_height,-thoth_cell_height),
(thoth_cell_height,-thoth_cell_height),
(thoth_cell_height,thoth_cell_height)
]:
osiris.goto(thoth_halo_a)
osiris.setheading(thoth_halo_start_heading)
osiris.forward(thoth_halo_size*thoth_halo_range)
osiris.right(90)
if thoth_halo_on_off == 1:
osiris.pendown()
osiris.circle(-(thoth_halo_size*thoth_halo_range),90)
osiris.penup()
thoth_halo_start_heading = thoth_halo_start_heading + 90
### RAYS FROM THE CENTRE ###
if thoth_ray_y == 1:
osiris.pensize(thoth_ray_pensize)
osiris.color(thoth_ray_color)
osiris.goto(0,0)
osiris.setheading(90)
for thoth_ray_range in range(0,(thoth_ray_no+1)):
thoth_ray_on_off = (randint(0,1))
for thoth_ray_a in range(1,5):
thoth_C = pythag(thoth_cell_height,(thoth_ray_height
*thoth_ray_range))
thoth_M = (work_acos(thoth_cell_height,
(thoth_ray_height*
thoth_ray_range),thoth_C))
osiris.left(thoth_M)
if thoth_ray_on_off == 1:
osiris.pendown()
osiris.forward(thoth_C)
osiris.penup()
osiris.goto(0,0)
osiris.left(90-(thoth_M*2)) # We're getting him to turn from the current line to the next liine
if thoth_ray_on_off == 1:
if 1 <= thoth_ray_range <= (thoth_ray_no-1):
osiris.pendown()
osiris.forward(thoth_C)
osiris.penup()
osiris.goto(0,0)
osiris.left(thoth_M)
### RAYS FROM THE CORNER ###
if thoth_ray_reverse_y == 1:
osiris.pensize(thoth_ray_reverse_pensize)
osiris.color(thoth_ray_reverse_color)
for thoth_reverse_ray_range in range(0,(thoth_ray_reverse_no+1)):
thoth_heading = 0
thoth_reverse_ray_on_off = (randint(0,1))
for thoth_x in [(-thoth_cell_height,thoth_cell_height),
(-thoth_cell_height,-thoth_cell_height),
(thoth_cell_height,-thoth_cell_height),
(thoth_cell_height,thoth_cell_height)
]:
osiris.goto(thoth_x)
osiris.setheading(thoth_heading)
thoth_Q = pythag(thoth_cell_height,(thoth_ray_reverse_height*
thoth_reverse_ray_range))
thoth_P = work_acos(thoth_cell_height,
(thoth_ray_reverse_height*
thoth_reverse_ray_range),thoth_Q)
osiris.right(thoth_P)
if thoth_reverse_ray_on_off == 1:
osiris.pendown()
osiris.forward(thoth_Q)
osiris.penup()
osiris.goto(thoth_x)
osiris.right(90-(thoth_P*2))
if thoth_reverse_ray_on_off == 1:
if thoth_reverse_ray_range <= (thoth_ray_reverse_no-1):
osiris.pendown()
osiris.forward(thoth_Q)
osiris.penup()
thoth_heading = thoth_heading + 90
### STRIPE FROM THE CENTRE ###
if thoth_stripe_y == 1:
osiris.pensize(thoth_stripe_pensize)
osiris.color(thoth_stripe_color)
osiris.goto(0,0)
osiris.setheading(90)
for thoth_stripe_range in range(1,(thoth_stripe_no+1)):
thoth_stripe_on_off_1 = (randint(0,1))
for thoth_zz in range(1,5):
thoth_D_working = thoth_stripe_height * thoth_stripe_range
thoth_F = pythag(thoth_D_working,thoth_D_working)
osiris.forward(thoth_cell_height-thoth_D_working)
osiris.left(45)
if thoth_stripe_on_off_1 == 1:
osiris.pendown()
osiris.forward(thoth_F)
osiris.penup()
osiris.goto(0,0)
osiris.left(45)
osiris.forward(thoth_cell_height-thoth_D_working)
osiris.right(45)
if thoth_stripe_on_off_1 == 1:
if thoth_stripe_range <= (thoth_stripe_no-1):
osiris.pendown()
osiris.forward(thoth_F)
osiris.penup()
osiris.goto(0,0)
osiris.left(45)
### STRIPE FROM THE CORNER ###
if thoth_stripe_reverse_y == 1:
osiris.pensize(thoth_stripe_reverse_pensize)
osiris.color(thoth_stripe_reverse_color)
osiris.goto(0,0)
thoth_heading = 180
for thoth_stripe_reverse_range in range(1,(thoth_stripe_reverse_no+1)):
thoth_stripe_on_off_1 = (randint(0,1))
thoth_stripe_on_off_2 = (randint(0,1))
for thoth_z in [(0,thoth_cell_height),
(-thoth_cell_height,0),
(0,-thoth_cell_height),
(thoth_cell_height,0)
]:
thoth_E_working = (thoth_stripe_reverse_height
* thoth_stripe_reverse_range)
thoth_R = pythag(thoth_E_working,thoth_E_working)
osiris.goto(thoth_z)
osiris.setheading(thoth_heading)
osiris.forward(thoth_cell_height-thoth_E_working)
osiris.left(45)
if thoth_stripe_on_off_1 == 1:
osiris.pendown()
osiris.forward(thoth_R)
osiris.penup()
if thoth_stripe_reverse_range <= (thoth_stripe_reverse_no-1):
osiris.goto(0,0)
osiris.setheading(thoth_heading)
osiris.forward(thoth_E_working)
osiris.right(135)
if thoth_stripe_on_off_2 == 1:
osiris.pendown()
osiris.forward(thoth_R)
osiris.penup()
thoth_heading = thoth_heading + 90
### Outputs the input values for the tile ###
osiris.goto(-thoth_cell_height,-thoth_cell_height)
osiris.setheading(90)
osiris.backward(20)
osiris.write(djet,font=('Arial',8,'normal'))
for thoth_write in ['thoth_ray_y','thoth_ray_no',
'thoth_ray_reverse_y','thoth_ray_reverse_no',
'thoth_halo_y','thoth_halo_no'
]:
osiris.setheading(90)
osiris.backward(20)
osiris.write(thoth_write,font=('Arial',8,'normal'))
osiris.goto(-thoth_cell_height+200,-thoth_cell_height)
osiris.setheading(90)
osiris.backward(20)
for thoth_write in [thoth_ray_y,thoth_ray_no,
thoth_ray_reverse_y,thoth_ray_reverse_no,
thoth_halo_y,thoth_halo_no
]:
osiris.setheading(90)
osiris.backward(20)
osiris.write(thoth_write)
osiris.goto(-thoth_cell_height+300,-thoth_cell_height)
osiris.setheading(90)
osiris.backward(20)
for thoth_write in ['thoth_stripe_y','thoth_stripe_no',
'thoth_stripe_reverse_y','thoth_stripe_reverse_no',
'thoth_circle_y','thoth_circle_no'
]:
osiris.setheading(90)
osiris.backward(20)
osiris.write(thoth_write,font=('Arial',8,'normal'))
osiris.goto(-thoth_cell_height+500,-thoth_cell_height)
osiris.setheading(90)
osiris.backward(20)
for thoth_write in [thoth_stripe_y,thoth_stripe_no,
thoth_stripe_reverse_y,thoth_stripe_reverse_no,
thoth_circle_y,thoth_circle_no
]:
osiris.setheading(90)
osiris.backward(20)
osiris.write(thoth_write,font=('Arial',8,'normal'))
'''
##############################################
##############################################
##################START#######################
##############################################
##############################################
'''
#####################
#CONFIGURING OSIRIS##
#####################
osiris.speed(0)
def osirisslow():
osiris.speed(1)
def osirismid():
osiris.speed(4)
def osirisquick():
osiris.speed(0)
turtle.onkey(osirisquick,"0")
turtle.onkey(osirismid,"4")
turtle.onkey(osirisslow,"1")
turtle.listen()
osiris.penup()
#####################
#BASE SHAPES SECTION#
#####################
djet = strftime("%Y-%m-%d %H-%M-%S")
thoth()
'''
##################################
##################################
################END###############
##################################
##################################
'''
turtle.done()