Last active
November 9, 2018 16:50
-
-
Save Slackwise/0bcd57e2a246255f20f16749c491ac02 to your computer and use it in GitHub Desktop.
Taco your JS Console!
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
const randomIntOf = i => ~~(i * Math.random()); | |
const randomOffsetFrom = i => (Math.random() * (i + 200) - 100); | |
function insertRandomFood() { | |
const taco = "\ud83c\udf2e"; | |
const burrito = "\ud83c\udf2e"; | |
const food = [taco, burrito]; | |
const randomFood = food[randomIntOf(2)]; | |
const int = randomIntOf(100); | |
const style = { | |
zIndex: int, | |
opacity: int / 100, | |
fontSize: int + 'pt', | |
position: 'absolute', | |
top: randomOffsetFrom(innerHeight) + 'px', | |
left: randomOffsetFrom(innerWidth) + 'px', | |
}; | |
let div = document.createElement('div'); | |
div.innerHTML = randomFood; | |
Object.assign(div.style, style); | |
document.body.appendChild(div); | |
requestAnimationFrame(insertRandomFood); | |
} | |
requestAnimationFrame(insertRandomFood); |
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
function c(){var a=document.createElement("div"),b=~~(100*Math.random());a.innerHTML=["\ud83c\udf2e","\ud83c\udf2f"][~~(2*Math.random())];a.style.cssText="z-index:"+b+";opacity:"+b/100+";font-size:"+b+"pt;position:absolute;top:"+(Math.random()*(innerHeight+200)-100)+"px;left:"+(Math.random()*(innerWidth+200)-100)+"px;";document.body.appendChild(a);requestAnimationFrame(c)}requestAnimationFrame(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment