Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,110 +5,72 @@ import random
|
|
5 |
import os
|
6 |
from PIL import Image
|
7 |
from deep_translator import GoogleTranslator
|
8 |
-
html='''
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
const noise2 = noise.simplex2(time * 0.5, 1000) * 0.5 + 0.5;
|
75 |
-
const noise3 = noise.simplex2(time * 0.5, 2000) * 0.5 + 0.5;
|
76 |
-
const noise4 = noise.simplex2(time * 0.5, 3000) * 0.5 + 0.5;
|
77 |
-
|
78 |
-
const [r1, g1, b1] = hslToRgb(noise1, 1, 0.5);
|
79 |
-
const [r2, g2, b2] = hslToRgb(noise2, 1, 0.5);
|
80 |
-
const [r3, g3, b3] = hslToRgb(noise3, 1, 0.5);
|
81 |
-
const [r4, g4, b4] = hslToRgb(noise4, 1, 0.5);
|
82 |
-
|
83 |
-
const gradient = `linear-gradient(45deg,
|
84 |
-
rgb(${r1},${g1},${b1}),
|
85 |
-
rgb(${r2},${g2},${b2}),
|
86 |
-
rgb(${r3},${g3},${b3}),
|
87 |
-
rgb(${r4},${g4},${b4}))`;
|
88 |
-
|
89 |
-
neonSquare.style.background = gradient;
|
90 |
-
neonSquare.style.boxShadow = `
|
91 |
-
0 0 20px rgb(${r1},${g1},${b1}),
|
92 |
-
0 0 40px rgb(${r2},${g2},${b2}),
|
93 |
-
0 0 60px rgb(${r3},${g3},${b3}),
|
94 |
-
0 0 80px rgb(${r4},${g4},${b4})
|
95 |
-
`;
|
96 |
-
|
97 |
-
neonSquare.style.setProperty('--glow', gradient);
|
98 |
-
|
99 |
-
time += 0.01;
|
100 |
-
}
|
101 |
-
|
102 |
-
// Update colors every frame
|
103 |
-
function animate() {
|
104 |
-
updateColors();
|
105 |
-
requestAnimationFrame(animate);
|
106 |
-
}
|
107 |
-
|
108 |
-
animate();
|
109 |
-
</script>
|
110 |
-
</body>
|
111 |
-
</html>'''
|
112 |
# os.makedirs('assets', exist_ok=True)
|
113 |
if not os.path.exists('icon.jpg'):
|
114 |
os.system("wget -O icon.jpg https://i.pinimg.com/564x/64/49/88/644988c59447eb00286834c2e70fdd6b.jpg")
|
|
|
5 |
import os
|
6 |
from PIL import Image
|
7 |
from deep_translator import GoogleTranslator
|
8 |
+
html='''<style>
|
9 |
+
body, html, #app {
|
10 |
+
margin: 0;
|
11 |
+
width: 100%;
|
12 |
+
height: 100%;
|
13 |
+
}
|
14 |
+
|
15 |
+
#app {
|
16 |
+
overflow: hidden;
|
17 |
+
touch-action: pan-up;
|
18 |
+
color: #ffffff;
|
19 |
+
font-family: 'Montserrat', sans-serif;
|
20 |
+
text-align: center;
|
21 |
+
text-shadow: 0 0 5px #000000, 0 0 20px #000;
|
22 |
+
user-select: none;
|
23 |
+
}
|
24 |
+
|
25 |
+
#app h1 {
|
26 |
+
--fontSize: 50px;
|
27 |
+
--lineHeight: 70px;
|
28 |
+
width: auto;
|
29 |
+
height: calc(2 * var(--lineHeight));
|
30 |
+
line-height: var(--lineHeight);
|
31 |
+
margin: calc(50vh - var(--lineHeight)) auto 0;
|
32 |
+
font-size: var(--fontSize);
|
33 |
+
}
|
34 |
+
|
35 |
+
#app a {
|
36 |
+
margin-top: 10px;
|
37 |
+
display: inline-block;
|
38 |
+
text-decoration: none;
|
39 |
+
color: #fff;
|
40 |
+
}
|
41 |
+
|
42 |
+
#app canvas {
|
43 |
+
display: block;
|
44 |
+
position: fixed;
|
45 |
+
z-index: -1;
|
46 |
+
top: 0;
|
47 |
+
}
|
48 |
+
</style>
|
49 |
+
|
50 |
+
<script>
|
51 |
+
import { swarmBackground } from 'https://unpkg.com/[email protected]/build/threejs-toys.module.cdn.min.js'
|
52 |
+
|
53 |
+
const bg = swarmBackground({
|
54 |
+
el: document.getElementById('app'),
|
55 |
+
eventsEl: document.body,
|
56 |
+
gpgpuSize: 256,
|
57 |
+
color: [Math.random() * 0xffffff, Math.random() * 0xffffff],
|
58 |
+
geometry: 'default'
|
59 |
+
})
|
60 |
+
|
61 |
+
bg.three.camera.position.set(0, 0, 200)
|
62 |
+
|
63 |
+
document.body.addEventListener('click', () => {
|
64 |
+
bg.setColors([Math.random() * 0xffffff, Math.random() * 0xffffff])
|
65 |
+
})
|
66 |
+
</script>
|
67 |
+
<div id="app">
|
68 |
+
<div id="hero">
|
69 |
+
<h1>SWARM<br/>BACKGROUND</h1>
|
70 |
+
<a target="_blank" href="https://github.com/klevron/threejs-toys">github/threejs-toys</a>
|
71 |
+
</div>
|
72 |
+
</div>
|
73 |
+
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
# os.makedirs('assets', exist_ok=True)
|
75 |
if not os.path.exists('icon.jpg'):
|
76 |
os.system("wget -O icon.jpg https://i.pinimg.com/564x/64/49/88/644988c59447eb00286834c2e70fdd6b.jpg")
|