File size: 12,245 Bytes
08d8ceb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sequence Generator V4 - Dual Color</title>
    <style>
        /* General Reset */
        body {
            margin: 0;
            padding: 0;
            background-color: black;
            overflow: hidden;
            font-family: 'Courier New', Courier, monospace;
        }

        /* --- SCREEN 1: INPUT INTERFACE --- */
        #input-screen {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: black;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            z-index: 10;
            transition: opacity 0.8s ease-in-out;
        }

        .input-container {
            width: 100%;
            max-width: 800px;
            text-align: center;
            display: flex;
            flex-direction: column;
            gap: 25px;
        }

        /* Text Input */
        input[type="text"] {
            background: transparent;
            border: none;
            border-bottom: 2px solid #003300;
            color: #0F0;
            font-family: 'Courier New', monospace;
            font-size: 1.5rem;
            width: 90%;
            padding: 10px;
            text-align: center;
            outline: none;
            margin: 0 auto;
            transition: border-color 0.3s;
        }

        input[type="text"]:focus {
            border-bottom: 2px solid #0F0;
        }

        input[type="text"]::placeholder {
            color: #004400;
            font-size: 1rem;
            text-transform: uppercase;
        }

        /* Settings Row */
        .settings-row {
            display: flex;
            justify-content: center;
            flex-wrap: wrap;
            gap: 20px;
            margin-bottom: 10px;
            align-items: flex-end; /* Align bottom */
        }

        .setting-group {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
        }

        label {
            color: #004400;
            font-size: 0.7rem;
            margin-bottom: 5px;
            text-transform: uppercase;
        }

        select, input[type="color"] {
            background: black;
            color: #0F0;
            border: 1px solid #003300;
            font-family: 'Courier New', monospace;
            font-size: 0.9rem;
            outline: none;
            cursor: pointer;
            height: 35px;
            box-sizing: border-box;
        }

        select {
            padding: 5px;
            min-width: 140px;
        }

        /* Custom Style for Color Picker */
        input[type="color"] {
            -webkit-appearance: none;
            width: 60px;
            padding: 0;
            border: 1px solid #003300;
            transition: all 0.3s;
        }
        
        input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
        input[type="color"]::-webkit-color-swatch { border: none; }

        select:hover, select:focus, input[type="color"]:hover {
            border-color: #0F0;
        }

        /* Hidden class for 2nd color picker */
        .invisible {
            display: none;
        }

        /* Action Button */
        button {
            background: transparent;
            color: #0F0;
            border: 1px solid #0F0;
            padding: 15px 30px;
            font-family: 'Courier New', monospace;
            font-size: 1rem;
            cursor: pointer;
            text-transform: uppercase;
            letter-spacing: 2px;
            transition: all 0.2s;
            width: fit-content;
            align-self: center;
        }

        button:hover {
            background: #0F0;
            color: black;
            box-shadow: 0 0 15px #0F0;
        }

        /* --- SCREEN 2: CANVAS --- */
        canvas {
            display: block;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 1;
        }

        #hint {
            position: absolute;
            bottom: 20px;
            right: 20px;
            color: #004400;
            z-index: 5;
            font-size: 0.8rem;
            opacity: 0;
            transition: opacity 2s;
            pointer-events: none;
        }

        .hidden {
            opacity: 0;
            pointer-events: none;
        }
    </style>
