-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwin95.html
More file actions
1770 lines (1560 loc) · 83.6 KB
/
win95.html
File metadata and controls
1770 lines (1560 loc) · 83.6 KB
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Retro Screensavers</title>
<style>
body {
margin: 0;
overflow: hidden;
font-family: 'Press Start 2P', cursive, Arial, sans-serif; /* Added a retro font, or fall back */
display: flex;
height: 100vh;
background-color: #000;
color: #fff;
position: relative; /* For the mouseleave detection */
}
/* Import a retro-style font if desired */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
#menu {
width: 250px;
background-color: #222;
padding: 20px;
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
transition: transform 0.3s ease-in-out; /* Keep for smooth visual hiding/showing */
z-index: 100;
flex-shrink: 0; /* Prevent shrinking when displayArea grows */
}
/* Use display: none for true hiding, overriding flex when hidden */
#menu.hidden {
display: none; /* Hide completely from layout flow */
transform: translateX(-100%); /* Still apply transform for potential visual effect on re-appearance */
}
#menu h2 {
margin-top: 0;
color: #0f0;
text-shadow: 0 0 5px #0f0;
}
#menu ul {
list-style: none;
padding: 0;
flex-grow: 1;
}
#menu li {
margin-bottom: 10px;
}
#menu a {
color: #fff;
text-decoration: none;
padding: 8px 10px;
display: block;
border-radius: 4px;
transition: background-color 0.2s;
border: 1px solid transparent;
}
#menu a:hover, #menu a.active {
background-color: #555;
border-color: #0f0;
}
.checkbox-container {
display: flex;
align-items: center;
margin-top: 15px;
color: #ccc;
}
.checkbox-container input[type="checkbox"] {
margin-right: 8px;
width: 18px;
height: 18px;
accent-color: #0f0; /* Green accent for checkbox */
}
#mainContent {
flex-grow: 1;
position: relative;
overflow: hidden;
display: flex;
}
#displayArea {
flex-grow: 1;
background-color: #000;
position: relative;
overflow: hidden;
border: 2px solid #000; /* To clearly define the display area */
}
#settings {
width: 280px;
background-color: #222;
padding: 20px;
box-shadow: -2px 0 5px rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
transition: transform 0.3s ease-in-out; /* Keep for smooth visual hiding/showing */
z-index: 100;
flex-shrink: 0; /* Prevent shrinking when displayArea grows */
}
/* Use display: none for true hiding, overriding flex when hidden */
#settings.hidden {
display: none; /* Hide completely from layout flow */
transform: translateX(100%); /* Still apply transform for potential visual effect on re-appearance */
}
#settings h2 {
margin-top: 0;
color: #0f0;
text-shadow: 0 0 5px #0f0;
}
.setting-group {
margin-bottom: 15px;
}
.setting-group label {
display: block;
margin-bottom: 5px;
color: #aaa;
font-size: 0.9em;
}
.setting-group input[type="range"],
.setting-group input[type="color"],
.setting-group select,
.setting-group input[type="text"] {
width: 100%;
padding: 8px;
border: 1px solid #444;
background-color: #333;
color: #fff;
border-radius: 4px;
box-sizing: border-box; /* Include padding in width */
}
/* Screensaver Styles */
.screensaver {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
overflow: hidden;
display: none; /* Hidden by default */
image-rendering: pixelated; /* For a retro look */
}
/* 3D Maze (Simplified) */
#maze3D.screensaver {
display: flex;
justify-content: center;
align-items: center;
background-color: #111;
/* Simple 2D grid effect */
background-image:
linear-gradient(0deg, transparent 95%, rgba(0,255,0,0.2) 95%),
linear-gradient(90deg, transparent 95%, rgba(0,255,0,0.2) 95%);
background-size: 20px 20px;
animation: scrollBackground 60s linear infinite;
}
@keyframes scrollBackground {
from { background-position: 0 0; }
to { background-position: 100% 100%; }
}
/* 3D Pipes (Simplified) */
#pipes3D.screensaver {
background-color: #000;
position: relative;
}
.pipe-segment {
position: absolute;
width: 10px;
height: 10px;
background-color: #888;
border: 1px solid #fff;
box-shadow: 0 0 5px #0ff, inset 0 0 3px #fff;
/* Animation properties are now mostly set by JS */
opacity: 0; /* Starts hidden, made visible by JS */
transform-origin: center center;
will-change: transform, opacity;
}
.pipe-trail {
position: absolute;
background-color: var(--pipe-color, #00FFFF);
opacity: 0.3;
animation: fadeOutTrail var(--trail-duration) forwards;
pointer-events: none; /* Ensure it doesn't interfere with mouse events */
}
@keyframes fadeOutTrail {
from { opacity: 0.3; }
to { opacity: 0; }
}
/* Flying Through Space - NEW Implementation */
#flyingThroughSpace.screensaver {
background-color: #000;
overflow: hidden;
}
.pixel-star {
position: absolute;
background-color: white;
box-shadow: 0 0 5px white, 0 0 10px white;
width: var(--size);
height: var(--size);
/* Transform is set directly by JS for precision */
opacity: 0; /* Managed by JS animation */
image-rendering: pixelated;
}
/* Orbit - NEW Implementation (Bouncing Multi-Color Sphere) */
#orbit.screensaver {
background-color: #000;
position: relative;
overflow: hidden;
}
.bouncing-sphere {
position: absolute;
/* Size and position are set by JS */
border-radius: 50%;
background-image: conic-gradient(
#f00 0% 16.6%,
#ff0 16.6% 33.3%,
#0f0 33.3% 50%,
#0ff 50% 66.6%,
#00f 66.6% 83.3%,
#f0f 83.3% 100%
);
box-shadow: 0 0 50px rgba(0, 255, 0, 0.7); /* Green glow */
animation: rotateSphere var(--rotation-duration) linear infinite;
transform-origin: center center;
background-size: 200% 200%; /* Make colors larger than sphere */
background-position: var(--bg-pos-x, 0%) var(--bg-pos-y, 0%); /* Controlled by JS */
will-change: transform, background-position;
}
@keyframes rotateSphere {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
/* Curves (Mystify) */
#curves.screensaver canvas {
display: block;
background-color: #000;
}
/* 3D FlowerBox (Simplified) */
#flowerBox3D.screensaver {
display: flex;
justify-content: center;
align-items: center;
background-color: #000;
perspective: 600px;
}
.flower-grid {
display: grid;
grid-template-columns: repeat(5, 50px);
grid-template-rows: repeat(5, 50px);
gap: 5px;
transform-style: preserve-3d;
animation: rotateFlowerGrid 30s linear infinite;
}
.flower-cell {
width: 50px;
height: 50px;
background-color: var(--flower-base-color, rgba(255, 0, 255, 0.5)); /* Magenta-ish */
border: 1px solid var(--flower-base-color-border, #f0f);
box-shadow: 0 0 10px var(--flower-base-color-shadow, #f0f), inset 0 0 3px #fff;
transform-style: preserve-3d;
transform: rotateX(var(--rx)) rotateY(var(--ry)) rotateZ(var(--rz));
animation: pulsateColor 5s infinite alternate ease-in-out;
}
@keyframes rotateFlowerGrid {
from { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
to { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg); }
}
@keyframes pulsateColor {
0% { background-color: var(--flower-base-color, rgba(255, 0, 255, 0.5)); box-shadow: 0 0 10px var(--flower-base-color-shadow, #f0f); }
100% { background-color: var(--flower-alt-color, rgba(0, 255, 255, 0.5)); box-shadow: 0 0 10px var(--flower-alt-color-shadow, #0ff); }
}
/* 3D Flying Objects (Simplified) */
#flyingObjects3D.screensaver {
background-color: #000;
position: relative;
}
.flying-object {
position: absolute;
font-size: 3em;
color: var(--obj-color, #fff);
text-shadow: 0 0 5px var(--obj-color, #fff);
animation: flyObject var(--duration) linear infinite;
opacity: 0;
transform: translate(var(--startX), var(--startY)) scale(0);
image-rendering: pixelated; /* For a retro object look */
}
.flying-object img {
width: 100%;
height: 100%;
object-fit: contain;
image-rendering: pixelated;
}
@keyframes flyObject {
0% { transform: translate(var(--startX), var(--startY)) scale(0); opacity: 0; }
20% { opacity: 1; transform: translate(var(--startX), var(--startY)) scale(1); }
80% { opacity: 1; }
100% { transform: translate(var(--endX), var(--endY)) scale(0.5); opacity: 0; }
}
/* 3D Text (Fake) - Revamped for Bouncing */
#text3D.screensaver {
position: absolute; /* Changed from flex container */
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #000;
perspective: 800px; /* Crucial for CSS 3D */
z-index: 1;
}
.text3d {
position: absolute; /* Now absolutely positioned within #text3D.screensaver */
font-size: 8em;
color: #0f0;
text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 30px #0f0, 0 0 40px #0f0; /* Stronger glow */
animation: animateText var(--rotation-duration, 10s) infinite alternate; /* Duration adjusted by JS */
transform-style: preserve-3d; /* CRITICAL for 3D appearance */
will-change: transform, left, top; /* Optimize animation and movement */
text-align: center;
line-height: 1;
padding: 20px;
white-space: nowrap; /* Prevent text from wrapping */
transform: translate(-50%, -50%); /* Center based on its own dimensions */
transform-origin: center center;
}
@keyframes animateText {
0% { transform: translate(-50%, -50%) translateZ(0px) rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
25% { transform: translate(-50%, -50%) translateZ(50px) rotateX(20deg) rotateY(45deg) rotateZ(10deg); }
50% { transform: translate(-50%, -50%) translateZ(0px) rotateX(-10deg) rotateY(90deg) rotateZ(-20deg); }
75% { transform: translate(-50%, -50%) translateZ(-50px) rotateX(30deg) rotateY(135deg) rotateZ(0deg); }
100% { transform: translate(-50%, -50%) translateZ(0px) rotateX(0deg) rotateY(180deg) rotateZ(0deg); }
}
/* Styling for Mystify controls (integrated into settings panel) */
#mystify-controls {
padding: 0; /* Remove padding as it's within settings */
box-shadow: none; /* Remove box shadow */
background-color: transparent; /* Transparent background */
color: #fff;
max-width: none;
z-index: auto;
transition: none;
}
#mystify-controls .control-group {
margin-bottom: 10px; /* Adjust spacing */
}
#mystify-controls h2 {
margin-top: 10px;
margin-bottom: 15px;
color: #63b3ed; /* Mystify blue */
text-shadow: none;
font-size: 1.2em;
}
#mystify-controls input[type="range"]::-webkit-slider-thumb {
background: #63b3ed;
}
#mystify-controls input[type="range"]::-moz-range-thumb {
background: #63b3ed;
}
#mystify-controls .reset-button {
margin-top: 15px;
}
</style>
</head>
<body>
<div id="menu">
<h2>Screensavers</h2>
<ul>
<li><a href="#" data-screensaver="maze3D">3D Maze (Flat)</a></li>
<li><a href="#" data-screensaver="pipes3D">3D Pipes (Animated)</a></li>
<li><a href="#" data-screensaver="flyingThroughSpace">Flying Through Space</a></li>
<li><a href="#" data-screensaver="orbit">Orbit</a></li>
<li><a href="#" data-screensaver="curves">Curves (Mystify)</a></li>
<li><a href="#" data-screensaver="flowerBox3D">3D FlowerBox (Grid)</a></li>
<li><a href="#" data-screensaver="flyingObjects3D">Flying Objects (ASCII/Image)</a></li>
<li><a href="#" data-screensaver="text3D">3D Text (Fake)</a></li>
</ul>
<div class="checkbox-container">
<input type="checkbox" id="hideMenuCheckbox" checked>
<label for="hideMenuCheckbox">Hide menu on mouse out</label>
</div>
</div>
<div id="mainContent">
<div id="displayArea">
<div id="maze3D" class="screensaver"></div>
<div id="pipes3D" class="screensaver"></div>
<div id="flyingThroughSpace" class="screensaver"></div>
<div id="orbit" class="screensaver">
<div class="bouncing-sphere"></div>
</div>
<div id="curves" class="screensaver">
</div>
<div id="flowerBox3D" class="screensaver">
<div class="flower-grid">
</div>
</div>
<div id="flyingObjects3D" class="screensaver"></div>
<div id="text3D" class="screensaver">
<span class="text3d" id="custom3DText">Windows 95</span>
</div>
</div>
<div id="settings">
<h2>Settings</h2>
<div class="setting-group">
<label for="brightness">Brightness</label>
<input type="range" id="brightness" min="0" max="100" value="100">
</div>
<div class="setting-group">
<label for="animationSpeed">Global Speed</label>
<input type="range" id="animationSpeed" min="0.1" max="3" step="0.1" value="1">
</div>
<div class="setting-group">
<label for="backgroundColor">Background Color</label>
<input type="color" id="backgroundColor" value="#000000">
</div>
<div class="setting-group" id="screensaverSpecificSettings">
</div>
<div class="checkbox-container">
<input type="checkbox" id="hideSettingsCheckbox" checked>
<label for="hideSettingsCheckbox">Hide settings on mouse out</label>
</div>
</div>
</div>
<script>
const menu = document.getElementById('menu');
const settings = document.getElementById('settings');
const displayArea = document.getElementById('displayArea');
const screensaverLinks = document.querySelectorAll('#menu a[data-screensaver]');
const screensavers = document.querySelectorAll('.screensaver');
const hideMenuCheckbox = document.getElementById('hideMenuCheckbox');
const hideSettingsCheckbox = document.getElementById('hideSettingsCheckbox');
const screensaverSpecificSettings = document.getElementById('screensaverSpecificSettings');
const globalSpeedSlider = document.getElementById('animationSpeed');
const body = document.body;
let activeScreensaverId = null; // To keep track of the currently active screensaver
let currentAnimationIntervals = {}; // To store intervals/timeouts for cleanup
let currentAnimationFrames = {}; // To store requestAnimationFrame IDs for cleanup
// --- Core Functionality ---
// Helper function to show the menu
function showMenu() {
menu.style.display = 'flex';
menu.classList.remove('hidden');
}
// Helper function to hide the menu
function hideMenu() {
menu.style.display = 'none';
menu.classList.add('hidden');
}
// Helper function to show the settings
function showSettings() {
settings.style.display = 'flex';
settings.classList.remove('hidden');
}
// Helper function to hide the settings
function hideSettings() {
settings.style.display = 'none';
settings.classList.add('hidden');
}
// Mouse leave/enter logic for the *entire window* (body)
// This is crucial for menus to reappear when the mouse re-enters the browser window
document.body.addEventListener('mouseleave', () => {
if (hideMenuCheckbox.checked) {
hideMenu();
}
if (hideSettingsCheckbox.checked) {
hideSettings();
}
});
document.body.addEventListener('mouseenter', () => {
if (hideMenuCheckbox.checked) {
showMenu();
}
if (hideSettingsCheckbox.checked) {
showSettings();
}
});
// Keep menus visible when mouse is explicitly over them, overriding body.mouseleave if applicable
menu.addEventListener('mouseenter', () => { showMenu(); });
settings.addEventListener('mouseenter', () => { showSettings(); });
// Event listeners for checkboxes to control visibility behavior
hideMenuCheckbox.addEventListener('change', () => {
if (!hideMenuCheckbox.checked) {
showMenu(); // If unchecked, ensure it's visible permanently
} else {
// If re-checked, hide if mouse is not currently over the menu or body (i.e. if it's already hidden)
if (!menu.matches(':hover') && !body.matches(':hover')) {
hideMenu();
}
}
});
hideSettingsCheckbox.addEventListener('change', () => {
if (!hideSettingsCheckbox.checked) {
showSettings(); // If unchecked, ensure it's visible permanently
} else {
// If re-checked, hide if mouse is not currently over the settings or body
if (!settings.matches(':hover') && !body.matches(':hover')) {
hideSettings();
}
}
});
// Set default checked state for checkboxes on load
hideMenuCheckbox.checked = true;
hideSettingsCheckbox.checked = true;
// Function to activate a screensaver
function activateScreensaver(screensaverId) {
// Clean up previous screensaver's specific animations and elements
cleanupCurrentScreensaver();
screensavers.forEach(ss => {
ss.style.display = 'none'; // Hide all screensavers
});
const targetScreensaver = document.getElementById(screensaverId);
if (targetScreensaver) {
targetScreensaver.style.display = 'block';
// Remove 'active' class from all links, then add to current
screensaverLinks.forEach(link => link.classList.remove('active'));
document.querySelector(`[data-screensaver="${screensaverId}"]`).classList.add('active');
activeScreensaverId = screensaverId;
updateScreensaverSpecificSettings(screensaverId); // Load settings UI
// Initialize/reset screensaver if needed
switch (screensaverId) {
case 'flyingThroughSpace':
initFlyingThroughSpace();
break;
case 'pipes3D':
initPipes3D();
break;
case 'orbit':
initOrbit();
break;
case 'curves':
initCurvesMystify(); // Call the Mystify initializer
break;
case 'flowerBox3D':
initFlowerBox3D();
break;
case 'flyingObjects3D':
initFlyingObjects3D();
break;
case 'text3D':
update3DText(); // Ensure text content, animation, and movement are set
break;
default:
// No specific init for simple CSS ones or conceptual ones
break;
}
} else {
displayArea.innerHTML = `<p style="text-align: center; margin-top: 50px; color: #aaa;">'${screensaverId}' Screensaver (Conceptual)</p>`;
activeScreensaverId = null;
screensaverSpecificSettings.innerHTML = '';
}
}
// Cleans up intervals/timeouts and specific elements for the currently active screensaver
function cleanupCurrentScreensaver() {
if (activeScreensaverId) {
// Clear any intervals/timeouts specific to the previous screensaver
for (const key in currentAnimationIntervals) {
clearInterval(currentAnimationIntervals[key]);
clearTimeout(currentAnimationIntervals[key]);
}
currentAnimationIntervals = {}; // Reset
// Cancel any requestAnimationFrame loops
for (const key in currentAnimationFrames) {
cancelAnimationFrame(currentAnimationFrames[key]);
}
currentAnimationFrames = {}; // Reset
// Specific cleanup for canvas-based screensavers (Mystify)
if (activeScreensaverId === 'curves') {
if (mystifyAnimationId) {
cancelAnimationFrame(mystifyAnimationId);
mystifyAnimationId = null; // Reset animation ID for Mystify
}
const mystifyCanvasEl = document.getElementById('mystifyCanvas');
if (mystifyCanvasEl) mystifyCanvasEl.remove(); // Remove the canvas
window.removeEventListener('resize', resizeMystifyCanvas); // Remove resize listener
}
// Clean up dynamically added elements for specific screensavers
const ss = document.getElementById(activeScreensaverId);
if (ss) {
switch (activeScreensaverId) {
case 'flyingThroughSpace':
// Remove all stars
ss.querySelectorAll('.pixel-star').forEach(star => star.remove());
break;
case 'pipes3D':
// Remove all pipe segments and trails
ss.querySelectorAll('.pipe-segment, .pipe-trail').forEach(pipe => pipe.remove());
break;
case 'flowerBox3D':
// Clear flower grid
const flowerGrid = ss.querySelector('.flower-grid');
if (flowerGrid) flowerGrid.innerHTML = '';
break;
case 'flyingObjects3D':
// Remove all flying objects
ss.querySelectorAll('.flying-object').forEach(obj => obj.remove());
break;
case 'text3D':
// Ensure 3D text is reset to initial state to prevent lingering animation issues
const custom3DText = document.getElementById('custom3DText');
if (custom3DText) {
custom3DText.style.animation = 'none'; // Stop current CSS animation
custom3DText.style.left = ''; // Clear JS set positions
custom3DText.style.top = '';
custom3DText.textContent = 'RETRO!'; // Reset default text
}
// Also clear the movement animation for 3D Text
if (text3DAnimationId) {
cancelAnimationFrame(text3DAnimationId);
text3DAnimationId = null;
delete currentAnimationFrames['raf-text3D'];
}
break;
case 'orbit':
// Reset sphere position variables
currentOrbitX = undefined;
currentOrbitY = undefined;
if (orbitAnimationId) {
cancelAnimationFrame(orbitAnimationId);
orbitAnimationId = null;
}
break;
default:
// For other simple screensavers, just hide them. Their CSS handles the rest.
break;
}
}
}
}
// Handle screensaver selection from menu
screensaverLinks.forEach(link => {
link.addEventListener('click', (e) => {
console.log('Menu link clicked:', e.target.dataset.screensaver); // Debugging log
e.preventDefault();
const screensaverId = e.target.dataset.screensaver;
activateScreensaver(screensaverId);
});
});
// --- General Settings Control ---
document.getElementById('brightness').addEventListener('input', (e) => {
const brightness = e.target.value / 100;
displayArea.style.filter = `brightness(${brightness})`;
});
globalSpeedSlider.addEventListener('input', (e) => {
const speedMultiplier = parseFloat(e.target.value);
// Apply a global speed factor to all animations via CSS variable
document.documentElement.style.setProperty('--global-speed-multiplier', speedMultiplier);
// Re-initialize the active screensaver to apply new speed
if (activeScreensaverId) {
activateScreensaver(activeScreensaverId);
}
});
document.getElementById('backgroundColor').addEventListener('input', (e) => {
displayArea.style.backgroundColor = e.target.value;
});
// --- Screensaver Specific Settings and Initialization ---
function updateScreensaverSpecificSettings(screensaverId) {
screensaverSpecificSettings.innerHTML = ''; // Clear previous settings
// Common 3D Text input (always present for 3D Text screensaver)
if (screensaverId === 'text3D') {
screensaverSpecificSettings.innerHTML += `
<div class="setting-group">
<label for="customTextContent">3D Text Content</label>
<input type="text" id="customTextContent" value="Windows 95" placeholder="Enter 3D text">
</div>
`;
document.getElementById('customTextContent').addEventListener('input', update3DText);
}
switch (screensaverId) {
case 'maze3D':
screensaverSpecificSettings.innerHTML += `
<div class="setting-group">
<label for="mazeCellSize">Cell Size (px)</label>
<input type="range" id="mazeCellSize" min="10" max="50" value="20">
</div>
<div class="setting-group">
<label for="mazeLineColor">Line Color</label>
<input type="color" id="mazeLineColor" value="#00FF00">
</div>
`;
document.getElementById('mazeCellSize').addEventListener('input', (e) => {
const size = e.target.value;
document.getElementById('maze3D').style.backgroundSize = `${size}px ${size}px`;
});
document.getElementById('mazeLineColor').addEventListener('input', (e) => {
const color = e.target.value;
document.getElementById('maze3D').style.backgroundImage = `
linear-gradient(0deg, transparent 95%, ${color}20 95%),
linear-gradient(90deg, transparent 95%, ${color}20 95%)
`;
});
break;
case 'pipes3D':
screensaverSpecificSettings.innerHTML += `
<div class="setting-group">
<label for="pipeColor">Pipe Color</label>
<input type="color" id="pipeColor" value="#00FFFF">
</div>
<div class="setting-group">
<label for="pipeDensity">Pipe Density</label>
<input type="range" id="pipeDensity" min="5" max="50" value="20">
</div>
`;
document.getElementById('pipeColor').addEventListener('input', (e) => {
document.documentElement.style.setProperty('--pipe-color', e.target.value);
// Also update existing pipes if any
document.querySelectorAll('#pipes3D .pipe-segment').forEach(p => {
p.style.backgroundColor = e.target.value;
p.style.boxShadow = `0 0 5px ${e.target.value}, inset 0 0 3px #fff`;
});
document.querySelectorAll('#pipes3D .pipe-trail').forEach(t => {
t.style.backgroundColor = e.target.value;
});
});
document.getElementById('pipeDensity').addEventListener('input', (e) => {
initPipes3D(e.target.value);
});
break;
case 'flyingThroughSpace':
screensaverSpecificSettings.innerHTML += `
<div class="setting-group">
<label for="starDensity">Star Density</label>
<input type="range" id="starDensity" min="10" max="300" value="100">
</div>
<div class="setting-group">
<label for="starColor">Star Color</label>
<input type="color" id="starColor" value="#FFFFFF">
</div>
`;
document.getElementById('starDensity').addEventListener('input', (e) => {
initFlyingThroughSpace(e.target.value);
});
document.getElementById('starColor').addEventListener('input', (e) => {
document.querySelectorAll('#flyingThroughSpace .pixel-star').forEach(star => {
star.style.backgroundColor = e.target.value;
star.style.boxShadow = `0 0 5px ${e.target.value}, 0 0 10px ${e.target.value}`;
});
});
break;
case 'orbit':
screensaverSpecificSettings.innerHTML += `
<div class="setting-group">
<label for="sphereGlowColor">Sphere Glow Color</label>
<input type="color" id="sphereGlowColor" value="#00FF00">
</div>
<div class="setting-group">
<label for="sphereSize">Sphere Size (px)</label>
<input type="range" id="sphereSize" min="50" max="300" value="150">
</div>
`;
document.getElementById('sphereGlowColor').addEventListener('input', (e) => {
const sphere = document.querySelector('#orbit .bouncing-sphere');
if (sphere) sphere.style.boxShadow = `0 0 50px ${e.target.value}`;
});
document.getElementById('sphereSize').addEventListener('input', (e) => {
const size = parseInt(e.target.value);
initOrbit(size); // Re-init to adjust size and bounce path
});
break;
case 'curves': // Mystify settings
screensaverSpecificSettings.innerHTML += `
<div id="mystify-controls">
<h2>Mystify Controls</h2>
<div class="control-group">
<label for="mystifyNumObjects">Number of Objects: <span id="mystifyNumObjectsValue">5</span></label>
<input type="range" id="mystifyNumObjects" min="1" max="20" value="5">
</div>
<div class="control-group">
<label for="mystifyNumNodes">Nodes per Object: <span id="mystifyNumNodesValue">4</span></label>
<input type="range" id="mystifyNumNodes" min="3" max="10" value="4">
</div>
<div class="control-group">
<label for="mystifySpeedControl">Speed: <span id="mystifySpeedValue">1.0</span>x</label>
<input type="range" id="mystifySpeedControl" min="0.1" max="10.0" step="0.1" value="1.0">
</div>
<div class="control-group">
<label for="mystifyTrailFrequency">Trail Frequency: <span id="mystifyTrailFrequencyValue">10</span></label>
<input type="range" id="mystifyTrailFrequency" min="1" max="50" value="10">
</div>
<div class="control-group flex items-center">
<input type="checkbox" id="mystifyIndividualPrints" class="mr-2">
<label for="mystifyIndividualPrints" class="mb-0">Individual Prints (Hollow)</label>
</div>
<div class="control-group">
<label for="mystifyColorPalette">Color Palette:</label>
<select id="mystifyColorPalette">
<option value="classicAtari">Classic Atari</option>
<option value="vibrantAtari">Vibrant Atari</option>
<option value="monochrome">Monochrome (Green)</option>
</select>
</div>
<button id="mystifyResetButton" class="reset-button">Reset Animation</button>
</div>
`;
// Set default for "Individual Prints (Hollow)"
const individualPrintsCheckbox = document.getElementById('mystifyIndividualPrints');
if (individualPrintsCheckbox) {
individualPrintsCheckbox.checked = true;
mystifySettings.trailMode = 'individual'; // Update internal setting
}
// Attach Mystify event listeners
attachMystifyEventListeners();
break;
case 'flowerBox3D':
screensaverSpecificSettings.innerHTML += `
<div class="setting-group">
<label for="flowerGridSize">Grid Size (e.g., 5 for 5x5)</label>
<input type="range" id="flowerGridSize" min="3" max="10" value="5">
</div>
<div class="setting-group">
<label for="flowerBaseColor">Base Color</label>
<input type="color" id="flowerBaseColor" value="#FF00FF">
</div>
<div class="setting-group">
<label for="flowerAltColor">Alt Color</label>
<input type="color" id="flowerAltColor" value="#00FFFF">
</div>
`;
document.getElementById('flowerGridSize').addEventListener('input', (e) => {
initFlowerBox3D(e.target.value);
});
document.getElementById('flowerBaseColor').addEventListener('input', (e) => {
document.documentElement.style.setProperty('--flower-base-color', e.target.value);
document.documentElement.style.setProperty('--flower-base-color-border', e.target.value);
document.documentElement.style.setProperty('--flower-base-color-shadow', e.target.value);
});
document.getElementById('flowerAltColor').addEventListener('input', (e) => {
document.documentElement.style.setProperty('--flower-alt-color', e.target.value);
document.documentElement.style.setProperty('--flower-alt-color-shadow', e.target.value);
});
break;
case 'flyingObjects3D':
screensaverSpecificSettings.innerHTML += `
<div class="setting-group">
<label for="objectSource">Object Source</label>
<select id="objectSource">
<option value="ascii">ASCII Symbols</option>
<option value="emoji" selected>Emojis</option>
<option value="image">Custom Image URL</option>
</select>
</div>
<div class="setting-group" id="imageURLGroup" style="display:none;">
<label for="objectImageURL">Image URL</label>
<input type="text" id="objectImageURL" placeholder="https://example.com/image.png">
</div>
<div class="setting-group">
<label for="objectColor">Object Color (for ASCII/Emoji)</label>
<input type="color" id="objectColor" value="#FFFFFF">
</div>
<div class="setting-group">
<label for="objectDensity">Object Density</label>
<input type="range" id="objectDensity" min="5" max="100" value="30">
</div>
`;
document.getElementById('objectSource').addEventListener('change', (e) => {
const imageURLGroup = document.getElementById('imageURLGroup');
imageURLGroup.style.display = (e.target.value === 'image') ? 'block' : 'none';
initFlyingObjects3D(document.getElementById('objectDensity').value); // Re-init with new source
});
document.getElementById('objectImageURL').addEventListener('input', () => {
if (document.getElementById('objectSource').value === 'image') {
initFlyingObjects3D(document.getElementById('objectDensity').value);
}
});
document.getElementById('objectColor').addEventListener('input', (e) => {
document.documentElement.style.setProperty('--obj-color', e.target.value);
});
document.getElementById('objectDensity').addEventListener('input', (e) => {
initFlyingObjects3D(e.target.value);
});
// Set initial state for image URL group
const initialObjectSource = document.getElementById('objectSource');
if (initialObjectSource && initialObjectSource.value === 'image') {
document.getElementById('imageURLGroup').style.display = 'block';
}
break;
case 'text3D':
screensaverSpecificSettings.innerHTML += `
<div class="setting-group">
<label for="textColor3D">Text Color</label>
<input type="color" id="textColor3D" value="#00FF00">
</div>
<div class="setting-group">
<label for="textRotationSpeed">Rotation Speed (s)</label>
<input type="range" id="textRotationSpeed" min="2" max="30" step="1" value="10">
</div>
<div class="setting-group">
<label for="textMovementSpeed">Movement Speed</label>
<input type="range" id="textMovementSpeed" min="0.5" max="5" step="0.1" value="2">
</div>
`;
document.getElementById('textColor3D').addEventListener('input', (e) => {
const color = e.target.value;
const custom3DText = document.getElementById('custom3DText');
if (custom3DText) {
custom3DText.style.color = color;
custom3DText.style.textShadow = `0 0 10px ${color}, 0 0 20px ${color}, 0 0 30px ${color}, 0 0 40px ${color}`;
}
});
document.getElementById('textRotationSpeed').addEventListener('input', (e) => {
update3DText(); // Call update to re-apply animation with new speed
});
document.getElementById('textMovementSpeed').addEventListener('input', (e) => {
text3DSpeed = parseFloat(e.target.value);
initText3DAnimation(); // Re-initialize movement with new speed
});
break;
default:
screensaverSpecificSettings.innerHTML += `<p style="color: #aaa;">No specific settings for this screensaver.</p>`;
break;
}
}
// Global variables for 3D Text movement
let text3DElement; // Reference to the .text3d span
let text3Dx, text3Dy;
let text3DDx, text3DDy;
let text3DAnimationId; // requestAnimationFrame ID for 3D Text movement
let text3DSpeed = 2; // Base speed for 3D text movement
// Initialize/Restart the 3D Text movement animation
function initText3DAnimation() {
text3DElement = document.getElementById('custom3DText');