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

How to generate contrast color? #85

Open
artalar opened this issue Feb 9, 2022 · 5 comments
Open

How to generate contrast color? #85

artalar opened this issue Feb 9, 2022 · 5 comments

Comments

@artalar
Copy link

artalar commented Feb 9, 2022

Hi! I have a color picker that should produce the main color and the opposite - contrast color. Right now I use "invert", but it is useless for gray colors and so on.

@omgovich
Copy link
Owner

omgovich commented Feb 10, 2022

Hi @artalar! colord doesn't have a method for that currently, but I can try to help you somehow if you provide more details and, maybe, some examples. I can't say it's clear for me what color should be "opposite" to gray. On my color picker website I always use black and white for text colors: https://omgovich.github.io/react-colorful/

@suhodolskiy
Copy link

Hi @artalar! Maybe it's not exactly what you need, but maybe it will help you: https://gist.github.com/suhodolskiy/d14b74e183607bbb34eae3313bce7c80

@artalar
Copy link
Author

artalar commented Feb 22, 2022

@suhodolskiy thx, will use it. Btw while(color.contrast(this) < 4.5) color = isLight ? color.darken(0.4) : color.lighten(0.4)

@artalar
Copy link
Author

artalar commented Feb 25, 2022

You could check this out at the work: https://monocss.vercel.app/

@jd-solanki
Copy link

Helper function would be nice 👍🏻

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

No branches or pull requests

4 participants