Last active
April 20, 2018 00:24
-
-
Save rista404/11946f90eba3806c79f3f6465b711ccb to your computer and use it in GitHub Desktop.
Some codegolfing I did, along with the progress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// random hex | |
'#'+Math.random().toString(16).slice(-6) | |
'#'+(~~(Math.random()*0xffffff)).toString(16) | |
'#'+parseInt(Math.random()*0xffffff).toString(16) | |
// random rgb | |
r=_=>(Math.random()*255|0),`rgb(${[r(),r(),r()]})` | |
// random rgba | |
r=_=>(Math.random()*255|0),`rgba(${[r(),r(),r()]},1)` | |
r=_=>(Math.random()*255|0)+',',`rgba(${r()+r()+r()}1)` | |
r=Math.random,a=_=>(r()*255|0)+',',`rgba(${a()+a()+a()}1)` | |
r=Math.random,a=_=>~~(r()*255)+',',`rgba(${a()+a()+a()}1)` | |
r=Math.random,a=_=>~~(r()*255)+',',x=a()+a()+a(),`rgba(${x}1)` | |
// rgb to hex - es6 version of https://gist.github.com/jed/983535 | |
(a,b,c)=>"#"+((256+a<<8|b)<<8|c).toString(16).slice(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment