forked from Ezhil-Language-Foundation/Ezhil-Lang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEZTurtle.py
330 lines (253 loc) · 6.87 KB
/
EZTurtle.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
## -*- coding: utf-8 -*-
## (C) 2013 Muthiah Annamalai,
## Licensed under GPL Version 3
import turtle
class EZTurtle:
""" EZTurtle class implements a singleton for famed Turtle module.
Unfortunately turtle class does not take Unicode arguments. """
instance = None
@staticmethod
def getInstance():
if not EZTurtle.instance:
EZTurtle.instance = turtle.Pen()
return EZTurtle.instance
@staticmethod
def functionAttributes():
attrib = {
0: [
'ht',
'home',
'showturtle',
'hideturtle',
'reset',
'penup',
'up',
'down',
'pendown',
'clear',
'isvisible',
],
1: [
'rt', 'lt', 'left', 'right', 'forward', 'fd', 'bd', 'backward',
'color', 'fill', 'speed', 'pencolor', 'dot'
],
2: ['goto'],
-1: ['circle', 'setworldcoordinates']
} #-1 => indicates varargs
return attrib
# 0-arg functions
@staticmethod
def home():
EZTurtle.getInstance().home(*[])
@staticmethod
def clear():
EZTurtle.getInstance().clear(*[])
@staticmethod
def showturtle():
EZTurtle.getInstance().showturtle(*[])
@staticmethod
def hideturtle():
EZTurtle.getInstance().hideturtle(*[])
@staticmethod
def penup():
EZTurtle.getInstance().penup(*[])
up = penup
@staticmethod
def pendown():
EZTurtle.getInstance().pendown(*[])
@staticmethod
def down():
EZTurtle.pendown()
# 1-arg functions
@staticmethod
def rt(x):
EZTurtle.getInstance().rt(*[x])
@staticmethod
def right(x):
EZTurtle.rt(x)
@staticmethod
def lt(x):
EZTurtle.getInstance().lt(*[x])
@staticmethod
def left(x):
EZTurtle.lt(x)
@staticmethod
def forward(x):
EZTurtle.getInstance().forward(*[x])
@staticmethod
def fd(x):
EZTurtle.forward(x)
@staticmethod
def backward(x):
EZTurtle.getInstance().backward(*[x])
@staticmethod
def bd(x):
EZTurtle.backward(x)
@staticmethod
def back(x):
EZTurtle.getInstance().back(*[x])
@staticmethod
def bk(x):
EZTurtle.getInstance().bk(*[x])
@staticmethod
def setworldcoordinates(*x): #polymorphic invocation supported here
turtle.setworldcoordinates(*x)
@staticmethod
def circle(*x): #polymorphic invocation supported here
EZTurtle.getInstance().circle(*x)
@staticmethod
def clearstamp(x):
EZTurtle.getInstance().clearstamp(*[x])
@staticmethod
def clearstamps(x):
EZTurtle.getInstance().clearstamps(*[x])
@staticmethod
def clone(x):
EZTurtle.getInstance().clone(*[x])
@staticmethod
def color(x):
EZTurtle.getInstance().color(*[str(x)])
@staticmethod
def degrees(x):
EZTurtle.getInstance().degrees(*[x])
@staticmethod
def distance(x):
EZTurtle.getInstance().distance(*[x])
@staticmethod
def dot(x):
EZTurtle.getInstance().dot(*[x])
@staticmethod
def fill(x):
EZTurtle.getInstance().fill(*[x])
@staticmethod
def fillcolor(x):
EZTurtle.getInstance().fillcolor(*[x])
@staticmethod
def getpen(x):
EZTurtle.getInstance().getpen(*[x])
@staticmethod
def getscreen(x):
EZTurtle.getInstance().getscreen(*[x])
@staticmethod
def getturtle(x):
EZTurtle.getInstance().getturtle(*[x])
@staticmethod
def goto(x, y):
EZTurtle.getInstance().goto(*[x, y])
@staticmethod
def heading(x):
EZTurtle.getInstance().heading(*[x])
@staticmethod
def ht():
EZTurtle.getInstance().ht(*[])
@staticmethod
def isdown(x):
EZTurtle.getInstance().isdown(*[x])
@staticmethod
def isvisible():
EZTurtle.getInstance().isvisible(*[])
@staticmethod
def ondrag(x):
EZTurtle.getInstance().ondrag(*[x])
@staticmethod
def onrelease(x):
EZTurtle.getInstance().onrelease(*[x])
@staticmethod
def pd(x):
EZTurtle.getInstance().pd(*[x])
@staticmethod
def pen(x):
EZTurtle.getInstance().pen(*[x])
@staticmethod
def pencolor(x):
EZTurtle.getInstance().pencolor(*[str(x)])
@staticmethod
def pensize(x):
EZTurtle.getInstance().pensize(*[x])
@staticmethod
def pos(x):
EZTurtle.getInstance().pos(*[x])
@staticmethod
def position(x):
EZTurtle.getInstance().position(*[x])
@staticmethod
def pu(x):
EZTurtle.getInstance().pu(*[x])
@staticmethod
def radians(x):
EZTurtle.getInstance().radians(*[x])
@staticmethod
def reset():
EZTurtle.getInstance().reset()
@staticmethod
def resizemode(x):
EZTurtle.getInstance().resizemode(*[x])
@staticmethod
def seth(x):
EZTurtle.getInstance().seth(*[x])
@staticmethod
def setpos(x):
EZTurtle.getInstance().setpos(*[x])
@staticmethod
def setposition(x):
EZTurtle.getInstance().setposition(*[x])
@staticmethod
def settiltangle(x):
EZTurtle.getInstance().settiltangle(*[x])
@staticmethod
def setundobuffer(x):
EZTurtle.getInstance().setundobuffer(*[x])
@staticmethod
def setx(x):
EZTurtle.getInstance().setx(*[x])
@staticmethod
def sety(x):
EZTurtle.getInstance().sety(*[x])
@staticmethod
def shape(x):
EZTurtle.getInstance().shape(*[x])
@staticmethod
def shapesize(x):
EZTurtle.getInstance().shapesize(*[x])
@staticmethod
def speed(x):
EZTurtle.getInstance().speed(*[x])
@staticmethod
def st(x):
EZTurtle.getInstance().st(*[x])
@staticmethod
def stamp(x):
EZTurtle.getInstance().stamp(*[x])
@staticmethod
def tilt(x):
EZTurtle.getInstance().tilt(*[x])
@staticmethod
def tiltangle(x):
EZTurtle.getInstance().tiltangle(*[x])
@staticmethod
def towards(x):
EZTurtle.getInstance().towards(*[x])
@staticmethod
def tracer(x):
EZTurtle.getInstance().tracer(*[x])
@staticmethod
def turtlesize(x):
EZTurtle.getInstance().turtlesize(*[x])
@staticmethod
def undo(x):
EZTurtle.getInstance().undo(*[x])
@staticmethod
def undobufferentries(x):
EZTurtle.getInstance().undobufferentries(*[x])
@staticmethod
def width(x):
EZTurtle.getInstance().width(*[x])
@staticmethod
def write(x):
EZTurtle.getInstance().write(*[x])
@staticmethod
def xcor(x):
EZTurtle.getInstance().xcor(*[x])
@staticmethod
def ycor(x):
EZTurtle.getInstance().ycor(*[x])