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

Complement function? #12

Closed
srcspider opened this issue Jun 26, 2013 · 4 comments
Closed

Complement function? #12

srcspider opened this issue Jun 26, 2013 · 4 comments

Comments

@srcspider
Copy link

ie. given a background color what's the appropriate foreground color and vise versa

@harthur
Copy link
Collaborator

harthur commented Jul 13, 2013

Do you mean whether to use black or white text over a background color? Or are you thinking of something else?

@srcspider
Copy link
Author

More like shades of gray, but black or white or a function that takes 3 colors, the background and two possible foreground colors (say #222 and #eee) and gives you the most appropriate of the two would also work.

@harthur
Copy link
Collaborator

harthur commented Jul 15, 2013

Seems like you could do something outside the library:

function betterColor(bg, color1, color2) {
  if (bg.contrast(color1) > bg.contrast(color2)) {
    return color1;
  }
  return color2;
}

@srcspider
Copy link
Author

Ah! Thanks.

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

2 participants