Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b66bf6f

Browse files
Add files via upload
1 parent 2613b2b commit b66bf6f

File tree

1 file changed

+371
-0
lines changed

1 file changed

+371
-0
lines changed

‎thoth.py

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /