File size: 11,198 Bytes
626eae2 | 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 | // QuantumCortex Main JavaScript
document.addEventListener('DOMContentLoaded', function() {
// Initialize Feather Icons
if (typeof feather !== 'undefined') {
feather.replace();
}
// Initialize Neural Network Visualization
initNeuralVisualization();
// Initialize Energy Consumption Chart
initEnergyChart();
// Initialize Particle Interactions
initParticleInteractions();
// Initialize Quantum Animations
initQuantumAnimations();
// Initialize Mobile Menu
initMobileMenu();
});
function initNeuralVisualization() {
const canvas = document.getElementById('neuralCanvas');
if (!canvas) return;
const ctx = canvas.getContext('2d');
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
const nodes = [];
const connections = [];
const numNodes = 15;
// Create nodes
for (let i = 0; i < numNodes; i++) {
nodes.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
radius: 4 + Math.random() * 6,
speedX: (Math.random() - 0.5) * 0.5,
speedY: (Math.random() - 0.5) * 0.5,
color: i % 2 === 0 ? '#0ea5e9' : '#a855f7',
pulse: Math.random() * Math.PI * 2
});
}
// Create connections
for (let i = 0; i < nodes.length; i++) {
for (let j = i + 1; j < nodes.length; j++) {
if (Math.random() > 0.7) {
connections.push({
from: i,
to: j,
strength: Math.random()
});
}
}
}
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Update and draw connections
connections.forEach(conn => {
const from = nodes[conn.from];
const to = nodes[conn.to];
const distance = Math.sqrt(Math.pow(to.x - from.x, 2) + Math.pow(to.y - from.y, 2));
if (distance < 150) {
ctx.beginPath();
ctx.moveTo(from.x, from.y);
ctx.lineTo(to.x, to.y);
ctx.strokeStyle = `rgba(${conn.from % 2 === 0 ? '14, 165, 233' : '168, 85, 247'}, ${0.3 * conn.strength})`;
ctx.lineWidth = 1;
ctx.stroke();
}
});
// Update and draw nodes
nodes.forEach(node => {
// Update position with boundary check
node.x += node.speedX;
node.y += node.speedY;
if (node.x < 0 || node.x > canvas.width) node.speedX *= -1;
if (node.y < 0 || node.y > canvas.height) node.speedY *= -1;
// Keep within bounds
node.x = Math.max(0, Math.min(canvas.width, node.x));
node.y = Math.max(0, Math.min(canvas.height, node.y));
// Update pulse
node.pulse += 0.05;
// Draw node
ctx.beginPath();
ctx.arc(node.x, node.y, node.radius + Math.sin(node.pulse) * 2, 0, Math.PI * 2);
ctx.fillStyle = node.color;
ctx.fill();
// Draw glow
ctx.beginPath();
ctx.arc(node.x, node.y, node.radius + 5, 0, Math.PI * 2);
ctx.fillStyle = node.color + '20';
ctx.fill();
});
requestAnimationFrame(animate);
}
animate();
// Handle window resize
window.addEventListener('resize', () => {
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
});
}
function initEnergyChart() {
const canvas = document.getElementById('energyCanvas');
if (!canvas) return;
const ctx = canvas.getContext('2d');
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
const data = [];
const dataPoints = 50;
let time = 0;
// Generate initial data
for (let i = 0; i < dataPoints; i++) {
data.push({
x: i,
y: 20 + Math.sin(i * 0.3) * 15 + Math.random() * 5
});
}
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw grid
ctx.strokeStyle = 'rgba(255, 255, 255, 0.1)';
ctx.lineWidth = 1;
// Horizontal lines
for (let i = 0; i <= 5; i++) {
const y = (canvas.height / 5) * i;
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(canvas.width, y);
ctx.stroke();
}
// Update data
time += 0.1;
data.shift();
data.push({
x: dataPoints - 1,
y: 20 + Math.sin(time) * 15 + Math.cos(time * 0.7) * 10 + Math.random() * 3
});
// Update x positions
data.forEach((point, i) => {
point.x = i;
});
// Draw area
ctx.beginPath();
ctx.moveTo(0, canvas.height);
data.forEach(point => {
const x = (point.x / dataPoints) * canvas.width;
const y = canvas.height - (point.y / 50) * canvas.height;
ctx.lineTo(x, y);
});
ctx.lineTo(canvas.width, canvas.height);
ctx.closePath();
const gradient = ctx.createLinearGradient(0, 0, 0, canvas.height);
gradient.addColorStop(0, 'rgba(168, 85, 247, 0.3)');
gradient.addColorStop(1, 'rgba(168, 85, 247, 0)');
ctx.fillStyle = gradient;
ctx.fill();
// Draw line
ctx.beginPath();
ctx.moveTo(0, canvas.height - (data[0].y / 50) * canvas.height);
data.forEach(point => {
const x = (point.x / dataPoints) * canvas.width;
const y = canvas.height - (point.y / 50) * canvas.height;
ctx.lineTo(x, y);
});
ctx.strokeStyle = '#a855f7';
ctx.lineWidth = 2;
ctx.stroke();
requestAnimationFrame(draw);
}
draw();
// Handle window resize
window.addEventListener('resize', () => {
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
});
}
function initParticleInteractions() {
const particles = document.querySelectorAll('.particle');
particles.forEach(particle => {
particle.addEventListener('mouseenter', () => {
particle.style.transform = 'scale(1.5)';
particle.style.transition = 'transform 0.3s ease';
});
particle.addEventListener('mouseleave', () => {
particle.style.transform = 'scale(1)';
});
});
}
function initQuantumAnimations() {
// Add floating animation to quantum elements
const quantumElements = document.querySelectorAll('.quantum-float');
quantumElements.forEach((el, index) => {
el.style.animationDelay = `${index * 0.2}s`;
});
// Initialize intersection observer for scroll animations
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-in');
}
});
}, {
threshold: 0.1
});
// Observe elements with quantum-animate class
document.querySelectorAll('.quantum-animate').forEach(el => {
observer.observe(el);
});
}
function initMobileMenu() {
const menuButton = document.querySelector('[data-menu-button]');
const mobileMenu = document.querySelector('[data-mobile-menu]');
if (menuButton && mobileMenu) {
menuButton.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
menuButton.querySelector('i').setAttribute('data-feather',
mobileMenu.classList.contains('hidden') ? 'menu' : 'x'
);
feather.replace();
});
}
}
// Quantum API Integration
class QuantumCortexAPI {
constructor() {
this.baseURL = 'https://api.quantumcortex.dev/v1';
}
async getThoughtProcess() {
try {
// Simulate API call
return await this.simulateThought();
} catch (error) {
console.error('Quantum thought error:', error);
return null;
}
}
async simulateThought() {
return new Promise(resolve => {
setTimeout(() => {
resolve({
thought: "The universe computes itself through quantum entanglement",
energy: Math.random() * 100,
coherence: 0.85 + Math.random() * 0.15
});
}, 1000);
});
}
async getDeviceCompatibility(deviceType) {
const compatibilities = {
smartphone: 0.95,
quantum: 1.0,
wearable: 0.85,
cloud: 0.98,
iot: 0.75
};
return compatibilities[deviceType] || 0.8;
}
// New Vector Physics API
async getVectorField(zeroPoint = Math.PI) {
return new Promise(resolve => {
setTimeout(() => {
const vectors = [];
for (let i = 0; i < 360; i++) {
vectors.push({
angle: (i * Math.PI * 2) / 360,
magnitude: 1 + Math.random() * 0.5,
charge: i < 180 ? 1 : -1,
zeroPoint: zeroPoint
});
}
resolve({
zeroPoint,
vectors,
gyroscopicConstant: Math.PI,
stability: 0.85 + Math.random() * 0.15
});
}, 800);
});
}
async solveThreeBody(pulsarCount = 2) {
return new Promise(resolve => {
setTimeout(() => {
resolve({
solution: "Stable orbit achieved via π‑gyroscopic damping",
pulsars: pulsarCount,
convergenceTime: (3 + Math.random() * 5).toFixed(2) + "s",
energyEfficiency: (0.7 + Math.random() * 0.25).toFixed(3)
});
}, 1200);
});
}
}
// Export for use in other modules
window.QuantumCortex = {
API: new QuantumCortexAPI(),
utils: {
formatEnergy: (energy) => `${energy.toFixed(2)} qubits`,
formatCoherence: (coherence) => `${(coherence * 100).toFixed(1)}%`,
vectorToCartesian: (angle, magnitude) => ({
x: magnitude * Math.cos(angle),
y: magnitude * Math.sin(angle)
}),
calculateGyroscopicForce: (mass, angularVelocity) => {
return mass * angularVelocity * Math.PI;
}
}
};
// Initialize Quantum API
const quantumAPI = new QuantumCortexAPI();
// Example usage
quantumAPI.getThoughtProcess().then(thought => {
if (thought) {
console.log('Quantum thought received:', thought);
}
}); |