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

Add a color limiter option #5

Merged
merged 5 commits into from
May 22, 2024
Merged

Conversation

tristen
Copy link
Member

@tristen tristen commented Apr 23, 2024

This PR adds a new limit option that limits the hue range of a color passed.

const color = new toColor('hi', { limit: ['blue'] });

The goal is to combat issues where blue in particular - which natively has low luminance - has poor contrast against dark colors:

Screenshot 2024-04-23 at 1 09 53 PM

@AlexanderBelokon
Copy link
Contributor

AlexanderBelokon commented Apr 24, 2024

Maybe instead of subjective bounds we could use something like sinebow or cube helix rainbow to ensure all hues have the same perceptual brightness and build upon that?

Edit: Actually nevermind, it's not exactly uniform with respect to L 🤔

It just seems that a better approach would be given a hue to calculate other values in a way that gives us predictable L, whatever hue we choose

@tristen
Copy link
Member Author

tristen commented Apr 24, 2024

@AlexanderBelokon to-color is already pretty subjective with respect to bounds. I'd prefer this implementation to be a starting place that we can rethink/improve on?

@AlexanderBelokon
Copy link
Contributor

I don't feel good about how close 6th and 7th colors are with the current limit:

image

let me think about how we can improve that 🤔

@tristen
Copy link
Member Author

tristen commented May 22, 2024

@AlexanderBelokon instead of halving the hue, let's try calling pickHue again. Back to you!

Copy link
Contributor

@AlexanderBelokon AlexanderBelokon left a comment

Choose a reason for hiding this comment

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

Love it! I think this is likely the most elegant way to handle the problem ✨

@tristen tristen merged commit c13c3d5 into publisher-production May 22, 2024
3 checks passed
@tristen tristen deleted the color-limiter-option branch May 22, 2024 20:17
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