Skip to content

Commit b217473

Browse files
authored
Merge pull request #8 from dastels/master
Tweaks and cleaning up
2 parents 8559c02 + eb2d63b commit b217473

File tree

1 file changed

+24
-38
lines changed

1 file changed

+24
-38
lines changed

adafruit_turtle.py

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def backward(self, distance):
226226
self.forward(-distance)
227227
bk = backward
228228
back = backward
229+
229230
def right(self, angle):
230231
"""Turn turtle right by angle units. (Units are by default degrees,
231232
but can be set via the degrees() and radians() functions.)
@@ -292,7 +293,6 @@ def goto(self, x1, y1=None):
292293
if steep:
293294
try:
294295
self._plot(int(y0), int(x0), self._pencolor)
295-
# self._fg_bitmap[int(y0), int(x0)] = self._pencolor
296296
except IndexError:
297297
pass
298298
self._x = y0
@@ -302,7 +302,6 @@ def goto(self, x1, y1=None):
302302
else:
303303
try:
304304
self._plot(int(x0), int(y0), self._pencolor)
305-
# self._fg_bitmap[int(x0), int(y0)] = self._pencolor
306305
except IndexError:
307306
pass
308307
self._x = x0
@@ -562,16 +561,12 @@ def towards(self, x1, y1=None):
562561
raise NotImplementedError
563562

564563
def xcor(self):
565-
"""Not implemented
566-
567-
Return the turtle's x coordinate."""
568-
raise NotImplementedError
564+
"""Return the turtle's x coordinate."""
565+
return self._x - self._w // 2
569566

570567
def ycor(self):
571-
"""Not implemented
572-
573-
Return the turtle's y coordinate."""
574-
raise NotImplementedError
568+
"""Return the turtle's y coordinate."""
569+
return self._h // 2 - self._y
575570

576571
def heading(self):
577572
"""Return the turtle's current heading (value depends on the turtle
@@ -726,18 +721,10 @@ def pencolor(self, c=None):
726721
tuple (see example). May be used as input to another color/
727722
pencolor/fillcolor call.
728723
729-
pencolor(colorstring)
730-
Set pencolor to colorstring, which is a Tk color specification
731-
string, such as "red", "yellow", or "#33cc8c".
732-
733-
pencolor((r, g, b))
734-
Set pencolor to the RGB color represented by the tuple of r, g, and
735-
b. Each of r, g, and b must be in the range 0..colormode, where
736-
colormode is either 1.0 or 255 (see colormode()).
737-
738-
pencolor(r, g, b)
739-
Set pencolor to the RGB color represented by r, g, and b. Each of r,
740-
g, and b must be in the range 0..colormode.
724+
pencolor(colorvalue)
725+
Set pencolor to colorvalue, which is a 24-bit integer such as 0xFF0000.
726+
The Color class provides the available values:
727+
WHITE, BLACK, RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE, PINK
741728
742729
If turtleshape is a polygon, the outline of that polygon is drawn with
743730
the newly set pencolor.
@@ -811,10 +798,7 @@ def reset(self):
811798
raise NotImplementedError
812799

813800
def clear(self):
814-
"""Delete the turtle's drawings from the screen. Do not move turtle.
815-
State and position of the turtle as well as drawings of other turtles
816-
are not affected.
817-
"""
801+
"""Delete the turtle's drawings from the screen. Do not move turtle."""
818802
for w in range(self._w):
819803
for h in range(self._h):
820804
self._fg_bitmap[w, h] = 0
@@ -1140,7 +1124,8 @@ def undobufferentries(self):
11401124
# Settings and special methods
11411125

11421126
def mode(self, mode=None):
1143-
"""
1127+
"""Not implemented
1128+
11441129
Set turtle mode ("standard" or "logo") and perform reset.
11451130
If mode is not given, current mode is returned.
11461131
@@ -1149,17 +1134,18 @@ def mode(self, mode=None):
11491134
11501135
:param mode: one of the strings "standard" or "logo"
11511136
"""
1152-
if mode == "standard":
1153-
self._logomode = False
1154-
elif mode == "logo":
1155-
self._logomode = True
1156-
elif mode is None:
1157-
if self._logomode:
1158-
return "logo"
1159-
return "standard"
1160-
else:
1161-
raise RuntimeError("Mode must be 'logo' or 'standard!'")
1162-
return None
1137+
raise NotImplementedError
1138+
# if mode == "standard":
1139+
# self._logomode = False
1140+
# elif mode == "logo":
1141+
# self._logomode = True
1142+
# elif mode is None:
1143+
# if self._logomode:
1144+
# return "logo"
1145+
# return "standard"
1146+
# else:
1147+
# raise RuntimeError("Mode must be 'logo', 'standard!', or None")
1148+
# return None
11631149

11641150
def colormode(self, cmode=None):
11651151
"""Not implemented

0 commit comments

Comments
 (0)