beta3 commited on
Commit
08d8ceb
·
verified ·
1 Parent(s): 6082f50

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +402 -19
index.html CHANGED
@@ -1,19 +1,402 @@
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>Sequence Generator V4 - Dual Color</title>
7
+ <style>
8
+ /* General Reset */
9
+ body {
10
+ margin: 0;
11
+ padding: 0;
12
+ background-color: black;
13
+ overflow: hidden;
14
+ font-family: 'Courier New', Courier, monospace;
15
+ }
16
+
17
+ /* --- SCREEN 1: INPUT INTERFACE --- */
18
+ #input-screen {
19
+ position: absolute;
20
+ top: 0;
21
+ left: 0;
22
+ width: 100%;
23
+ height: 100%;
24
+ background-color: black;
25
+ display: flex;
26
+ flex-direction: column;
27
+ justify-content: center;
28
+ align-items: center;
29
+ z-index: 10;
30
+ transition: opacity 0.8s ease-in-out;
31
+ }
32
+
33
+ .input-container {
34
+ width: 100%;
35
+ max-width: 800px;
36
+ text-align: center;
37
+ display: flex;
38
+ flex-direction: column;
39
+ gap: 25px;
40
+ }
41
+
42
+ /* Text Input */
43
+ input[type="text"] {
44
+ background: transparent;
45
+ border: none;
46
+ border-bottom: 2px solid #003300;
47
+ color: #0F0;
48
+ font-family: 'Courier New', monospace;
49
+ font-size: 1.5rem;
50
+ width: 90%;
51
+ padding: 10px;
52
+ text-align: center;
53
+ outline: none;
54
+ margin: 0 auto;
55
+ transition: border-color 0.3s;
56
+ }
57
+
58
+ input[type="text"]:focus {
59
+ border-bottom: 2px solid #0F0;
60
+ }
61
+
62
+ input[type="text"]::placeholder {
63
+ color: #004400;
64
+ font-size: 1rem;
65
+ text-transform: uppercase;
66
+ }
67
+
68
+ /* Settings Row */
69
+ .settings-row {
70
+ display: flex;
71
+ justify-content: center;
72
+ flex-wrap: wrap;
73
+ gap: 20px;
74
+ margin-bottom: 10px;
75
+ align-items: flex-end; /* Align bottom */
76
+ }
77
+
78
+ .setting-group {
79
+ display: flex;
80
+ flex-direction: column;
81
+ align-items: flex-start;
82
+ }
83
+
84
+ label {
85
+ color: #004400;
86
+ font-size: 0.7rem;
87
+ margin-bottom: 5px;
88
+ text-transform: uppercase;
89
+ }
90
+
91
+ select, input[type="color"] {
92
+ background: black;
93
+ color: #0F0;
94
+ border: 1px solid #003300;
95
+ font-family: 'Courier New', monospace;
96
+ font-size: 0.9rem;
97
+ outline: none;
98
+ cursor: pointer;
99
+ height: 35px;
100
+ box-sizing: border-box;
101
+ }
102
+
103
+ select {
104
+ padding: 5px;
105
+ min-width: 140px;
106
+ }
107
+
108
+ /* Custom Style for Color Picker */
109
+ input[type="color"] {
110
+ -webkit-appearance: none;
111
+ width: 60px;
112
+ padding: 0;
113
+ border: 1px solid #003300;
114
+ transition: all 0.3s;
115
+ }
116
+
117
+ input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
118
+ input[type="color"]::-webkit-color-swatch { border: none; }
119
+
120
+ select:hover, select:focus, input[type="color"]:hover {
121
+ border-color: #0F0;
122
+ }
123
+
124
+ /* Hidden class for 2nd color picker */
125
+ .invisible {
126
+ display: none;
127
+ }
128
+
129
+ /* Action Button */
130
+ button {
131
+ background: transparent;
132
+ color: #0F0;
133
+ border: 1px solid #0F0;
134
+ padding: 15px 30px;
135
+ font-family: 'Courier New', monospace;
136
+ font-size: 1rem;
137
+ cursor: pointer;
138
+ text-transform: uppercase;
139
+ letter-spacing: 2px;
140
+ transition: all 0.2s;
141
+ width: fit-content;
142
+ align-self: center;
143
+ }
144
+
145
+ button:hover {
146
+ background: #0F0;
147
+ color: black;
148
+ box-shadow: 0 0 15px #0F0;
149
+ }
150
+
151
+ /* --- SCREEN 2: CANVAS --- */
152
+ canvas {
153
+ display: block;
154
+ position: absolute;
155
+ top: 0;
156
+ left: 0;
157
+ z-index: 1;
158
+ }
159
+
160
+ #hint {
161
+ position: absolute;
162
+ bottom: 20px;
163
+ right: 20px;
164
+ color: #004400;
165
+ z-index: 5;
166
+ font-size: 0.8rem;
167
+ opacity: 0;
168
+ transition: opacity 2s;
169
+ pointer-events: none;
170
+ }
171
+
172
+ .hidden {
173
+ opacity: 0;
174
+ pointer-events: none;
175
+ }
176
+ </style>
177
+ </head>
178
+ <body>
179
+
180
+ <!-- SCREEN 1: User Input -->
181
+ <div id="input-screen">
182
+ <div class="input-container">
183
+ <!-- Text Input -->
184
+ <input type="text" id="userWords" placeholder="> Enter dataset keywords..." autocomplete="off">
185
+
186
+ <!-- Controls Row -->
187
+ <div class="settings-row">
188
+ <!-- 1. Orientation -->
189
+ <div class="setting-group">
190
+ <label>Orientation</label>
191
+ <select id="orientation">
192
+ <option value="vertical">Vertical Rain</option>
193
+ <option value="horizontal">Horizontal Data</option>
194
+ </select>
195
+ </div>
196
+
197
+ <!-- 2. Flow -->
198
+ <div class="setting-group">
199
+ <label>Flow Direction</label>
200
+ <select id="flow">
201
+ <option value="one">One Way</option>
202
+ <option value="both">Bidirectional</option>
203
+ </select>
204
+ </div>
205
+
206
+ <!-- 3. Color Mode -->
207
+ <div class="setting-group">
208
+ <label>Color Mode</label>
209
+ <select id="colorMode" onchange="toggleColorInputs()">
210
+ <option value="single">Single Color</option>
211
+ <option value="dual">Dual Colors</option>
212
+ </select>
213
+ </div>
214
+
215
+ <!-- 4. Pickers -->
216
+ <div class="setting-group">
217
+ <label>Colors</label>
218
+ <div style="display: flex; gap: 5px;">
219
+ <input type="color" id="color1" value="#00FF00" title="Primary Color">
220
+ <input type="color" id="color2" value="#FF0000" title="Secondary Color" class="invisible">
221
+ </div>
222
+ </div>
223
+ </div>
224
+
225
+ <button onclick="startSequence()">[ GENERATE SEQUENCE ]</button>
226
+ </div>
227
+ </div>
228
+
229
+ <!-- SCREEN 2: Matrix Rain -->
230
+ <canvas id="matrixCanvas"></canvas>
231
+ <div id="hint">Press ESC to reset</div>
232
+
233
+ <script>
234
+ const canvas = document.getElementById('matrixCanvas');
235
+ const ctx = canvas.getContext('2d');
236
+ const inputScreen = document.getElementById('input-screen');
237
+ const hint = document.getElementById('hint');
238
+
239
+ // Input Elements
240
+ const inputField = document.getElementById('userWords');
241
+ const orientationSelect = document.getElementById('orientation');
242
+ const flowSelect = document.getElementById('flow');
243
+ const colorModeSelect = document.getElementById('colorMode');
244
+ const color1Input = document.getElementById('color1');
245
+ const color2Input = document.getElementById('color2');
246
+
247
+ // Setup Canvas
248
+ canvas.width = window.innerWidth;
249
+ canvas.height = window.innerHeight;
250
+
251
+ // State Variables
252
+ const fontSize = 16;
253
+ let animationId = null;
254
+ let characters = [];
255
+ let drops = [];
256
+ let isVertical = true;
257
+
258
+ // Color State
259
+ let useDualColor = false;
260
+ let col1 = '#00FF00';
261
+ let col2 = '#FF0000';
262
+
263
+ // --- UI LOGIC ---
264
+ function toggleColorInputs() {
265
+ if (colorModeSelect.value === 'dual') {
266
+ color2Input.classList.remove('invisible');
267
+ } else {
268
+ color2Input.classList.add('invisible');
269
+ }
270
+ }
271
+
272
+ // --- CORE LOGIC ---
273
+
274
+ function initDrops(orientation, flow) {
275
+ drops = [];
276
+ isVertical = (orientation === 'vertical');
277
+
278
+ const limit = isVertical ? canvas.width / fontSize : canvas.height / fontSize;
279
+
280
+ for (let i = 0; i < limit; i++) {
281
+ let speed = 1;
282
+ if (flow === 'both') {
283
+ speed = Math.random() > 0.5 ? 1 : -1;
284
+ }
285
+
286
+ // Initial Position
287
+ let startPos = Math.random() * (isVertical ? canvas.height : canvas.width);
288
+
289
+ drops.push({
290
+ val: startPos,
291
+ speed: speed
292
+ });
293
+ }
294
+ }
295
+
296
+ function draw() {
297
+ // Fade effect
298
+ ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
299
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
300
+
301
+ ctx.font = fontSize + 'px monospace';
302
+ const maxLimit = isVertical ? canvas.height : canvas.width;
303
+
304
+ for (let i = 0; i < drops.length; i++) {
305
+ const text = characters[Math.floor(Math.random() * characters.length)];
306
+ const drop = drops[i];
307
+
308
+ // COLOR LOGIC: Per Character
309
+ if (useDualColor) {
310
+ // Randomly pick between color 1 and 2 for a "noisy" mix
311
+ ctx.fillStyle = Math.random() > 0.5 ? col1 : col2;
312
+ } else {
313
+ ctx.fillStyle = col1;
314
+ }
315
+
316
+ // COORDINATES
317
+ let x, y;
318
+ if (isVertical) {
319
+ x = i * fontSize;
320
+ y = drop.val;
321
+ } else {
322
+ x = drop.val;
323
+ y = i * fontSize;
324
+ }
325
+
326
+ ctx.fillText(text, x, y);
327
+
328
+ // MOVEMENT
329
+ drop.val += drop.speed * fontSize;
330
+
331
+ // LOOPING
332
+ if (drop.speed > 0) {
333
+ if (drop.val > maxLimit && Math.random() > 0.975) drop.val = -fontSize;
334
+ } else {
335
+ if (drop.val < -fontSize && Math.random() > 0.975) drop.val = maxLimit;
336
+ }
337
+ }
338
+ }
339
+
340
+ // --- ACTIONS ---
341
+
342
+ function startSequence() {
343
+ const textVal = inputField.value.trim();
344
+
345
+ // Capture Settings
346
+ col1 = color1Input.value;
347
+ col2 = color2Input.value;
348
+ useDualColor = (colorModeSelect.value === 'dual');
349
+
350
+ // Set Characters
351
+ if (textVal.length > 0) {
352
+ characters = (textVal + " ").split('');
353
+ } else {
354
+ characters = "01".split('');
355
+ }
356
+
357
+ // Init Logic
358
+ initDrops(orientationSelect.value, flowSelect.value);
359
+
360
+ // Hide UI
361
+ inputScreen.classList.add('hidden');
362
+ setTimeout(() => { hint.style.opacity = 1; }, 2000);
363
+
364
+ // Start Animation
365
+ if (animationId) clearInterval(animationId);
366
+ animationId = setInterval(draw, 33);
367
+ }
368
+
369
+ function stopSequence() {
370
+ clearInterval(animationId);
371
+ ctx.fillStyle = 'black';
372
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
373
+ inputScreen.classList.remove('hidden');
374
+ hint.style.opacity = 0;
375
+ inputField.focus();
376
+ }
377
+
378
+ // --- LISTENERS ---
379
+
380
+ window.addEventListener('resize', () => {
381
+ canvas.width = window.innerWidth;
382
+ canvas.height = window.innerHeight;
383
+ if (inputScreen.classList.contains('hidden')) {
384
+ initDrops(orientationSelect.value, flowSelect.value);
385
+ }
386
+ });
387
+
388
+ inputField.addEventListener('keypress', (e) => {
389
+ if (e.key === 'Enter') startSequence();
390
+ });
391
+
392
+ document.addEventListener('keydown', (e) => {
393
+ if (e.key === "Escape") stopSequence();
394
+ });
395
+
396
+ // Initialize
397
+ toggleColorInputs(); // Set correct initial state
398
+ inputField.focus();
399
+
400
+ </script>
401
+ </body>
402
+ </html>