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

[ColorUtil] optimise constants; hue overflow check #3629

Merged
merged 2 commits into from
May 26, 2023

Conversation

andrewfg
Copy link
Contributor

Two improvements to ColorUtils..

  • define static constants for code optimisation
  • hue value overflow check and correction

Signed-off-by: Andrew Fiddian-Green software@whitebear.ch

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
@andrewfg andrewfg requested a review from a team as a code owner May 25, 2023 11:45
Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
@andrewfg andrewfg requested a review from J-N-K May 25, 2023 17:57
@J-N-K J-N-K merged commit 4d3535a into openhab:main May 26, 2023
@J-N-K J-N-K added the enhancement An enhancement or new feature of the Core label May 26, 2023
@J-N-K J-N-K added this to the 4.0 milestone May 26, 2023
}
if (hue.compareTo(BigDecimal.ZERO) < 0) {
hue = hue.add(BigDecimal.valueOf(360));
hue = hue.add(BIG_DECIMAL_360);
} else if (hue.compareTo(BIG_DECIMAL_360) > 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@J-N-K just re-reading this line, I think it should be >= rather than > to cover the exact edge case where hue is 360. Or??

Copy link
Member

Choose a reason for hiding this comment

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

No, I think it's fine. If that is the case 360-360=0 which is the same color.

Copy link
Contributor Author

@andrewfg andrewfg left a comment

Choose a reason for hiding this comment

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

After thoughts

andrewfg

This comment was marked as duplicate.

splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 12, 2023
* [ColorUtil] define constants; fix hue overflow

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
GitOrigin-RevId: 4d3535a
@andrewfg andrewfg deleted the colorutil branch August 25, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants