Skip to content
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

Account for fractions of a pixel when drawing #45

Merged
merged 1 commit into from
Dec 5, 2024
Merged

Account for fractions of a pixel when drawing #45

merged 1 commit into from
Dec 5, 2024

Conversation

jepler
Copy link
Member

@jepler jepler commented Dec 4, 2024

Previously, the endpoint of the line was always moved along in increments of 1 pixel, so that the endpoint would always be rounded down. This could accumulate to give quite large differences from what the program intended.

Ensure that "goto" always ends up storing the floating point endpoints and that the line is drawn from the rounded-integer starting coordinate and rounded-integer ending coordinate.

This makes the 3 test lines in the OP's "turtle_truncate.txt" example be the same length. (the second line in each pair in the photo shows the length of the line produced BEFORE the bugfix)

Closes: #41

PXL_20241204_235342910

@jepler jepler requested a review from FoamyGuy December 4, 2024 23:55
Copy link

github-actions bot commented Dec 4, 2024

👋 Thanks for this pull request! Unfortunately, it looks like the automated continuous integration (CI) test(s) failed. These can be tricky to fix so we've written a guide on how to fix them locally. It has pages about running pre-commit locally and another about building the docs locally with sphinx. Thanks for contributing to CircuitPython! If you have more questions, feel free to join the Adafruit Discord and post in #circuitpython-dev.

Previously, the endpoint of the line was always moved
along in increments of 1 pixel, so that the endpoint would always be
rounded down. This could accumulate to give quite large differences
from what the program intended.

Ensure that "goto" always ends up storing the floating point endpoints
and that the line is drawn from the rounded-integer starting coordinate
and rounded-integer ending coordinate.

This makes the 3 test lines in the OP's "turtle_truncate.txt" example
be the same length.

Closes: #41
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, Thank you for looking into this and finding the fix!

This looks good to me. I tested it successfully with the line reproducer code on a CPB + Gizmo

@FoamyGuy FoamyGuy merged commit 49d941a into main Dec 5, 2024
2 checks passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Dec 6, 2024
Updating https://github.com/adafruit/Adafruit_CircuitPython_24LC32 to 1.2.0 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_24LC32#25 from FoamyGuy/dont_rewrite_same

Updating https://github.com/adafruit/Adafruit_CircuitPython_VL53L0X to 3.6.13 from 3.6.12:
  > Merge pull request adafruit/Adafruit_CircuitPython_VL53L0X#40 from jposada202020/adding_displayIO_example

Updating https://github.com/adafruit/Adafruit_CircuitPython_VS1053 to 1.2.20 from 1.2.19:
  > Merge pull request adafruit/Adafruit_CircuitPython_VS1053#21 from FoamyGuy/use_ruff

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Button to 1.11.1 from 1.9.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Button#53 from FoamyGuy/debounced_example
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Button#52 from FoamyGuy/focal_touch_support
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Button#51 from FoamyGuy/use_ruff
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Button#49 from ch4nsuk3/expose-name-property
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Button#48 from ch4nsuk3/add-annotations
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Button#50 from FoamyGuy/type_annotations

Updating https://github.com/adafruit/Adafruit_CircuitPython_turtle to 3.1.1 from 3.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_turtle#45 from adafruit/issue41

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

turtle location is wrong after several moves
2 participants