I'll create a solar system simulation with interactive features. This will be a web-based application using HTML5 Canvas and JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Solar System Simulation</title>
<style>
body {
margin: 0;
padding: 0;
background: #000;
font-family: Arial, sans-serif;
overflow: hidden;
}
canvas {
display: block;
cursor: crosshair;
}
.popup {
position: absolute;
background: rgba(0, 0, 0, 0.9);
color: white;
padding: 15px;
border-radius: 8px;
border: 2px solid #444;
max-width: 300px;
font-size: 12px;
line-height: 1.4;
z-index: 1000;
display: none;
}
.popup h3 {
margin: 0 0 10px 0;
color: #ffd700;
font-size: 16px;
}
.popup .close {
position: absolute;
top: 5px;
right: 10px;
cursor: pointer;
font-size: 18px;
color: #fff;
}
.controls {
position: absolute;
top: 10px;
left: 10px;
color: white;
background: rgba(0, 0, 0, 0.7);
padding: 10px;
border-radius: 5px;
}
button {
margin: 5px;
padding: 5px 10px;
background: #333;
color: white;
border: 1px solid #666;
border-radius: 3px;
cursor: pointer;
}
button:hover {
background: #555;
}
</style>
</head>
<body>
<canvas id="solarSystem"></canvas>
<div class="controls">
<button onclick="togglePause()">Pause/Play</button>
<button onclick="changeSpeed(-1)">Slower</button>
<button onclick="changeSpeed(1)">Faster</button>
<button onclick="resetView()">Reset View</button>
<div>Speed: <span id="speedDisplay">1x</span></div>
</div>
<div id="popup" class="popup">
<span class="close" onclick="closePopup()">×</span>
<div id="popupContent"></div>
</div>
<script>
const canvas = document.getElementById('solarSystem');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let centerX = canvas.width / 2;
let centerY = canvas.height / 2;
let scale = 1;
let offsetX = 0;
let offsetY = 0;
let animationSpeed = 1;
let isPaused = false;
let time = 0;
// Celestial body data
const celestialBodies = {
sun: {
name: "Sun",
radius: 20,
color: "#FDB813",
x: 0,
y: 0,
diameter: "1,392,700 km",
satellites: 8,
temperature: "5,778 K (surface)",
orbitalPeriod: "N/A",
rotationPeriod: "25.4 Earth days",
composition: "73% Hydrogen, 25% Helium, 2% Other",
atmosphere: "Corona: Hydrogen, Helium plasma"
},
mercury: {
name: "Mercury",
radius: 3,
color: "#8C7853",
distance: 80,
speed: 0.02,
angle: 0,
diameter: "4,879 km",
satellites: 0,
temperature: "-173°C to 427°C",
orbitalPeriod: "88 Earth days",
rotationPeriod: "59 Earth days",
composition: "Iron core, silicate mantle",
atmosphere: "Extremely thin: Oxygen, Sodium, Hydrogen"
},
venus: {
name: "Venus",
radius: 4,
color: "#FFC649",
distance: 110,
speed: 0.015,
angle: 0,
diameter: "12,104 km",
satellites: 0,
temperature: "462°C (surface)",
orbitalPeriod: "225 Earth days",
rotationPeriod: "243 Earth days (retrograde)",
composition: "Iron core, silicate mantle",
atmosphere: "96% CO₂, 3.5% N₂, sulfuric acid clouds"
},
earth: {
name: "Earth",
radius: 5,
color: "#6B93D6",
distance: 150,
speed: 0.01,
angle: 0,
diameter: "12,756 km",
satellites: 1,
temperature: "-89°C to 58°C",
orbitalPeriod: "365.25 days",
rotationPeriod: "24 hours",
composition: "Iron core, silicate mantle, water oceans",
atmosphere: "78% N₂, 21% O₂, 1% other gases",
moons: [{
name: "Moon",
radius: 1.5,
color: "#C0C0C0",
distance: 15,
speed: 0.1,
angle: 0,
diameter: "3,475 km",
temperature: "-233°C to 123°C",
orbitalPeriod: "27.3 Earth days",
rotationPeriod: "27.3 Earth days (tidally locked)",
composition: "Iron core, silicate mantle",
atmosphere: "Extremely thin: Argon, Helium, Neon"
}]
},
mars: {
name: "Mars",
radius: 4,
color: "#CD5C5C",
distance: 200,
speed: 0.008,
angle: 0,
diameter: "6,792 km",
satellites: 2,
temperature: "-87°C to -5°C",
orbitalPeriod: "687 Earth days",
rotationPeriod: "24.6 hours",
composition: "Iron core, basaltic mantle",
atmosphere: "95% CO₂, 3% N₂, 2% Argon",
moons: [
{
name: "Phobos",
radius: 0.8,
color: "#8C7853",
distance: 12,
speed: 0.15,
angle: 0,
diameter: "22.5 km",
temperature: "-4°C to -112°C",
orbitalPeriod: "7.6 hours",
rotationPeriod: "7.6 hours (tidally locked)",
composition: "Carbonaceous rock",
atmosphere: "None"
},
{
name: "Deimos",
radius: 0.6,
color: "#696969",
distance: 18,
speed: 0.08,
angle: Math.PI,
diameter: "12.4 km",
temperature: "-40°C to -233°C",
orbitalPeriod: "30.3 hours",
rotationPeriod: "30.3 hours (tidally locked)",
composition: "Carbonaceous rock",
atmosphere: "None"
}
]
},
jupiter: {
name: "Jupiter",
radius: 12,
color: "#D8CA9D",
distance: 300,
speed: 0.005,
angle: 0,
diameter: "142,984 km",
satellites: 4,
temperature: "-108°C (cloud tops)",
orbitalPeriod: "12 Earth years",
rotationPeriod: "9.9 hours",
composition: "Hydrogen and Helium gas giant",
atmosphere: "89% H₂, 10% He, 1% other gases",
moons: [
{
name: "Io",
radius: 1.2,
color: "#FFFF99",
distance: 20,
speed: 0.12,
angle: 0,
diameter: "3,643 km",
temperature: "-183°C to -143°C",
orbitalPeriod: "1.8 Earth days",
rotationPeriod: "1.8 Earth days (tidally locked)",
composition: "Silicate rock, sulfur",
atmosphere: "Thin: SO₂, sulfur compounds"
},
{
name: "Europa",
radius: 1.1,
color: "#4FD0E7",
distance: 25,
speed: 0.09,
angle: Math.PI/2,
diameter: "3,122 km",
temperature: "-160°C to -220°C",
orbitalPeriod: "3.5 Earth days",
rotationPeriod: "3.5 Earth days (tidally locked)",
composition: "Water ice crust, rocky mantle",
atmosphere: "Thin: O₂"
},
{
name: "Ganymede",
radius: 1.4,
color: "#87CEEB",
distance: 30,
speed: 0.07,
angle: Math.PI,
diameter: "5,268 km",
temperature: "-180°C to -120°C",
orbitalPeriod: "7.2 Earth days",
rotationPeriod: "7.2 Earth days (tidally locked)",
composition: "Water ice, silicate rock",
atmosphere: "Thin: O₂"
},
{
name: "Callisto",
radius: 1.3,
color: "#2F4F4F",
distance: 35,
speed: 0.05,
angle: 3*Math.PI/2,
diameter: "4,821 km",
temperature: "-193°C to -108°C",
orbitalPeriod: "16.7 Earth days",
rotationPeriod: "16.7 Earth days (tidally locked)",
composition: "Water ice, silicate rock",
atmosphere: "Very thin: CO₂, O₂"
}
]
},
saturn: {
name: "Saturn",
radius: 10,
color: "#FAD5A5",
distance: 400,
speed: 0.003,
angle: 0,
diameter: "120,536 km",
satellites: 2,
temperature: "-139°C (cloud tops)",
orbitalPeriod: "29 Earth years",
rotationPeriod: "10.7 hours",
composition: "Hydrogen and Helium gas giant",
atmosphere: "96% H₂, 3% He, 1% other gases",
hasRings: true,
moons: [
{
name: "Titan",
radius: 1.8,
color: "#CD853F",
distance: 25,
speed: 0.08,
angle: 0,
diameter: "5,149 km",
temperature: "-179°C",
orbitalPeriod: "16 Earth days",
rotationPeriod: "16 Earth days (tidally locked)",
composition: "Water ice, rocky core",
atmosphere: "Dense: 95% N₂, 5% CH₄"
},
{
name: "Enceladus",
radius: 0.9,
color: "#F0F8FF",
distance: 18,
speed: 0.15,
angle: Math.PI,
diameter: "504 km",
temperature: "-201°C to -128°C",
orbitalPeriod: "1.4 Earth days",
rotationPeriod: "1.4 Earth days (tidally locked)",
composition: "Water ice crust, rocky core",
atmosphere: "Thin: H₂O vapor, N₂"
}
]
}
};
function drawCelestialBody(body, x, y) {
ctx.beginPath();
ctx.arc(x, y, body.radius * scale, 0, 2 * Math.PI);
ctx.fillStyle = body.color;
ctx.fill();
// Add a subtle glow effect
ctx.shadowColor = body.color;
ctx.shadowBlur = body.radius * scale * 0.5;
ctx.fill();
ctx.shadowBlur = 0;
// Draw rings for Saturn
if (body.hasRings) {
ctx.strokeStyle = '#DAA520';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.arc(x, y, (body.radius + 5) * scale, 0, 2 * Math.PI);
ctx.stroke();
ctx.beginPath();
ctx.arc(x, y, (body.radius + 8) * scale, 0, 2 * Math.PI);
ctx.stroke();
}
}
function drawOrbit(distance) {
ctx.strokeStyle = 'rgba(255, 255, 255, 0.1)';
ctx.lineWidth = 1;
ctx.beginPath();
ctx.arc(centerX + offsetX, centerY + offsetY, distance * scale, 0, 2 * Math.PI);
ctx.stroke();
}
function animate() {
if (!isPaused) {
time += 0.01 * animationSpeed;
}
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw stars
drawStars();
// Draw sun
drawCelestialBody(celestialBodies.sun, centerX + offsetX, centerY + offsetY);
// Draw planets and their moons
Object.keys(celestialBodies).forEach(key => {
const body = celestialBodies[key];
if (key === 'sun') return;
// Draw orbit
drawOrbit(body.distance);
// Calculate planet position
body.angle = time * body.speed;
const planetX = centerX + offsetX + Math.cos(body.angle) * body.distance * scale;
const planetY = centerY + offsetY + Math.sin(body.angle) * body.distance * scale;
// Draw planet
drawCelestialBody(body, planetX, planetY);
// Draw moons
if (body.moons) {
body.moons.forEach(moon => {
moon.angle += moon.speed * animationSpeed * 0