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 pixel alignment math #312

Merged
merged 1 commit into from
Jul 31, 2024
Merged

Conversation

bryankeller
Copy link
Contributor

Details

This fixes a subtle screen-pixel alignment bug. The existing math causes slight oscillations between 2 adjacent pixels, which can cause some additional layout churn.

Related Issue

N/A

Motivation and Context

Bug fix / optimization

How Has This Been Tested

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@bryankeller bryankeller added the bug Something isn't working label Jul 31, 2024
Comment on lines +27 to +30
func isEqual(to rhs: CGFloat, screenScale: CGFloat) -> Bool {
let lhs = alignedToPixel(forScreenWithScale: screenScale)
let rhs = rhs.alignedToPixel(forScreenWithScale: screenScale)
return lhs == rhs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bryankeller bryankeller merged commit e19a229 into master Jul 31, 2024
2 checks passed
@bryankeller bryankeller deleted the bk/fix-screen-pixel-alignment branch July 31, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants