Advertisement
Guest User

Untitled

a guest
May 24th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. generateTextAndBg(color) {
  2. let bg = Color(color);
  3. const text = bg.isLight() ? bg.darken(.5) : bg.lighten(.5);
  4.  
  5. let constrast = text.contrast(bg);
  6.  
  7. while (constrast < MIN_CONTRAST) {
  8. bg = text.isLight() ? bg.darken(0.5) : bg.lighten(0.5);
  9. constrast = text.contrast(bg);
  10. }
  11. return {
  12. text: text.string(),
  13. bg: bg.string()
  14. };
  15. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement