-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
176 lines (148 loc) · 6.48 KB
/
Copy pathscript.js
File metadata and controls
176 lines (148 loc) · 6.48 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
/**
* ==========================================================================
* Priyanraj J | Interactive Mainframe Script Engine Core
* Architecture: Optimized Vanishing Vector Arrays & Performance Node Clusters
* ==========================================================================
*/
"use strict";
document.addEventListener('DOMContentLoaded', () => {
// --- 01. HARDWARE-ACCELERATED HTML5 CANVASES NEURAL ENGINE ---
const canvas = document.getElementById('cyberCanvas');
const ctx = canvas.getContext('2d', { alpha: false }); // Disable transparency layer for memory optimization
let nodeArray = [];
let animationFrameId = null;
const maxConnectionDistance = 140;
const targetNodeDensityCount = 60;
// Viewport Scaler Configuration Mapping
function fitEngineViewportBounds() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
// Low-overhead debouncer rule matching resize events
let resizeDebounceTimeout;
window.addEventListener('resize', () => {
clearTimeout(resizeDebounceTimeout);
resizeDebounceTimeout = setTimeout(() => {
fitEngineViewportBounds();
rebootNeuralClusterGrid();
}, 150);
});
fitEngineViewportBounds();
// Data-Structure Model Tracking Physics Properties
class MainframeNode {
constructor() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.radius = Math.random() * 1.2 + 0.5;
this.vx = (Math.random() - 0.5) * 0.35;
this.vy = (Math.random() - 0.5) * 0.35;
}
computePhysicsVector() {
this.x += this.vx;
this.y += this.vy;
// Boundary Collisions Check Logic Loop
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
}
renderNodeDot() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
ctx.fillStyle = 'rgba(88, 166, 255, 0.25)';
ctx.fill();
}
}
function rebootNeuralClusterGrid() {
nodeArray = [];
for (let i = 0; i < targetNodeDensityCount; i++) {
nodeArray.push(new MainframeNode());
}
}
function traceNeuralIntersections() {
const nodesCount = nodeArray.length;
const maxDistSq = maxConnectionDistance * maxConnectionDistance;
for (let a = 0; a < nodesCount; a++) {
const nodeA = nodeArray[a];
for (let b = a + 1; b < nodesCount; b++) {
const nodeB = nodeArray[b];
// Fast distance approximation checking before Math.sqrt execution
const dx = nodeA.x - nodeB.x;
const dy = nodeA.y - nodeB.y;
const distSq = (dx * dx) + (dy * dy);
if (distSq < maxDistSq) {
const linearAlpha = 1 - (Math.sqrt(distSq) / maxConnectionDistance);
ctx.strokeStyle = `rgba(33, 38, 45, ${linearAlpha * 0.55})`;
ctx.lineWidth = 0.8;
ctx.beginPath();
ctx.moveTo(nodeA.x, nodeA.y);
ctx.lineTo(nodeB.x, nodeB.y);
ctx.stroke();
}
}
}
}
function coreRenderEngineLoop() {
ctx.fillStyle = '#05070a'; // Matches your precise CSS background hex token
ctx.fillRect(0, 0, canvas.width, canvas.height);
const nodesCount = nodeArray.length;
for (let i = 0; i < nodesCount; i++) {
nodeArray[i].computePhysicsVector();
nodeArray[i].renderNodeDot();
}
traceNeuralIntersections();
animationFrameId = requestAnimationFrame(coreRenderEngineLoop);
}
rebootNeuralClusterGrid();
coreRenderEngineLoop();
// --- 02. FLUID POINTER GLOW INTERACTIVE TRACKER ---
const mouseGlowElement = document.getElementById('mouseGlow');
window.addEventListener('mousemove', (e) => {
mouseGlowElement.style.left = `${e.clientX}px`;
mouseGlowElement.style.top = `${e.clientY}px`;
}, { passive: true }); // Passivity optimization flags for frame performance
// --- 03. HIGH-FIDELITY MATRIX LOG TYPEWRITER ENGINE ---
const typewriterTargetField = document.getElementById('typewriterText');
const logDataStringsArray = [
"AI & Data Science Enthusiast | Builder | Researcher",
"Initializing secure mainframe node dependencies...",
"Current Status: Active Member // System Integrity: Nominal"
];
let activeStringIndex = 0;
let currentCharacterIndex = 0;
let isDeletingStateActive = false;
function executeTypewriterLifecycleLoop() {
const fullStringText = logDataStringsArray[activeStringIndex];
if (!isDeletingStateActive) {
typewriterTargetField.textContent = fullStringText.substring(0, currentCharacterIndex + 1);
currentCharacterIndex++;
if (currentCharacterIndex === fullStringText.length) {
isDeletingStateActive = true;
setTimeout(executeTypewriterLifecycleLoop, 2000); // Terminal visual dwell delay
} else {
setTimeout(executeTypewriterLifecycleLoop, 50);
}
} else {
typewriterTargetField.textContent = fullStringText.substring(0, currentCharacterIndex - 1);
currentCharacterIndex--;
if (currentCharacterIndex === 0) {
isDeletingStateActive = false;
activeStringIndex = (activeStringIndex + 1) % logDataStringsArray.length;
setTimeout(executeTypewriterLifecycleLoop, 400); // Transition buffer delay
} else {
setTimeout(executeTypewriterLifecycleLoop, 25);
}
}
}
setTimeout(executeTypewriterLifecycleLoop, 800);
// --- 04. HIGH-PERFORMANCE INTERSECTION OBSERVER SCROLL REVEALS ---
const revealNodeTargetsList = document.querySelectorAll('.reveal-node');
const viewportScrollObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('active-reveal');
}
});
}, { threshold: 0.05 });
revealNodeTargetsList.forEach(targetNode => {
viewportScrollObserver.observe(targetNode);
});
});