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

Update FieldUtil.kt #21

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

Update FieldUtil.kt #21

wants to merge 1 commit into from

Conversation

TheChii
Copy link

@TheChii TheChii commented Jan 25, 2025

Key Improvements:

Precise Field Dimensions:

Changed to Double type for accuracy

Added default constants with JVM static fields

Made field dimensions customizable while maintaining defaults

Safe Canvas Handling:

Added validation for positive canvas dimensions

Created dedicated setter method for canvas dimensions

Added runtime checks for proper initialization

Accurate Coordinate Conversion:

Fixed aspect ratio handling with proper per-axis scaling

Clear separation of screen and field coordinate systems

Added documentation about coordinate system assumptions

Improved Scaling Logic:

Unified scale calculation maintains aspect ratio

inchesToPixels now uses aspect-ratio-correct scaling

Removed unnecessary mirroring functions

Code Quality:

Meaningful method names (screenToField instead of screenCoordsToFieldCoords)

Proper JVM annotations for Java interoperability

Clear documentation explaining coordinate systems

Validation for invalid canvas states

Error Prevention:

Added input validation for canvas dimensions

Private setters for canvas dimensions to prevent accidental modification

Runtime checks ensure proper initialization before conversion

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