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

Tweak some comments and add a new from_hex_alpha function #841

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

addiment
Copy link

No description provided.

.gitignore Outdated
@@ -1,3 +1,38 @@
/target
**/*.rs.bk
# Generated by Cargo
Copy link
Owner

Choose a reason for hiding this comment

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

This sneaked into the PR by accident, right? :) Could you please rebase it out?

/// assert_eq!(light_blue.b, 0.8352941);
/// assert_eq!(light_blue.a, 0.5019608);
/// ```
pub fn from_hex_alpha(hex: u32, alpha: u8) -> Color {
Copy link
Owner

Choose a reason for hiding this comment

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

I do not have very strong opinion here, but it looks like #rrggbbaa notation is fairly common. Maybe we should follow it to? Keep from_hex #rrggbb for the sake of backwards compatibility, while the new one will be 0xRRGGBBAA?

Copy link
Author

Choose a reason for hiding this comment

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

oops-- totally forgot that 32 bits has room for alpha. Will patch that in, stupid oversight on my part.

Copy link
Owner

Choose a reason for hiding this comment

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

It got room, the problem is that 0xff0000 is either red in from_hex or very transparent green in from_hex_alpha, which might be confusing. 0xAARRGGBB is a bit less error prone, but with #rrggbbaa being popular - even more confusing. So hex: u32, alpha: u8 actually does makes sense to me!

Undid tweaks to the gitignore to RustRover usage easier, by request
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.

2 participants