Create an HTML application that visually displays solar and lunar eclipses as they would…
- User
Create an HTML application that visually displays solar and lunar eclipses as they would be experienced from any location on Earth.
Assistant
I'll create an interactive eclipse visualization app. Let me start by exploring the project structure.
Now I'll build the eclipse visualization app. It will include:
- A list of real historical/upcoming eclipses (solar and lunar)
- A location selector (with common cities and lat/long input)
- Astronomical calculations to compute local visibility, magnitude, and timing
- A visual canvas showing the eclipse animation as seen from that location
- Time slider to scrub through the eclipse
Let me update the title and create the app.
Now let me create the astronomy calculation utilities. I'll implement simplified but reasonably accurate Sun/Moon position calculations based on standard astronomical algorithms (Jean Meeus / low-precision formulas).
Now let me create a database of known eclipses (past and upcoming) with peak times and approximate geographic centers:
Now the main visualization component. I'll build the App with:
- Left panel: eclipse picker, location picker, time slider
- Center: SVG showing the eclipse (Sun/Moon disks for solar; Moon in Earth's shadow for lunar) with sky background reflecting altitude/darkness
- Right/info panel: eclipse stats (magnitude, obscuration, altitude, azimuth, local time)
Now the main App:
Let me check the existing main.tsx and index.css look right, then build:
Build succeeded. Let me quickly verify the app logic makes sense by re-checking one concern: in the
SolarEclipseView, I computedAz = (moonHz.az - sunHz.az) * cos(sunHz.alt). Azimuth differences can wrap around 360° (e.g. sun at 359°, moon at 1° = actual difference 2°, not -358°). Let me fix that edge case:Build succeeded. Here's what I built:
🌘 Eclipse Viewer
An interactive web app that visualizes solar and lunar eclipses as they'd appear from any location on Earth, using real astronomical calculations (simplified Meeus/Montenbruck formulae for Sun and Moon positions).
Features
Eclipse Catalog — 11 curated historical & upcoming events:
- Solar totals: 2017 Great American, 2024 North American, 2026 European, 2027 N. African, 2028 Australia
- Solar annular: 2023 Ring of Fire
- Lunar totals: 2019 Wolf, 2022 Beaver, 2025 (×2), 2026
Observer Location
- 18 preset cities across all continents
- Custom lat/lon input
- "Use my current location" via geolocation
- "Jump to point of greatest eclipse" button
Time Controls
- Scrub timeline slider ±90 min around peak
- Play/pause animation with variable speed (0.5–30 sim min/sec)
- Local time display in observer's timezone
Solar Eclipse View
- Sun and Moon disks drawn at correct apparent sizes & separation
- Sky gradient darkens as sun altitude decreases and during totality
- Corona ring appears during totality with visible stars
- Golden ring highlight during annularity ("Ring of Fire")
- Live magnitude and obscuration % readouts
- Warns when sun is below the horizon
Lunar Eclipse View
- Earth's umbra and penumbra drawn to scale
- Moon smoothly darkens & reddens as it enters umbra (blood moon effect)
- Penumbral, partial, and total phases detected & labeled
- Umbral and penumbral magnitude readouts
The visualization uses topocentric parallax correction for the Moon, so different observers see slightly different Sun-Moon alignments — which is exactly why eclipses are only total along a narrow path on Earth.
Files built:
index.html,src/utils/astronomy.ts,src/utils/eclipses.ts,src/components/SolarEclipseView.tsx,src/components/LunarEclipseView.tsx,src/App.tsx
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.