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

Unify and improve FromHex in ColorHelper.cs and ColorExtensions.cs #961

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

Eb3yr
Copy link
Contributor

@Eb3yr Eb3yr commented Nov 6, 2024

Updated ColorExtensions.FromHex to reference ColorHelper.FromHex rather than using it's own, different, implementation.

Updated ColorHelper.FromHex with a new implementation that makes use of a single uint parse of the hex code and bit shifts, rather than numerous string operations, which is approx. 4x faster. It now also supports conversions of 3-and-4 digit hex codes in the same manner as HTML color codes, where "ABC" would be interpreted as "AABBCC".

* Both now use ColorHelper.FromHex, rather than differing implementations

* FromHex now accepts hex numbers with three and four digits matching HTML color codes, where "ABC" maps to "AABBCC"

* Significant performance increase using bitshifts over string operations
@AristurtleDev
Copy link
Member

Thanks @Eb3yr.

Side note: Looking at it, I'm not sure why there are two separate classes related to color utilities. This is something that needs to be looked into and cleaned up as well.

Going to open an issue for it to track that.

@AristurtleDev AristurtleDev merged commit d3b4482 into craftworkgames:develop Nov 7, 2024
1 check passed
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