Manual
Almnck.
Price: 50ⓐ

Interactive Figures Visual Polish

Design document for Phase 2 of the interactive figures framework: replacing placeholder graphics with real imagery.

Overview

The interactive figures framework is functional but displays placeholder graphics (gray circles for moons, blue rectangle for Earth map). This phase adds visual polish using NASA moon frames and a Wikimedia Mercator projection.

Data Sources

NASA SVS 5587 Moon Frames

NASA’s Scientific Visualization Studio publishes daily moon appearance images showing phase, libration, and apparent size for each day of 2026.

  • Source: https://svs.gsfc.nasa.gov/5587/
  • Subset: Every 3rd day (~122 frames) balances quality vs. download size
  • Storage: fallback/frames/001.jpg, 004.jpg, 007.jpg, etc.
  • Index: data/frame-index.json maps day-of-year to available frames

Wikimedia Mercator Earth Map

A Mercator projection world map for the latitude picker background.

  • Source: https://upload.wikimedia.org/wikipedia/commons/thumb/7/74/Mercator-projection.jpg/1280px-Mercator-projection.jpg
  • License: CC BY-SA 3.0 (attribution required)
  • Storage: textures/earth-mercator.jpg

Moon Renderer Changes

Frame Selection

  1. Convert date parameter to day-of-year (1-365)
  2. Find closest available frame from index (worst case: 1 day off)
  3. Load frame image, cache in memory
  4. Preload adjacent frames (±3 days) when idle for smooth scrubbing

Latitude Rotation

Apply canvas rotation based on latitude before drawing the frame:

ctx.save();
ctx.translate(centerX, centerY);
ctx.rotate(latitude * Math.PI / 180);
ctx.drawImage(frame, -halfSize, -halfSize, size, size);
ctx.restore();

Note: This is a placeholder formula. The actual relationship between viewer latitude and perceived moon orientation is more complex (depends on moon’s position in sky, time, position angle). Wiring the rotation now lets us verify the pub/sub works; accuracy can be refined later.

Loading Strategy

  1. Show placeholder gray circle immediately (current behavior)
  2. Begin loading frame for current date
  3. Once loaded, cache and render
  4. On date/latitude change, check cache or load new frame

Latitude Picker Changes

Earth Map Background

Replace blue rectangle with the Mercator projection image:

  1. Load textures/earth-mercator.jpg on initialization
  2. Draw scaled to fill canvas (2:1 aspect ratio already enforced)
  3. Draw red latitude line on top
  4. Fall back to blue rectangle until image loads

No changes to pointer events, keyboard controls, or pub/sub wiring.

Updated sync.sh

#!/bin/bash
# Fetch NASA moon frames and Earth map

# Moon frames (every 3rd day)
for day in $(seq 1 3 365); do
  # Fetch from NASA SVS 5587
  # Format: moon.XXXX.jpg where XXXX is day of year
done

# Earth map
curl -o textures/earth-mercator.jpg \
  "https://upload.wikimedia.org/wikipedia/commons/thumb/7/74/Mercator-projection.jpg/1280px-Mercator-projection.jpg"

# Generate frame index
# Creates data/frame-index.json

File Structure

assets/figures/
├── sync.sh                 # Updated: fetch moon frames + Earth map
├── data/
│   └── frame-index.json    # Maps day-of-year → frame filename
├── textures/
│   └── earth-mercator.jpg  # Wikimedia Mercator projection
├── fallback/
│   └── frames/
│       ├── 001.jpg         # Moon frame day 1
│       ├── 004.jpg         # Moon frame day 4
│       └── ...             # ~122 frames total
├── moon-renderer.js        # Updated: load frames, apply rotation
└── latitude-picker.js      # Updated: draw Earth map background

What Changes

Component Before After
Moon display Gray circle with latitude text NASA moon frame, rotated by latitude
Earth map Blue rectangle Wikimedia Mercator projection
sync.sh Creates placeholder JSON Downloads real assets (~20MB)

What Stays the Same

  • Pub/sub wiring and capability system
  • Keyboard and pointer controls
  • Lazy loading via IntersectionObserver
  • three-moons and moon-timeline figures (they use moon-renderer, so they inherit the upgrade)
  • Test infrastructure

Attribution

The Mercator projection image requires CC BY-SA 3.0 attribution. Add to article or site credits:

Earth map: Mercator projection by Wikimedia Commons contributors, CC BY-SA 3.0