Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getContrastYIQ(hexcolor){
- const r = parseInt(hexcolor.substr(0,2), 16)
- const g = parseInt(hexcolor.substr(2,2), 16)
- const b = parseInt(hexcolor.substr(4,2), 16)
- const yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000
- return (yiq >= 128) ? 'black' : 'white'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement