-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Simplified bevy_color Srgba hex string parsing
#12082
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
Simplified bevy_color Srgba hex string parsing
#12082
Conversation
bushrat011899
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice change, might as well tidy these kinds of functions while we're making a new crate!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to add some test cases for RGBA and RRGGBBAA variants where the colors have different values.
assert_eq!(Srgba::hex("11223344"), Ok(Srgba::rgba_u8(17, 34, 51, 68)));
assert_eq!(Srgba::hex("1234"), Ok(Srgba::rgba_u8(17, 34, 51, 68)));Co-authored-by: Rob Parrett <[email protected]>
Added more tests to make sure RGBA is right. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less code, more tests, and significantly faster than the old implementation.
# Objective - Simplify `Srgba` hex string parsing using std hex parsing functions and removing loops in favor of bitwise ops. This is a follow-up of the `bevy_color` upstream PR review: bevyengine#12013 (comment) ## Solution - Reworked `Srgba::hex` to use `from_str_radix` and some bitwise ops; --------- Co-authored-by: Rob Parrett <[email protected]>
# Objective - Simplify `Srgba` hex string parsing using std hex parsing functions and removing loops in favor of bitwise ops. This is a follow-up of the `bevy_color` upstream PR review: bevyengine#12013 (comment) ## Solution - Reworked `Srgba::hex` to use `from_str_radix` and some bitwise ops; --------- Co-authored-by: Rob Parrett <[email protected]>
Objective
Srgbahex string parsing using std hex parsing functions and removing loops in favor of bitwise ops.This is a follow-up of the
bevy_colorupstream PR review: #12013 (comment)Solution
Srgba::hexto usefrom_str_radixand some bitwise ops;