-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.py
196 lines (169 loc) · 4.03 KB
/
demo.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
#!/usr/bin/python3
import turtle
import time
import math
# There is a chance all of this has to be in raw mode on the pi
#Demo functions for sketch-y-etch
t = turtle.Turtle()
t.hideturtle()
t.speed(0.5)
t.width(4)
t.color("blue")
# Set up the turtle screen
screen = turtle.Screen()
screen.setup(width=1.0, height=1.0) # Set the window to full-screen mode
####General Use Function#####
def blank():
t.clear()
t.goto(0,0)
#######Function drawings#####
def draw_Flower():
#inverted Arguelle's mandala
RAD = 200
radii = [RAD, RAD/1.25, RAD/1.5, RAD/1.75, RAD/2, RAD/2.25, RAD/3, RAD/4]
def derp():
t.pendown()
for r in radii:
t.circle(r, 360)
t.penup()
derp()
t.left(-90)
derp()
t.goto(0,0)
t.left(-180)
derp()
t.goto(0,0)
t.left(-270)
derp()
def mandala():
## http://programming1work.oyosite.com/ch_turtle-mandala.html
t.pendown()
for times in range(36):
t.color("blue")
t.speed(11)
t.circle(100)
t.color("red")
t.forward(200)
t.left(120)
t.color("orange")
t.forward(100)
t.right(120)
t.left(170)
t.left(20)
t.forward(15)
def arguelles():
RAD = 200
radii = [RAD, RAD/1.25, RAD/1.5, RAD/1.75, RAD/2, RAD/2.25, RAD/3, RAD/4]
def derp():
t.pendown()
for r in radii:
t.circle(r, 360)
t.penup()
derp()
t.goto(RAD,RAD)
t.left(90)
derp()
t.goto(0,0)
t.goto(-RAD,RAD)
t.left(180)
derp()
t.goto(0,0)
t.goto(0,RAD*2)
t.left(270)
derp()
#Demo mode function for dumping source code clone to the turtle window
def dumpSRC():
def draw_text_line(t, text, y):
t.penup()
t.goto(-300, y) # Start position for the text
t.pendown()
t.write(text, font=("Arial", 12, "normal")) # Write the text
with open("source.txt", "r") as file:
y = 350 # Starting y-coordinate for the first line of text
for line in file:
draw_text_line(t, line.strip(), y)
y -= 20 # Move down for the next line
# Check if the next line will exceed the window height
if y < -350:
time.sleep(2)
# Clear the screen & resume writing
t.clear()
# Reset the start position
y = 350
draw_text_line(t, "Source Code Dump Successful", y)
# Draw a yin yang symbol
def taiju():
t.penup()
RAD = 200
RAD2 = RAD / 2
RAD6 = RAD / 6
t.hideturtle()
t.degrees() # Switch to degrees
t.goto(0,-RAD)
t.pendown()
# Draw the circle, radius 100, half black
t.fillcolor('black')
t.begin_fill()
t.circle(RAD, 180)
t.end_fill()
t.circle(RAD, 180)
# Draw black head
t.left(180)
t.penup()
t.goto(0, RAD)
t.pendown()
t.begin_fill()
t.circle(RAD2, 180)
t.end_fill()
# Draw white head
t.penup()
t.goto(0, -RAD)
t.pendown()
t.fillcolor('white')
t.begin_fill()
t.circle(RAD2, 180)
t.end_fill()
# Draw eyes
t.penup()
t.goto(0, RAD2 + RAD6)
t.begin_fill()
t.circle(RAD6)
t.end_fill()
t.fillcolor('black')
#t.goto(0, 2 * (RAD - RAD6))
t.goto(0, 2 * (-RAD6))
t.begin_fill()
t.circle(RAD6)
t.end_fill()
"""
Functions:
draw_Flower()
mandala()
arguelles()
dumpSRC()
taiju()
"""
arguelles()
time.sleep(3)
blank()
draw_Flower()
time.sleep(3)
blank()
dumpSRC() #text size could be increased
time.sleep(3)
t.clear()
t.color("black")
taiju()
time.sleep(3)
blank()
mandala() # on func end color is yellow
time.sleep(3)
"""
#Todo
*Fixed! bugs that occurred when making it run full screen
add more functions,
write a loop.
listen for IO,
kill other processes,
write a class, or a library
"""