Skip to content

Account for fractions of a pixel when drawing #45

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 1 commit into from
Dec 5, 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
12 changes: 6 additions & 6 deletions adafruit_turtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,17 @@ def goto(
xn: float = x1[0] if y1 is None else x1 # type: ignore
xn += self._w // 2
yn = self._h // 2 - yn
x0 = self._x
y0 = self._y
if not self.isdown():
self._x = xn # woot, we just skip ahead
self._y = yn
self._drawturtle()
return

self._do_draw_line(round(self._x), round(self._y), round(xn), round(yn))
self._x = xn
self._y = yn

def _do_draw_line(self, x0: int, y0: int, xn: int, yn: int):
steep = abs(yn - y0) > abs(xn - x0)
rev = False
dx = xn - x0
Expand Down Expand Up @@ -444,15 +448,11 @@ def goto(
self._plot(int(y0), int(x0), self._pencolor)
except IndexError:
pass
self._x = y0
self._y = x0
else:
try:
self._plot(int(x0), int(y0), self._pencolor)
except IndexError:
pass
self._x = x0
self._y = y0
if self._speed > 0:
if step >= self._speed:
# mark the step
Expand Down
Loading