r0cketboy commited on
Commit
21ea3d5
·
verified ·
1 Parent(s): 979c38e

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +308 -228
index.html CHANGED
@@ -1,248 +1,328 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
 
3
  <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>ASCII Wave Animation</title>
7
- <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
8
- <style>
9
- * {
10
- margin: 0;
11
- padding: 0;
12
- box-sizing: border-box;
13
- }
14
 
15
- body {
16
- background-color: #000;
17
- min-height: 100vh;
18
- display: flex;
19
- flex-direction: column;
20
- align-items: center;
21
- justify-content: center;
22
- font-family: 'JetBrains Mono', monospace;
23
- overflow: hidden;
24
- }
25
 
26
- header {
27
- position: fixed;
28
- top: 0;
29
- left: 0;
30
- width: 100%;
31
- padding: 1rem;
32
- text-align: center;
33
- z-index: 100;
34
- }
35
 
36
- header a {
37
- color: #333;
38
- text-decoration: none;
39
- font-size: 0.8rem;
40
- letter-spacing: 2px;
41
- transition: color 0.3s ease;
42
- }
43
 
44
- header a:hover {
45
- color: #666;
46
- }
47
 
48
- #ascii-container {
49
- display: flex;
50
- flex-direction: column;
51
- align-items: center;
52
- justify-content: center;
53
- gap: 0;
54
- line-height: 1.2;
55
- }
 
56
 
57
- .ascii-row {
58
- display: flex;
59
- gap: 0;
60
- }
61
 
62
- .ascii-char {
63
- width: clamp(8px, 2vw, 16px);
64
- height: clamp(12px, 2.5vw, 20px);
65
- display: flex;
66
- align-items: center;
67
- justify-content: center;
68
- font-size: clamp(8px, 2vw, 16px);
69
- color: #0f0;
70
- transition: transform 0.1s ease-out;
71
- }
72
 
73
- @media (max-width: 768px) {
74
- .ascii-char {
75
- width: 6px;
76
- height: 10px;
77
- font-size: 6px;
78
- }
79
- }
80
 
81
- @media (max-width: 480px) {
82
- .ascii-char {
83
- width: 5px;
84
- height: 8px;
85
- font-size: 5px;
86
- }
87
- }
88
- </style>
89
  </head>
 
90
  <body>
91
- <header>
92
- <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">Built with anycoder</a>
93
- </header>
94
-
95
- <div id="ascii-container"></div>
96
-
97
- <script>
98
- const container = document.getElementById('ascii-container');
99
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@#$%&*!?<>[]{}|/\\~^';
100
-
101
- let cols, rows;
102
- let grid = [];
103
- let time = 0;
104
-
105
- function calculateGridSize() {
106
- const charWidth = Math.max(8, Math.min(16, window.innerWidth * 0.02));
107
- const charHeight = Math.max(12, Math.min(20, window.innerWidth * 0.025));
108
-
109
- cols = Math.floor(window.innerWidth / charWidth);
110
- rows = Math.floor(window.innerHeight / charHeight);
111
-
112
- // Ensure minimum grid size
113
- cols = Math.max(40, Math.min(cols, 120));
114
- rows = Math.max(20, Math.min(rows, 60));
115
- }
116
-
117
- function getRandomChar() {
118
- return characters[Math.floor(Math.random() * characters.length)];
119
- }
120
-
121
- function createGrid() {
122
- container.innerHTML = '';
123
- grid = [];
124
-
125
- for (let y = 0; y < rows; y++) {
126
- const row = document.createElement('div');
127
- row.className = 'ascii-row';
128
- const rowData = [];
129
-
130
- for (let x = 0; x < cols; x++) {
131
- const charSpan = document.createElement('span');
132
- charSpan.className = 'ascii-char';
133
- charSpan.textContent = getRandomChar();
134
- row.appendChild(charSpan);
135
- rowData.push({
136
- element: charSpan,
137
- baseChar: getRandomChar(),
138
- changeTimer: Math.random() * 100
139
- });
140
- }
141
-
142
- container.appendChild(row);
143
- grid.push(rowData);
144
- }
 
 
145
  }
146
-
147
- function hslToRgb(h, s, l) {
148
- let r, g, b;
149
-
150
- if (s === 0) {
151
- r = g = b = l;
152
- } else {
153
- const hue2rgb = (p, q, t) => {
154
- if (t < 0) t += 1;
155
- if (t > 1) t -= 1;
156
- if (t < 1/6) return p + (q - p) * 6 * t;
157
- if (t < 1/2) return q;
158
- if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
159
- return p;
160
- };
161
-
162
- const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
163
- const p = 2 * l - q;
164
- r = hue2rgb(p, q, h + 1/3);
165
- g = hue2rgb(p, q, h);
166
- b = hue2rgb(p, q, h - 1/3);
167
- }
168
-
169
- return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
170
  }
