Skip to content

Tweaks and cleaning up #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 24 additions & 38 deletions adafruit_turtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def backward(self, distance):
self.forward(-distance)
bk = backward
back = backward

def right(self, angle):
"""Turn turtle right by angle units. (Units are by default degrees,
but can be set via the degrees() and radians() functions.)
Expand Down Expand Up @@ -292,7 +293,6 @@ def goto(self, x1, y1=None):
if steep:
try:
self._plot(int(y0), int(x0), self._pencolor)
# self._fg_bitmap[int(y0), int(x0)] = self._pencolor
except IndexError:
pass
self._x = y0
Expand All @@ -302,7 +302,6 @@ def goto(self, x1, y1=None):
else:
try:
self._plot(int(x0), int(y0), self._pencolor)
# self._fg_bitmap[int(x0), int(y0)] = self._pencolor
except IndexError:
pass
self._x = x0
Expand Down Expand Up @@ -562,16 +561,12 @@ def towards(self, x1, y1=None):
raise NotImplementedError

def xcor(self):
"""Not implemented

Return the turtle's x coordinate."""
raise NotImplementedError
"""Return the turtle's x coordinate."""
return self._x - self._w // 2

def ycor(self):
"""Not implemented

Return the turtle's y coordinate."""
raise NotImplementedError
"""Return the turtle's y coordinate."""
return self._h // 2 - self._y

def heading(self):
"""Return the turtle's current heading (value depends on the turtle
Expand Down Expand Up @@ -726,18 +721,10 @@ def pencolor(self, c=None):
tuple (see example). May be used as input to another color/
pencolor/fillcolor call.

pencolor(colorstring)
Set pencolor to colorstring, which is a Tk color specification
string, such as "red", "yellow", or "#33cc8c".

pencolor((r, g, b))
Set pencolor to the RGB color represented by the tuple of r, g, and
b. Each of r, g, and b must be in the range 0..colormode, where
colormode is either 1.0 or 255 (see colormode()).

pencolor(r, g, b)
Set pencolor to the RGB color represented by r, g, and b. Each of r,
g, and b must be in the range 0..colormode.
pencolor(colorvalue)
Set pencolor to colorvalue, which is a 24-bit integer such as 0xFF0000.
The Color class provides the available values:
WHITE, BLACK, RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE, PINK

If turtleshape is a polygon, the outline of that polygon is drawn with
the newly set pencolor.
Expand Down Expand Up @@ -811,10 +798,7 @@ def reset(self):
raise NotImplementedError

def clear(self):
"""Delete the turtle's drawings from the screen. Do not move turtle.
State and position of the turtle as well as drawings of other turtles
are not affected.
"""
"""Delete the turtle's drawings from the screen. Do not move turtle."""
for w in range(self._w):
for h in range(self._h):
self._fg_bitmap[w, h] = 0
Expand Down Expand Up @@ -1140,7 +1124,8 @@ def undobufferentries(self):
# Settings and special methods

def mode(self, mode=None):
"""
"""Not implemented

Set turtle mode ("standard" or "logo") and perform reset.
If mode is not given, current mode is returned.

Expand All @@ -1149,17 +1134,18 @@ def mode(self, mode=None):

:param mode: one of the strings "standard" or "logo"
"""
if mode == "standard":
self._logomode = False
elif mode == "logo":
self._logomode = True
elif mode is None:
if self._logomode:
return "logo"
return "standard"
else:
raise RuntimeError("Mode must be 'logo' or 'standard!'")
return None
raise NotImplementedError
# if mode == "standard":
# self._logomode = False
# elif mode == "logo":
# self._logomode = True
# elif mode is None:
# if self._logomode:
# return "logo"
# return "standard"
# else:
# raise RuntimeError("Mode must be 'logo', 'standard!', or None")
# return None

def colormode(self, cmode=None):
"""Not implemented
Expand Down