Skip to content

Instantly share code, notes, and snippets.

@saiki-k
Last active March 18, 2017 09:13
Show Gist options
  • Save saiki-k/fcaa5b272b374a46dfa1931b0744f399 to your computer and use it in GitHub Desktop.
Save saiki-k/fcaa5b272b374a46dfa1931b0744f399 to your computer and use it in GitHub Desktop.
Happy St. Patrick's Day!
(() => {
const clover = () => {
const emoji = ['☘️', '🍀'];
const pick = Math.floor(Math.random() * 2);
const depth = Math.floor(Math.random() * 100);
const tag = document.createElement('div');
tag.innerHTML = emoji[pick];
tag.style.zIndex = depth;
tag.style.opacity = depth / 100;
tag.style.fontSize = `${depth}pt`;
tag.style.position = 'absolute';
tag.style.top = `${Math.random() * (innerHeight + 200) - 100}px`;
tag.style.left = `${Math.random() * (innerWidth + 200) - 100}px`;
document.body.appendChild(tag);
window.requestAnimationFrame(clover);
}
document.body.style.background = 'springgreen';
window.requestAnimationFrame(clover);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment