-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1341 lines (1126 loc) · 58.5 KB
/
Copy pathindex.html
File metadata and controls
1341 lines (1126 loc) · 58.5 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>Optimized AI Visualization</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Merriweather:ital,opsz,wght@0,18..144,300..900;1,18..144,300..900&display=swap" rel="stylesheet">
<style>
body {
margin: 0;
overflow: hidden;
background-color: #060014;
font-family: 'Arial', sans-serif;
}
canvas {
position: fixed;
top: 0;
left: 0;
z-index: 1;
}
.info {
position: absolute;
top: 10%;
left: 10%;
color: rgba(255, 255, 255, 0.9);
background-color: rgba(0, 0, 0, 0.5);
padding: 10px;
border-radius: 10px;
width: 80%;
max-width: 320px;
z-index: 10;
font-size: 14px;
line-height: 1.5;
}
h2 {
margin-top: 0;
font-weight: 300;
color: #ff00aa;
letter-spacing: 1px;
}
.merriweather-<uniquifier> {
font-family: "Merriweather", serif;
font-optical-sizing: auto;
font-weight: <weight>;
font-style: normal;
font-variation-settings:
"wdth" 100;
}
</style>
</head>
<body>
<div class="info">
<h2>Ai Neural Network Friend</h2>
<p>Interactive Ai Neural Network Made Using Physics Based JavaScript.</p>
<p><strong>Click Below to Communicate...</strong></p>
</div>
<canvas id="visualization"></canvas>
<script>
window.onload = function() {
const canvas = document.getElementById('visualization');
const ctx = canvas.getContext('2d');
// Set canvas size
function setCanvasSize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
setCanvasSize();
// Colors 22c5fc-ff1fb4-f168f1-C46EFD-71FFF1
const colors = ['#22c5fc', '#ff1fb4', '#f168f1', '#C46EFD', '#71FFF1'];
const colorValues = colors.map(color => {
const hex = color.substring(1);
return {
r: parseInt(hex.substring(0, 2), 16),
g: parseInt(hex.substring(2, 4), 16),
b: parseInt(hex.substring(4, 6), 16)
};
});
// Add these customization variables at the top of your script, perhaps right after the colors array
const communicationSettings = {
// Appearance settings
outgoingColor: '#22c5fc' || '#f168f1' || '#71FFF1' || '#ff1fb4' || '#C46EFD',
incomingColor: '#22c5fc' || '#f168f1' || '#71FFF1' || '#ff1fb4' || '#C46EFD',
lineThickness: .02, // Width of the communication lines
maxOpacity: 0.002, // Maximum opacity (0-1) of the lines
curveRandomness: 0.8, // How random the curve paths are (0-1)
// Behavior settings
commProbabilityBase: 0.0017, // Base probability of starting a communication
commProbabilityMult: 0.0016, // Multiplier for time-based probability increase
minDuration: 0.3, // Minimum duration of a communication in seconds
maxDuration: 1.0, // Maximum duration of a communication in seconds
// Data packet settings
packetMinCount: 2, // Minimum number of packets per communication
packetMaxCount: 3, // Maximum number of packets per communication
packetSize: 3, // Base size of the data packets
packetPulseSpeed: 0.03, // Speed of the packet pulse animation
packetOpacityMult: 0.2 // Opacity multiplier for packets (relative to line opacity)
};
// Add this at the top of your file, outside any functions
const communicationConfig = {
// Communication frequency controls
communicationFrequency: 1, // Base probability (0-1) of starting a new communication each frame
minCommunicationInterval: 500, // Minimum time (ms) between communications for a single particle
maxConcurrentCommunications: 30, // Maximum number of particles communicating at once
communicationDuration: 1500, // Duration (ms) of each communication
// Direction controls
incomingChance: 0.6,
// Core path settings
lineWidth: 1.5, // Width of the main communication path
maxOpacity: 0.7, // Maximum opacity of the path and particles
// Control point settings
curveVariationStrength: 0.3, // How much the control points can deviate (0-1)
curveAnimationSpeed: 0.0011, // Speed of organic movement (lower = slower)
// Packet/particle settings
minPackets: 1, // Minimum number of packets along the path
maxPackets: 3, // Maximum number of packets along the path
packetSizeBase: 3, // Base size of the packets
packetPulseStrength: 0.3, // How much the packets pulse in size (0-1)
packetPulseSpeed: 2, // Speed of packet pulsing
packetGlowSize: 1.5, // Size of outer glow relative to packet (1 = no glow)
packetGlowOpacity: 0.3, // Opacity of the outer glow
// Ambient particles settings
ambientParticleChance: 0.3, // Probability (0-1) of spawning ambient particles
ambientParticleSize: 0.8, // Base size of ambient particles
ambientParticleVariation: 0.8,// Size variation of ambient particles
ambientParticleOpacity: 0.15, // Opacity of ambient particles
ambientParticleDrift: 12, // How far ambient particles can drift from the path
// Color settings
outgoingColor: '#ff00aa', // Base color for outgoing communication
outgoingColorSoft: '#ff45b8', // Softer variant for particles
incomingColor: '#00ccff', // Base color for incoming communication
incomingColorSoft: '#45cfff', // Softer variant for particles
colorVariationAmount: 8, // How much the color can vary (in hue degrees)
colorVariationSpeed: 0.5 // Speed of color variation
};
// Add this to your global configuration section (near where you have communicationConfig)
const brightCoreConfig = {
// Size parameters
innerRadius: 5, // Inner solid core radius in pixels
outerRadius: 20, // Outer glow radius in pixels
pulseEnabled: true, // Whether the core should pulse
pulseAmount: 4, // How much the size pulses (pixels)
pulseSpeed: 0.005, // Speed of pulsing animation
// Color parameters
centerColor: { // Color at the very center
r: 255,
g: 255,
b: 255
},
midColor: { // Color between center and edge
r: 240,
g: 240,
b: 255
},
edgeColor: { // Color at the edge of the glow
r: 180,
g: 200,
b: 255
},
// Opacity parameters
centerOpacity: 0.30, // Opacity at the very center
midOpacity: 0.10, // Opacity at the middle point
edgeOpacity: 0.00, // Opacity at the edge
// Blending parameters
blendMode: 'lighter', // 'source-over', 'lighter', 'screen', etc.
// Animation parameters
colorCycleEnabled: true, // Whether the color should cycle
colorCycleSpeed: 0.02, // Speed of color cycling
colorCycleAmount: 20 // How much the color changes during cycling
};
// Animation state
let lastTime = 0;
let mouseX = window.innerWidth / 2;
let mouseY = window.innerHeight / 2;
let mouseInCanvas = false;
// Star field
const starfield = [];
function createStarfield() {
starfield.length = 0;
for (let i = 0; i < 200; i++) {
starfield.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
baseSize: (Math.random() * 2.5 + 0.5) * 0.2, // 20% of original size
baseOpacity: Math.random() * 0.6 + 0.3,
pulseSpeed: 0.0005 + Math.random() * 0.001,
pulsePhase: Math.random() * Math.PI * 2,
pulseAmount: 0.2 + Math.random() * 0.3
});
}
}
createStarfield();
// Core AI entity
const core = {
x: window.innerWidth * (3/5), // 2/3 of the width from the left (1/3 from the right)
y: window.innerHeight / 2, // Keeping the same height (center)
radius: 40,
pulseSpeed: 0.0042,
pulseAmount: 5,
colorPhase: 0,
colorSpeed: 0.0028,
lastX: 0,
lastY: 0,
isMouseOver: false,
textDisplay: "", // Current word being displayed
words: ["I", "am", "Ai"], // Words to display in sequence
wordIndex: 0, // Current word in the sequence
charIndex: 0, // Current character being displayed
currentChar: "", // Current character animation
charProgress: 0, // Progress of current character animation
textFadeIn: 0,
textDisplaying: false,
textDisplayDuration: 0,
textAnimationSpeed: 0.02, // Increased by 40% to speed up first letter
typingDelay: 13, // Delay between characters
typingTimer: 0,
cursorVisible: true,
cursorBlinkRate: 0.03 * 0.2, // Reduced by 80% to slow down blinking
mode: "idle", // idle, ai, hi, bye
textPulsePhase: Math.random() * Math.PI * 2, // Random starting phase for text pulsation
textPulseSpeed: 0.002, // Speed of text pulsation
// Click reaction properties
clickReaction: false,
clickReactionTime: 0,
clickReactionDuration: 0.6, // Duration in seconds
clickReactionIntensity: 0,
gradients: {
outer: null,
core: null,
soft: null
},
hasInteracted: false, // NEW: Track if AI has been interacted with
textOpacity: 0.65, // NEW: Control for text opacity, default 1 (fully opaque)
shadowOpacity: 0.35, // NEW: Control for text opacity, default 1 (fully opaque)
wordFontSizes: { // NEW: Control for individual word sizes (multipliers)
"I": 0.8, // Slightly smaller "I"
"am": 0.6,
"Ai": 0.8, // Larger "Ai"
"bye": 0.5,
"Hi": 0.9
},
update(deltaTime) {
this.colorPhase += this.colorSpeed * deltaTime;
this.textPulsePhase += this.textPulseSpeed * deltaTime;
// Apply vertical offset to mouse position for better text visibility
const mouseOffsetY = 30; // 40 pixel vertical offset
let targetX = mouseInCanvas ? mouseX : window.innerWidth * (3/5); // 2/3 of the width from the left (1/3 from the right)
let targetY = mouseInCanvas ? mouseY - mouseOffsetY : window.innerHeight / 2; // Center height
const moveSpeed = 0.005 * deltaTime;
this.x += (targetX - this.x) * moveSpeed;
this.y += (targetY - this.y) * moveSpeed;
// Update click reaction effect
if (this.clickReaction) {
this.clickReactionTime += deltaTime * 0.016; // Convert to seconds
if (this.clickReactionTime < this.clickReactionDuration) {
// Create a smooth animation curve that starts fast and slows down
const progress = this.clickReactionTime / this.clickReactionDuration;
this.clickReactionIntensity = Math.sin(progress * Math.PI) * (1 - progress);
} else {
this.clickReaction = false;
this.clickReactionTime = 0;
this.clickReactionIntensity = 0;
}
}
// Check if mouse is over the core
const distToMouse = Math.sqrt(
Math.pow(mouseX - this.x, 2) +
Math.pow(mouseY - this.y, 2)
);
const wasMouseOver = this.isMouseOver;
this.isMouseOver = distToMouse < this.radius && mouseInCanvas;
// Cursor blinking
this.cursorVisible = Math.sin(Date.now() * this.cursorBlinkRate) > 0;
// ---- State Management ----
// If we're in idle mode and mouse enters, start the word sequence
if (this.mode === "idle" && this.isMouseOver && !wasMouseOver) {
this.mode = "ai";
this.wordIndex = 0; // Track which word we're on
this.showNextWord();
this.hasInteracted = true; // Set hasInteracted on first hover
}
// Update text animation based on current mode
if (this.textDisplaying) {
if (this.charIndex < this.textDisplay.length) {
this.textFadeIn += 0.05 * deltaTime;
if (this.textFadeIn > 1) this.textFadeIn = 1;
// Typing animation for current character
if (this.charProgress < 1) {
this.charProgress += this.textAnimationSpeed * deltaTime;
if (this.charProgress >= 1) {
this.charProgress = 0;
this.currentChar = this.textDisplay[this.charIndex];
this.charIndex++;
this.typingTimer = this.typingDelay;
}
} else if (this.typingTimer > 0) {
this.typingTimer -= deltaTime;
}
} else {
this.textDisplayDuration += deltaTime * 0.016;
// Word sequence - after displaying a word
if (this.textDisplayDuration > 1.5 && this.mode === "ai" && this.wordIndex < this.words.length - 1) {
// Move to next word in sequence
this.wordIndex++;
this.showNextWord();
} else if (this.textDisplayDuration > 3) { // Regular display period
this.textFadeIn -= 0.02 * deltaTime;
if (this.textFadeIn <= 0) {
this.textFadeIn = 0;
this.textDisplaying = false;
// Return to idle mode after "Hi" is done
if (this.mode === "hi") {
this.mode = "idle";
this.wordIndex = 0;
}
// Reset to idle after completing the "Ai" sequence too
else if (this.mode === "ai" && this.wordIndex >= this.words.length - 1) {
this.mode = "idle";
this.wordIndex = 0;
}
// After "Bye" is done, also return to idle and RESET interaction flag
else if (this.mode === "bye") {
this.mode = "idle";
this.hasInteracted = false; // NEW: Reset hasInteracted here
}
}
}
}
} else if (this.mode === "idle" && this.isMouseOver) {
// Restart sequence if mouse is still over after completion
this.mode = "ai";
this.wordIndex = 0;
this.showNextWord();
this.hasInteracted = true; // Ensure hasInteracted is set here as well (though should already be true)
}
// If mouse leaves canvas, switch to 'bye' mode (if not already displaying text)
else if (this.mode === "idle" && !mouseInCanvas && !this.textDisplaying && this.hasInteracted) { // NEW: Check this.hasInteracted
this.mode = "bye";
this.showNextWord(); // Show "Bye" text
}
},
// Helper method to start text animation
startTextAnimation() {
this.textDisplaying = true;
this.charIndex = 0;
this.currentChar = "";
this.charProgress = 0;
this.textFadeIn = 0;
this.textDisplayDuration = 0;
this.typingTimer = 0;
},
// Helper to show the next word in sequence
showNextWord() {
// Reset any existing animation state
this.textDisplaying = true;
this.charIndex = 0;
this.currentChar = "";
this.charProgress = 0;
this.textFadeIn = 0;
this.textDisplayDuration = 0;
this.typingTimer = 0;
// Set current word based on mode and sequence
if (this.mode === "ai") {
this.textDisplay = this.words[this.wordIndex];
} else if (this.mode === "hi") {
this.textDisplay = "Hi";
} else if (this.mode === "bye") {
this.textDisplay = "Bye"; // **Changed "bye" to "Bye"**
}
},
draw() {
const pulse = Math.sin(Date.now() * this.pulseSpeed) * this.pulseAmount;
// Click reaction effect - temporarily increase pulse size and brightness
const clickPulseAdd = this.clickReactionIntensity * this.radius * 0.65;
const clickBrightnessBoost = this.clickReactionIntensity * 80; // Brightness boost factor
const r = Math.sin(this.colorPhase) * 60 + 195 + clickBrightnessBoost;
const g = Math.sin(this.colorPhase + 2) * 100 + 100 + clickBrightnessBoost * 0.7;
const b = Math.sin(this.colorPhase + 4) * 30 + 225 + clickBrightnessBoost * 0.5;
// Create new gradients
// Outer glow gradient
const glowRadius = this.radius * 3;
const outerGlow = ctx.createRadialGradient(
this.x, this.y, this.radius * 0.9,
this.x, this.y, glowRadius
);
outerGlow.addColorStop(0, `rgba(${r}, ${g}, ${b}, 0.5)`);
outerGlow.addColorStop(0.3, `rgba(${r}, ${g}, ${b}, 0.35)`);
outerGlow.addColorStop(0.6, `rgba(${r}, ${g}, ${b}, 0.15)`);
outerGlow.addColorStop(0.8, `rgba(${r}, ${g}, ${b}, 0.05)`);
outerGlow.addColorStop(1, 'rgba(0, 0, 0, 0)');
// Core gradient
const coreGrad = ctx.createRadialGradient(
this.x - this.radius * 0.3, this.y - this.radius * 0.3, this.radius * 0.1,
this.x, this.y, this.radius * 1.2 + pulse
);
const opacityFactor = 0.88;
coreGrad.addColorStop(0, `rgba(${Math.min(255, r + 40)}, ${Math.min(255, g + 40)}, ${Math.min(255, b + 40)}, ${0.9 * opacityFactor})`);
coreGrad.addColorStop(0.3, `rgba(${Math.min(255, r + 20)}, ${Math.min(255, g + 20)}, ${Math.min(255, b + 20)}, ${0.85 * opacityFactor})`);
coreGrad.addColorStop(0.5, `rgba(${r}, ${g}, ${b}, ${0.8 * opacityFactor})`);
coreGrad.addColorStop(0.8, `rgba(${Math.max(0, r - 30)}, ${Math.max(0, g - 30)}, ${Math.max(0, b - 30)}, ${0.75 * opacityFactor})`);
coreGrad.addColorStop(1, `rgba(${Math.max(0, r - 60)}, ${Math.max(0, g - 60)}, ${Math.max(0, b - 60)}, ${0.7 * opacityFactor})`);
// Soft glow gradient
const softGlowRadius = this.radius * 1.5;
const softGlow = ctx.createRadialGradient(
this.x, this.y, this.radius * 0.5,
this.x, this.y, softGlowRadius
);
softGlow.addColorStop(0, `rgba(${Math.min(255, r + 30)}, ${Math.min(255, g + 30)}, ${Math.min(255, b + 30)}, 0.15)`);
softGlow.addColorStop(0.5, `rgba(${Math.min(255, r + 20)}, ${Math.min(255, g + 20)}, ${Math.min(255, b + 20)}, 0.08)`);
softGlow.addColorStop(1, 'rgba(0, 0, 0, 0)');
// Draw outer glow
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius * 3, 0, Math.PI * 2);
ctx.fillStyle = outerGlow;
ctx.fill();
// Draw core with hover effect
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius + pulse, 0, Math.PI * 2);
ctx.fillStyle = coreGrad;
ctx.fill();
// Add highlight
ctx.beginPath();
const highlightSize = (this.radius + pulse) * 0.6;
const offsetX = this.x - (this.radius + pulse) * 0.2;
const offsetY = this.y - (this.radius + pulse) * 0.2;
ctx.arc(offsetX, offsetY, highlightSize, 0, Math.PI * 2);
const highlightGradient = ctx.createRadialGradient(
offsetX, offsetY, 0,
offsetX, offsetY, highlightSize
);
highlightGradient.addColorStop(0, `rgba(255, 255, 255, 0.15)`);
highlightGradient.addColorStop(0.5, `rgba(255, 255, 255, 0.05)`);
highlightGradient.addColorStop(1, `rgba(255, 255, 255, 0)`);
ctx.fillStyle = highlightGradient;
ctx.fill();
// Add this code inside the core.draw() method,
// right after the "Add highlight" section and before "Soft glow with blending" section
// Add configurable bright center core
ctx.save(); // Save the current context state
// Apply blend mode if specified
if (brightCoreConfig.blendMode) {
ctx.globalCompositeOperation = brightCoreConfig.blendMode;
}
// Calculate pulse effect if enabled
let pulseEffect = 0;
if (brightCoreConfig.pulseEnabled) {
pulseEffect = Math.sin(Date.now() * brightCoreConfig.pulseSpeed) * brightCoreConfig.pulseAmount;
}
// Calculate color cycling if enabled
let colorShift = {r: 0, g: 0, b: 0};
if (brightCoreConfig.colorCycleEnabled) {
const cyclePhase = Date.now() * brightCoreConfig.colorCycleSpeed;
colorShift.r = Math.sin(cyclePhase) * brightCoreConfig.colorCycleAmount;
colorShift.g = Math.sin(cyclePhase + 2) * brightCoreConfig.colorCycleAmount;
colorShift.b = Math.sin(cyclePhase + 4) * brightCoreConfig.colorCycleAmount;
}
// Draw the bright core
ctx.beginPath();
ctx.arc(this.x, this.y, brightCoreConfig.outerRadius + pulseEffect, 0, Math.PI * 2);
const brightCoreGradient = ctx.createRadialGradient(
this.x, this.y, 0,
this.x, this.y, brightCoreConfig.outerRadius + pulseEffect
);
// Apply colors with any cycling effect
const centerColor = `rgba(
${Math.min(255, Math.max(0, brightCoreConfig.centerColor.r + colorShift.r))},
${Math.min(255, Math.max(0, brightCoreConfig.centerColor.g + colorShift.g))},
${Math.min(255, Math.max(0, brightCoreConfig.centerColor.b + colorShift.b))},
${brightCoreConfig.centerOpacity})`;
const midColor = `rgba(
${Math.min(255, Math.max(0, brightCoreConfig.midColor.r + colorShift.r))},
${Math.min(255, Math.max(0, brightCoreConfig.midColor.g + colorShift.g))},
${Math.min(255, Math.max(0, brightCoreConfig.midColor.b + colorShift.b))},
${brightCoreConfig.midOpacity})`;
const edgeColor = `rgba(
${Math.min(255, Math.max(0, brightCoreConfig.edgeColor.r + colorShift.r))},
${Math.min(255, Math.max(0, brightCoreConfig.edgeColor.g + colorShift.g))},
${Math.min(255, Math.max(0, brightCoreConfig.edgeColor.b + colorShift.b))},
${brightCoreConfig.edgeOpacity})`;
// Create three-point gradient for smoother appearance
const innerStop = brightCoreConfig.innerRadius / brightCoreConfig.outerRadius;
brightCoreGradient.addColorStop(0, centerColor);
brightCoreGradient.addColorStop(innerStop, midColor);
brightCoreGradient.addColorStop(1, edgeColor);
ctx.fillStyle = brightCoreGradient;
ctx.fill();
ctx.restore(); // Restore the context state
// Soft glow with blending
ctx.globalCompositeOperation = 'lighter';
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius * 1.5, 0, Math.PI * 2);
ctx.fillStyle = softGlow;
ctx.fill();
// Outer ring
// ctx.beginPath();
// ctx.arc(this.x, this.y, this.radius * 2.2, 0, Math.PI * 2);
// ctx.lineWidth = 0.5;
// ctx.strokeStyle = `rgba(${Math.min(255, r + 30)}, ${Math.min(255, g + 30)}, ${Math.min(255, b + 30)}, 0.0)`;
// ctx.stroke();
// Add hover effect when mouse is over
if (this.isMouseOver) {
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius + pulse, 0, Math.PI * 2);
ctx.fillStyle = softGlow;
ctx.fill();
// Change cursor to pointer
canvas.style.cursor = 'pointer';
} else {
canvas.style.cursor = 'default';
}
ctx.globalCompositeOperation = 'source-over';
// Draw text when mouse is over or text is displaying
if (this.textDisplaying) {
// Set text properties but don't use center alignment
ctx.textBaseline = 'middle';
const currentWordFontSizeMultiplier = this.wordFontSizes[this.textDisplay] || 0.7;
const fontSize = this.radius * currentWordFontSizeMultiplier;
ctx.font = `bold ${fontSize}px Merriweather`;
// Calculate text positioning
let displayText = "";
for (let i = 0; i < this.charIndex; i++) {
displayText += this.textDisplay[i];
}
const fullTextWidth = ctx.measureText(this.textDisplay).width;
const currentTextWidth = ctx.measureText(displayText).width;
const leftShift = this.textDisplay === "Ai" || this.textDisplay === "Hi" ? -this.radius * 0.04 : this.radius * 0.01;
const textStartX = this.x - fullTextWidth / 2 + leftShift;
const textY = this.y + fontSize * 0.06;
// Save context state
ctx.save();
// First shadow (red with offset)
ctx.save();
ctx.shadowOffsetX = 1;
ctx.shadowOffsetY = 1;
ctx.shadowBlur = 2;
ctx.shadowColor = 'red';
ctx.fillStyle = `rgba(255, 254, 173, ${this.textFadeIn * this.shadowOpacity})`;
ctx.fillText(displayText, textStartX, textY);
ctx.restore();
// Second shadow (blue glow 1em)
ctx.save();
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
ctx.shadowBlur = 13; // ~1em
ctx.shadowColor = 'blue';
ctx.fillStyle = `rgba(251, 244, 207, ${this.textFadeIn * this.shadowOpacity})`;
ctx.fillText(displayText, textStartX, textY);
ctx.restore();
// Add this after the two existing shadow blocks
// Main text (no shadow)
ctx.save();
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
ctx.shadowBlur = 0;
ctx.fillStyle = `rgba(250, 250, 250, ${this.textFadeIn * this.textOpacity})`;
ctx.fillText(displayText, textStartX, textY);
ctx.restore();
// Add blinking cursor
if (this.cursorVisible && this.charIndex < this.textDisplay.length) {
const cursorX = textStartX + currentTextWidth + 2;
// Save current context state
ctx.save();
// Need to redraw with second shadow
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
ctx.shadowBlur = 13;
ctx.shadowColor = 'blue';
ctx.fillStyle = "rgba(251, 244, 207, 0.8)";
ctx.fillRect(cursorX, this.y - fontSize/3, 3, fontSize/1.5);
// Main fill (no shadow)
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
ctx.shadowBlur = 0;
ctx.fillStyle = "rgba(250, 250, 250, 0.8)";
ctx.fillRect(cursorX, this.y - fontSize/3, 3, fontSize/1.5);
}
ctx.restore();
}
}
};
// Orbital rings
const rings = [];
function createRings() {
rings.length = 0;
for (let i = 0; i < 5; i++) {
rings.push({
radius: 90 + i * 30,
rotation: Math.random() * Math.PI * 2,
rotationSpeed: 0.001 + Math.random() * 0.002,
color: colorValues[Math.floor(Math.random() * colorValues.length)],
opacity: 0.3 - i * 0.03,
tiltValue: Math.random() * Math.PI * 2,
wobble: 0.6 + Math.random() * 0.3,
wobbleSpeed: 0.001 + Math.random() * 0.001,
wobblePhase: Math.random() * Math.PI * 3,
update(deltaTime) {
this.rotation += this.rotationSpeed * deltaTime;
this.wobblePhase += this.wobbleSpeed * deltaTime * 0.5;
},
draw() {
const wobbleAmount = Math.sin(Date.now() * this.wobbleSpeed + this.wobblePhase) * this.wobble;
ctx.save();
ctx.translate(core.x, core.y);
ctx.rotate(this.rotation);
const dynamicTilt = this.tiltValue + wobbleAmount;
const tiltX = Math.cos(dynamicTilt + this.rotation * 2.3);
const tiltY = Math.sin(dynamicTilt + this.rotation * 1.9);
ctx.transform(
tiltX, 0,
0, tiltY,
0, 0
);
const { r, g, b } = this.color;
const brightnessFactor = 0.7 + 0.3 * Math.abs(Math.sin(this.rotation * 2));
ctx.beginPath();
ctx.arc(0, 0, this.radius, 0, Math.PI * 2);
ctx.lineCap = 'round';
ctx.lineWidth = 2 * Math.abs(tiltY);
ctx.strokeStyle = `rgba(${r}, ${g}, ${b}, ${this.opacity * brightnessFactor})`;
ctx.stroke();
if (Math.abs(tiltY) > 0.7) {
ctx.beginPath();
ctx.arc(0, 0, this.radius * 0.98, 0, Math.PI * 2);
ctx.lineWidth = 0.5;
ctx.strokeStyle = `rgba(${Math.min(255, r + 50)}, ${Math.min(255, g + 50)}, ${Math.min(255, b + 50)}, ${this.opacity * 0.7})`;
ctx.stroke();
}
ctx.restore();
}
});
}
}
createRings();
// Particles
const particles = [];
const particleBatches = {};
function createParticles() {
particles.length = 0;
for (let i = 0; i < 70; i++) {
const phi = Math.acos(2 * Math.random() - 1);
const theta = Math.random() * Math.PI * 2;
const distance = 80 + Math.random() * 200;
const colorIndex = Math.floor(Math.random() * colorValues.length);
particles.push({
orbitData: {
distance: distance,
theta: theta,
phi: phi,
tilt: Math.random() * Math.PI,
phase: Math.random() * Math.PI * 2,
speed: 0.005 + Math.random() * 0.01,
amplitude: 5 + Math.random() * 10,
oscPhase: Math.random() * Math.PI * 2
},
x: core.x,
y: core.y,
z: 0,
size: 2 + Math.random() * 3,
colorIndex: colorIndex,
batchKey: colorIndex,
communicating: false,
communicationTimer: 0,
communicationDuration: 0,
communicationDirection: null,
lastCommunicationTime: -10000,
update(deltaTime) {
this.orbitData.phase += this.orbitData.speed * deltaTime;
const orbitX = Math.sin(this.orbitData.phase) * Math.cos(this.orbitData.tilt) * this.orbitData.distance;
const orbitY = Math.sin(this.orbitData.phase) * Math.sin(this.orbitData.tilt) * this.orbitData.distance;
const orbitZ = Math.cos(this.orbitData.phase) * this.orbitData.distance * 0.3;
const oscillationX = Math.sin(Date.now() * 0.0007 + this.orbitData.oscPhase) * this.orbitData.amplitude;
const oscillationY = Math.cos(Date.now() * 0.0005 + this.orbitData.oscPhase) * this.orbitData.amplitude;
const targetX = core.x + orbitX + oscillationX;
const targetY = core.y + orbitY + oscillationY;
const moveSpeed = 0.01 * deltaTime;
this.x += (targetX - this.x) * moveSpeed;
this.y += (targetY - this.y) * moveSpeed;
this.z = orbitZ;
// Communication logic
const now = Date.now();
const timeSinceLastComm = now - this.lastCommunicationTime;
const commProbability = Math.min(0.0013 * deltaTime, 0.0026 * deltaTime * (timeSinceLastComm / 3000));
if (!this.communicating && Math.random() < commProbability) {
this.communicating = true;
this.communicationTimer = 0;
this.communicationDuration = 1 + Math.random() * 2;
this.communicationDirection = Math.random() > 0.5 ? 'incoming' : 'outgoing';
this.lastCommunicationTime = now;
}
if (this.communicating) {
this.communicationTimer += 0.016 * deltaTime;
if (this.communicationTimer > this.communicationDuration) {
this.communicating = false;
}
}
},
addToBatch() {
if (!particleBatches[this.batchKey]) {
particleBatches[this.batchKey] = {
color: colorValues[this.colorIndex],
particles: []
};
}
const zFactor = (this.z + 200) / 400;
const displaySize = this.size * (0.5 + zFactor);
particleBatches[this.batchKey].particles.push({
x: this.x,
y: this.y,
size: displaySize,
zFactor: zFactor
});
},
// Replace your existing drawCommunication method with this one
drawCommunication() {
if (!this.communicating) return;
const config = communicationConfig; // Use the global config object
const progress = this.communicationTimer / this.communicationDuration;
const coreX = core.x;
const coreY = core.y;
let startX, startY, endX, endY;
if (this.communicationDirection === 'outgoing') {
startX = coreX;
startY = coreY;
endX = this.x;
endY = this.y;
} else {
startX = this.x;
startY = this.y;
endX = coreX;
endY = coreY;
}
const dx = endX - startX;
const dy = endY - startY;
const distance = Math.sqrt(dx*dx + dy*dy);
// Create more organic control points using sine wave variation
const now = Date.now() * config.curveAnimationSpeed;
// First control point - slow organic variation
const cpDist1 = distance * (0.2 + 0.15 * Math.sin(now));
const cpAngle1 = Math.atan2(dy, dx) + (Math.sin(now * 0.7) * config.curveVariationStrength);
const cp1x = startX + Math.cos(cpAngle1) * cpDist1;
const cp1y = startY + Math.sin(cpAngle1) * cpDist1;
// Second control point - different phase for natural asymmetry
const cpDist2 = distance * (0.7 + 0.15 * Math.sin(now * 0.8 + 2));
const cpAngle2 = Math.atan2(dy, dx) + (Math.sin(now * 0.9 + 1) * config.curveVariationStrength);
const cp2x = startX + Math.cos(cpAngle2) * cpDist2;
const cp2y = startY + Math.sin(cpAngle2) * cpDist2;
// Draw the main communication path
ctx.beginPath();
ctx.moveTo(startX, startY);
ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, endX, endY);
// Use subtle HSL colors for more natural glow
if (this.communicationDirection === 'outgoing') {
// Extract hue from outgoing color (simplified - you might want a more accurate conversion)
const r = parseInt(config.outgoingColor.slice(1, 3), 16);
const g = parseInt(config.outgoingColor.slice(3, 5), 16);
const b = parseInt(config.outgoingColor.slice(5, 7), 16);
const hsl = rgbToHsl(r, g, b);
const hue = hsl.h + Math.sin(now * config.colorVariationSpeed) * config.colorVariationAmount;
const sat = 100;
const light = 50 + Math.sin(now * 0.6) * 5;
ctx.strokeStyle = `hsl(${hue}, ${sat}%, ${light}%)`;
} else {
// Extract hue from incoming color
const r = parseInt(config.incomingColor.slice(1, 3), 16);
const g = parseInt(config.incomingColor.slice(3, 5), 16);
const b = parseInt(config.incomingColor.slice(5, 7), 16);
const hsl = rgbToHsl(r, g, b);
const hue = hsl.h + Math.sin(now * config.colorVariationSpeed) * config.colorVariationAmount;
const sat = 100;
const light = 50 + Math.sin(now * 0.6) * 5;
ctx.strokeStyle = `hsl(${hue}, ${sat}%, ${light}%)`;
}
// Opacity fades in and out with gentle easing
const opacity = (progress < 0.2 ? progress / 0.2 :
progress > 0.8 ? (1 - progress) / 0.2 :
1) * config.maxOpacity;
ctx.globalAlpha = opacity;
ctx.lineWidth = config.lineWidth;
ctx.stroke();
ctx.globalAlpha = 1;
// Calculate dynamic packet count based on config
const sinVal = Math.sin(now * 2) * 0.5 + 0.5; // 0-1 value
const packetCount = Math.floor(config.minPackets + sinVal * (config.maxPackets - config.minPackets));
for (let i = 0; i < packetCount; i++) {
// Space packets evenly but with slight variation
const baseOffset = i / packetCount;
const timeVariation = Math.sin(now * 3 + i * 2) * 0.05;
const packetOffset = baseOffset + timeVariation;
// Packet progress with subtle easing for more natural flow
const easedProgress = progress * (0.9 + Math.sin(now * 2 + i) * 0.1);
const packetProgress = (easedProgress + packetOffset) % 1;
if (packetProgress >= 0 && packetProgress <= 1) {
const t = packetProgress;
const t1 = 1 - t;
// Position along the curve
const px = t1*t1*t1*startX + 3*t1*t1*t*cp1x + 3*t1*t*t*cp2x + t*t*t*endX;
const py = t1*t1*t1*startY + 3*t1*t1*t*cp1y + 3*t1*t*t*cp2y + t*t*t*endY;
// Gentle organic pulsing
const packetPulse = 1 - config.packetPulseStrength +
Math.sin(now * config.packetPulseSpeed + i * 1.5) * config.packetPulseStrength;
const packetSize = config.packetSizeBase * packetPulse;
// Draw outer glow if configured
if (config.packetGlowSize > 1) {
ctx.beginPath();
ctx.arc(px, py, packetSize * config.packetGlowSize, 0, Math.PI * 2);
if (this.communicationDirection === 'outgoing') {
// Get RGB values from outgoing color
const r = parseInt(config.outgoingColor.slice(1, 3), 16);
const g = parseInt(config.outgoingColor.slice(3, 5), 16);
const b = parseInt(config.outgoingColor.slice(5, 7), 16);
ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${config.packetGlowOpacity})`;
} else {
// Get RGB values from incoming color
const r = parseInt(config.incomingColor.slice(1, 3), 16);
const g = parseInt(config.incomingColor.slice(3, 5), 16);
const b = parseInt(config.incomingColor.slice(5, 7), 16);
ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${config.packetGlowOpacity})`;
}
ctx.globalAlpha = opacity * 0.6;
ctx.fill();
}
// Draw inner core
ctx.beginPath();
ctx.arc(px, py, packetSize * 0.6, 0, Math.PI * 2);
if (this.communicationDirection === 'outgoing') {
ctx.fillStyle = config.outgoingColorSoft;
} else {
ctx.fillStyle = config.incomingColorSoft;
}
ctx.globalAlpha = opacity * 0.9;
ctx.fill();
ctx.globalAlpha = 1;
}
}
// Ambient particles with configurable chance
if (Math.random() < config.ambientParticleChance && progress > 0.2 && progress < 0.8) {
const driftX = (Math.random() * 2 - 1) * config.ambientParticleDrift;
const driftY = (Math.random() * 2 - 1) * config.ambientParticleDrift;
// Position along the curve (random)
const t = 0.3 + Math.random() * 0.4; // Mostly in the middle section
const t1 = 1 - t;
const ambientX = t1*t1*t1*startX + 3*t1*t1*t*cp1x + 3*t1*t*t*cp2x + t*t*t*endX + driftX;
const ambientY = t1*t1*t1*startY + 3*t1*t1*t*cp1y + 3*t1*t*t*cp2y + t*t*t*endY + driftY;
const ambientSize = config.ambientParticleSize + Math.random() * config.ambientParticleVariation;
ctx.beginPath();
ctx.arc(ambientX, ambientY, ambientSize, 0, Math.PI * 2);
if (this.communicationDirection === 'outgoing') {
// Get RGB values from outgoing color
const r = parseInt(config.outgoingColor.slice(1, 3), 16);