akhaliq HF Staff commited on
Commit
930977e
·
verified ·
1 Parent(s): 0915681

Upload index.html with huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +416 -19
index.html CHANGED
@@ -1,19 +1,416 @@
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 lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Fourier Series Square Wave Visualization</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ body {
15
+ background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
16
+ color: #fff;
17
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
18
+ min-height: 100vh;
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ padding: 20px;
23
+ overflow-x: hidden;
24
+ }
25
+
26
+ header {
27
+ text-align: center;
28
+ margin: 20px 0 30px;
29
+ max-width: 800px;
30
+ animation: fadeIn 1.5s ease-out;
31
+ }
32
+
33
+ h1 {
34
+ font-size: 2.8rem;
35
+ margin-bottom: 15px;
36
+ background: linear-gradient(to right, #ff7e5f, #feb47b);
37
+ -webkit-background-clip: text;
38
+ background-clip: text;
39
+ color: transparent;
40
+ text-shadow: 0 2px 4px rgba(0,0,0,0.2);
41
+ }
42
+
43
+ .subtitle {
44
+ font-size: 1.2rem;
45
+ opacity: 0.9;
46
+ margin-bottom: 20px;
47
+ }
48
+
49
+ .container {
50
+ display: flex;
51
+ flex-wrap: wrap;
52
+ justify-content: center;
53
+ gap: 30px;
54
+ max-width: 1400px;
55
+ width: 100%;
56
+ }
57
+
58
+ .visualization-container {
59
+ flex: 1;
60
+ min-width: 500px;
61
+ background: rgba(255, 255, 255, 0.05);
62
+ border-radius: 20px;
63
+ padding: 20px;
64
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
65
+ backdrop-filter: blur(10px);
66
+ border: 1px solid rgba(255, 255, 255, 0.1);
67
+ }
68
+
69
+ .canvas-wrapper {
70
+ position: relative;
71
+ width: 100%;
72
+ height: 500px;
73
+ border-radius: 15px;
74
+ overflow: hidden;
75
+ background: rgba(0, 0, 0, 0.2);
76
+ }
77
+
78
+ canvas {
79
+ display: block;
80
+ }
81
+
82
+ .controls {
83
+ display: flex;
84
+ flex-wrap: wrap;
85
+ gap: 20px;
86
+ margin-top: 25px;
87
+ padding: 20px;
88
+ background: rgba(255, 255, 255, 0.05);
89
+ border-radius: 15px;
90
+ }
91
+
92
+ .control-group {
93
+ flex: 1;
94
+ min-width: 200px;
95
+ }
96
+
97
+ label {
98
+ display: block;
99
+ margin-bottom: 8px;
100
+ font-weight: 500;
101
+ }
102
+
103
+ input[type="range"] {
104
+ width: 100%;
105
+ height: 8px;
106
+ border-radius: 4px;
107
+ background: rgba(255, 255, 255, 0.1);
108
+ outline: none;
109
+ -webkit-appearance: none;
110
+ }
111
+
112
+ input[type="range"]::-webkit-slider-thumb {
113
+ -webkit-appearance: none;
114
+ width: 20px;
115
+ height: 20px;
116
+ border-radius: 50%;
117
+ background: #ff7e5f;
118
+ cursor: pointer;
119
+ box-shadow: 0 0 10px rgba(255, 126, 95, 0.5);
120
+ }
121
+
122
+ .value-display {
123
+ display: inline-block;
124
+ width: 40px;
125
+ text-align: center;
126
+ font-weight: bold;
127
+ color: #ff7e5f;
128
+ }
129
+
130
+ .info-panel {
131
+ flex: 1;
132
+ min-width: 300px;
133
+ background: rgba(255, 255, 255, 0.05);
134
+ border-radius: 20px;
135
+ padding: 25px;
136
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
137
+ backdrop-filter: blur(10px);
138
+ border: 1px solid rgba(255, 255, 255, 0.1);
139
+ }
140
+
141
+ .info-panel h2 {
142
+ font-size: 1.8rem;
143
+ margin-bottom: 20px;
144
+ color: #feb47b;
145
+ }
146
+
147
+ .explanation {
148
+ line-height: 1.6;
149
+ margin-bottom: 25px;
150
+ }
151
+
152
+ .formula {
153
+ background: rgba(0, 0, 0, 0.2);
154
+ padding: 15px;
155
+ border-radius: 10px;
156
+ font-family: 'Courier New', monospace;
157
+ margin: 15px 0;
158
+ overflow-x: auto;
159
+ }
160
+
161
+ .terms-list {
162
+ margin-top: 20px;
163
+ }
164
+
165
+ .terms-list li {
166
+ margin-bottom: 10px;
167
+ padding-left: 20px;
168
+ position: relative;
169
+ }
170
+
171
+ .terms-list li:before {
172
+ content: "•";
173
+ color: #ff7e5f;
174
+ position: absolute;
175
+ left: 0;
176
+ }
177
+
178
+ footer {
179
+ margin-top: 40px;
180
+ text-align: center;
181
+ opacity: 0.7;
182
+ font-size: 0.9rem;
183
+ }
184
+
185
+ @keyframes fadeIn {
186
+ from { opacity: 0; transform: translateY(-20px); }
187
+ to { opacity: 1; transform: translateY(0); }
188
+ }
189
+
190
+ @media (max-width: 768px) {
191
+ .container {
192
+ flex-direction: column;
193
+ }
194
+
195
+ .visualization-container, .info-panel {
196
+ min-width: 100%;
197
+ }
198
+
199
+ h1 {
200
+ font-size: 2.2rem;
201
+ }
202
+ }
203
+ </style>
204
+ </head>
205
+ <body>
206
+ <header>
207
+ <h1>Fourier Series Square Wave Visualization</h1>
208
+ <p class="subtitle">Watch the magic of rotating circles approximating a square wave</p>
209
+ </header>
210
+
211
+ <div class="container">
212
+ <div class="visualization-container">
213
+ <div class="canvas-wrapper">
214
+ <canvas id="fourierCanvas"></canvas>
215
+ </div>
216
+
217
+ <div class="controls">
218
+ <div class="control-group">
219
+ <label for="terms">Number of Terms: <span id="termsValue" class="value-display">5</span></label>
220
+ <input type="range" id="terms" min="1" max="50" value="5">
221
+ </div>
222
+
223
+ <div class="control-group">
224
+ <label for="speed">Animation Speed: <span id="speedValue" class="value-display">1.0</span>x</label>
225
+ <input type="range" id="speed" min="0.1" max="3" step="0.1" value="1.0">
226
+ </div>
227
+
228
+ <div class="control-group">
229
+ <label for="scale">Scale: <span id="scaleValue" class="value-display">1.0</span>x</label>
230
+ <input type="range" id="scale" min="0.5" max="2" step="0.1" value="1.0">
231
+ </div>
232
+ </div>
233
+ </div>
234
+
235
+ <div class="info-panel">
236
+ <h2>About Fourier Series</h2>
237
+ <div class="explanation">
238
+ <p>The Fourier series represents periodic functions as a sum of sine and cosine waves. This visualization shows how rotating circles (epicycles) can approximate a square wave.</p>
239
+
240
+ <div class="formula">
241
+ f(t) = (4/π) Σ<sub>n=1,3,5...<sup>∞</sup></sub> [sin(nωt)/n]
242
+ </div>
243
+
244
+ <p>Each rotating circle corresponds to a term in the series. As more terms are added, the approximation becomes more accurate.</p>
245
+ </div>
246
+
247
+ <h3>Key Concepts:</h3>
248
+ <ul class="terms-list">
249
+ <li>Only odd harmonics contribute to the square wave</li>
250
+ <li>Amplitude decreases as 1/n for the nth harmonic</li>
251
+ <li>Gibbs phenomenon causes overshoots near discontinuities</li>
252
+ <li>Infinite terms required for perfect reconstruction</li>
253
+ </ul>
254
+ </div>
255
+ </div>
256
+
257
+ <footer>
258
+ <p>Fourier Series Visualization | Created with HTML5 Canvas and JavaScript</p>
259
+ </footer>
260
+
261
+ <script>
262
+ // Get canvas and context
263
+ const canvas = document.getElementById('fourierCanvas');
264
+ const ctx = canvas.getContext('2d');
265
+
266
+ // Set canvas dimensions
267
+ function resizeCanvas() {
268
+ const wrapper = canvas.parentElement;
269
+ canvas.width = wrapper.clientWidth;
270
+ canvas.height = wrapper.clientHeight;
271
+ }
272
+
273
+ // Initial resize
274
+ resizeCanvas();
275
+ window.addEventListener('resize', resizeCanvas);
276
+
277
+ // Control elements
278
+ const termsSlider = document.getElementById('terms');
279
+ const speedSlider = document.getElementById('speed');
280
+ const scaleSlider = document.getElementById('scale');
281
+ const termsValue = document.getElementById('termsValue');
282
+ const speedValue = document.getElementById('speedValue');
283
+ const scaleValue = document.getElementById('scaleValue');
284
+
285
+ // Initial values
286
+ let numTerms = parseInt(termsSlider.value);
287
+ let speed = parseFloat(speedSlider.value);
288
+ let scale = parseFloat(scaleSlider.value);
289
+
290
+ // Update value displays
291
+ termsValue.textContent = numTerms;
292
+ speedValue.textContent = speed.toFixed(1);
293
+ scaleValue.textContent = scale.toFixed(1);
294
+
295
+ // Event listeners for sliders
296
+ termsSlider.addEventListener('input', () => {
297
+ numTerms = parseInt(termsSlider.value);
298
+ termsValue.textContent = numTerms;
299
+ });
300
+
301
+ speedSlider.addEventListener('input', () => {
302
+ speed = parseFloat(speedSlider.value);
303
+ speedValue.textContent = speed.toFixed(1);
304
+ });
305
+
306
+ scaleSlider.addEventListener('input', () => {
307
+ scale = parseFloat(scaleSlider.value);
308
+ scaleValue.textContent = scale.toFixed(1);
309
+ });
310
+
311
+ // Animation variables
312
+ let time = 0;
313
+ const wave = [];
314
+ const maxWavePoints = 1000;
315
+
316
+ // Function to calculate Fourier series approximation
317
+ function calculateFourierSeries() {
318
+ let x = 0;
319
+ let y = 0;
320
+
321
+ // Draw circles and calculate position
322
+ for (let i = 0; i < numTerms; i++) {
323
+ const n = i * 2 + 1; // Only odd harmonics (1, 3, 5, ...)
324
+ const radius = 70 * (4 / (n * Math.PI)) * scale;
325
+ const prevX = x;
326
+ const prevY = y;
327
+
328
+ x += radius * Math.cos(n * time);
329
+ y += radius * Math.sin(n * time);
330
+
331
+ // Draw circle
332
+ ctx.beginPath();
333
+ ctx.arc(prevX, prevY, Math.abs(radius), 0, Math.PI * 2);
334
+ ctx.strokeStyle = `hsla(${200 + i * 10}, 80%, 60%, ${0.4 + 0.6 * (1 - i/numTerms)})`;
335
+ ctx.lineWidth = 1;
336
+ ctx.stroke();
337
+
338
+ // Draw line from center of circle to point
339
+ ctx.beginPath();
340
+ ctx.moveTo(prevX, prevY);
341
+ ctx.lineTo(x, y);
342
+ ctx.strokeStyle = `hsla(${200 + i * 10}, 100%, 70%, 0.7)`;
343
+ ctx.lineWidth = 2;
344
+ ctx.stroke();
345
+
346
+ // Draw point on circle
347
+ ctx.beginPath();
348
+ ctx.arc(x, y, 3, 0, Math.PI * 2);
349
+ ctx.fillStyle = `hsl(${200 + i * 10}, 100%, 70%)`;
350
+ ctx.fill();
351
+ }
352
+
353
+ // Add current y position to wave array
354
+ wave.unshift(y);
355
+
356
+ // Limit wave array size
357
+ if (wave.length > maxWavePoints) {
358
+ wave.pop();
359
+ }
360
+
361
+ // Draw the wave
362
+ const waveStartX = 300;
363
+ ctx.beginPath();
364
+ ctx.moveTo(waveStartX, wave[0]);
365
+
366
+ for (let i = 1; i < wave.length; i++) {
367
+ ctx.lineTo(waveStartX + i, wave[i]);
368
+ }
369
+
370
+ ctx.strokeStyle = '#ff7e5f';
371
+ ctx.lineWidth = 2;
372
+ ctx.stroke();
373
+
374
+ // Draw line from last circle to wave
375
+ ctx.beginPath();
376
+ ctx.moveTo(x, y);
377
+ ctx.lineTo(waveStartX, wave[0]);
378
+ ctx.strokeStyle = 'rgba(255, 255, 255, 0.5)';
379
+ ctx.lineWidth = 1;
380
+ ctx.stroke();
381
+
382
+ // Draw endpoint
383
+ ctx.beginPath();
384
+ ctx.arc(waveStartX, wave[0], 5, 0, Math.PI * 2);
385
+ ctx.fillStyle = '#feb47b';
386
+ ctx.fill();
387
+
388
+ // Update time
389
+ time += 0.05 * speed;
390
+ }
391
+
392
+ // Animation loop
393
+ function animate() {
394
+ // Clear canvas with a semi-transparent overlay for trail effect
395
+ ctx.fillStyle = 'rgba(15, 12, 41, 0.1)';
396
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
397
+
398
+ // Save context and move to center left
399
+ ctx.save();
400
+ ctx.translate(150, canvas.height / 2);
401
+
402
+ // Calculate and draw Fourier series
403
+ calculateFourierSeries();
404
+
405
+ // Restore context
406
+ ctx.restore();
407
+
408
+ // Continue animation loop
409
+ requestAnimationFrame(animate);
410
+ }
411
+
412
+ // Start animation
413
+ animate();
414
+ </script>
415
+ </body>
416
+ </html>