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

Fix non-integer array indexing in line drawing algorithm #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Dmytro-Malets
Copy link

Summary

This pull request addresses an issue with non-integer array indexing in the line drawing algorithm within ect.py.

Changes Made

  • Replaced image2[y, x] = color with image2[int(round(y)), int(round(x))] = color.

Reason for Change

The original indexing method using image2[y, x] = color can lead to runtime errors when non-integer values are provided for y and x. This is especially problematic when the coordinates are calculated from floating-point operations, which can result in non-integer values.

By changing the indexing to image2[int(round(y)), int(round(x))] = color, we ensure that the coordinates are rounded to the nearest integers before being used for indexing. This modification prevents runtime errors and guarantees that the drawing function behaves consistently with the expected integer index requirements. The new method is more robust and handles various input scenarios better.

Testing

To verify the changes, you can run the drawing function with both integer and non-integer inputs to ensure it behaves as expected without raising errors.

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.

1 participant