</head>
<body>

    <!-- SCREEN 1: User Input -->
    <div id="input-screen">
        <div class="input-container">
            <!-- Text Input -->
            <input type="text" id="userWords" placeholder="> Enter dataset keywords..." autocomplete="off">
            
            <!-- Controls Row -->
            <div class="settings-row">
                <!-- 1. Orientation -->
                <div class="setting-group">
                    <label>Orientation</label>
                    <select id="orientation">
                        <option value="vertical">Vertical Rain</option>
                        <option value="horizontal">Horizontal Data</option>
                    </select>
                </div>

                <!-- 2. Flow -->
                <div class="setting-group">
                    <label>Flow Direction</label>
                    <select id="flow">
                        <option value="one">One Way</option>
                        <option value="both">Bidirectional</option>
                    </select>
                </div>

                <!-- 3. Color Mode -->
                <div class="setting-group">
                    <label>Color Mode</label>
                    <select id="colorMode" onchange="toggleColorInputs()">
                        <option value="single">Single Color</option>
                        <option value="dual">Dual Colors</option>
                    </select>
                </div>

                <!-- 4. Pickers -->
                <div class="setting-group">
                    <label>Colors</label>
                    <div style="display: flex; gap: 5px;">
                        <input type="color" id="color1" value="#00FF00" title="Primary Color">
                        <input type="color" id="color2" value="#FF0000" title="Secondary Color" class="invisible">
                    </div>
                </div>
            </div>

            <button onclick="startSequence()">[ GENERATE SEQUENCE ]</button>
        </div>
    </div>

    <!-- SCREEN 2: Matrix Rain -->
    <canvas id="matrixCanvas"></canvas>
    <div id="hint">Press ESC to reset</div>

    <script>
        const canvas = document.getElementById('matrixCanvas');
        const ctx = canvas.getContext('2d');
        const inputScreen = document.getElementById('input-screen');
        const hint = document.getElementById('hint');
        
        // Input Elements
        const inputField = document.getElementById('userWords');
        const orientationSelect = document.getElementById('orientation');
        const flowSelect = document.getElementById('flow');
        const colorModeSelect = document.getElementById('colorMode');
        const color1Input = document.getElementById('color1');
        const color2Input = document.getElementById('color2');

        // Setup Canvas
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;

        // State Variables
        const fontSize = 16;
        let animationId = null;
        let characters = [];
        let drops = []; 
        let isVertical = true;
        
        // Color State
        let useDualColor = false;
        let col1 = '#00FF00';
        let col2 = '#FF0000';

        // --- UI LOGIC ---
        function toggleColorInputs() {
            if (colorModeSelect.value === 'dual') {
                color2Input.classList.remove('invisible');
            } else {
                color2Input.classList.add('invisible');
            }
        }

        // --- CORE LOGIC ---

        function initDrops(orientation, flow) {
            drops = [];
            isVertical = (orientation === 'vertical');
            
            const limit = isVertical ? canvas.width / fontSize : canvas.height / fontSize;
            
            for (let i = 0; i < limit; i++) {
                let speed = 1;
                if (flow === 'both') {
                    speed = Math.random() > 0.5 ? 1 : -1;
                }

                // Initial Position
                let startPos = Math.random() * (isVertical ? canvas.height : canvas.width);
                
                drops.push({
                    val: startPos, 
                    speed: speed
                });
            }
        }

        function draw() {
            // Fade effect
            ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
            ctx.fillRect(0, 0, canvas.width, canvas.height);

            ctx.font = fontSize + 'px monospace';
            const maxLimit = isVertical ? canvas.height : canvas.width;

            for (let i = 0; i < drops.length; i++) {
                const text = characters[Math.floor(Math.random() * characters.length)];
                const drop = drops[i];

                // COLOR LOGIC: Per Character
                if (useDualColor) {
                    // Randomly pick between color 1 and 2 for a "noisy" mix
                    ctx.fillStyle = Math.random() > 0.5 ? col1 : col2;
                } else {
                    ctx.fillStyle = col1;
                }

                // COORDINATES
                let x, y;
                if (isVertical) {
                    x = i * fontSize;
                    y = drop.val;
                } else {
                    x = drop.val;
                    y = i * fontSize;
                }

                ctx.fillText(text, x, y);

                // MOVEMENT
                drop.val += drop.speed * fontSize; 

                // LOOPING
                if (drop.speed > 0) {
                    if (drop.val > maxLimit && Math.random() > 0.975) drop.val = -fontSize;
                } else {
                    if (drop.val < -fontSize && Math.random() > 0.975) drop.val = maxLimit;
                }
            }
        }

        // --- ACTIONS ---

        function startSequence() {
            const textVal = inputField.value.trim();
            
            // Capture Settings
            col1 = color1Input.value;
            col2 = color2Input.value;
            useDualColor = (colorModeSelect.value === 'dual');

            // Set Characters
            if (textVal.length > 0) {
                characters = (textVal + "  ").split('');
            } else {
                characters = "01".split('');
            }

            // Init Logic
            initDrops(orientationSelect.value, flowSelect.value);

            // Hide UI
            inputScreen.classList.add('hidden');
            setTimeout(() => { hint.style.opacity = 1; }, 2000);

            // Start Animation
            if (animationId) clearInterval(animationId);
            animationId = setInterval(draw, 33);
        }

        function stopSequence() {
            clearInterval(animationId);
            ctx.fillStyle = 'black';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            inputScreen.classList.remove('hidden');
            hint.style.opacity = 0;
            inputField.focus();
        }

        // --- LISTENERS ---

        window.addEventListener('resize', () => {
            canvas.width = window.innerWidth;
            canvas.height = window.innerHeight;
            if (inputScreen.classList.contains('hidden')) {
                initDrops(orientationSelect.value, flowSelect.value);
            }
        });

        inputField.addEventListener('keypress', (e) => {
            if (e.key === 'Enter') startSequence();
        });

        document.addEventListener('keydown', (e) => {
            if (e.key === "Escape") stopSequence();
        });

        // Initialize
        toggleColorInputs(); // Set correct initial state
        inputField.focus();

    </script>
</body>
</html>