58
58
__version__ = "0.0.0-auto.0"
59
59
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_turtle.git"
60
60
61
- class Color :
61
+ class Color ( object ) :
62
62
"""Standard colors"""
63
63
WHITE = 0xFFFFFF
64
64
BLACK = 0x000000
@@ -72,6 +72,10 @@ class Color:
72
72
73
73
colors = (WHITE , BLACK , RED , ORANGE , YELLOW , GREEN , BLUE , PURPLE , PINK )
74
74
75
+ def __init__ (self ):
76
+ pass
77
+
78
+
75
79
class Vec2D (tuple ):
76
80
"""A 2 dimensional vector class, used as a helper class
77
81
for implementing turtle graphics.
@@ -86,7 +90,7 @@ class Vec2D(tuple):
86
90
# |a| absolute value of a
87
91
# a.rotate(angle) rotation
88
92
def __init__ (self , x , y ):
89
- super ().__init__ ((x , y ))
93
+ super (Vec2D , self ).__init__ ((x , y ))
90
94
91
95
def __add__ (self , other ):
92
96
return Vec2D (self [0 ] + other [0 ], self [1 ] + other [1 ])
@@ -128,7 +132,7 @@ def __repr__(self):
128
132
return "(%.2f,%.2f)" % self
129
133
130
134
131
- class turtle :
135
+ class turtle ( object ) :
132
136
"""A Turtle that can be given commands to draw."""
133
137
134
138
def __init__ (self , display = board .DISPLAY ):
@@ -206,7 +210,7 @@ def forward(self, distance):
206
210
207
211
def backward (self , distance ):
208
212
"""Move the turtle backward by distance, opposite to the direction the turtle is headed.
209
- Does not change the turtle’ s heading.
213
+ Does not change the turtle' s heading.
210
214
211
215
:param distance: how far to move (integer or float)
212
216
"""
@@ -216,7 +220,7 @@ def backward(self, distance):
216
220
back = backward
217
221
218
222
def degrees (self , fullcircle = 360 ):
219
- """Set angle measurement units, i.e. set number of “ degrees” for a full circle.
223
+ """Set angle measurement units, i.e. set number of " degrees" for a full circle.
220
224
Default value is 360 degrees.
221
225
222
226
:param fullcircle: the number of degrees in a full circle
@@ -252,7 +256,7 @@ def goto(self, x1, y1=None):
252
256
"""If y1 is None, x1 must be a pair of coordinates or an (x, y) tuple
253
257
254
258
Move turtle to an absolute position. If the pen is down, draw line.
255
- Does not change the turtle’ s orientation.
259
+ Does not change the turtle' s orientation.
256
260
257
261
:param x1: a number or a pair of numbers
258
262
:param y1: a number or None
@@ -320,7 +324,7 @@ def goto(self, x1, y1=None):
320
324
setposition = goto
321
325
322
326
def setx (self , x ):
323
- """Set the turtle’ s first coordinate to x, leave second coordinate
327
+ """Set the turtle' s first coordinate to x, leave second coordinate
324
328
unchanged.
325
329
326
330
:param x: new value of the turtle's x coordinate (a number)
@@ -329,7 +333,7 @@ def setx(self, x):
329
333
self .goto (x , self .pos ()[1 ])
330
334
331
335
def sety (self , y ):
332
- """Set the turtle’ s second coordinate to y, leave first coordinate
336
+ """Set the turtle' s second coordinate to y, leave first coordinate
333
337
unchanged.
334
338
335
339
:param y: new value of the turtle's y coordinate (a number)
@@ -355,7 +359,7 @@ def setheading(self, to_angle):
355
359
seth = setheading
356
360
357
361
def home (self ):
358
- """Move turtle to the origin – coordinates (0,0) – and set its heading to
362
+ """Move turtle to the origin - coordinates (0,0) - and set its heading to
359
363
its start-orientation
360
364
(which depends on the mode, see mode()).
361
365
"""
@@ -364,7 +368,7 @@ def home(self):
364
368
365
369
def circle (self , radius , extent = None , steps = None ):
366
370
"""Draw a circle with given radius. The center is radius units left of
367
- the turtle; extent – an angle – determines which part of the circle is
371
+ the turtle; extent - an angle - determines which part of the circle is
368
372
drawn. If extent is not given, draw the entire circle. If extent is not
369
373
a full circle, one endpoint of the arc is the current pen position.
370
374
Draw the arc in counterclockwise direction if radius is positive,
@@ -410,7 +414,7 @@ def clearstamp(self, stampid):
410
414
raise NotImplementedError
411
415
412
416
def clearstamps (self , n = None ):
413
- """Delete all or first/last n of turtle’ s stamps. If n is None, delete
417
+ """Delete all or first/last n of turtle' s stamps. If n is None, delete
414
418
all stamps, if n > 0 delete first n stamps, else if n < 0 delete last
415
419
n stamps.
416
420
@@ -426,17 +430,17 @@ def undo(self):
426
430
raise NotImplementedError
427
431
428
432
def speed (self , speed = None ):
429
- """Set the turtle’ s speed to an integer value in the range 0..10. If no
433
+ """Set the turtle' s speed to an integer value in the range 0..10. If no
430
434
argument is given, return current speed.
431
435
432
436
If input is a number greater than 10 or smaller than 0.5, speed is set
433
437
to 0. Speedstrings are mapped to speedvalues as follows:
434
438
435
- “ fastest” : 0
436
- “ fast” : 10
437
- “ normal” : 6
438
- “ slow” : 3
439
- “ slowest” : 1
439
+ " fastest" : 0
440
+ " fast" : 10
441
+ " normal" : 6
442
+ " slow" : 3
443
+ " slowest" : 1
440
444
441
445
Speeds from 1 to 10 enforce increasingly faster animation of line
442
446
drawing and turtle turning.
@@ -453,12 +457,12 @@ def speed(self, speed=None):
453
457
####################
454
458
# Tell turtle's state
455
459
def pos (self ):
456
- """Return the turtle’ s current location (x,y) (as a Vec2D vector)."""
460
+ """Return the turtle' s current location (x,y) (as a Vec2D vector)."""
457
461
return Vec2D (self ._x - self ._w // 2 , self ._h // 2 - self ._y )
458
462
position = pos
459
463
460
464
def clear (self ):
461
- """Delete the turtle’ s drawings from the screen. Do not move turtle.
465
+ """Delete the turtle' s drawings from the screen. Do not move turtle.
462
466
State and position of the turtle as well as drawings of other turtles
463
467
are not affected.
464
468
"""
@@ -474,24 +478,24 @@ def clear(self):
474
478
time .sleep (0.1 )
475
479
476
480
def heading (self ):
477
- """Return the turtle’ s current heading (value depends on the turtle mode, see mode())."""
481
+ """Return the turtle' s current heading (value depends on the turtle mode, see mode())."""
478
482
return self ._heading
479
483
480
484
# Pen control
481
485
def pendown (self ):
482
- """Pull the pen down – drawing when moving."""
486
+ """Pull the pen down - drawing when moving."""
483
487
self ._penstate = True
484
488
pd = pendown
485
489
down = pendown
486
490
487
491
def penup (self ):
488
- """Pull the pen up – no drawing when moving."""
492
+ """Pull the pen up - no drawing when moving."""
489
493
self ._penstate = False
490
494
pu = penup
491
495
up = penup
492
496
493
497
def isdown (self ):
494
- """Return True if pen is down, False if it’ s up."""
498
+ """Return True if pen is down, False if it' s up."""
495
499
return self ._penstate
496
500
497
501
def pencolor (self , c = None ):
@@ -510,13 +514,13 @@ def pencolor(self, c=None):
510
514
511
515
def mode (self , mode = None ):
512
516
"""
513
- Set turtle mode (“ standard”, “ logo” or “ world” ) and perform reset.
517
+ Set turtle mode (" standard", " logo" or " world" ) and perform reset.
514
518
If mode is not given, current mode is returned.
515
519
516
- Mode “ standard” is compatible with old turtle.
517
- Mode “ logo” is compatible with most Logo turtle graphics.
520
+ Mode " standard" is compatible with old turtle.
521
+ Mode " logo" is compatible with most Logo turtle graphics.
518
522
519
- :param mode: one of the strings “ standard” or “ logo"
523
+ :param mode: one of the strings " standard" or " logo"
520
524
"""
521
525
if mode == "standard" :
522
526
self ._logomode = False
0 commit comments