x-mas / snow-effect.py
fantos's picture
Update snow-effect.py
44ae35e verified
#gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ๋‹จ์— ์‚ฝ์ž… : create_snow_effect()
def create_snow_effect():
# CSS ์Šคํƒ€์ผ ์ •์˜
snow_css = """
@keyframes snowfall {
0% {
transform: translateY(-10vh) translateX(0);
opacity: 1;
}
100% {
transform: translateY(100vh) translateX(100px);
opacity: 0.3;
}
}
.snowflake {
position: fixed;
color: white;
font-size: 1.5em;
user-select: none;
z-index: 1000;
pointer-events: none;
animation: snowfall linear infinite;
}
"""
# JavaScript ์ฝ”๋“œ ์ •์˜
snow_js = """
function createSnowflake() {
const snowflake = document.createElement('div');
snowflake.innerHTML = 'โ„';
snowflake.className = 'snowflake';
snowflake.style.left = Math.random() * 100 + 'vw';
snowflake.style.animationDuration = Math.random() * 3 + 2 + 's';
snowflake.style.opacity = Math.random();
document.body.appendChild(snowflake);
setTimeout(() => {
snowflake.remove();
}, 5000);
}
setInterval(createSnowflake, 200);
"""
# CSS์™€ JavaScript๋ฅผ ๊ฒฐํ•ฉํ•œ HTML
snow_html = f"""
<style>
{snow_css}
</style>
<script>
{snow_js}
</script>
"""
return gr.HTML(snow_html)
# Gradio ์•ฑ์—์„œ ์‚ฌ์šฉํ•  ๋•Œ:
# with app: ์•„๋ž˜์—
create_snow_effect()