171
-
172
- function animate() {
173
- time += 0.03;
174
-
175
- for (let y = 0; y < rows; y++) {
176
- for (let x = 0; x < cols; x++) {
177
- const cell = grid[y][x];
178
-
179
- // Multiple wave patterns combined
180
- const wave1 = Math.sin(x * 0.1 + time) * 0.5;
181
- const wave2 = Math.sin(y * 0.08 + time * 1.3) * 0.3;
182
- const wave3 = Math.sin((x + y) * 0.05 + time * 0.7) * 0.4;
183
- const wave4 = Math.cos(x * 0.15 - time * 0.5) * Math.sin(y * 0.12 + time * 0.8) * 0.3;
184
-
185
- // Radial wave from center
186
- const centerX = cols / 2;
187
- const centerY = rows / 2;
188
- const distFromCenter = Math.sqrt((x - centerX) ** 2 + (y - centerY) ** 2);
189
- const radialWave = Math.sin(distFromCenter * 0.15 - time * 2) * 0.4;
190
-
191
- const combinedWave = wave1 + wave2 + wave3 + wave4 + radialWave;
192
-
193
- // Calculate brightness based on wave
194
- const brightness = 0.3 + (combinedWave + 1) * 0.35;
195
-
196
- // Calculate hue shift for color variation
197
- const hue = (120 + combinedWave * 60 + time * 10) % 360;
198
- const saturation = 0.8 + combinedWave * 0.2;
199
- const lightness = Math.max(0.1, Math.min(0.7, brightness));
200
-
201
- const [r, g, b] = hslToRgb(hue / 360, saturation, lightness);
202
-
203
- // Apply transformations
204
- const scale = 0.8 + (combinedWave + 1) * 0.3;
205
- const translateY = combinedWave * 5;
206
-
207
- cell.element.style.color = `rgb(${r}, ${g}, ${b})`;
208
- cell.element.style.transform = `translateY(${translateY}px) scale(${scale})`;
209
- cell.element.style.opacity = Math.max(0.2, brightness);
210
-
211
- // Randomly change characters
212
- cell.changeTimer += 0.1;
213
- if (cell.changeTimer > 50 + Math.random() * 100) {
214
- cell.element.textContent = getRandomChar();
215
- cell.changeTimer = 0;
216
- }
217
-
218
- // More frequent changes at wave peaks
219
- if (combinedWave > 0.8 && Math.random() < 0.1) {
220
- cell.element.textContent = getRandomChar();
221
- }
222
- }
223
  }
224
-
225
- requestAnimationFrame(animate);
226
- }
227
-
228
- function init() {
229
- calculateGridSize();
230
- createGrid();
231
- animate();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  }
233
-
234
- // Handle window resize
235
- let resizeTimeout;
236
- window.addEventListener('resize', () => {
237
- clearTimeout(resizeTimeout);
238
- resizeTimeout = setTimeout(() => {
239
- calculateGridSize();
240
- createGrid();
241
- }, 250);
242
- });
243
-
244
- // Initialize
245
- init();
246
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  </body>
 
248
  </html>
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
+
4
  <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>ASCII Wave Animation</title>
8
+ <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
9
+ <style>
10
+ * {
11
+ margin: 0;
12
+ padding: 0;
13
+ box-sizing: border-box;
14
+ }
15
 
16
+ body {
17
+ background-color: #000;
18
+ min-height: 100vh;
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ justify-content: center;
23
+ font-family: 'JetBrains Mono', monospace;
24
+ overflow: hidden;
25
+ }
26
 
27
+ header {
28
+ position: fixed;
29
+ top: 0;
30
+ left: 0;
31
+ width: 100%;
32
+ padding: 1rem;
33
+ text-align: center;
34
+ z-index: 100;
35
+ }
36
 
37
+ header a {
38
+ color: #444;
39
+ text-decoration: none;
40
+ font-size: 0.8rem;
41
+ letter-spacing: 2px;
42
+ transition: color 0.3s ease;
43
+ }
44
 
45
+ header a:hover {
46
+ color: #888;
47
+ }
48
 
49
+ #ascii-container {
50
+ display: flex;
51
+ flex-direction: column;
52
+ align-items: center;
53
+ justify-content: center;
54
+ gap: 0;
55
+ line-height: 1.2;
56
+ cursor: none;
57
+ }
58
 
59
+ .ascii-row {
60
+ display: flex;
61
+ gap: 0;
62
+ }
63
 
64
+ .ascii-char {
65
+ width: clamp(8px, 2vw, 16px);
66
+ height: clamp(12px, 2.5vw, 20px);
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ font-size: clamp(8px, 2vw, 16px);
71
+ color: #fff;
72
+ transition: transform 0.15s ease-out, text-shadow 0.15s ease-out;
73
+ }
74
 
