Add 1 files
Browse files- index.html +31 -16
index.html
CHANGED
|
@@ -329,7 +329,7 @@
|
|
| 329 |
</h2>
|
| 330 |
<div class="space-time h-64 rounded-lg relative" id="gravityCanvas">
|
| 331 |
<div class="gravity-well w-20 h-20 absolute" id="centralMass" style="bottom: 50%; left: 50%; transform: translate(-50%, 50%);"></div>
|
| 332 |
-
<div class="particle w-3 h-3 absolute" id="orbitingObject" style="bottom: 30%; left: 50%;"></div>
|
| 333 |
<div class="absolute bottom-4 left-0 right-0 flex justify-center">
|
| 334 |
<button id="startOrbit" class="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-lg text-sm">
|
| 335 |
<i class="fas fa-play mr-1"></i> Start Orbit
|
|
@@ -494,32 +494,54 @@
|
|
| 494 |
const speed = parseInt(document.getElementById('orbitSpeed').value);
|
| 495 |
const centralMass = document.getElementById('centralMass');
|
| 496 |
|
|
|
|
| 497 |
centralMass.style.width = `${massSize}px`;
|
| 498 |
centralMass.style.height = `${massSize}px`;
|
| 499 |
|
|
|
|
| 500 |
orbitingObject.style.transition = 'none';
|
|
|
|
|
|
|
| 501 |
orbitingObject.style.transform = 'translate(-50%, 50%)';
|
| 502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 503 |
let angle = 0;
|
| 504 |
-
const radius = 80;
|
| 505 |
-
const centerX = 50;
|
| 506 |
-
const centerY = 50;
|
| 507 |
|
|
|
|
| 508 |
function animateOrbit() {
|
| 509 |
angle += 0.02 * speed;
|
| 510 |
-
const x = centerX +
|
| 511 |
-
const y = centerY +
|
| 512 |
|
| 513 |
orbitingObject.style.left = `${x}%`;
|
| 514 |
orbitingObject.style.bottom = `${y}%`;
|
| 515 |
|
| 516 |
-
|
|
|
|
| 517 |
}
|
| 518 |
|
| 519 |
-
|
|
|
|
| 520 |
|
|
|
|
| 521 |
this.disabled = true;
|
| 522 |
this.innerHTML = '<i class="fas fa-sync-alt mr-1"></i> Orbiting';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 523 |
});
|
| 524 |
|
| 525 |
// Time Dilation Calculator
|
|
@@ -552,13 +574,6 @@
|
|
| 552 |
document.getElementById('observerTime').textContent = `${observerTime} sec`;
|
| 553 |
document.getElementById('dilationResult').classList.remove('hidden');
|
| 554 |
});
|
| 555 |
-
|
| 556 |
-
// Update mass size display
|
| 557 |
-
document.getElementById('massSize').addEventListener('input', function() {
|
| 558 |
-
const size = this.value;
|
| 559 |
-
document.getElementById('centralMass').style.width = `${size}px`;
|
| 560 |
-
document.getElementById('centralMass').style.height = `${size}px`;
|
| 561 |
-
});
|
| 562 |
</script>
|
| 563 |
-
|
| 564 |
</html>
|
|
|
|
| 329 |
</h2>
|
| 330 |
<div class="space-time h-64 rounded-lg relative" id="gravityCanvas">
|
| 331 |
<div class="gravity-well w-20 h-20 absolute" id="centralMass" style="bottom: 50%; left: 50%; transform: translate(-50%, 50%);"></div>
|
| 332 |
+
<div class="particle w-3 h-3 absolute" id="orbitingObject" style="bottom: 30%; left: 50%; transform: translate(-50%, 50%);"></div>
|
| 333 |
<div class="absolute bottom-4 left-0 right-0 flex justify-center">
|
| 334 |
<button id="startOrbit" class="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-lg text-sm">
|
| 335 |
<i class="fas fa-play mr-1"></i> Start Orbit
|
|
|
|
| 494 |
const speed = parseInt(document.getElementById('orbitSpeed').value);
|
| 495 |
const centralMass = document.getElementById('centralMass');
|
| 496 |
|
| 497 |
+
// Update central mass size
|
| 498 |
centralMass.style.width = `${massSize}px`;
|
| 499 |
centralMass.style.height = `${massSize}px`;
|
| 500 |
|
| 501 |
+
// Reset position
|
| 502 |
orbitingObject.style.transition = 'none';
|
| 503 |
+
orbitingObject.style.left = '50%';
|
| 504 |
+
orbitingObject.style.bottom = '30%';
|
| 505 |
orbitingObject.style.transform = 'translate(-50%, 50%)';
|
| 506 |
|
| 507 |
+
// Orbit parameters
|
| 508 |
+
const orbitRadius = 80; // pixels
|
| 509 |
+
const centerX = 50; // percentage
|
| 510 |
+
const centerY = 30; // percentage
|
| 511 |
let angle = 0;
|
|
|
|
|
|
|
|
|
|
| 512 |
|
| 513 |
+
// Start animation
|
| 514 |
function animateOrbit() {
|
| 515 |
angle += 0.02 * speed;
|
| 516 |
+
const x = centerX + orbitRadius * Math.cos(angle);
|
| 517 |
+
const y = centerY + orbitRadius * Math.sin(angle);
|
| 518 |
|
| 519 |
orbitingObject.style.left = `${x}%`;
|
| 520 |
orbitingObject.style.bottom = `${y}%`;
|
| 521 |
|
| 522 |
+
// Continue animation
|
| 523 |
+
animationId = requestAnimationFrame(animateOrbit);
|
| 524 |
}
|
| 525 |
|
| 526 |
+
// Start the animation
|
| 527 |
+
let animationId = requestAnimationFrame(animateOrbit);
|
| 528 |
|
| 529 |
+
// Update button state
|
| 530 |
this.disabled = true;
|
| 531 |
this.innerHTML = '<i class="fas fa-sync-alt mr-1"></i> Orbiting';
|
| 532 |
+
|
| 533 |
+
// Allow restart by clicking again (though it will create multiple animations)
|
| 534 |
+
setTimeout(() => {
|
| 535 |
+
this.disabled = false;
|
| 536 |
+
this.innerHTML = '<i class="fas fa-redo mr-1"></i> Restart';
|
| 537 |
+
}, 2000);
|
| 538 |
+
});
|
| 539 |
+
|
| 540 |
+
// Update mass size display
|
| 541 |
+
document.getElementById('massSize').addEventListener('input', function() {
|
| 542 |
+
const size = this.value;
|
| 543 |
+
document.getElementById('centralMass').style.width = `${size}px`;
|
| 544 |
+
document.getElementById('centralMass').style.height = `${size}px`;
|
| 545 |
});
|
| 546 |
|
| 547 |
// Time Dilation Calculator
|
|
|
|
| 574 |
document.getElementById('observerTime').textContent = `${observerTime} sec`;
|
| 575 |
document.getElementById('dilationResult').classList.remove('hidden');
|
| 576 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 577 |
</script>
|
| 578 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=smjain/gr" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
| 579 |
</html>
|