Last active
March 18, 2017 09:13
-
-
Save saiki-k/fcaa5b272b374a46dfa1931b0744f399 to your computer and use it in GitHub Desktop.
Happy St. Patrick's Day!
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 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