Skip to content

Instantly share code, notes, and snippets.

@Slackwise
Last active November 9, 2018 16:50
Show Gist options
  • Save Slackwise/0bcd57e2a246255f20f16749c491ac02 to your computer and use it in GitHub Desktop.
Save Slackwise/0bcd57e2a246255f20f16749c491ac02 to your computer and use it in GitHub Desktop.
Taco your JS Console!
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);
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