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

Refactor and improve component API with f32 infinities #62

Merged
merged 6 commits into from
Aug 4, 2024

Conversation

Nexfader
Copy link
Contributor

First of all, thanks for the library! I wanted to improve its code quality, so I've decided to open this PR. Here's what I've done:

  • Made use of Bevy's Rect, Aabb2d and Rust's Range types to make the code more idiomatic;
  • Extracted some logic into separate functions, which reduced code duplication and also will be helpful in unit-testing later;
  • Simplified bound handling: it now heavily uses f32::INFINITY and f32::NEG_INFINITY, making calculations seamless and simpler (as opposed to constantly dealing with Options);
  • Standardized the usage of vec2 over Vec2::new (previously, the code contained both);
  • Changed single to get_single in camera_zoom (similar to what use get_single when getting the window #58 did for camera_movement);
  • Reduced if-nesting using if-guards [source];
  • Formatted comments according to the style guide.

Sorry if this turned out too opinionated. Feel free to discuss any points in the PR :)

@johanhelsing
Copy link
Owner

Looks great! Thanks!

I have some trouble understanding that one line, but otherwise this should be ready to merge :)

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@Nexfader Nexfader changed the title Refactor and improve code readability Refactor and improve component API with f32 infinities Aug 3, 2024
src/lib.rs Outdated Show resolved Hide resolved
Copy link
Owner

@johanhelsing johanhelsing left a comment

Choose a reason for hiding this comment

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

Awesome. Great work :)

@johanhelsing johanhelsing merged commit a7dda6e into johanhelsing:main Aug 4, 2024
3 checks passed
@johanhelsing johanhelsing added the enhancement New feature or request label Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants