ProPerNounpYK commited on
Commit
ecae3bb
·
verified ·
1 Parent(s): 164454b

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +176 -18
index.html CHANGED
@@ -1,19 +1,177 @@
1
- <!doctype html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
  <html>
3
+ <head>
4
+ <style>
5
+ body {
6
+ margin: 0;
7
+ overflow: hidden;
8
+ background: #1a1a1a;
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ min-height: 100vh;
13
+ }
14
+
15
+ canvas {
16
+ cursor: pointer;
17
+ }
18
+ </style>
19
+ </head>
20
+ <body>
21
+ <canvas id="canvas"></canvas>
22
+
23
+ <script>
24
+ const canvas = document.getElementById('canvas');
25
+ const ctx = canvas.getContext('2d');
26
+
27
+ let particles = [];
28
+ const phrases = [
29
+ { text: 'Hello everyone.', size: 65, duration: 5000 },
30
+ { text: 'You have been selected as the next\nTimewalker for our team of Space Guardians.', size: 42, duration: 7000 },
31
+ { text: 'Repair the collapsing timelines\nand return safely.', size: 42, duration: 6000 },
32
+ { text: 'Good luck.\n- From the Space Guardians Leader', sizes: [65, 40], spacing: 45, duration: null }
33
+ ];
34
+
35
+ let currentPhraseIndex = 0;
36
+ let animationFrame;
37
+ let mouseX = 0;
38
+ let mouseY = 0;
39
+
40
+ canvas.width = window.innerWidth;
41
+ canvas.height = window.innerHeight;
42
+
43
+ class Particle {
44
+ constructor(x, y, targetX, targetY) {
45
+ this.x = Math.random() * canvas.width;
46
+ this.y = Math.random() * canvas.height;
47
+ this.targetX = targetX;
48
+ this.targetY = targetY;
49
+ this.dx = (Math.random() - 0.5) * 8;
50
+ this.dy = (Math.random() - 0.5) * 8;
51
+ this.radius = 2;
52
+ this.alpha = 1;
53
+ this.fadeSpeed = 0.02;
54
+ }
55
+
56
+ draw() {
57
+ ctx.beginPath();
58
+ ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
59
+ ctx.fillStyle = `rgba(255, 255, 255, ${this.alpha})`;
60
+ ctx.fill();
61
+ ctx.closePath();
62
+ }
63
+
64
+ update() {
65
+ const distance = Math.hypot(mouseX - this.x, mouseY - this.y);
66
+
67
+ if(distance < 100) {
68
+ this.x += this.dx;
69
+ this.y += this.dy;
70
+ } else {
71
+ this.x += (this.targetX - this.x) * 0.1;
72
+ this.y += (this.targetY - this.y) * 0.1;
73
+ }
74
+ }
75
+ }
76
+
77
+ function createParticles(phrase) {
78
+ let newParticles = [];
79
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
80
+
81
+ const lines = phrase.text.split('\n');
82
+
83
+ lines.forEach((line, index) => {
84
+ const size = phrase.sizes ? phrase.sizes[index] : phrase.size;
85
+ const font = index === 0 ? 'Arial' : 'Arial';
86
+ ctx.font = `${size}px ${font}`;
87
+ ctx.fillStyle = 'white';
88
+ ctx.textAlign = 'center';
89
+ ctx.textBaseline = 'middle';
90
+
91
+ const spacing = phrase.spacing || size * 1.2;
92
+ const y = (canvas.height/2 - 20) + (index - (lines.length-1)/2) * spacing; // Moved up by 20px
93
+ ctx.fillText(line, canvas.width/2, y);
94
+ });
95
+
96
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
97
+
98
+ for(let y = 0; y < canvas.height; y += 4) {
99
+ for(let x = 0; x < canvas.width; x += 4) {
100
+ const index = (y * canvas.width + x) * 4;
101
+ const alpha = imageData[index + 3];
102
+
103
+ if(alpha > 128) {
104
+ newParticles.push(new Particle(x, y, x, y));
105
+ }
106
+ }
107
+ }
108
+
109
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
110
+ return newParticles;
111
+ }
112
+
113
+ function transition() {
114
+ if(currentPhraseIndex < phrases.length - 1) {
115
+ currentPhraseIndex++;
116
+ const currentPhrase = phrases[currentPhraseIndex];
117
+
118
+ particles.forEach(particle => {
119
+ particle.dx = (Math.random() - 0.5) * 20;
120
+ particle.dy = (Math.random() - 0.5) * 20;
121
+ const fadeOut = setInterval(() => {
122
+ particle.alpha -= particle.fadeSpeed;
123
+ if(particle.alpha <= 0) clearInterval(fadeOut);
124
+ }, 50);
125
+ });
126
+
127
+ setTimeout(() => {
128
+ particles = createParticles(currentPhrase);
129
+ particles.forEach(particle => {
130
+ particle.alpha = 0;
131
+ const fadeIn = setInterval(() => {
132
+ particle.alpha += particle.fadeSpeed;
133
+ if(particle.alpha >= 1) clearInterval(fadeIn);
134
+ }, 50);
135
+ });
136
+ }, 800);
137
+
138
+ if(currentPhrase.duration) {
139
+ setTimeout(transition, currentPhrase.duration);
140
+ }
141
+ }
142
+ }
143
+
144
+ function animate() {
145
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
146
+ particles.forEach(particle => {
147
+ particle.update();
148
+ particle.draw();
149
+ });
150
+ animationFrame = requestAnimationFrame(animate);
151
+ }
152
+
153
+ canvas.addEventListener('mousemove', (e) => {
154
+ mouseX = e.clientX;
155
+ mouseY = e.clientY;
156
+ });
157
+
158
+ window.addEventListener('resize', () => {
159
+ canvas.width = window.innerWidth;
160
+ canvas.height = window.innerHeight;
161
+ particles = createParticles(phrases[currentPhraseIndex]);
162
+ });
163
+
164
+ particles = createParticles(phrases[0]);
165
+ particles.forEach(particle => {
166
+ particle.alpha = 0;
167
+ const fadeIn = setInterval(() => {
168
+ particle.alpha += particle.fadeSpeed;
169
+ if(particle.alpha >= 1) clearInterval(fadeIn);
170
+ }, 50);
171
+ });
172
+
173
+ animate();
174
+ setTimeout(transition, phrases[0].duration);
175
+ </script>
176
+ </body>
177
+ </html>