Guest User

Untitled

a guest
Feb 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. getContrastFontColor () {
  2. if(this.colorSelected.length == 7) {
  3. let r = parseInt(this.colorSelected.substr(1,2),16);
  4. let g = parseInt(this.colorSelected.substr(3,2),16);
  5. let b = parseInt(this.colorSelected.substr(5,2),16);
  6. r *= 0.299;
  7. g *= 0.587;
  8. b *= 0.114;
  9. if((r + g + b) > 186)
  10. return '#000000';
  11. else
  12. return '#ffffff';
  13. } else {
  14. return '#000000';
  15. }
  16. }
Add Comment
Please, Sign In to add comment