Skip to content

make circle and dot always use degrees internally #44

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 3 commits into from
Dec 12, 2024
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
23 changes: 23 additions & 0 deletions adafruit_turtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,12 @@ def circle(
# --or: circle(radius, extent) # arc
# --or: circle(radius, extent, steps)
# --or: circle(radius, steps=6) # 6-sided polygon
change_back = False
if not self._in_degrees():
change_back = True
original_mode = "standard" if not self._logomode else "logo"
self.degrees()
self.mode("standard")
pos = self.pos()
h = self._heading
if extent is None:
Expand All @@ -647,6 +653,9 @@ def circle(
# get back to exact same position and heading
self.goto(pos)
self.setheading(h)
if change_back:
self.radians()
self.mode(original_mode)

# pylint:disable=inconsistent-return-statements
def speed(self, speed: Optional[int] = None) -> Optional[int]:
Expand Down Expand Up @@ -690,6 +699,13 @@ def dot(self, size: Optional[int] = None, color: Optional[int] = None) -> None:
:param color: the color of the dot

"""
change_back = False
if not self._in_degrees():
change_back = True
original_mode = "standard" if not self._logomode else "logo"
print(f"old mode: {original_mode}")
self.degrees()
self.mode("standard")
if size is None:
size = max(self._pensize + 4, self._pensize * 2)
if color is None:
Expand All @@ -713,6 +729,9 @@ def dot(self, size: Optional[int] = None, color: Optional[int] = None) -> None:
self._pensize = 1
self._plot(self._x, self._y, color)
self._pensize = pensize
if change_back:
self.radians()
self.mode(original_mode)

def stamp(
self,
Expand Down Expand Up @@ -882,6 +901,10 @@ def degrees(self, fullcircle: float = 360) -> None:
"""
self._setDegreesPerAU(fullcircle)

def _in_degrees(self) -> bool:
print(self._degreesPerAU)
return self._degreesPerAU == 1.0

def radians(self) -> None:
"""Set the angle measurement units to radians.
Equivalent to degrees(2*math.pi)."""
Expand Down
Loading