Skip to content

Modify canvas update to round newWidth and newHeight to nearest integer#140

Open
tindleroot wants to merge 1 commit intoPWNAGERobotics:mainfrom
tindleroot:clean-upstream
Open

Modify canvas update to round newWidth and newHeight to nearest integer#140
tindleroot wants to merge 1 commit intoPWNAGERobotics:mainfrom
tindleroot:clean-upstream

Conversation

@tindleroot
Copy link

[BUGFIX]

Issue: When clickable image (e.g. field image for auto/teleop shot locations) is updated after click, the canvas width and height are recalculated incorrectly, leading to canvas shrinking over many presses.

Bug explanation: The canvas width and height are integers, but the calculated width and height are not (due to ratio between image size and canvas size being non-integer). Therefore, on every update the dimension that is slightly larger shrinks by 1 pixel due to the (fractional) new size being truncated down to integer.

Fix: By rounding the new values to nearest integer, the canvas no longer shrinks on update, but the original intended behavior of recalculating the aspect ratio based on the image is left intact.

@tindleroot
Copy link
Author

Note: original bug was detected (and fix tested) on Chrome (Windows desktop) and Chrome (mobile/Android)

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