fantos commited on
Commit
f6bbe6a
·
verified ·
1 Parent(s): 522deb0

Create snow

Browse files
Files changed (1) hide show
  1. snow +57 -0
snow ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def create_snow_effect():
2
+ # CSS 스타일 정의
3
+ snow_css = """
4
+ @keyframes snowfall {
5
+ 0% {
6
+ transform: translateY(-10vh) translateX(0);
7
+ opacity: 1;
8
+ }
9
+ 100% {
10
+ transform: translateY(100vh) translateX(100px);
11
+ opacity: 0.3;
12
+ }
13
+ }
14
+ .snowflake {
15
+ position: fixed;
16
+ color: white;
17
+ font-size: 1.5em;
18
+ user-select: none;
19
+ z-index: 1000;
20
+ pointer-events: none;
21
+ animation: snowfall linear infinite;
22
+ }
23
+ """
24
+
25
+ # JavaScript 코드 정의
26
+ snow_js = """
27
+ function createSnowflake() {
28
+ const snowflake = document.createElement('div');
29
+ snowflake.innerHTML = '❄';
30
+ snowflake.className = 'snowflake';
31
+ snowflake.style.left = Math.random() * 100 + 'vw';
32
+ snowflake.style.animationDuration = Math.random() * 3 + 2 + 's';
33
+ snowflake.style.opacity = Math.random();
34
+ document.body.appendChild(snowflake);
35
+
36
+ setTimeout(() => {
37
+ snowflake.remove();
38
+ }, 5000);
39
+ }
40
+ setInterval(createSnowflake, 200);
41
+ """
42
+
43
+ # CSS와 JavaScript를 결합한 HTML
44
+ snow_html = f"""
45
+ <style>
46
+ {snow_css}
47
+ </style>
48
+ <script>
49
+ {snow_js}
50
+ </script>
51
+ """
52
+
53
+ return gr.HTML(snow_html)
54
+
55
+ # Gradio 앱에서 사용할 때:
56
+ with app:
57
+ create_snow_effect()