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] UIColor transformer - Increase to 3 decimals to retain 8bit precision #314

Merged

Conversation

patriknyblad
Copy link
Contributor

Description of changes:
Two decimals only allow for 100 different shades for each channel. Using a gray scale color of #1d with only 2 decimals of precision would produce 0.11 for each channel, converting this number back to hex would result in #1c which is incorrect. This is now fixed by using 3 decimals of precision allowing a theoretical 1000 different shades.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Two decimals only allow for 100 different shades for each channel. Using a gray scale color of #1d with only 2 decimals of precision would produce 0.11 for each channel, converting this number back to hex would result in #1c which is incorrect. This is now fixed by using 3 decimals of precision allowing a theoretical 1000 different shades.
Copy link
Member

@dbanksdesign dbanksdesign left a comment

Choose a reason for hiding this comment

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

Love this pull request! Thank you so much for bringing this up!

@chazzmoney
Copy link
Collaborator

Since we are in the range of 0/255 to 255/255, fixed(3) will work, although swift supports any float value (included those longer than 3 decimals).

:shipit:

@dbanksdesign dbanksdesign merged commit a3bde96 into amzn:master Aug 14, 2019
@shaunbent
Copy link

Hej @dbanksdesign, do you have an idea of when you plan to release SD next? The last release was back in July.

@dbanksdesign
Copy link
Member

I think we can do a release this week. We really should get a more consistent mechanism for releasing... So I created an issue for that: #321

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.

4 participants