Advertisement
leomaster

Colors

Apr 4th, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const hexToRgb = h => /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(h).slice(1).map(i=>parseInt(i,16))
  2.  
  3. const rgbToHex = (r,g,b) => '#'+((1<<24)+(r<<16)+(g<<8)+b).toString(16).slice(1)
  4.  
  5. //Random Hex Color
  6. (λ=>`#${λ.replace(/./g,h=>(Math[λ]()*0x10|0).toString(0x10))}`)('random')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement