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

Handle out of bounds for rgbatoHex and not quite always 100% color translation #36

Merged
merged 1 commit into from
Aug 10, 2022

Conversation

rpearce
Copy link
Owner

@rpearce rpearce commented Aug 10, 2022

Closes #23

@rpearce rpearce added the bug Something isn't working label Aug 10, 2022
@rpearce rpearce self-assigned this Aug 10, 2022
.min(255, Math.max(0, Math.round(x)))
.toString(16)
.padStart(2, '0')
).join('')
Copy link
Owner Author

Choose a reason for hiding this comment

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

const hex = rgbN.toString(16).slice(1)
const hex = [r, g, b].map(x =>
Math
.min(255, Math.max(0, Math.round(x)))
Copy link
Owner Author

Choose a reason for hiding this comment

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

This adds the upper and lower bounds (0, 255)

@rpearce rpearce merged commit c071ceb into main Aug 10, 2022
@rpearce rpearce deleted the fix/rgbaToHex branch August 10, 2022 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate rgbaToHex function might be a little bit off in some cases
1 participant