75
+ @media (max-width: 768px) {
76
+ .ascii-char {
77
+ width: 6px;
78
+ height: 10px;
79
+ font-size: 6px;
80
+ }
81
+ }
82
 
83
+ @media (max-width: 480px) {
84
+ .ascii-char {
85
+ width: 5px;
86
+ height: 8px;
87
+ font-size: 5px;
88
+ }
89
+ }
90
+ </style>
91
  </head>
92
+
93
  <body>
94
+ <header>
95
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">Built with anycoder</a>
96
+ </header>
97
+
98
+ <div id="ascii-container"></div>
99
+
100
+ <script>
101
+ const container = document.getElementById('ascii-container');
102
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@#$%&*!?<>[]{}|/\\~^';
103
+
104
+ let cols, rows;
105
+ let grid = [];
106
+ let time = 0;
107
+ let mouseX = -1000;
108
+ let mouseY = -1000;
109
+ let targetMouseX = -1000;
110
+ let targetMouseY = -1000;
111
+ let isMouseInside = false;
112
+
113
+ function calculateGridSize() {
114
+ const charWidth = Math.max(8, Math.min(16, window.innerWidth * 0.02));
115
+ const charHeight = Math.max(12, Math.min(20, window.innerWidth * 0.025));
116
+
117
+ cols = Math.floor(window.innerWidth / charWidth);
118
+ rows = Math.floor(window.innerHeight / charHeight);
119
+
120
+ // Ensure minimum grid size
121
+ cols = Math.max(40, Math.min(cols, 120));
122
+ rows = Math.max(20, Math.min(rows, 60));
123
+ }
124
+
125
+ function getRandomChar() {
126
+ return characters[Math.floor(Math.random() * characters.length)];
127
+ }
128
+
129
+ function createGrid() {
130
+ container.innerHTML = '';
131
+ grid = [];
132
+
133
+ for (let y = 0; y < rows; y++) {
134
+ const row = document.createElement('div');
135
+ row.className = 'ascii-row';
136
+ const rowData = [];
137
+
138
+ for (let x = 0; x < cols; x++) {
139
+ const charSpan = document.createElement('span');
140
+ charSpan.className = 'ascii-char';
141
+ charSpan.textContent = getRandomChar();
142
+ row.appendChild(charSpan);
143
+ rowData.push({
144
+ element: charSpan,
145
+ baseChar: getRandomChar(),
146
+ changeTimer: Math.random() * 100,
147
+ x: 0,
148
+ y: 0
149
+ });
150
  }
151
+
152
+ container.appendChild(row);
153
+ grid.push(rowData);
154
+ }
155
+
156
+ // Calculate positions after grid is created
157
+ updateCellPositions();
158
+ }
159
+
160
+ function updateCellPositions() {
161
+ for (let y = 0; y < rows; y++) {
162
+ for (let x = 0; x < cols; x++) {
163
+ const cell = grid[y][x];
164
+ const rect = cell.element.getBoundingClientRect();
165
+ cell.x = rect.left + rect.width / 2;
166
+ cell.y = rect.top + rect.height / 2;
 
 
 
 
 
 
 
 
167
  }
168
+ }
169
+ }
170
+
171
+ function animate() {
172
+ time += 0.03;
173
+
174
+ // Smooth mouse following
175
+ mouseX += (targetMouseX - mouseX) * 0.15;
176
+ mouseY += (targetMouseY - mouseY) * 0.15;
177
+
178
+ for (let y = 0; y < rows; y++) {
179
+ for (let x = 0; x < cols; x++) {
180
+ const cell = grid[y][x];
181
+
182
+ // Multiple wave patterns combined
183
+ const wave1 = Math.sin(x * 0.1 + time) * 0.5;
184
+ const wave2 = Math.sin(y * 0.08 + time * 1.3) * 0.3;
185
+ const wave3 = Math.sin((x + y) * 0.05 + time * 0.7) * 0.4;
186
+ const wave4 = Math.cos(x * 0.15 - time * 0.5) * Math.sin(y * 0.12 + time * 0.8) * 0.3;
187
+
188
+ // Radial wave from center
189
+ const centerX = cols / 2;
190
+ const centerY = rows / 2;
191
+ const distFromCenter = Math.sqrt((x - centerX) ** 2 + (y - centerY) ** 2);
192
+ const radialWave = Math.sin(distFromCenter * 0.15 - time * 2) * 0.4;
193
+
194
+ let combinedWave = wave1 + wave2 + wave3 + wave4 + radialWave;
195
+
196
+ // Mouse interaction
197
+ let mouseInfluence = 0;
198
+ let pushX = 0;
199
+ let pushY = 0;
200
+
201
+ if (isMouseInside) {
202
+ const dx = cell.x - mouseX;
203
+ const dy = cell.y - mouseY;
204
+ const distance = Math.sqrt(dx * dx + dy * dy);
205
+ const maxDistance = 150;
206
+
207
+ if (distance < maxDistance) {
208
+ const strength = 1 - (distance / maxDistance);
209
+ mouseInfluence = strength * strength;
210
+
211
+ // Push characters away from mouse
212
+ const angle = Math.atan2(dy, dx);
213
+ const pushStrength = mouseInfluence * 20;
214
+ pushX = Math.cos(angle) * pushStrength;
215
+ pushY = Math.sin(angle) * pushStrength;
216
+
217
+ // Add ripple effect around mouse
218
+ combinedWave += Math.sin(distance * 0.1 - time * 4) * mouseInfluence * 0.8;
 
219
  }
220
+ }
221
+
222
+ // Calculate brightness based on wave and mouse
223
+ const baseBrightness = 0.2 + (combinedWave + 1) * 0.3;
224
+ const brightness = Math.min(1, baseBrightness + mouseInfluence * 0.8);
225
+
226
+ // Apply transformations
227
+ const baseScale = 0.7 + (combinedWave + 1) * 0.25;
228
+ const scale = baseScale + mouseInfluence * 0.5;
229
+ const translateY = combinedWave * 5 + pushY;
230
+ const translateX = pushX;
231
+
232
+ // White color with varying opacity
233
+ const alpha = Math.max(0.15, Math.min(1, brightness));
234
+ cell.element.style.color = `rgba(255, 255, 255, ${alpha})`;
235
+ cell.element.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scale})`;
236
+
237
+ // Add glow effect near mouse
238
+ if (mouseInfluence > 0.3) {
239
+ const glowIntensity = mouseInfluence * 15;
240
+ cell.element.style.textShadow = `0 0 ${glowIntensity}px rgba(255, 255, 255, ${mouseInfluence})`;
241
+ } else {
242
+ cell.element.style.textShadow = 'none';
243
+ }
244
+
245
+ // Randomly change characters
246
+ cell.changeTimer += 0.1 + mouseInfluence * 0.5;
247
+ if (cell.changeTimer > 50 + Math.random() * 100) {
248
+ cell.element.textContent = getRandomChar();
249
+ cell.changeTimer = 0;
250
+ }
251
+
252
+ // More frequent changes at wave peaks and near mouse
253
+ if ((combinedWave > 0.8 || mouseInfluence > 0.5) && Math.random() < 0.15) {
254
+ cell.element.textContent = getRandomChar();
255
+ }
256
  }
257
+ }
258
+
259
+ requestAnimationFrame(animate);
260
+ }
261
+
262
+ function init() {
263
+ calculateGridSize();
264
+ createGrid();
265
+ animate();
266
+ }
267
+
268
+ // Mouse event handlers
269
+ document.addEventListener('mousemove', (e) => {
270
+ targetMouseX = e.clientX;
271
+ targetMouseY = e.clientY;
272
+ isMouseInside = true;
273
+ });
274
+
275
+ document.addEventListener('mouseleave', () => {
276
+ isMouseInside = false;
277
+ targetMouseX = -1000;
278
+ targetMouseY = -1000;
279
+ });
280
+
281
+ document.addEventListener('mouseenter', () => {
282
+ isMouseInside = true;
283
+ });
284
+
285
+ // Touch support for mobile
286
+ document.addEventListener('touchmove', (e) => {
287
+ if (e.touches.length > 0) {
288
+ targetMouseX = e.touches[0].clientX;
289
+ targetMouseY = e.touches[0].clientY;
290
+ isMouseInside = true;
291
+ }
292
+ });
293
+
294
+ document.addEventListener('touchstart', (e) => {
295
+ if (e.touches.length > 0) {
296
+ targetMouseX = e.touches[0].clientX;
297
+ targetMouseY = e.touches[0].clientY;
298
+ mouseX = targetMouseX;
299
+ mouseY = targetMouseY;
300
+ isMouseInside = true;
301
+ }
302
+ });
303
+
304
+ document.addEventListener('touchend', () => {
305
+ isMouseInside = false;
306
+ targetMouseX = -1000;
307
+ targetMouseY = -1000;
308
+ });
309
+
310
+ // Handle window resize
311
+ let resizeTimeout;
312
+ window.addEventListener('resize', () => {
313
+ clearTimeout(resizeTimeout);
314
+ resizeTimeout = setTimeout(() => {
315
+ calculateGridSize();
316
+ createGrid();
317
+ }, 250);
318
+ });
319
+
320
+ // Update cell positions on scroll (if any)
321
+ window.addEventListener('scroll', updateCellPositions);
322
+
323
+ // Initialize
324
+ init();
325
+ </script>
326
  </body>
327
+
328
  </html>