Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Calculate black / white as the better text on top of a given color #50

Open
schlosser opened this issue Nov 1, 2015 · 4 comments
Open
Labels

Comments

@schlosser
Copy link
Member

Not sure what algorithm to use. @jhil, any ideas?

@schlosser schlosser added the p2 label Nov 1, 2015
@jhil
Copy link
Member

jhil commented Nov 1, 2015

might this help? https://github.com/SlexAxton/css-colorguard

@schlosser
Copy link
Member Author

Apparently, R*0.299 + G*0.587 + B*0.114 is a good algorithm for calculating brightness in a range from 0 to 1, so then we could just split at 0.5.

@jhil
Copy link
Member

jhil commented Nov 6, 2015

Cool!

@1j01
Copy link

1j01 commented Jan 20, 2016

Or you can train your own algorithm: https://harthur.github.io/brain/
Serious recommendation – the results can be really good, and there's no dependency.
(You have to pass the resulting function an object {r, g, b} with values in the range 0 to 1.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants