Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

feat(site): physics sample chapter 19, shelf counts, no header flicker in Firefox

yzrefc823de1fcb
diff --git a/.claude/skills/papermorph/assets/templates/book.html b/.claude/skills/papermorph/assets/templates/book.html
index ca824b2..05e76c7 100644
--- a/.claude/skills/papermorph/assets/templates/book.html
+++ b/.claude/skills/papermorph/assets/templates/book.html
@@ -164,6 +164,9 @@ main#contents { padding-bottom: 80px; }
/* ---------- page-to-page motion ---------- */
@view-transition { navigation: auto; }
+/* Firefox flickers through view transitions (the header blinks for several frames): it switches without one, and the
+ contents still rise in. -moz-orient exists only in Firefox. */
+@supports (-moz-orient: inline) { @view-transition { navigation: none; } }
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: var(--ease); }
::view-transition-old(lesson), ::view-transition-new(lesson) { height: 100%; object-fit: cover; }
::view-transition-old(lesson) { animation-duration: .18s; }
@@ -292,7 +295,7 @@ function show(animate) {
heading?.focus({ preventScroll: true });
}
};
- if (animate && document.startViewTransition && !reduced) {
+ if (animate && document.startViewTransition && !reduced && !CSS.supports('-moz-orient', 'inline')) {
const transition = document.startViewTransition(apply);
// Navigation can interrupt either promise; the new view is already applied.
transition.ready.catch(() => {});
diff --git a/site/elementary-algebra/index.html b/site/elementary-algebra/index.html
index 4a35e3a..6f2fa59 100644
--- a/site/elementary-algebra/index.html
+++ b/site/elementary-algebra/index.html
@@ -172,6 +172,9 @@ main#contents { padding-bottom: 80px; }
/* ---------- page-to-page motion ---------- */
@view-transition { navigation: auto; }
+/* Firefox flickers through view transitions (the header blinks for several frames): it switches without one, and the
+ contents still rise in. -moz-orient exists only in Firefox. */
+@supports (-moz-orient: inline) { @view-transition { navigation: none; } }
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: var(--ease); }
::view-transition-old(lesson), ::view-transition-new(lesson) { height: 100%; object-fit: cover; }
::view-transition-old(lesson) { animation-duration: .18s; }
@@ -320,7 +323,7 @@ function show(animate) {
heading?.focus({ preventScroll: true });
}
};
- if (animate && document.startViewTransition && !reduced) {
+ if (animate && document.startViewTransition && !reduced && !CSS.supports('-moz-orient', 'inline')) {
const transition = document.startViewTransition(apply);
// Navigation can interrupt either promise; the new view is already applied.
transition.ready.catch(() => {});
diff --git a/site/index.html b/site/index.html
index 9e44ee7..aad816f 100644
--- a/site/index.html
+++ b/site/index.html
@@ -23,11 +23,11 @@
<a class="book-hotspot algebra-book" data-book="elementary-algebra" href="elementary-algebra/" aria-label="Open Elementary Algebra, 68 narrated chapters">
<span class="book-caption"><strong>Elementary Algebra <span aria-hidden="true">↗</span></strong><small>68 narrated chapters</small></span>
</a>
- <a class="book-hotspot math-book" data-book="math-notebook" href="math-notebook/" aria-label="Open Elementary Mathematics, 22 narrated chapters">
- <span class="book-caption"><strong>Elementary Mathematics <span aria-hidden="true">↗</span></strong><small>22 narrated chapters</small></span>
+ <a class="book-hotspot math-book" data-book="math-notebook" href="math-notebook/" aria-label="Open Elementary Mathematics, 23 narrated chapters">
+ <span class="book-caption"><strong>Elementary Mathematics <span aria-hidden="true">↗</span></strong><small>23 narrated chapters</small></span>
</a>
- <a class="book-hotspot physics-book" data-book="science" href="science/" aria-label="Open Elementary Physics, 3 narrated chapters">
- <span class="book-caption"><strong>Elementary Physics <span aria-hidden="true">↗</span></strong><small>3 narrated chapters</small></span>
+ <a class="book-hotspot physics-book" data-book="science" href="science/" aria-label="Open Elementary Physics, 4 narrated chapters and a sample chapter">
+ <span class="book-caption"><strong>Elementary Physics <span aria-hidden="true">↗</span></strong><small>4 narrated chapters · 1 sample</small></span>
</a>
</section>
<section class="shelf-tier" aria-labelledby="picture-title">
diff --git a/site/math-notebook/index.html b/site/math-notebook/index.html
index 9531870..273be98 100644
--- a/site/math-notebook/index.html
+++ b/site/math-notebook/index.html
@@ -172,6 +172,9 @@ main#contents { padding-bottom: 80px; }
/* ---------- page-to-page motion ---------- */
@view-transition { navigation: auto; }
+/* Firefox flickers through view transitions (the header blinks for several frames): it switches without one, and the
+ contents still rise in. -moz-orient exists only in Firefox. */
+@supports (-moz-orient: inline) { @view-transition { navigation: none; } }
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: var(--ease); }
::view-transition-old(lesson), ::view-transition-new(lesson) { height: 100%; object-fit: cover; }
::view-transition-old(lesson) { animation-duration: .18s; }
@@ -304,7 +307,7 @@ function show(animate) {
heading?.focus({ preventScroll: true });
}
};
- if (animate && document.startViewTransition && !reduced) {
+ if (animate && document.startViewTransition && !reduced && !CSS.supports('-moz-orient', 'inline')) {
const transition = document.startViewTransition(apply);
// Navigation can interrupt either promise; the new view is already applied.
transition.ready.catch(() => {});
diff --git a/site/science/ch19/audio/en/angle.mp3 b/site/science/ch19/audio/en/angle.mp3
new file mode 100644
index 0000000..5e7d66e
Binary files /dev/null and b/site/science/ch19/audio/en/angle.mp3 differ
diff --git a/site/science/ch19/audio/en/cycle.mp3 b/site/science/ch19/audio/en/cycle.mp3
new file mode 100644
index 0000000..8e3648d
Binary files /dev/null and b/site/science/ch19/audio/en/cycle.mp3 differ
diff --git a/site/science/ch19/audio/en/daily.mp3 b/site/science/ch19/audio/en/daily.mp3
new file mode 100644
index 0000000..22df8f3
Binary files /dev/null and b/site/science/ch19/audio/en/daily.mp3 differ
diff --git a/site/science/ch19/audio/en/daynight.mp3 b/site/science/ch19/audio/en/daynight.mp3
new file mode 100644
index 0000000..86adbd2
Binary files /dev/null and b/site/science/ch19/audio/en/daynight.mp3 differ
diff --git a/site/science/ch19/audio/en/ellipse.mp3 b/site/science/ch19/audio/en/ellipse.mp3
new file mode 100644
index 0000000..4e62acc
Binary files /dev/null and b/site/science/ch19/audio/en/ellipse.mp3 differ
diff --git a/site/science/ch19/audio/en/equinox.mp3 b/site/science/ch19/audio/en/equinox.mp3
new file mode 100644
index 0000000..e1899a3
Binary files /dev/null and b/site/science/ch19/audio/en/equinox.mp3 differ
diff --git a/site/science/ch19/audio/en/final1.mp3 b/site/science/ch19/audio/en/final1.mp3
new file mode 100644
index 0000000..cca4386
Binary files /dev/null and b/site/science/ch19/audio/en/final1.mp3 differ
diff --git a/site/science/ch19/audio/en/final2.mp3 b/site/science/ch19/audio/en/final2.mp3
new file mode 100644
index 0000000..6bc1845
Binary files /dev/null and b/site/science/ch19/audio/en/final2.mp3 differ
diff --git a/site/science/ch19/audio/en/finish.mp3 b/site/science/ch19/audio/en/finish.mp3
new file mode 100644
index 0000000..3db9866
Binary files /dev/null and b/site/science/ch19/audio/en/finish.mp3 differ
diff --git a/site/science/ch19/audio/en/hemis.mp3 b/site/science/ch19/audio/en/hemis.mp3
new file mode 100644
index 0000000..8e660f6
Binary files /dev/null and b/site/science/ch19/audio/en/hemis.mp3 differ
diff --git a/site/science/ch19/audio/en/hours.mp3 b/site/science/ch19/audio/en/hours.mp3
new file mode 100644
index 0000000..12ccf1b
Binary files /dev/null and b/site/science/ch19/audio/en/hours.mp3 differ
diff --git a/site/science/ch19/audio/en/intro.mp3 b/site/science/ch19/audio/en/intro.mp3
new file mode 100644
index 0000000..ca69ac3
Binary files /dev/null and b/site/science/ch19/audio/en/intro.mp3 differ
diff --git a/site/science/ch19/audio/en/leap.mp3 b/site/science/ch19/audio/en/leap.mp3
new file mode 100644
index 0000000..38f76ae
Binary files /dev/null and b/site/science/ch19/audio/en/leap.mp3 differ
diff --git a/site/science/ch19/audio/en/lunar.mp3 b/site/science/ch19/audio/en/lunar.mp3
new file mode 100644
index 0000000..a953673
Binary files /dev/null and b/site/science/ch19/audio/en/lunar.mp3 differ
diff --git a/site/science/ch19/audio/en/magnet.mp3 b/site/science/ch19/audio/en/magnet.mp3
new file mode 100644
index 0000000..550a8a6
Binary files /dev/null and b/site/science/ch19/audio/en/magnet.mp3 differ
diff --git a/site/science/ch19/audio/en/moon.mp3 b/site/science/ch19/audio/en/moon.mp3
new file mode 100644
index 0000000..dbea0b7
Binary files /dev/null and b/site/science/ch19/audio/en/moon.mp3 differ
diff --git a/site/science/ch19/audio/en/phases.mp3 b/site/science/ch19/audio/en/phases.mp3
new file mode 100644
index 0000000..b33db5e
Binary files /dev/null and b/site/science/ch19/audio/en/phases.mp3 differ
diff --git a/site/science/ch19/audio/en/q1.mp3 b/site/science/ch19/audio/en/q1.mp3
new file mode 100644
index 0000000..aafc889
Binary files /dev/null and b/site/science/ch19/audio/en/q1.mp3 differ
diff --git a/site/science/ch19/audio/en/q2.mp3 b/site/science/ch19/audio/en/q2.mp3
new file mode 100644
index 0000000..cbbba85
Binary files /dev/null and b/site/science/ch19/audio/en/q2.mp3 differ
diff --git a/site/science/ch19/audio/en/q3.mp3 b/site/science/ch19/audio/en/q3.mp3
new file mode 100644
index 0000000..4951a61
Binary files /dev/null and b/site/science/ch19/audio/en/q3.mp3 differ
diff --git a/site/science/ch19/audio/en/q4.mp3 b/site/science/ch19/audio/en/q4.mp3
new file mode 100644
index 0000000..ffda522
Binary files /dev/null and b/site/science/ch19/audio/en/q4.mp3 differ
diff --git a/site/science/ch19/audio/en/q5.mp3 b/site/science/ch19/audio/en/q5.mp3
new file mode 100644
index 0000000..7a189ce
Binary files /dev/null and b/site/science/ch19/audio/en/q5.mp3 differ
diff --git a/site/science/ch19/audio/en/rare.mp3 b/site/science/ch19/audio/en/rare.mp3
new file mode 100644
index 0000000..8b6dc05
Binary files /dev/null and b/site/science/ch19/audio/en/rare.mp3 differ
diff --git a/site/science/ch19/audio/en/revolve.mp3 b/site/science/ch19/audio/en/revolve.mp3
new file mode 100644
index 0000000..f32c615
Binary files /dev/null and b/site/science/ch19/audio/en/revolve.mp3 differ
diff --git a/site/science/ch19/audio/en/rotate.mp3 b/site/science/ch19/audio/en/rotate.mp3
new file mode 100644
index 0000000..c007bc3
Binary files /dev/null and b/site/science/ch19/audio/en/rotate.mp3 differ
diff --git a/site/science/ch19/audio/en/sameface.mp3 b/site/science/ch19/audio/en/sameface.mp3
new file mode 100644
index 0000000..d424bf1
Binary files /dev/null and b/site/science/ch19/audio/en/sameface.mp3 differ
diff --git a/site/science/ch19/audio/en/seasons.mp3 b/site/science/ch19/audio/en/seasons.mp3
new file mode 100644
index 0000000..161b73f
Binary files /dev/null and b/site/science/ch19/audio/en/seasons.mp3 differ
diff --git a/site/science/ch19/audio/en/shape.mp3 b/site/science/ch19/audio/en/shape.mp3
new file mode 100644
index 0000000..1a75b38
Binary files /dev/null and b/site/science/ch19/audio/en/shape.mp3 differ
diff --git a/site/science/ch19/audio/en/solar.mp3 b/site/science/ch19/audio/en/solar.mp3
new file mode 100644
index 0000000..e58aaa1
Binary files /dev/null and b/site/science/ch19/audio/en/solar.mp3 differ
diff --git a/site/science/ch19/audio/en/solstice.mp3 b/site/science/ch19/audio/en/solstice.mp3
new file mode 100644
index 0000000..179897f
Binary files /dev/null and b/site/science/ch19/audio/en/solstice.mp3 differ
diff --git a/site/science/ch19/audio/en/spring.mp3 b/site/science/ch19/audio/en/spring.mp3
new file mode 100644
index 0000000..f99d5e9
Binary files /dev/null and b/site/science/ch19/audio/en/spring.mp3 differ
diff --git a/site/science/ch19/audio/en/surface.mp3 b/site/science/ch19/audio/en/surface.mp3
new file mode 100644
index 0000000..46830f7
Binary files /dev/null and b/site/science/ch19/audio/en/surface.mp3 differ
diff --git a/site/science/ch19/audio/en/tideday.mp3 b/site/science/ch19/audio/en/tideday.mp3
new file mode 100644
index 0000000..1d0092a
Binary files /dev/null and b/site/science/ch19/audio/en/tideday.mp3 differ
diff --git a/site/science/ch19/audio/en/tides.mp3 b/site/science/ch19/audio/en/tides.mp3
new file mode 100644
index 0000000..fbe2b83
Binary files /dev/null and b/site/science/ch19/audio/en/tides.mp3 differ
diff --git a/site/science/ch19/audio/en/tilt.mp3 b/site/science/ch19/audio/en/tilt.mp3
new file mode 100644
index 0000000..c8dc14d
Binary files /dev/null and b/site/science/ch19/audio/en/tilt.mp3 differ
diff --git a/site/science/ch19/audio/en/timings.js b/site/science/ch19/audio/en/timings.js
new file mode 100644
index 0000000..159e92b
--- /dev/null
+++ b/site/science/ch19/audio/en/timings.js
@@ -0,0 +1,991 @@
+window.TIMINGS = {
+ "intro": {
+ "dur": 9.384,
+ "marks": {
+ "sub": 4.154
+ },
+ "cues": [
+ [
+ 0.091,
+ "Chapter nineteen."
+ ],
+ [
+ 1.445,
+ "The sun, the earth, and the moon."
+ ],
+ [
+ 4.154,
+ "Three bodies, always moving, and every day we see the results."
+ ]
+ ]
+ },
+ "daily": {
+ "dur": 20.712,
+ "marks": {
+ "set": 2.305,
+ "rise": 4.583,
+ "tide": 6.211,
+ "seas": 9.661,
+ "all": 12.669
+ },
+ "cues": [
+ [
+ 0.104,
+ "Watch the sky for one evening."
+ ],
+ [
+ 2.305,
+ "The sun sinks below the horizon."
+ ],
+ [
+ 4.583,
+ "The moon rises."
+ ],
+ [
+ 6.211,
+ "Down at the beach, the tide is slowly coming in."
+ ],
+ [
+ 9.661,
+ "And over the months, the seasons change."
+ ],
+ [
+ 12.669,
+ "Sunsets, moonrises, tides and seasons all come from how the sun, Earth and moon move together."
+ ]
+ ]
+ },
+ "shape": {
+ "dur": 27.624,
+ "marks": {
+ "sq": 2.747,
+ "dough": 7.318,
+ "eq": 12.917,
+ "pole": 19.479,
+ "tiny": 23.49
+ },
+ "cues": [
+ [
+ 0.104,
+ "Start with Earth itself."
+ ],
+ [
+ 2.096,
+ "It's a sphere, but a slightly squashed one, like a gym ball pressed between your hands."
+ ],
+ [
+ 7.318,
+ "Spinning makes it bulge at the middle, the way a spinning ball of pizza dough spreads out."
+ ],
+ [
+ 12.917,
+ "Across the equator, Earth is about twelve thousand seven hundred fifty-six kilometers wide."
+ ],
+ [
+ 19.479,
+ "From pole to pole, it's about forty-three kilometers less."
+ ],
+ [
+ 23.49,
+ "That's a third of a percent, far too little to notice just by looking."
+ ]
+ ]
+ },
+ "magnet": {
+ "dur": 27.12,
+ "marks": {
+ "field": 7.917,
+ "comp": 13.854,
+ "off": 20.286,
+ "drift": 25.0
+ },
+ "cues": [
+ [
+ 0.104,
+ "Deep inside, Earth has a core of iron, and its outer part is liquid metal, churning as the planet turns."
+ ],
+ [
+ 7.917,
+ "That makes Earth a giant magnet, with a magnetic field looping out into space."
+ ],
+ [
+ 13.854,
+ "A compass is a tiny magnet that lines up with this field, so its needle points toward magnetic north."
+ ],
+ [
+ 20.286,
+ "But magnetic north isn't the same spot as the geographic North Pole, and it wanders a little every year."
+ ]
+ ]
+ },
+ "rotate": {
+ "dur": 13.224,
+ "marks": {
+ "axis": 5.859,
+ "rot": 7.096,
+ "day": 9.479
+ },
+ "cues": [
+ [
+ 0.104,
+ "Now let Earth move."
+ ],
+ [
+ 1.667,
+ "It spins around an imaginary line through the North and South Poles: its axis."
+ ],
+ [
+ 7.096,
+ "This spinning is called rotation."
+ ],
+ [
+ 9.479,
+ "One full turn takes about twenty-four hours: one day."
+ ]
+ ]
+ },
+ "daynight": {
+ "dur": 25.032,
+ "marks": {
+ "lit": 2.227,
+ "ride": 7.422,
+ "noon": 11.107,
+ "eve": 12.318,
+ "sky": 14.844,
+ "us": 22.682
+ },
+ "cues": [
+ [
+ 0.091,
+ "Look down from above the North Pole."
+ ],
+ [
+ 2.227,
+ "Sunlight comes from one side, so half of Earth has day and half has night."
+ ],
+ [
+ 7.422,
+ "As Earth turns, we're carried out of the night into morning, through noon, into evening, and back into night."
+ ],
+ [
+ 14.844,
+ "From the ground, it looks as if the sun travels across the sky, rising in the east and setting in the west."
+ ],
+ [
+ 22.682,
+ "But really, we're the ones moving."
+ ]
+ ]
+ },
+ "revolve": {
+ "dur": 13.872,
+ "marks": {
+ "rev": 3.893,
+ "orb": 6.198,
+ "year": 8.19
+ },
+ "cues": [
+ [
+ 0.104,
+ "While it spins, Earth also travels around the sun."
+ ],
+ [
+ 3.893,
+ "This trip is called revolution, and its path is called an orbit."
+ ],
+ [
+ 8.19,
+ "One revolution takes three hundred sixty-five and a quarter days: one year."
+ ]
+ ]
+ },
+ "leap": {
+ "dur": 17.184,
+ "marks": {
+ "q1": 4.258,
+ "q4": 8.177,
+ "feb": 12.409,
+ "leap": 15.925
+ },
+ "cues": [
+ [
+ 0.091,
+ "Our calendar year has only three hundred sixty-five days."
+ ],
+ [
+ 4.258,
+ "So each year, about a quarter of a day is left over."
+ ],
+ [
+ 8.177,
+ "After four years, those quarters add up to a whole day, and we add it to the calendar as February twenty-ninth."
+ ],
+ [
+ 15.925,
+ "That's a leap year."
+ ]
+ ]
+ },
+ "ellipse": {
+ "dur": 22.056,
+ "marks": {
+ "ell": 2.76,
+ "jan": 8.906,
+ "jul": 11.081,
+ "q": 13.555,
+ "not": 18.112
+ },
+ "cues": [
+ [
+ 0.104,
+ "Earth's orbit isn't a perfect circle."
+ ],
+ [
+ 2.76,
+ "It's an ellipse, a slightly stretched circle, so our distance from the sun changes during the year."
+ ],
+ [
+ 8.906,
+ "We're closest in early January, and farthest in early July."
+ ],
+ [
+ 13.555,
+ "Wait."
+ ],
+ [
+ 14.31,
+ "Closest in January?"
+ ],
+ [
+ 15.977,
+ "That's winter in the United States."
+ ],
+ [
+ 18.112,
+ "So our distance from the sun can't be what causes the seasons."
+ ]
+ ]
+ },
+ "tilt": {
+ "dur": 19.992,
+ "marks": {
+ "perp": 2.826,
+ "lean": 7.565,
+ "same": 12.721
+ },
+ "cues": [
+ [
+ 0.117,
+ "The real reason is Earth's tilt."
+ ],
+ [
+ 2.826,
+ "Imagine a line standing straight up from the flat plane of Earth's orbit."
+ ],
+ [
+ 7.565,
+ "Earth's axis leans away from that line by about twenty-three and a half degrees."
+ ],
+ [
+ 12.721,
+ "And as Earth travels around the sun, its axis keeps pointing the same direction in space, toward the North Star."
+ ]
+ ]
+ },
+ "seasons": {
+ "dur": 19.872,
+ "marks": {
+ "jun": 2.175,
+ "dec": 6.445,
+ "away": 12.721,
+ "nowob": 15.104
+ },
+ "cues": [
+ [
+ 0.104,
+ "Now follow Earth through the year."
+ ],
+ [
+ 2.175,
+ "In June, the northern half of Earth leans toward the sun."
+ ],
+ [
+ 6.445,
+ "Six months later, Earth is on the other side of the sun."
+ ],
+ [
+ 10.039,
+ "The axis still points the same way, so now the northern half leans away."
+ ],
+ [
+ 15.104,
+ "The tilt doesn't wobble back and forth."
+ ],
+ [
+ 17.578,
+ "Earth just moves to the other side."
+ ]
+ ]
+ },
+ "angle": {
+ "dur": 23.904,
+ "marks": {
+ "torch": 4.167,
+ "spot": 8.685,
+ "tilt": 11.68,
+ "high": 18.464
+ },
+ "cues": [
+ [
+ 0.104,
+ "Why does leaning toward the sun bring summer?"
+ ],
+ [
+ 2.63,
+ "There are two reasons."
+ ],
+ [
+ 4.167,
+ "First, the angle of the light."
+ ],
+ [
+ 6.419,
+ "Shine a flashlight straight down, and its light lands in a small, bright spot."
+ ],
+ [
+ 11.68,
+ "Tilt it, and the same light spreads over a bigger area, so each bit of ground gets less."
+ ],
+ [
+ 18.464,
+ "In summer the sun is high in the sky, and its light hits the ground more directly."
+ ]
+ ]
+ },
+ "hours": {
+ "dur": 18.576,
+ "marks": {
+ "sumd": 2.344,
+ "wind": 10.0,
+ "both": 13.242
+ },
+ "cues": [
+ [
+ 0.104,
+ "Second, the length of the day."
+ ],
+ [
+ 2.344,
+ "In summer, the sun takes a long, high path across the sky, so the ground soaks up sunlight for many hours."
+ ],
+ [
+ 10.0,
+ "In winter, the path is short and low."
+ ],
+ [
+ 13.242,
+ "More intense light for more hours makes summer."
+ ],
+ [
+ 16.497,
+ "Less of both makes winter."
+ ]
+ ]
+ },
+ "hemis": {
+ "dur": 10.032,
+ "marks": {
+ "us": 6.536,
+ "au": 8.359
+ },
+ "cues": [
+ [
+ 0.104,
+ "Because the two hemispheres lean opposite ways, they always have opposite seasons."
+ ],
+ [
+ 6.536,
+ "When it's winter in the United States, it's summer in Australia."
+ ]
+ ]
+ },
+ "q1": {
+ "dur": 2.736,
+ "marks": {},
+ "cues": [
+ [
+ 0.091,
+ "Quick check."
+ ],
+ [
+ 1.12,
+ "Think about where Earth is."
+ ]
+ ]
+ },
+ "solstice": {
+ "dur": 27.168,
+ "marks": {
+ "sol": 3.242,
+ "jun": 8.802,
+ "dec": 19.193
+ },
+ "cues": [
+ [
+ 0.104,
+ "Two kinds of days mark the turning points of the year."
+ ],
+ [
+ 3.242,
+ "On a solstice, Earth's axis leans most directly toward or away from the sun."
+ ],
+ [
+ 8.802,
+ "Around June twenty-first, the north leans most toward the sun."
+ ],
+ [
+ 13.229,
+ "That's the summer solstice: the longest day of the year, with the sun at its highest at noon."
+ ],
+ [
+ 19.193,
+ "Around December twenty-first comes the winter solstice: the shortest day, the longest night, and the lowest noon sun."
+ ]
+ ]
+ },
+ "equinox": {
+ "dur": 26.736,
+ "marks": {
+ "eq": 5.169,
+ "over": 7.148,
+ "twelve": 9.596,
+ "mar": 14.583,
+ "sep": 18.529,
+ "south": 23.112
+ },
+ "cues": [
+ [
+ 0.104,
+ "Halfway between, the axis leans neither toward nor away from the sun."
+ ],
+ [
+ 5.169,
+ "These days are equinoxes."
+ ],
+ [
+ 7.148,
+ "The sun is directly over the equator, so day and night are each about twelve hours long everywhere on Earth."
+ ],
+ [
+ 14.583,
+ "The vernal equinox, around March twentieth, begins spring."
+ ],
+ [
+ 18.529,
+ "The autumnal equinox, around September twenty-second, begins fall."
+ ],
+ [
+ 23.112,
+ "In the southern hemisphere, all of these labels are flipped."
+ ]
+ ]
+ },
+ "moon": {
+ "dur": 21.744,
+ "marks": {
+ "sat": 4.492,
+ "young": 6.198,
+ "hit": 9.74,
+ "ring": 13.633,
+ "ball": 17.057,
+ "moon": 20.885
+ },
+ "cues": [
+ [
+ 0.104,
+ "Now, the moon."
+ ],
+ [
+ 1.211,
+ "A moon is a natural object that orbits a planet: a natural satellite."
+ ],
+ [
+ 6.198,
+ "Ours most likely formed early in Earth's history, when a body about the size of Mars crashed into the young Earth."
+ ],
+ [
+ 13.633,
+ "The impact blasted debris into orbit, and gravity pulled that debris together into one ball: our moon."
+ ]
+ ]
+ },
+ "surface": {
+ "dur": 24.024,
+ "marks": {
+ "hi": 4.154,
+ "mar": 9.401,
+ "quake": 16.185,
+ "ice": 18.737
+ },
+ "cues": [
+ [
+ 0.091,
+ "On a clear night, you can see that the moon has different kinds of ground."
+ ],
+ [
+ 4.154,
+ "The bright, rugged areas are mountains and craters: the lunar highlands."
+ ],
+ [
+ 9.401,
+ "The dark, smooth patches are maria, plains of hardened lava from ancient eruptions."
+ ],
+ [
+ 16.185,
+ "The moon even shakes with moonquakes."
+ ],
+ [
+ 18.737,
+ "And space missions have found water ice hiding in dark craters near its poles."
+ ]
+ ]
+ },
+ "sameface": {
+ "dur": 24.12,
+ "marks": {
+ "rev": 2.044,
+ "rot": 4.844,
+ "same": 9.349,
+ "ride": 12.227,
+ "far": 18.151
+ },
+ "cues": [
+ [
+ 0.104,
+ "The moon circles Earth once every twenty-seven point three days."
+ ],
+ [
+ 4.844,
+ "It also spins once on its own axis, in exactly the same time."
+ ],
+ [
+ 9.349,
+ "So the same side always faces Earth."
+ ],
+ [
+ 12.227,
+ "It's like a spinning carnival ride: you go round and round, but you always face the center."
+ ],
+ [
+ 18.151,
+ "Nobody saw the far side of the moon until a spacecraft photographed it, in nineteen fifty-nine."
+ ]
+ ]
+ },
+ "q2": {
+ "dur": 3.336,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Quick check."
+ ],
+ [
+ 1.107,
+ "Why do we always see the same face?"
+ ]
+ ]
+ },
+ "phases": {
+ "dur": 16.608,
+ "marks": {
+ "half": 4.948,
+ "see": 8.672,
+ "name": 13.594
+ },
+ "cues": [
+ [
+ 0.104,
+ "The moon makes no light of its own."
+ ],
+ [
+ 2.578,
+ "It shines by reflecting sunlight."
+ ],
+ [
+ 4.948,
+ "The sun always lights the half of the moon that faces it."
+ ],
+ [
+ 8.672,
+ "But as the moon circles Earth, we see different amounts of that bright half."
+ ],
+ [
+ 13.594,
+ "These changing shapes are the moon phases."
+ ]
+ ]
+ },
+ "cycle": {
+ "dur": 23.088,
+ "marks": {
+ "new": 1.576,
+ "cres": 6.849,
+ "fq": 9.18,
+ "gib": 12.396,
+ "full": 14.505,
+ "back": 17.435,
+ "lq": 20.039,
+ "wcres": 21.159,
+ "new2": 21.979
+ },
+ "cues": [
+ [
+ 0.169,
+ "Follow the moon around."
+ ],
+ [
+ 1.576,
+ "New moon: the lit side faces away from us, so we see almost nothing."
+ ],
+ [
+ 6.849,
+ "A thin crescent appears."
+ ],
+ [
+ 9.18,
+ "First quarter: half of the face is lit."
+ ],
+ [
+ 12.396,
+ "Gibbous: more than half."
+ ],
+ [
+ 14.505,
+ "Full moon: the whole face shines."
+ ],
+ [
+ 17.435,
+ "Then it all runs backward: gibbous, last quarter, crescent, and new again."
+ ]
+ ]
+ },
+ "waxwane": {
+ "dur": 22.656,
+ "marks": {
+ "wan": 5.078,
+ "cyc": 8.828,
+ "why": 14.141
+ },
+ "cues": [
+ [
+ 0.091,
+ "While the lit part grows, from new to full, the moon is waxing."
+ ],
+ [
+ 5.078,
+ "As it shrinks, from full back to new, it's waning."
+ ],
+ [
+ 8.828,
+ "One whole cycle of phases takes twenty-nine and a half days, about a month."
+ ],
+ [
+ 14.141,
+ "That's two days longer than one orbit, because Earth has moved along its own path, and the moon needs a little extra time to line up with the sun again."
+ ]
+ ]
+ },
+ "q3": {
+ "dur": 3.048,
+ "marks": {},
+ "cues": [
+ [
+ 0.091,
+ "Quick check."
+ ],
+ [
+ 1.172,
+ "Find the moon on its orbit."
+ ]
+ ]
+ },
+ "solar": {
+ "dur": 20.88,
+ "marks": {
+ "mid": 4.453,
+ "shad": 7.07,
+ "ecl": 10.625,
+ "tot": 12.344,
+ "part": 17.266
+ },
+ "cues": [
+ [
+ 0.104,
+ "Sometimes the sun, the moon and Earth line up exactly."
+ ],
+ [
+ 4.453,
+ "When the moon passes between the sun and Earth, it blocks the sunlight and casts its shadow on Earth."
+ ],
+ [
+ 10.625,
+ "That's a solar eclipse."
+ ],
+ [
+ 12.344,
+ "Inside the darkest part of the shadow, the sun is completely covered."
+ ],
+ [
+ 17.266,
+ "Around it, people see only part of the sun blocked."
+ ]
+ ]
+ },
+ "lunar": {
+ "dur": 17.208,
+ "marks": {
+ "earthmid": 1.641,
+ "into": 4.258,
+ "red": 8.398
+ },
+ "cues": [
+ [
+ 0.104,
+ "Now switch places."
+ ],
+ [
+ 1.641,
+ "When Earth is between the sun and the moon, the moon slides into Earth's shadow: a lunar eclipse."
+ ],
+ [
+ 8.398,
+ "But it doesn't go completely dark."
+ ],
+ [
+ 10.56,
+ "Earth's atmosphere bends a little red sunlight into the shadow, so the moon glows a deep red."
+ ]
+ ]
+ },
+ "rare": {
+ "dur": 16.752,
+ "marks": {
+ "tilt": 2.669,
+ "miss": 6.38,
+ "line": 12.669
+ },
+ "cues": [
+ [
+ 0.104,
+ "So why isn't there an eclipse every month?"
+ ],
+ [
+ 2.669,
+ "The moon's orbit is tilted about five degrees from Earth's."
+ ],
+ [
+ 6.38,
+ "Most months, the moon passes a little above or below the line, and its shadow misses."
+ ],
+ [
+ 12.669,
+ "Only when all three line up exactly do we get an eclipse."
+ ]
+ ]
+ },
+ "q4": {
+ "dur": 2.544,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Quick check."
+ ],
+ [
+ 1.133,
+ "Solar or lunar?"
+ ]
+ ]
+ },
+ "tides": {
+ "dur": 21.096,
+ "marks": {
+ "near": 4.779,
+ "far": 10.521,
+ "hi": 16.836,
+ "lo": 19.206
+ },
+ "cues": [
+ [
+ 0.104,
+ "The moon's gravity pulls on Earth, too, and the oceans respond."
+ ],
+ [
+ 4.779,
+ "Water on the side facing the moon is pulled the hardest, so it bulges toward the moon."
+ ],
+ [
+ 10.521,
+ "On the far side, water is pulled the least and gets left behind, making a second bulge."
+ ],
+ [
+ 16.836,
+ "Under the bulges, it's high tide."
+ ],
+ [
+ 19.206,
+ "In between, it's low tide."
+ ]
+ ]
+ },
+ "tideday": {
+ "dur": 16.56,
+ "marks": {
+ "beach": 2.969,
+ "h1": 5.117,
+ "l1": 6.029,
+ "h2": 7.188,
+ "l2": 8.229,
+ "two": 9.128
+ },
+ "cues": [
+ [
+ 0.104,
+ "Earth rotates under these two bulges."
+ ],
+ [
+ 2.969,
+ "Follow one beach through a day: high tide, low tide, high tide again, and low."
+ ],
+ [
+ 9.128,
+ "Most places get two high tides and two low tides a day, with about six hours from a high tide to the next low."
+ ]
+ ]
+ },
+ "spring": {
+ "dur": 26.232,
+ "marks": {
+ "line": 4.05,
+ "spr": 10.104,
+ "name": 14.766,
+ "right": 18.698,
+ "neap": 23.32
+ },
+ "cues": [
+ [
+ 0.104,
+ "The sun pulls on the oceans too, more weakly than the moon."
+ ],
+ [
+ 4.05,
+ "At new moon and full moon, the sun and moon line up and their pulls add together."
+ ],
+ [
+ 10.104,
+ "We get spring tides: extra high highs and extra low lows."
+ ],
+ [
+ 14.766,
+ "They have nothing to do with the season; the water springs up."
+ ],
+ [
+ 18.698,
+ "At first and last quarter, the sun and moon pull at right angles, and the tides are smaller: neap tides."
+ ]
+ ]
+ },
+ "q5": {
+ "dur": 2.28,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Quick check."
+ ],
+ [
+ 1.185,
+ "Which kind of tide?"
+ ]
+ ]
+ },
+ "wrap": {
+ "dur": 25.344,
+ "marks": {
+ "w1": 1.016,
+ "w2": 7.279,
+ "w3": 11.302,
+ "w4": 18.893,
+ "end": 23.242
+ },
+ "cues": [
+ [
+ 0.104,
+ "To sum up."
+ ],
+ [
+ 1.016,
+ "Earth rotates once a day, giving us day and night, and revolves around the sun once a year."
+ ],
+ [
+ 7.279,
+ "Seasons come from Earth's tilt, not its distance from the sun."
+ ],
+ [
+ 11.302,
+ "Moon phases show how much of the moon's sunlit half we can see, and eclipses happen when all three line up."
+ ],
+ [
+ 18.893,
+ "The moon's gravity, helped by the sun, raises the tides."
+ ],
+ [
+ 23.242,
+ "Now try the chapter practice."
+ ]
+ ]
+ },
+ "final1": {
+ "dur": 3.864,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Chapter practice, set one."
+ ],
+ [
+ 2.227,
+ "Earth and the seasons."
+ ]
+ ]
+ },
+ "final2": {
+ "dur": 4.488,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Chapter practice, set two."
+ ],
+ [
+ 2.148,
+ "The moon, eclipses and tides."
+ ]
+ ]
+ },
+ "finish": {
+ "dur": 3.144,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Well done."
+ ],
+ [
+ 1.107,
+ "That's the end of chapter nineteen."
+ ]
+ ]
+ }
+};
diff --git a/site/science/ch19/audio/en/waxwane.mp3 b/site/science/ch19/audio/en/waxwane.mp3
new file mode 100644
index 0000000..6179bc3
Binary files /dev/null and b/site/science/ch19/audio/en/waxwane.mp3 differ
diff --git a/site/science/ch19/audio/en/wrap.mp3 b/site/science/ch19/audio/en/wrap.mp3
new file mode 100644
index 0000000..292e992
Binary files /dev/null and b/site/science/ch19/audio/en/wrap.mp3 differ
diff --git a/site/science/ch19/index.html b/site/science/ch19/index.html
new file mode 100644
index 0000000..cf3d417
--- /dev/null
+++ b/site/science/ch19/index.html
@@ -0,0 +1,899 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>The Sun-Earth-Moon System</title>
+<link rel="stylesheet" href="../lib/engine.css">
+<link rel="expect" href="#bar" blocking="render"><!-- hold the first frame until the player exists, so the page transition can run -->
+</head>
+<body>
+<script src="../lib/engine.js"></script>
+<script src="../lib/space.js"></script>
+<script src="../lib/notes.js"></script>
+<script src="../lib/cast.js"></script>
+<script src="audio/en/timings.js"></script>
+<script>
+'use strict';
+const CHAPTER = { number: 19, title: 'The Sun-Earth-Moon System', minutes: 14, language: 'en' };
+
+/* ---------- chapter helpers ---------- */
+const at = (e, o, t) => tw(e, o, t, 0); // a cut: e takes state o at time t
+const call = (t, f) => prog(q => { if (q === 1) f(); }, t, 0, lin);
+const TILT = 23.44;
+const deg = d => d * Math.PI / 180;
+const clamp01 = v => Math.max(0, Math.min(1, v));
+const lerp = (a, b, q) => a + (b - a) * q;
+// Piecewise motion through keyframes [[t, v], …]: held before the first and after the last; ease per segment.
+function keyf(t, keys, ease = lin) {
+ if (t <= keys[0][0]) return keys[0][1];
+ for (let i = 1; i < keys.length; i++) if (t <= keys[i][0]) {
+ const [t0, v0] = keys[i - 1], [t1, v1] = keys[i];
+ return lerp(v0, v1, ease(clamp01((t - t0) / Math.max(1e-6, t1 - t0))));
+ }
+ return keys[keys.length - 1][1];
+}
+// Screen angle (degrees) from (x, y) toward (sx, sy): where the light comes from.
+const toward = (x, y, sx, sy) => Math.atan2(sy - y, sx - x) * 180 / Math.PI;
+// Keep e in the back layer while it is behind (far side of an orbit), in the front layer otherwise.
+function depth(e, behind, front) { let cur; return far => { const L = far ? behind : front; if (L !== cur) { L.appendChild(e); cur = L; } }; }
+// Blinks for the cast, every few seconds; a wagging tail for the dog.
+function alive(D, kidG, dogG, seed = 0) {
+ clockRun(t => {
+ if (kidG) kidG.blink(((t + seed) % 3.7) < .13);
+ if (dogG) { dogG.blink(((t + seed + 1.6) % 4.3) < .13); if (!dogG._still) dogG.wag(t); }
+ }, D);
+}
+// Section heading in the notebook's green, top left.
+function heading(p, str, t0 = .2) { const h = pen(p, str, { x: 56, y: 76, size: 44, fill: INK.def }); show(h, t0); return h; }
+// A handwritten label shown at t0.
+function lab(p, str, x, y, t0, o = {}) { const e = pen(p, str, { x, y, size: 32, ...o }); show(e, t0, .4); return e; }
+function hlAt(p, str, x, y, t0, o = {}) { return hlIn(hl(p, str, { x, y, size: 40, o: 0, ...o }), t0); }
+function lead(p, x1, y1, x2, y2, t0, color = INK.note) { const e = path(p, `M${x1} ${y1}L${x2} ${y2}`, { stroke: color, 'stroke-width': 2.5, 'stroke-opacity': .8 }, { d: 0 }); draw(e, t0, .4); return e; }
+const setText = (g, str) => { const t = g.firstChild; if (t.textContent !== str) t.textContent = str; };
+// A small moon disc for top-down diagrams, lit from the sun on the left.
+const moonDot = (p, x, y, r = 34, o = 1) => globe(p, { x, y, r, kind: '#c9c6bd', light: 180, night: .9, rim: false, o });
+
+// Evening on a hill above the sea: sky, a setting sun and a rising moon behind the land, a tree for the seasons.
+function dusk(p) {
+ const g = G(p), id = 'dusk' + (++spaceN);
+ const gr = mk('linearGradient', { id, x1: 0, y1: 0, x2: 0, y2: 1 }, mk('defs', {}, g));
+ [[0, '#18204a'], [.55, '#5b3f74'], [.8, '#e0805a'], [1, '#f4b26a']].forEach(([k, c]) => mk('stop', { offset: k, 'stop-color': c }, gr));
+ mk('rect', { width: 1600, height: 700, fill: `url(#${id})` }, g);
+ const dim = put(mk('rect', { width: 1600, height: 700, fill: '#0b1226' }, g), { o: 0 });
+ const sky = G(g);
+ const sun = sunBody(sky, { x: 1290, y: 600, r: 52, glow: 3 });
+ const moon = globe(sky, { x: 170, y: 720, r: 40, kind: 'moon', light: 0, c: 1, rim: false });
+ const sea = G(g);
+ mk('rect', { x: 0, y: 650, width: 1600, height: 250, fill: '#2d4f78' }, sea);
+ path(sea, 'M0 650H1600', { stroke: '#f4b26a', 'stroke-width': 2, 'stroke-opacity': .6 });
+ path(g, 'M820 900C960 790 1080 760 1600 742V900Z', { fill: '#cdb07c', stroke: 'none' });
+ const water = path(g, 'M1010 900C1120 820 1250 790 1600 778H1720V960H1010Z', { fill: '#3d6b98', stroke: 'none', 'fill-opacity': .92 });
+ path(g, 'M0 690C180 600 420 560 620 600C780 632 880 760 960 900H0Z', { fill: '#24402f', stroke: 'none' });
+ const tree = G(g, { x: 250, y: 616 });
+ path(tree, 'M0 0V-90M0 -50L-26 -78M0 -64L22 -92', { stroke: '#4a3426', 'stroke-width': 12 });
+ const leaves = mk('circle', { cx: 0, cy: -110, r: 58, fill: '#4f9a52' }, tree);
+ return { g, sun, moon, water, tree, leaves, dim };
+}
+
+// The orbit with Earth at the solstices and equinoxes (June left, September in front, December right, March behind),
+// axes all parallel; the ones in dim are faded.
+function fourSeasons(p, D, dim) {
+ const C = [800, 480], RX = 560, RY = 220, E = {};
+ orbit(p, ...C, RX, RY);
+ sunBody(p, { x: C[0], y: C[1], r: 80 });
+ const pos = { jun: [180, 0, 0], sep: [270, -90, -.6], dec: [0, 180, 0], mar: [90, 90, .6] };
+ for (const [k, [a, light, c]] of Object.entries(pos)) {
+ const [x, y] = orbitAt(...C, RX, RY, a);
+ E[k] = globe(p, { x, y, r: 62, light, c, tilt: TILT, o: dim.includes(k) ? .35 : 1 }); put(E[k].axis, { o: 1 });
+ }
+ clockRun(t => Object.values(E).forEach(e => e.spin(30 * t)), D);
+ return E;
+}
+
+/* ---------- beats: [id, title, run(m, D), { ask }?] ---------- */
+const BEATS = [
+ ['intro', 'The Sun-Earth-Moon System', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 3 });
+ const C = [250, 610], RX = 640, RY = 110;
+ const behind = G(p); orbit(p, C[0], C[1], RX, RY, { o: .6 });
+ sunBody(p, { x: 250, y: 600, r: 150 });
+ const front = G(p);
+ const e = globe(front, { r: 70 }), mo = globe(front, { r: 20, kind: 'moon' }), moDepth = depth(mo, behind, front);
+ clockRun(t => {
+ const [x, y] = orbitAt(...C, RX, RY, -26 + 3 * t);
+ put(e, { x, y }); e.spin(40 + 30 * t).light(toward(x, y, ...C));
+ const a = 40 * t, mx = x + 110 * Math.cos(deg(a)), my = y - 34 * Math.sin(deg(a));
+ put(mo, { x: mx, y: my }); mo.light(toward(mx, my, ...C)); moDepth(Math.sin(deg(a)) > 0);
+ }, D);
+ const t = G(p, { o: 0, y: 20 });
+ pen(t, 'Unit 5 · Chapter 19', { x: 800, y: 170, size: 34, fill: INK.blue, anchor: 'middle', o: 1 });
+ pen(t, 'The Sun-Earth-Moon System', { x: 800, y: 270, size: 92, fill: INK.note, anchor: 'middle', o: 1 });
+ const ul = path(t, 'M380 302Q800 286 1220 300', { stroke: INK.hl, 'stroke-width': 8 }, { d: 0 });
+ tw(t, { o: 1, y: 0 }, .2, 1, out); draw(ul, .9, .7);
+ lab(p, 'three bodies, always moving', 800, 380, m('sub'), { anchor: 'middle', fill: INK.hl, size: 38 });
+ }],
+ ['daily', 'Every day in the sky', (m, D) => {
+ const p = panel(0), d = dusk(p);
+ const k = kid(p, { x: 600, y: 600, s: .8, pose: 'stand' }), dg = dog(p, { x: 700, y: 606, s: .8 });
+ alive(D, k, dg);
+ // sunset: the sun sinks behind the sea and the sky dims with it
+ tw(d.sun, { y: 700 }, m('set') - .6, 3.4, io); tw(d.dim, { o: .35 }, m('set') - .6, 4);
+ prog(q => k.pose('stand', 'point', q), m('set') - .4, .5);
+ lab(p, 'sunset', 1290, 560, m('set', .4), { anchor: 'middle' });
+ // moonrise on the other side: kid and dog turn to it
+ call(m('rise') - .45, () => { k.face(-1); dg.face(-1); });
+ prog(q => k.pose('point', 'pointUp', q), m('rise') - .4, .6);
+ tw(d.moon, { y: 330 }, m('rise') - .5, 3.2, out);
+ lab(p, 'moonrise', 170, 260, m('rise', .8), { anchor: 'middle' });
+ // the tide creeps up the beach
+ call(m('tide') - .4, () => { k.face(1); dg.face(1); });
+ prog(q => k.pose('pointUp', 'stand', q), m('tide') - .4, .5);
+ tw(d.water, { y: -42, x: -90 }, m('tide') - .3, 4.5, soft);
+ lab(p, 'the tide comes in', 1330, 860, m('tide', .6), { anchor: 'middle' });
+ // a year passes on the tree
+ const cols = ['#4f9a52', '#d9822b', '#e8eef5', '#7cc76f'];
+ prog(q => { const u = q * 3, i = Math.min(2, Math.floor(u)); d.leaves.setAttribute('fill', mix(cols[i], cols[i + 1], u - i)); }, m('seas') - .2, 4, lin);
+ lab(p, 'seasons', 250, 440, m('seas'), { anchor: 'middle' });
+ const all = G(p, { o: 0, y: -16 }); tw(all, { o: 1, y: 0 }, m('all'), .6, out);
+ mk('rect', { x: 330, y: 40, width: 940, height: 92, rx: 20, fill: INK.paper, 'fill-opacity': .95 }, all);
+ pen(all, 'all from the sun, Earth & moon moving together', { x: 800, y: 100, size: 40, fill: INK.ink, anchor: 'middle', o: 1 });
+ }],
+ ['shape', 'A slightly squashed sphere', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 11 }); heading(p, 'The EARTH');
+ const sqg = G(p), e = globe(sqg, { x: 600, y: 470, r: 270, kind: 'earthBig', light: 180, c: .9, night: .6 });
+ prog(q => sqg.setAttribute('transform', `translate(600 470) scale(${1 + .06 * q} ${1 - .08 * q}) translate(-600 -470)`), m('sq'), 1.4);
+ lab(p, 'SPHERE', 600, 150, .4, { anchor: 'middle', fill: INK.blue, size: 44 });
+ lab(p, '(squash exaggerated!)', 600, 800, m('sq', .9), { anchor: 'middle', fill: INK.hl, size: 28 });
+ // the kid walks in and spins a ball of dough on one finger; it flattens into a crust
+ const k = kid(p, { x: 1700, y: 860, s: 1.1, face: -1 }), t0 = m('dough') - 1.9, t1 = m('dough') - .2;
+ alive(D, k, null);
+ clockRun(t => { const x = keyf(t, [[t0, 1700], [t1, 1240]]); put(k, { x }); if (t < t1) k.walk(1700 - x); }, D);
+ prog(q => k.pose('stand', 'pointUp', q), t1, .5);
+ const dough = G(k.prop, { y: -24, o: 0 }), dz = mk('g', {}, dough);
+ mk('ellipse', { rx: 110, ry: 20, fill: '#efd9a8' }, dz); mk('ellipse', { rx: 92, ry: 13, fill: '#f6e6c2' }, dz);
+ const streak = path(dough, 'M-70 -34A90 26 0 0 0 70 -34', { stroke: INK.note, 'stroke-width': 3, 'stroke-dasharray': '10 10' });
+ show(dough, t1 + .3, .3);
+ prog(q => { dz.setAttribute('transform', `scale(${.5 + .5 * q} ${1.9 - .9 * q})`); streak.setAttribute('stroke-dashoffset', -q * 200); }, t1 + .3, 3.2, out);
+ lab(p, 'spinning dough spreads out', 1250, 330, m('dough', 1), { anchor: 'middle' });
+ const eq = G(p), eqL = path(eq, 'M330 470H870', { stroke: INK.blue, 'stroke-width': 5 }, { d: 0 }); draw(eqL, m('eq'), .8);
+ lab(eq, 'equator: 12,756 km', 600, 455, m('eq', .5), { anchor: 'middle', fill: INK.blue, size: 36 });
+ const pl = G(p), plL = path(pl, 'M600 200V740', { stroke: INK.pink, 'stroke-width': 5 }, { d: 0 }); draw(plL, m('pole'), .8);
+ const plT = G(pl, { o: 0 }); show(plT, m('pole', .5));
+ pen(plT, 'pole to pole:\n12,713 km', { x: 900, y: 150, size: 34, fill: INK.pink, o: 1 });
+ path(plT, 'M890 170L620 200', { stroke: INK.pink, 'stroke-width': 2.5 });
+ lab(p, 'only 0.3% different —\ntoo small to see!', 900, 640, m('tiny'), { fill: INK.hl, size: 34 });
+ }],
+ ['magnet', 'Earth is a magnet', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 12 }); heading(p, 'The EARTH');
+ const C = [700, 480], R = 200;
+ const field = G(p, { x: C[0], y: C[1], r: -10 }), lines = [];
+ [1.35, 1.8, 2.5, 3.6].forEach(L => [1, -1].forEach(sd => {
+ const pts = []; for (let a = 8; a <= 172; a += 4) { const th = deg(a), r = L * R * Math.sin(th) ** 2; if (r >= R * .98) pts.push([sd * r * Math.sin(th), -r * Math.cos(th)]); }
+ if (pts.length > 1) lines.push(path(field, 'M' + pts.map(q => q.map(v => v.toFixed(1)).join(' ')).join('L'), { stroke: INK.blue, 'stroke-width': 3, 'stroke-opacity': .75 }, { d: 0 }));
+ }));
+ lines.forEach((l, i) => draw(l, m('field') + i * .12, 1.1));
+ globe(p, { x: C[0], y: C[1], r: R, kind: 'earthBig', light: 180, c: .9, night: .5 });
+ const core = G(p, { x: C[0], y: C[1], o: 0, s: .6 });
+ mk('circle', { r: 110, fill: '#e07a3a', 'fill-opacity': .92 }, core); mk('circle', { r: 50, fill: '#ffd36b' }, core);
+ pen(core, 'liquid iron\nouter core', { x: 0, y: -60, size: 28, fill: INK.ink, anchor: 'middle', o: 1 });
+ // the core churns: its glow pulses while the narration describes it
+ tw(core, { o: 1, s: 1 }, .5, .7, back);
+ prog(q => put(core.children[0], { s: 1 + .03 * Math.sin(q * 40) }), .5, 5, lin);
+ hide(core, m('field'), .6);
+ lab(p, 'magnetic field', 1020, 200, m('field', .6), { fill: INK.blue });
+ // the compass needle swings and settles pointing north
+ const cp = G(p, { x: 1320, y: 620, o: 0, s: .7 }); pop(cp, m('comp') - .3);
+ mk('circle', { r: 120, fill: INK.paper, stroke: '#8a6f55', 'stroke-width': 10 }, cp);
+ pen(cp, 'N', { y: -78, size: 36, fill: INK.ink, anchor: 'middle', o: 1 });
+ const nd = G(cp);
+ path(nd, 'M0 -90L14 0L0 0Z', { fill: '#e5533d', stroke: 'none' }); path(nd, 'M0 90L-14 0L0 0Z', { fill: '#9aa3b5', stroke: 'none' });
+ path(nd, 'M0 -90L-14 0L0 0Z', { fill: '#c43f2c', stroke: 'none' }); path(nd, 'M0 90L14 0L0 0Z', { fill: '#7b8396', stroke: 'none' });
+ mk('circle', { r: 8, fill: INK.ink }, cp);
+ clockRun(t => { const u = Math.max(0, t - m('comp')); put(nd, { r: t < m('comp') ? 75 : 75 * Math.exp(-1.3 * u) * Math.cos(4.2 * u) }); }, D);
+ lab(p, 'compass', 1320, 790, m('comp', .4), { anchor: 'middle' });
+ const gn = G(p, { o: 0 }); show(gn, m('off'));
+ mk('circle', { cx: C[0], cy: C[1] - R, r: 9, fill: INK.note }, gn);
+ pen(gn, 'geographic North Pole', { x: C[0] + 70, y: C[1] - R - 70, size: 28, o: 1 });
+ path(gn, `M${C[0] + 6} ${C[1] - R - 8}L${C[0] + 66} ${C[1] - R - 62}`, { stroke: INK.note, 'stroke-width': 2.5 });
+ const mn = G(p, { o: 0 }); show(mn, m('off', 1.2));
+ const mx = C[0] - R * Math.sin(deg(10)), my = C[1] - R * Math.cos(deg(10));
+ const md = G(mn, { x: mx, y: my }); mk('circle', { r: 9, fill: '#e5533d' }, md);
+ pen(mn, 'magnetic north', { x: mx - 70, y: my - 70, size: 28, fill: '#ff8f7a', anchor: 'end', o: 1 });
+ path(mn, `M${mx - 6} ${my - 8}L${mx - 66} ${my - 62}`, { stroke: '#ff8f7a', 'stroke-width': 2.5 });
+ // it wanders: the dot drifts a little, leaving a dotted trail
+ const trail = path(mn, `M${mx} ${my}Q${mx + 14} ${my - 6} ${mx + 26} ${my + 2}`, { stroke: '#ff8f7a', 'stroke-width': 3, 'stroke-dasharray': '3 6' }, { d: 0 });
+ draw(trail, m('drift'), 2.4, lin); prog(q => put(md, { x: mx + 26 * q, y: my - 6 * Math.sin(q * Math.PI) + 2 * q }), m('drift'), 2.4, lin);
+ lab(p, 'it drifts a little every year', 220, 820, m('drift'), { fill: INK.hl });
+ }],
+ ['rotate', 'Rotation', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 13 }); heading(p, "Earth's Motion");
+ const e = globe(p, { x: 800, y: 470, r: 220, light: 180, c: .6 }), T0 = m('day');
+ // a slow spin, then one whole turn while the clock counts a day
+ const turn = t => 12 * t + 360 * soft(clamp01((t - T0) / 4));
+ const hrs = lab(p, '', 1230, 760, T0, { fill: INK.hl, size: 44 });
+ clockRun(t => { e.spin(turn(t)); setText(hrs, t < T0 ? '' : `${Math.round(24 * soft(clamp01((t - T0) / 4)))} h`); }, D);
+ tw(e.axis, { o: 1 }, m('axis') - .3, .5);
+ lab(p, 'axis', 830, 160, m('axis', .2), { size: 36 });
+ lab(p, 'N', 770, 196, m('axis', .2), { size: 36, fill: INK.hl }); lab(p, 'S', 770, 790, m('axis', .2), { size: 36, fill: INK.hl });
+ draw(spinArrow(p, 800, 470, 290, 200, 340, { ry: 70, color: INK.hl, w: 6 }), m('rot'), .8);
+ hlAt(p, 'ROTATION', 1260, 260, m('rot'));
+ lab(p, '1 turn ≈ 24 hours\n= 1 day', 1170, 600, m('day'), { fill: INK.blue, size: 40 });
+ }],
+ ['daynight', 'Day and night', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 14 });
+ sunBody(p, { x: -120, y: 450, r: 220 });
+ raysOn(sunRays(p, { x0: 140, x1: 560, y0: 250, y1: 650, n: 5 }), m('lit') - .3);
+ const e = globe(p, { x: 900, y: 450, r: 240, kind: 'pole', light: 180, night: .82 });
+ lab(p, 'seen from above the North Pole', 900, 120, .4, { anchor: 'middle', fill: INK.dim });
+ lab(p, 'DAY', 640, 260, m('lit'), { size: 40, fill: INK.hl }); lab(p, 'NIGHT', 1180, 260, m('lit'), { size: 40, fill: INK.blue });
+ // the kid stands on the turning Earth: midnight on the right, morning at the top, noon facing the sun, evening below
+ const pin = G(p, { x: 900, y: 450 }), me = G(pin, { y: -240 }), k = kid(me, { s: .32 });
+ const spin = t => keyf(t, [[0, 50], [m('ride'), 90], [m('noon'), 180], [m('eve'), 270], [D, 330]]);
+ clockRun(t => { const a = spin(t); e.spin(a); put(pin, { r: 90 - a }); }, D);
+ alive(D, k, null);
+ lab(p, 'morning', 1060, 200, m('ride')); lab(p, 'noon', 560, 530, m('noon'), { anchor: 'end' });
+ lab(p, 'evening', 900, 740, m('eve'), { anchor: 'middle' });
+ draw(spinArrow(p, 900, 450, 290, 60, 120, { color: INK.hl }), m('ride'));
+ // from the ground: the sun seems to cross the sky from east to west
+ const box = G(p, { o: 0 }); show(box, m('sky') - .2);
+ mk('rect', { x: 1150, y: 540, width: 420, height: 300, rx: 18, fill: '#2f4f86', stroke: INK.note, 'stroke-width': 3 }, box);
+ path(box, 'M1190 760Q1360 560 1530 760', { stroke: INK.hl, 'stroke-width': 3, 'stroke-dasharray': '8 8' });
+ const bs = G(box); mk('circle', { r: 22, fill: SKY.sun }, bs);
+ mk('rect', { x: 1150, y: 760, width: 420, height: 80, fill: '#24402f' }, box);
+ kid(box, { x: 1360, y: 790, s: .18, pose: 'lookUp' });
+ pen(box, 'E', { x: 1170, y: 805, size: 30, o: 1 }); pen(box, 'W', { x: 1535, y: 805, size: 30, o: 1 });
+ pen(box, 'what we see from the ground', { x: 1360, y: 580, size: 26, anchor: 'middle', fill: INK.note, o: 1 });
+ clockRun(t => { const u = clamp01((t - m('sky')) / 5.5); put(bs, { x: (1 - u) ** 2 * 1190 + 2 * u * (1 - u) * 1360 + u * u * 1530, y: (1 - u) ** 2 * 760 + 2 * u * (1 - u) * 560 + u * u * 760 }); }, D);
+ lab(p, "the sun isn't moving — we are!", 1360, 880, m('us'), { anchor: 'middle', fill: INK.hl });
+ }],
+ ['revolve', 'Revolution', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 15 });
+ const C = [800, 470], RX = 600, RY = 230;
+ const o = put(orbit(p, ...C, RX, RY), { o: 0 }); show(o, m('orb') - .3);
+ const behind = G(p); sunBody(p, { x: C[0], y: C[1], r: 90 }); const front = G(p);
+ const e = globe(front, { r: 50 }), dz = depth(e, behind, front), T0 = m('rev'), T1 = D - .4;
+ const day = lab(p, '', 1250, 800, T0, { fill: INK.blue, size: 40 });
+ clockRun(t => {
+ const a = 250 + 360 * soft(clamp01((t - T0) / (T1 - T0))), [x, y] = orbitAt(...C, RX, RY, a);
+ put(e, { x, y, s: 1 + .3 * (y - C[1]) / RY }); e.spin(40 * t).light(toward(x, y, ...C)); dz(y < C[1]);
+ setText(day, t < T0 ? '' : `day ${Math.round(365.25 * soft(clamp01((t - T0) / (T1 - T0))))}`);
+ }, D);
+ hlAt(p, 'REVOLUTION', 800, 140, m('rev'));
+ lab(p, 'ORBIT', 1290, 330, m('orb'), { size: 40, fill: INK.blue });
+ lab(p, '1 revolution = 365¼ days = 1 year', 800, 880, m('year'), { anchor: 'middle', size: 40, fill: INK.hl });
+ }],
+ ['leap', 'Leap years', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 16, o: .6 });
+ [260, 620, 980, 1340].forEach((x, i) => {
+ const c = G(p, { x, y: 330, o: 0 }); tw(c, { o: 1, y: 300 }, .3 + i * .15, .5, out);
+ mk('rect', { x: -140, y: -110, width: 280, height: 220, rx: 16, fill: INK.paper }, c);
+ mk('rect', { x: -140, y: -110, width: 280, height: 56, rx: 16, fill: '#e5533d' }, c);
+ pen(c, `Year ${i + 1}`, { y: -70, size: 34, fill: INK.paper, anchor: 'middle', o: 1 });
+ pen(c, '365 days', { y: 10, size: 40, fill: INK.ink, anchor: 'middle', o: 1 });
+ pen(c, '+ ¼ day', { y: 70, size: 36, fill: '#c43f2c', anchor: 'middle', o: 1 });
+ // each year's left-over quarter drops out, then all four fly together into one whole day
+ const q = G(p, { x, y: 470, o: 0 }); tw(q, { o: 1, y: 520 }, m('q1') + i * .45, .5, back);
+ path(q, 'M0 0V-60A60 60 0 0 1 60 0Z', { fill: INK.hl, stroke: INK.ink, 'stroke-width': 3 });
+ tw(q, { x: 800, y: 620, r: 90 * i }, m('q4') + i * .25, .9, io);
+ });
+ lab(p, '4 × ¼ day = 1 whole day', 800, 750, m('q4', 1.6), { anchor: 'middle', size: 40, fill: INK.hl });
+ const feb = G(p, { x: 1250, y: 640, o: 0, s: .6 }); pop(feb, m('feb'));
+ mk('rect', { x: -110, y: -110, width: 220, height: 200, rx: 16, fill: INK.paper }, feb);
+ mk('rect', { x: -110, y: -110, width: 220, height: 50, rx: 16, fill: INK.blue }, feb);
+ pen(feb, 'FEB', { y: -74, size: 34, fill: INK.ink, anchor: 'middle', o: 1 }); pen(feb, '29', { y: 50, size: 96, fill: INK.ink, anchor: 'middle', o: 1 });
+ hlAt(p, 'LEAP YEAR', 1250, 820, m('leap'));
+ }],
+ ['ellipse', 'An ellipse, not a circle', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 17 });
+ const C = [820, 450], RX = 480, RY = 360, F = Math.sqrt(RX * RX - RY * RY), Sx = C[0] - F;
+ orbit(p, ...C, RX, RY, { dash: '', w: 3 });
+ sunBody(p, { x: Sx, y: C[1], r: 60 });
+ lab(p, 'seen from above, stretched so you can see it —\nthe real orbit is almost a circle', 60, 80, .4, { fill: INK.dim, size: 28 });
+ hlAt(p, 'ELLIPSE', 1180, 150, m('ell'));
+ // Earth runs along the ellipse: January at the near end, July at the far end; the sun-Earth line shows the distance
+ const dl = path(p, '', { stroke: INK.note, 'stroke-width': 2.5, 'stroke-dasharray': '6 8' });
+ const e = globe(p, { r: 34 });
+ const th = t => keyf(t, [[0, 120], [m('jan'), 180], [m('jul'), 360], [D, 400]]);
+ clockRun(t => {
+ const [x, y] = orbitAt(...C, RX, RY, th(t)); put(e, { x, y }); e.spin(60 * t).light(toward(x, y, Sx, C[1]));
+ dl.setAttribute('d', `M${Sx} ${C[1]}L${x.toFixed(1)} ${y.toFixed(1)}`);
+ }, D);
+ lab(p, 'early January\n147 million km', C[0] - RX - 10, C[1] + 90, m('jan'), { fill: INK.hl });
+ lab(p, 'early July\n152 million km', C[0] + RX - 160, C[1] + 90, m('jul'), { fill: INK.blue });
+ const k = kid(p, { x: 1700, y: 880, s: .6, face: -1 }), t0 = m('q') - 1.4, t1 = m('q');
+ alive(D, k, null);
+ clockRun(t => { const x = keyf(t, [[t0, 1700], [t1, 1400]]); put(k, { x }); if (t < t1) k.walk((1700 - x) / .6); }, D);
+ prog(q => k.pose('stand', 'shrug', q), t1, .4);
+ pop(bubble(p, 'closest in WINTER?!', { x: 1200, y: 700, tx: 150, ty: 70 }), t1 + .2);
+ lab(p, 'distance ≠ seasons', 800, 820, m('not'), { anchor: 'middle', size: 48, fill: '#ff8f7a' });
+ }],
+ ['tilt', "Earth's tilt", (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 18 });
+ const C = [800, 470], R = 180, RX = 640, RY = 70, T2 = m('same'), T3 = T2 + 1.4;
+ const pl = G(p, { o: 0 }); show(pl, .3);
+ path(pl, `M${C[0] - RX} ${C[1]}A${RX} ${RY} 0 1 0 ${C[0] + RX} ${C[1]}A${RX} ${RY} 0 1 0 ${C[0] - RX} ${C[1]}`, { stroke: SKY.orbit, 'stroke-width': 3, 'stroke-dasharray': '10 12' });
+ pen(pl, 'plane of the orbit', { x: 180, y: C[1] + 110, size: 28, fill: SKY.orbit, o: 1 });
+ const behind = G(p), sun = sunBody(p, { x: C[0], y: C[1], r: 64, o: 0, s: .5 }), front = G(p);
+ const e = globe(front, { x: C[0], y: C[1], r: R, light: 180, c: .5 }), dz = depth(e, behind, front);
+ show(e.axis, .4);
+ const perp = path(p, `M${C[0]} ${C[1] - 300}V${C[1] + 300}`, { stroke: INK.note, 'stroke-width': 3, 'stroke-dasharray': '4 10' }, { d: 0 });
+ draw(perp, m('perp'));
+ // the axis leans away from the upright line; the arc grows with it
+ const rA = 300, arc = path(p, '', { stroke: INK.hl, 'stroke-width': 5 });
+ const lean = t => TILT * soft(clamp01((t - m('lean')) / 1.6));
+ const deg23 = hlAt(p, '23.44°', C[0] + 120, C[1] - 330, m('lean', 1.2), { size: 44 });
+ // then Earth shrinks onto its orbit around the sun and travels, its axis staying parallel to itself
+ const pos = t => {
+ if (t < T2) return [C[0], C[1], 1];
+ const [x, y] = orbitAt(...C, RX, RY, 200 + 26 * Math.max(0, t - T3)), q = soft(clamp01((t - T2) / 1.4));
+ return [lerp(C[0], x, q), lerp(C[1], y, q), lerp(1, .38, q)];
+ };
+ clockRun(t => {
+ const a = lean(t), [x, y, s] = pos(t);
+ e.tilt(a); put(e, { x, y, s }); e.spin(20 * t); dz(t > T3 && y < C[1] - 1);
+ if (t >= T2) e.light(toward(x, y, ...C), 0);
+ const a1 = -90 + a;
+ arc.setAttribute('d', a < .1 ? '' : `M${C[0]} ${C[1] - rA}A${rA} ${rA} 0 0 1 ${(C[0] + rA * Math.cos(deg(a1))).toFixed(1)} ${(C[1] + rA * Math.sin(deg(a1))).toFixed(1)}`);
+ }, D);
+ tw(sun, { o: 1, s: 1 }, T2 + .6, .6, back);
+ [perp, arc, deg23].forEach(x => hide(x, T2, .5));
+ const st = G(p, { x: 1330, y: 140, o: 0 }); show(st, T2 + .4);
+ path(st, 'M0 -26L7 -8L26 -8L11 4L17 24L0 12L-17 24L-11 4L-26 -8L-7 -8Z', { fill: INK.hl, stroke: 'none' });
+ pen(st, 'North Star', { x: 36, y: 10, size: 32, fill: INK.hl, o: 1 });
+ lab(p, 'the axis always points\nthe same way in space', 1080, 700, T2 + 1.5, { fill: INK.hl });
+ }],
+ ['seasons', 'Seasons', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 19 });
+ const C = [800, 470], RX = 560, RY = 190;
+ orbit(p, ...C, RX, RY);
+ const behind = G(p); sunBody(p, { x: C[0], y: C[1], r: 90 }); const front = G(p);
+ const ghost = globe(front, { x: C[0] - RX, y: C[1], r: 90, light: 0, tilt: TILT, spin: 30, o: 0 }); put(ghost.axis, { o: 1 });
+ const e = globe(front, { r: 90, tilt: TILT }); show(e.axis, 0, .01);
+ const N = pen(p, 'N', { size: 34, fill: INK.hl, anchor: 'middle', o: 1 });
+ const T0 = m('dec') - 3.6, T1 = m('dec') - .2;
+ clockRun(t => {
+ const a = 180 + 180 * soft(clamp01((t - T0) / (T1 - T0))), [x, y] = orbitAt(...C, RX, RY, a), s = 1 + .2 * (y - C[1]) / RY;
+ put(e, { x, y, s }); e.spin(30 * t).light(toward(x, y, ...C));
+ put(N, { x: x + 1.55 * 90 * s * Math.sin(deg(TILT)), y: y - 1.55 * 90 * s * Math.cos(deg(TILT)) + 10 });
+ }, D);
+ at(ghost, { o: .3 }, T0);
+ lab(p, 'JUNE', C[0] - RX, C[1] - 170, m('jun'), { anchor: 'middle', size: 40, fill: INK.hl });
+ lab(p, 'north leans TOWARD the sun', C[0] - RX, C[1] + 160, m('jun', .5), { anchor: 'middle', size: 30, fill: INK.hl });
+ lab(p, 'DECEMBER', C[0] + RX, C[1] - 170, m('dec'), { anchor: 'middle', size: 40, fill: INK.blue });
+ lab(p, 'north leans AWAY', C[0] + RX, C[1] + 160, m('away'), { anchor: 'middle', size: 30, fill: INK.blue });
+ lab(p, "no wobble — Earth just moved\nto the other side of the sun", 800, 790, m('nowob'), { anchor: 'middle', fill: INK.note });
+ }],
+ ['angle', 'The angle of sunlight', (m, D) => {
+ const p = panel(0); mk('rect', { width: 1600, height: 900, fill: '#20283f' }, p);
+ const Y = 720, W = 120;
+ mk('rect', { x: 0, y: Y, width: 1600, height: 200, fill: '#3b4a3a' }, p);
+ const grid = G(p); for (let x = 0; x <= 1600; x += 40) path(grid, `M${x} ${Y}v14`, { stroke: INK.dim, 'stroke-width': 2 });
+ const k = kid(p, { x: 300, y: Y, s: 1.6, pose: { ...KID_POSE.stand, fa: [92, 92], head: 14 } }); alive(D, k, null);
+ const [hx, hy] = k.hand();
+ // the flashlight in the kid's hand; phi is its angle from straight down. The beam (width W) lands on the ground
+ // over W / cos(phi): the same light spread over more ground, so each bit gets cos(phi) as much.
+ const ghost = G(p, { o: 0 }), beam = path(p, '', { fill: '#fff3c2', stroke: 'none' }, { o: 0 }), patch = path(p, '', { stroke: SKY.light, 'stroke-width': 14 }, { o: 0 });
+ const torch = G(p, { x: hx, y: hy }), LENS = 46;
+ mk('rect', { x: -18, y: -40, width: 36, height: 54, rx: 7, fill: '#9aa3b5' }, torch);
+ path(torch, `M-18 12L${-W / 2} ${LENS}H${W / 2}L18 12Z`, { fill: '#cfd5e2', stroke: 'none' });
+ path(ghost, `M${hx - W / 2} ${Y}H${hx + W / 2}`, { stroke: SKY.light, 'stroke-width': 14, 'stroke-opacity': .5 });
+ const span = lab(p, '', 0, Y + 70, 0, { size: 32, anchor: 'middle', fill: INK.hl });
+ const phi = t => 60 * soft(clamp01((t - m('tilt')) / 2.2));
+ clockRun(t => {
+ const f = phi(t), c = Math.cos(deg(f)), s = Math.sin(deg(f)), lx = hx + LENS * s, ly = hy + LENS * c, h = Y - ly;
+ const cx = lx + h * Math.tan(deg(f)), half = W / 2 / c, ux = -c * W / 2, uy = s * W / 2; // ux, uy: half-width across the beam
+ beam.setAttribute('d', `M${lx + ux} ${ly + uy}L${cx - half} ${Y}H${cx + half}L${lx - ux} ${ly - uy}Z`);
+ beam.setAttribute('fill-opacity', (.42 * c).toFixed(3)); patch.setAttribute('stroke-opacity', c.toFixed(3));
+ patch.setAttribute('d', `M${cx - half} ${Y}H${cx + half}`);
+ put(torch, { r: -f }); put(span, { x: cx });
+ setText(span, t < m('spot') ? '' : `${Math.round(2 * half / 40)} squares lit`);
+ }, D);
+ show(beam, m('spot') - .3, .3); show(patch, m('spot') - .3, .3);
+ lab(p, 'flashlight', hx, hy - 70, m('torch'), { anchor: 'middle' });
+ lab(p, 'small, bright spot', hx, Y + 120, m('spot', .5), { anchor: 'middle', fill: INK.hl });
+ show(ghost, m('tilt'), .3);
+ lab(p, 'same light, spread out: dimmer', hx + 560, Y + 120, m('tilt', 2), { anchor: 'middle', fill: INK.blue });
+ const s1 = G(p, { o: 0 }); show(s1, m('high')); sunBody(s1, { x: 380, y: 110, r: 36 }); pen(s1, 'summer sun: high, like the straight beam', { x: 440, y: 120, size: 30, fill: INK.hl, o: 1 });
+ const s2 = G(p, { o: 0 }); show(s2, m('high', 1.4)); sunBody(s2, { x: 1460, y: 300, r: 36 }); pen(s2, 'winter sun: low,\nlike the tilted beam', { x: 1400, y: 270, size: 30, fill: INK.blue, anchor: 'end', o: 1 });
+ }],
+ ['hours', 'Longer days', (m, D) => {
+ const p = panel(0); mk('rect', { width: 1600, height: 900, fill: '#2a4677' }, p);
+ const Y = 720, bez = (u, x0, cy, x1) => [(1 - u) ** 2 * x0 + 2 * u * (1 - u) * 800 + u * u * x1, (1 - u) ** 2 * Y + 2 * u * (1 - u) * cy + u * u * Y];
+ mk('rect', { x: 0, y: Y, width: 1600, height: 180, fill: '#2d4a35' }, p);
+ const k = kid(p, { x: 300, y: Y + 10, s: .7, pose: 'lookUp' }), dg = dog(p, { x: 390, y: Y + 12, s: .6 }); alive(D, k, dg);
+ pen(p, 'E', { x: 120, y: Y + 60, size: 36, o: 1 }); pen(p, 'W', { x: 1460, y: Y + 60, size: 36, o: 1 });
+ const sum = path(p, `M170 ${Y}Q800 -330 1430 ${Y}`, { stroke: INK.hl, 'stroke-width': 5, 'stroke-dasharray': '12 10' });
+ const win = path(p, `M420 ${Y}Q800 330 1180 ${Y}`, { stroke: INK.blue, 'stroke-width': 5, 'stroke-dasharray': '12 10' });
+ put(sum, { o: 0 }); put(win, { o: 0 }); show(sum, m('sumd'), .4); show(win, m('wind'), .4);
+ // each sun crosses its own path; a counter adds up its hours of daylight
+ const s1 = sunBody(p, { r: 46, o: 0 }), s2 = sunBody(p, { r: 40, o: 0 });
+ const c1 = lab(p, '', 1000, 230, m('sumd'), { fill: INK.hl, size: 34 }), c2 = lab(p, '', 960, 560, m('wind'), { fill: INK.blue, size: 34 });
+ show(s1, m('sumd'), .3); show(s2, m('wind'), .3);
+ clockRun(t => {
+ const u1 = clamp01((t - m('sumd')) / 5), u2 = clamp01((t - m('wind')) / 3.4);
+ const [x1, y1] = bez(u1, 170, -330, 1430), [x2, y2] = bez(u2, 420, 330, 1180);
+ put(s1, { x: x1, y: y1 }); put(s2, { x: x2, y: y2 });
+ setText(c1, `${Math.round(15 * u1)} hours of daylight`); setText(c2, `${Math.round(9 * u2)} hours`);
+ }, D);
+ lab(p, 'summer: long, high path', 1000, 170, m('sumd', .4), { fill: INK.hl });
+ lab(p, 'winter: short, low path', 960, 500, m('wind', .4), { fill: INK.blue });
+ lab(p, 'more intense light + more hours = SUMMER', 800, 860, m('both'), { anchor: 'middle', size: 36, fill: INK.hl });
+ }],
+ ['hemis', 'Opposite seasons', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 20 });
+ sunBody(p, { x: 1720, y: 450, r: 260 });
+ const e = globe(p, { x: 700, y: 460, r: 250, light: 0, tilt: -TILT }); show(e.axis, 0, .01);
+ clockRun(t => e.spin(225 + 8 * t), D);
+ const hemi = e.axis.parentNode;
+ const nH = path(hemi, 'M-250 0A250 250 0 0 1 250 0Z', { fill: INK.blue, 'fill-opacity': .16, stroke: 'none' }, { o: 0 });
+ const sH = path(hemi, 'M-250 0A250 250 0 0 0 250 0Z', { fill: INK.hl, 'fill-opacity': .14, stroke: 'none' }, { o: 0 });
+ path(hemi, 'M-262 0H262', { stroke: INK.note, 'stroke-width': 3, 'stroke-dasharray': '8 8' });
+ pen(hemi, 'equator', { x: 268, y: 10, size: 26, o: 1 });
+ show(nH, m('us') - .2); show(sH, m('au') - .2);
+ lab(p, 'NORTH leans away', 260, 170, .4, { fill: INK.blue, size: 34 });
+ lab(p, 'United States: WINTER', 120, 260, m('us'), { fill: INK.blue, size: 40 });
+ lab(p, 'SOUTH leans toward', 260, 770, .4, { fill: INK.hl, size: 34 });
+ lab(p, 'Australia: SUMMER', 120, 700, m('au'), { fill: INK.hl, size: 40 });
+ }],
+ ['q1', 'Quick check: seasons', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 21 });
+ const C = [470, 450];
+ orbit(p, ...C, 380, 150);
+ sunBody(p, { x: C[0], y: C[1], r: 70 });
+ const e = globe(p, { x: C[0] + 380, y: C[1], r: 80, light: 180, tilt: TILT, spin: 40 }); show(e.axis, 0, .01);
+ lab(p, 'N', C[0] + 380 + 60, C[1] - 150, 0, { fill: INK.hl, size: 36 });
+ }, { ask: done => quiz({ x: 1010, y: 120, w: 560, cls: 'side' }, [{
+ id: 'c-seasons', prompt: ['Earth is here in its orbit, with its north end leaning away from the sun. What season does each hemisphere have?'],
+ build: grid([
+ { parts: ['Northern'], ans: ['win'], why: 'The north leans away from the sun: low sunlight and short days.' },
+ { parts: ['Southern'], ans: ['sum'], why: 'The south leans toward the sun: high sunlight and long days.' },
+ ], [['sum', 'Summer', INK.hl], ['win', 'Winter', INK.blue]], { multi: false, text: true }),
+ }], done) }],
+ ['solstice', 'Solstices', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 22 });
+ const E = fourSeasons(p, D, ['sep', 'mar']);
+ hlAt(p, 'SOLSTICE', 800, 110, m('sol'));
+ pulse(E.jun, m('jun'), 1.25); pulse(E.dec, m('dec'), 1.25);
+ lab(p, 'SUMMER SOLSTICE\n~ June 21', 70, 300, m('jun'), { fill: INK.hl, size: 34 });
+ lab(p, 'longest day,\nhighest noon sun', 70, 640, m('jun', 1.5), { fill: INK.hl, size: 30 });
+ lab(p, 'WINTER SOLSTICE\n~ December 21', 1310, 300, m('dec'), { fill: INK.blue, size: 34 });
+ lab(p, 'shortest day,\nlowest noon sun', 1330, 640, m('dec', 1.5), { fill: INK.blue, size: 30 });
+ }],
+ ['equinox', 'Equinoxes', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 22 });
+ const E = fourSeasons(p, D, ['jun', 'dec']);
+ hlAt(p, 'EQUINOX', 800, 110, m('eq'), { color: INK.def });
+ // close-up: sunlight from the side, the day-night line through both poles
+ const z = G(p, { o: 0, y: 30 }); tw(z, { o: 1, y: 0 }, m('over') - .2, .6, out);
+ mk('rect', { x: 980, y: 560, width: 560, height: 300, rx: 18, fill: SKY.deep, stroke: INK.note, 'stroke-width': 3 }, z);
+ const ze = globe(z, { x: 1360, y: 710, r: 110, light: 180 }); put(ze.axis, { o: 1 });
+ clockRun(t => ze.spin(30 * t), D);
+ sunRays(z, { x0: 1010, x1: 1230, y0: 650, y1: 770, n: 3 })._lines.forEach(l => put(l, { d: 1 }));
+ pen(z, 'sun over the equator', { x: 1020, y: 610, size: 28, fill: INK.hl, o: 1 });
+ lab(p, 'day ≈ night ≈ 12 hours, everywhere', 1260, 886, m('twelve'), { anchor: 'middle', size: 30, fill: INK.hl });
+ pulse(E.mar, m('mar'), 1.25); pulse(E.sep, m('sep'), 1.25);
+ lab(p, 'VERNAL EQUINOX\n~ March 20: spring', 960, 200, m('mar'), { size: 32, fill: INK.def });
+ lab(p, 'AUTUMNAL EQUINOX\n~ Sept 22: fall', 450, 760, m('sep'), { anchor: 'end', size: 32, fill: INK.def });
+ const dg = dog(p, { x: 140, y: 880, s: .7, o: 0 }); show(dg, m('south') - .4); alive(D, null, dg);
+ pop(bubble(p, 'Southern hemisphere?\nFlip every label!', { x: 260, y: 700, tx: -90, ty: 80 }), m('south'));
+ }],
+ ['moon', 'Our moon', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 30 }); heading(p, 'The MOON');
+ const e = globe(p, { x: 420, y: 470, r: 120, light: 180, c: .4 });
+ orbit(p, 420, 470, 300, 300, { o: .7 });
+ const mo = globe(p, { r: 32, kind: 'moon', light: 180, c: .4 });
+ clockRun(t => { const [x, y] = orbitAt(420, 470, 300, 300, 18 * t); put(mo, { x, y }); e.spin(20 * t); }, D);
+ hlAt(p, 'NATURAL SATELLITE', 420, 160, m('sat'));
+ // long ago: a Mars-sized body hits the young Earth, debris rings it, then gathers into the moon
+ const imp = G(p, { o: 0 }); show(imp, m('young') - .2);
+ mk('rect', { x: 860, y: 140, width: 700, height: 680, rx: 20, fill: SKY.deep, stroke: INK.note, 'stroke-width': 3 }, imp);
+ pen(imp, '4.5 billion years ago', { x: 890, y: 190, size: 28, fill: INK.dim, o: 1 });
+ const cam = G(imp), ye = G(cam, { x: 1210, y: 500 });
+ mk('circle', { r: 130, fill: '#a8462a' }, ye); mk('circle', { r: 130, fill: 'none', stroke: '#ff9a55', 'stroke-width': 6 }, ye);
+ pen(imp, 'young Earth', { x: 1210, y: 690, size: 30, anchor: 'middle', o: 1 });
+ const th = G(cam, { x: 960, y: 310, o: 0 }); mk('circle', { r: 68, fill: '#8a6f55' }, th);
+ const thL = pen(th, 'Mars-sized body', { y: -84, size: 28, anchor: 'middle', o: 1 });
+ show(th, m('hit') - .6, .3);
+ tw(th, { x: 1110, y: 410 }, m('hit') - .3, 1, p => p * p);
+ const flash = G(cam, { x: 1150, y: 440, o: 0, s: .2 }); mk('circle', { r: 120, fill: '#fff2c4' }, flash);
+ const T = m('hit') + .7;
+ tw(flash, { o: 1, s: 1 }, T, .15, out); tw(flash, { o: 0, s: 1.6 }, T + .15, .7);
+ at(th, { o: 0 }, T + .1);
+ prog(q => cam.setAttribute('transform', q > 0 && q < 1 ? `translate(${(8 * Math.sin(q * 60) * (1 - q)).toFixed(1)} ${(6 * Math.cos(q * 47) * (1 - q)).toFixed(1)})` : ''), T, 1.2, lin);
+ const R = rng(4), dots = [];
+ for (let i = 0; i < 90; i++) dots.push([R() * 6.283, 190 + R() * 60, 3 + R() * 5, R() * .4]);
+ const deb = path(imp, '', { fill: '#c9b59a', stroke: 'none' }), MB = [1440, 560];
+ clockRun(t => {
+ if (t < T) { if (deb._on) { deb.setAttribute('d', ''); deb._on = 0; } return; }
+ const sp = clamp01((t - T) / 1.2), g = soft(clamp01((t - m('ball')) / 2.2));
+ deb._on = 1;
+ deb.setAttribute('d', dotsPath(dots.map(([a0, rr, r, dl]) => {
+ const a = a0 + .35 * (t - T), x = 1150 + (60 + (rr - 60) * sp) * Math.cos(a), y = 470 + (60 + (rr - 60) * sp) * Math.sin(a) * .35;
+ return [lerp(x, MB[0], clamp01(g * 1.15 - dl * .3)), lerp(y, MB[1], clamp01(g * 1.15 - dl * .3)), r * (1 - .7 * g)];
+ })));
+ }, D);
+ lab(imp, 'debris', 1450, 420, m('ring', .4), { size: 28 });
+ const mb = globe(imp, { x: MB[0], y: MB[1], r: 34, kind: 'moon', light: 180, c: .5, o: 0, s: .3 });
+ tw(mb, { o: 1, s: 1 }, m('ball') + 1.2, 1.2, out); hide(deb, m('ball') + 2.2, .5);
+ lab(p, 'the moon!', MB[0], MB[1] + 80, m('moon'), { anchor: 'middle', fill: INK.hl, size: 36 });
+ }],
+ ['surface', "The moon's surface", (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 31 });
+ const C = [760, 470], R = 340, cam = camera(p, D);
+ globe(cam.world, { x: C[0], y: C[1], r: R, kind: 'moon', light: 0, c: 1, rim: false });
+ const ice = G(cam.world, { o: 0 }); show(ice, m('ice') + 1.2);
+ mk('circle', { cx: C[0] + 30, cy: C[1] + R - 20, r: 24, fill: 'none', stroke: INK.blue, 'stroke-width': 4 }, ice);
+ heading(p, 'The MOON');
+ const labels = G(p);
+ lead(labels, C[0] + 40, C[1] + 230, 1160, 760, m('hi'), INK.hl);
+ hlAt(labels, 'LUNAR HIGHLANDS', 1300, 790, m('hi'));
+ lab(labels, 'bright mountains & craters', 1170, 850, m('hi', .6), { fill: INK.note, size: 28 });
+ lead(labels, C[0] - 120, C[1] - 120, 340, 230, m('mar'), INK.hl);
+ hlAt(labels, 'MARIA', 260, 200, m('mar'));
+ lab(labels, 'dark plains of\nhardened lava', 160, 280, m('mar', .6), { size: 30 });
+ lab(labels, 'moonquakes!', 1240, 200, m('quake'), { fill: '#ff8f7a', size: 40 });
+ cam.shake(12, m('quake') - .1, 1.6, 9);
+ // push in on the south pole, where dark craters hide ice
+ hide(labels, m('ice') - .3, .4);
+ cam.to({ x: C[0] + 30, y: C[1] + R - 60, z: 2.4 }, m('ice') - .2, 1.8);
+ lab(p, 'water ice in dark craters near the poles', 800, 700, m('ice', 1.4), { anchor: 'middle', fill: INK.blue, size: 34 });
+ const dg = dog(p, { x: 1440, y: 880, s: .7, o: 0, face: -1 }); show(dg, m('ice') + 1.6); alive(D, null, dg);
+ pop(bubble(p, 'Lunar sorbet!\nMMM.', { x: 1400, y: 720, tx: 30, ty: 70 }), m('ice', 2.2));
+ }],
+ ['sameface', 'The same face', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 32 });
+ const C = [560, 470], OR = 300;
+ const e = globe(p, { x: C[0], y: C[1], r: 90, kind: 'pole', light: 180 });
+ orbit(p, C[0], C[1], OR, OR, { o: .7 });
+ const flagMoon = (o) => { const g = G(p, { o }); mk('circle', { r: 40, fill: '#b9b7b0' }, g);
+ const f = G(g); path(f, 'M36 0H58', { stroke: INK.note, 'stroke-width': 4 }); path(f, 'M58 0L58 -18L76 -10Z', { fill: '#e5533d', stroke: 'none' }); g._f = f; return g; };
+ // ghosts at the quarter points show the flag's direction there; the real moon carries it round
+ const ghosts = [0, 90, 180, 270].map(a => { const g = flagMoon(0), [x, y] = orbitAt(C[0], C[1], OR, OR, a); put(g, { x, y }); put(g._f, { r: toward(x, y, ...C) }); return g; });
+ ghosts.forEach((g, i) => tw(g, { o: .35 }, m('same') + i * .2, .4));
+ const mo = flagMoon(1), T0 = m('rev') - .5, W = 360 / (m('far') - T0);
+ const days = lab(p, '', 560, 860, T0, { anchor: 'middle', fill: INK.hl, size: 34 });
+ clockRun(t => {
+ const a = 300 + W * Math.max(0, t - T0), [x, y] = orbitAt(C[0], C[1], OR, OR, a);
+ put(mo, { x, y }); put(mo._f, { r: toward(x, y, ...C) }); e.spin(8 * t);
+ setText(days, t < T0 ? '' : `day ${(27.3 * clamp01((t - T0) / (m('far') - T0))).toFixed(1)}`);
+ }, D);
+ lab(p, '1 trip around Earth: 27.3 days', 920, 160, m('rev'), { fill: INK.hl, size: 34 });
+ lab(p, '1 spin on its axis: 27.3 days', 920, 220, m('rot'), { fill: INK.blue, size: 34 });
+ lab(p, 'same time, so the flag side\nalways faces Earth', 920, 300, m('same'), { size: 34 });
+ // a spinning ride: the riders go round but always face the centre
+ const ride = G(p, { x: 1290, y: 560, o: 0 }); show(ride, m('ride') - .2);
+ const wheel = G(ride);
+ mk('circle', { r: 120, fill: 'none', stroke: INK.pink, 'stroke-width': 8 }, wheel);
+ mk('circle', { r: 16, fill: INK.pink }, wheel);
+ [0, 120, 240].forEach(a => { const g = G(wheel, { r: a }); const kk = G(g, { x: 118, r: -90 }); kid(kk, { s: .22, face: 1 }); });
+ clockRun(t => put(wheel, { r: 70 * Math.max(0, t - m('ride') + .2) }), D);
+ pen(ride, 'riders always face the centre', { y: 170, size: 26, anchor: 'middle', o: 1 });
+ hide(ride, m('far'), .3);
+ const far = G(p, { x: 1290, y: 560, o: 0, s: .6 }); pop(far, m('far', .2));
+ globe(far, { r: 130, kind: 'moonFar', light: 0, c: 1, rim: false });
+ pen(far, 'far side · first seen in 1959', { y: 175, size: 28, anchor: 'middle', o: 1 });
+ }],
+ ['q2', 'Quick check: the same face', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 32 });
+ globe(p, { x: 400, y: 380, r: 260, kind: 'moon', light: 0, c: 1, rim: false });
+ }, { ask: done => quiz({ x: 760, y: 110, w: 800, cls: 'side' }, [{
+ id: 'c-face', prompt: ['Why do we always see the same side of the moon?'],
+ build: choice([
+ ['It spins once in the same time it takes to orbit Earth.'],
+ ["It doesn't spin at all."],
+ ['Earth blocks our view of the far side.'],
+ ['The far side is always dark.'],
+ ], 0, 'One spin per orbit keeps the same face turned toward Earth, like a rider facing the centre of a spinning ride.',
+ [null, 'A moon that never spun would show us all of its sides as it went around.', 'Nothing blocks it: the far side simply never turns toward us.',
+ 'The far side gets sunlight too: at new moon it is fully lit.']),
+ }], done) }],
+ ['phases', 'Moon phases', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 33 });
+ const C = [860, 460], OR = 300;
+ sunBody(p, { x: -100, y: 460, r: 200 });
+ raysOn(sunRays(p, { x0: 150, x1: 450, y0: 220, y1: 700, n: 5 }), .5);
+ const e = globe(p, { x: C[0], y: C[1], r: 70, kind: 'pole', light: 180 });
+ clockRun(t => e.spin(10 * t), D);
+ orbit(p, C[0], C[1], OR, OR, { o: .6 });
+ for (let i = 0; i < 8; i++) { const [x, y] = orbitAt(C[0], C[1], OR, OR, 180 + i * 45), mo = moonDot(p, x, y, 34, 0); put(mo, { s: .4 }); tw(mo, { o: 1, s: 1 }, m('half') + i * .18, .4, back); }
+ lab(p, 'the sunlit half always faces the sun', 860, 90, m('half', .4), { anchor: 'middle', fill: INK.hl });
+ const [vx, vy] = orbitAt(C[0], C[1], OR, OR, 315);
+ draw(path(p, `M${C[0] + 50} ${C[1] + 50}L${vx - 30} ${vy - 30}`, { stroke: INK.blue, 'stroke-width': 4, 'stroke-dasharray': '8 8' }, { d: 0 }), m('see'));
+ lab(p, 'we see part lit, part dark', 1260, 800, m('see', .4), { fill: INK.blue });
+ hlAt(p, 'MOON PHASES', 1340, 300, m('name'));
+ }],
+ ['cycle', 'Eight phases', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 34 });
+ const C = [560, 470], OR = 290;
+ sunBody(p, { x: -160, y: 470, r: 210 });
+ const e = globe(p, { x: C[0], y: C[1], r: 66, kind: 'pole', light: 180 });
+ orbit(p, C[0], C[1], OR, OR, { o: .6 });
+ pen(p, 'sunlight', { x: 70, y: 150, size: 30, fill: INK.hl, o: 1 });
+ // phi: the moon's angle from the sun's direction (left), counterclockwise seen from above the North Pole.
+ // Seen from Earth, the lit side is on the right while waxing (phi < 180) and the lit fraction is (1 - cos phi) / 2.
+ const posAt = ph => orbitAt(C[0], C[1], OR, OR, 180 + ph);
+ const mo = moonDot(p, ...posAt(0), 36);
+ const V = [1290, 400], view = globe(p, { x: V[0], y: V[1], r: 170, kind: 'moon', light: 0, c: -1, night: .93, rim: false });
+ pen(p, 'what we see from Earth', { x: V[0], y: 170, size: 30, anchor: 'middle', fill: INK.dim, o: 1 });
+ const look = path(p, '', { stroke: INK.blue, 'stroke-width': 3, 'stroke-dasharray': '6 8' });
+ const name = pen(p, '', { x: V[0], y: 680, size: 44, anchor: 'middle', fill: INK.hl, o: 1 });
+ const K = [['new', 0, 'New moon'], ['cres', 45, 'Crescent (waxing)'], ['fq', 90, 'First quarter'], ['gib', 135, 'Gibbous (waxing)'], ['full', 180, 'Full moon'],
+ ['back', 225, 'Gibbous (waning)'], ['lq', 270, 'Last quarter'], ['wcres', 315, 'Crescent (waning)'], ['new2', 360, 'New moon']];
+ const keys = K.map(([k, ph]) => [m(k) - .7, ph]);
+ clockRun(t => {
+ const ph = keyf(t, keys, soft), [x, y] = posAt(ph);
+ put(mo, { x, y }); e.spin(12 * t);
+ view.light(ph % 360 < 180 ? 0 : 180, -Math.cos(deg(ph)));
+ look.setAttribute('d', `M${C[0]} ${C[1]}L${x.toFixed(1)} ${y.toFixed(1)}`);
+ let str = ''; K.forEach(([k, , s]) => { if (t >= m(k) - .2) str = s; }); setText(name, str);
+ }, D);
+ }],
+ ['waxwane', 'Waxing and waning', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 35 });
+ const names = ['new', 'crescent', '1st quarter', 'gibbous', 'full', 'gibbous', 'last quarter', 'crescent'];
+ names.forEach((n, i) => {
+ const ph = i * 45, g = G(p, { x: 150 + i * 186, y: 260, o: 0, s: .6 });
+ globe(g, { r: 70, kind: 'moon', light: ph < 180 ? 0 : 180, c: -Math.cos(deg(ph)), night: .93, rim: false });
+ pen(g, n, { y: 112, size: 26, anchor: 'middle', o: 1 });
+ tw(g, { o: 1, s: 1 }, .3 + i * .2, .4, back);
+ });
+ const wx = G(p); draw(path(wx, 'M120 400Q470 470 860 400', { stroke: INK.hl, 'stroke-width': 5 }, { d: 0 }), .6, 1.4);
+ lab(wx, 'WAXING: growing', 490, 490, 1, { size: 38, fill: INK.hl, anchor: 'middle' });
+ const wn = G(p); draw(path(wn, 'M900 400Q1200 470 1490 400', { stroke: INK.blue, 'stroke-width': 5 }, { d: 0 }), m('wan'), 1.2);
+ lab(wn, 'WANING: shrinking', 1200, 490, m('wan', .3), { size: 38, fill: INK.blue, anchor: 'middle' });
+ hlAt(p, 'LUNAR CYCLE = 29.5 days ≈ 1 month', 800, 620, m('cyc'));
+ lab(p, '1 orbit = 27.3 days, but Earth moves along too,\nso lining up with the sun again takes about 2 days more', 800, 730, m('why'), { anchor: 'middle', size: 30 });
+ }],
+ ['q3', 'Quick check: find the moon', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 34 });
+ const C = [520, 470], OR = 290;
+ sunBody(p, { x: -160, y: 470, r: 210 });
+ pen(p, 'sunlight', { x: 70, y: 150, size: 30, fill: INK.hl, o: 1 });
+ globe(p, { x: C[0], y: C[1], r: 66, kind: 'pole', light: 180 });
+ orbit(p, C[0], C[1], OR, OR, { o: .6 });
+ S.q3 = [];
+ for (let i = 0; i < 8; i++) { const [x, y] = orbitAt(C[0], C[1], OR, OR, 180 + i * 45); S.q3.push([moonDot(p, x, y), x, y]); }
+ globe(p, { x: 1300, y: 640, r: 110, kind: 'moon', light: 0, c: -Math.cos(deg(45)), night: .93, rim: false });
+ pen(p, 'tonight from Earth', { x: 1300, y: 800, size: 30, anchor: 'middle', o: 1 });
+ }, { ask: done => quiz({ x: 1000, y: 70, w: 570, cls: 'side' }, [{
+ id: 'c-phase', prompt: ['From Earth we see this waxing crescent. Click where the moon is on its orbit.'],
+ build: pickEls(S.q3.map(([el, x, y], i) => ({ el, box: [x - 48, y - 48, 96, 96], label: `moon position ${i + 1}` })), 1,
+ 'Just past new moon, the moon is a little way round from the sun: we see a thin sliver of its lit half.',
+ i => i === 0 ? 'Here the lit half faces away from us: that is a new moon.' : i === 7 ? 'This is a crescent too, but a waning one: the moon is just before new.'
+ : i === 4 ? 'Opposite the sun we would see the whole lit half: a full moon.' : 'From here we would see more of the lit half. Look for a spot just past new moon.'),
+ }], done) }],
+ ['solar', 'Solar eclipse', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 40 }); heading(p, 'ECLIPSES');
+ sunBody(p, { x: -40, y: 450, r: 260, glow: 1.6 });
+ const mx = 760, ex = 1260, Y0 = 300, T = m('mid') + 1;
+ // the moon slides down into the sun-Earth line; its shadow follows it onto Earth
+ const sc = shadowCone(p, { x: mx, y: Y0, r: 28, rs: 260, dist: 2900, len: ex - mx - 100, o: 0 });
+ const e = globe(p, { x: ex, y: 450, r: 140, light: 180 });
+ const mo = globe(p, { x: mx, y: Y0, r: 28, kind: 'moon', light: 180, c: 0 });
+ clockRun(t => { const y = keyf(t, [[m('mid') - .6, Y0], [T, 450]], soft); put(mo, { y }); put(sc, { y }); e.spin(15 * t); }, D);
+ show(sc, m('shad') - .3, .6);
+ // where the shadow lands: a dark spot (total) inside a grey patch (partial), on the day side
+ const spot = G(p, { x: ex - 132, y: 450, o: 0 }); show(spot, m('shad') + .2, .6);
+ mk('ellipse', { rx: 14, ry: 46, fill: SKY.penumbra, 'fill-opacity': .8 }, spot); mk('ellipse', { rx: 6, ry: 12, fill: SKY.umbra }, spot);
+ lab(p, 'moon', mx, 400, m('mid', 1.2), { anchor: 'middle' }); lab(p, 'Earth', ex, 260, m('mid'), { anchor: 'middle' });
+ hlAt(p, 'SOLAR ECLIPSE', 520, 150, m('ecl'));
+ lead(p, ex - 134, 452, 1000, 640, m('tot'), INK.hl);
+ lab(p, 'total: sun fully covered', 960, 690, m('tot'), { fill: INK.hl, size: 30 });
+ lead(p, ex - 128, 500, 1000, 720, m('part'), INK.dim);
+ lab(p, 'partial: part of the sun covered', 960, 760, m('part'), { fill: INK.dim, size: 30 });
+ const ph = G(p, { x: 1010, y: 170, o: 0, s: .8 }); tw(ph, { o: 1, s: 1 }, m('tot'), .5, out);
+ mk('image', { href: '../img/solar_eclipse.jpg', x: -160, y: -110, width: 320, height: 213 }, ph);
+ pen(ph, 'total solar eclipse, 2017 (NASA)', { y: 130, size: 22, anchor: 'middle', fill: INK.dim, o: 1 });
+ lab(p, 'not to scale', 60, 860, .5, { fill: INK.dim, size: 24 });
+ }],
+ ['lunar', 'Lunar eclipse', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 41 }); heading(p, 'ECLIPSES');
+ sunBody(p, { x: -40, y: 450, r: 260, glow: 1.6 });
+ const ex = 700, mx = 1300;
+ const sc = shadowCone(p, { x: ex, y: 450, r: 110, rs: 260, dist: 1600, len: 900, o: 0 }); show(sc, m('earthmid') - .2, .8);
+ const e = globe(p, { x: ex, y: 450, r: 110, light: 180 });
+ const mg = G(p, { x: mx, y: 220 });
+ globe(mg, { r: 32, kind: 'moon', light: 180, c: 1 });
+ const red = put(mk('circle', { r: 32, fill: '#b5402a' }, mg), { o: 0 });
+ // the moon glides into the umbra: it darkens, then glows red
+ const dark = put(mk('circle', { r: 32, fill: SKY.night }, mg), { o: 0 });
+ clockRun(t => { const y = keyf(t, [[m('earthmid'), 220], [m('into') + 1.2, 450]], soft); put(mg, { y }); e.spin(15 * t); }, D);
+ tw(dark, { o: .7 }, m('into') + .4, 1); tw(red, { o: .8 }, m('red'), 2); tw(dark, { o: .15 }, m('red'), 2);
+ hlAt(p, 'LUNAR ECLIPSE', 800, 150, m('into'));
+ lab(p, "the moon in Earth's shadow", mx, 540, m('into', 1), { anchor: 'middle', size: 30 });
+ const ph = G(p, { x: 1300, y: 740, o: 0, s: .8 }); tw(ph, { o: 1, s: 1 }, m('red', 1), .5, out);
+ mk('image', { href: '../img/lunar_eclipse.jpg', x: -150, y: -100, width: 300, height: 200 }, ph);
+ pen(ph, 'blood moon, 2025 (NASA)', { y: 125, size: 22, anchor: 'middle', fill: INK.dim, o: 1 });
+ lab(p, "red light bent by\nEarth's atmosphere", 860, 720, m('red', .6), { fill: '#ff8f7a', size: 30 });
+ }],
+ ['rare', 'Why eclipses are rare', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 42 }); heading(p, 'ECLIPSES');
+ sunBody(p, { x: -40, y: 450, r: 220, glow: 1.6 });
+ path(p, 'M200 450H1560', { stroke: INK.note, 'stroke-width': 2, 'stroke-dasharray': '6 10', 'stroke-opacity': .6 });
+ const E = [900, 450], behind = G(p);
+ const e = globe(p, { x: E[0], y: E[1], r: 90, light: 180 }), front = G(p);
+ const tl = G(p, { x: E[0], y: E[1], r: -10, o: 0 }); show(tl, m('tilt') - .3);
+ path(tl, 'M-460 0A460 70 0 1 0 460 0A460 70 0 1 0 -460 0', { stroke: SKY.orbit, 'stroke-width': 3, 'stroke-dasharray': '10 12' });
+ lab(p, "moon's orbit, tilted about 5°\n(drawn bigger)", 1080, 270, m('tilt'), { fill: SKY.orbit });
+ // the moon goes round its tilted orbit: at the lined-up points it passes above or below the shadow line
+ const mo = globe(front, { r: 26, kind: 'moon' }), dz = depth(mo, behind, front), c10 = Math.cos(deg(-10)), s10 = Math.sin(deg(-10));
+ clockRun(t => {
+ const a = 150 + 22 * t, lx = 460 * Math.cos(deg(a)), ly = -70 * Math.sin(deg(a));
+ const x = E[0] + lx * c10 - ly * s10, y = E[1] + lx * s10 + ly * c10;
+ put(mo, { x, y }); mo.light(toward(x, y, -40, 450)); dz(Math.sin(deg(a)) > 0); e.spin(15 * t);
+ }, D);
+ lab(p, 'usually passes above\nor below the shadow', 300, 640, m('miss'), { fill: INK.hl });
+ lab(p, 'eclipse only when all three line up exactly', 800, 840, m('line'), { anchor: 'middle', size: 34 });
+ }],
+ ['q4', 'Quick check: eclipses', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 43 });
+ const ph1 = G(p, { x: 260, y: 300 }); mk('image', { href: '../img/solar_eclipse.jpg', x: -200, y: -133, width: 400, height: 266 }, ph1);
+ const ph2 = G(p, { x: 260, y: 640 }); mk('image', { href: '../img/lunar_eclipse.jpg', x: -180, y: -120, width: 360, height: 240 }, ph2);
+ }, { ask: done => quiz({ x: 540, y: 90, w: 1020, cls: 'side' }, [{
+ id: 'c-eclipse', prompt: ['Solar or lunar eclipse?'],
+ build: grid([
+ { parts: ['The moon is between the sun and Earth.'], ans: ['sol'], why: "The moon blocks the sun: its shadow falls on Earth." },
+ { parts: ["Earth's shadow falls on the moon."], ans: ['lun'], why: 'Earth is in the middle, so the moon is in its shadow.' },
+ { parts: ['The moon can glow deep red.'], ans: ['lun'], why: "Earth's air bends red sunlight into its shadow." },
+ { parts: ['It can only happen at new moon.'], ans: ['sol'], why: 'Only at new moon is the moon between us and the sun.' },
+ ], [['sol', 'Solar', INK.hl], ['lun', 'Lunar', INK.blue]], { multi: false, text: true }),
+ }], done) }],
+ ['tides', 'Tides', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 50 }); heading(p, 'TIDES');
+ const E = [640, 460], R = 190;
+ // the ocean layer stretches toward the moon, then the far side bulges too
+ const bulge = put(mk('ellipse', { cx: E[0], cy: E[1], rx: R + 8, ry: R + 8, fill: '#6fb7ff', 'fill-opacity': .55 }, p), {});
+ const nearB = put(mk('ellipse', { cx: E[0], cy: E[1], rx: R + 8, ry: R - 2, fill: '#6fb7ff', 'fill-opacity': .55 }, p), {});
+ tw(nearB, { a_cx: E[0] + 34, a_rx: R + 40 }, m('near'), 1.6, soft); tw(nearB, { a_cx: E[0], a_rx: R + 70 }, m('far'), 1.6, soft);
+ tw(bulge, { a_ry: R - 4 }, m('near'), 1.6, soft);
+ const e = globe(p, { x: E[0], y: E[1], r: R, kind: 'pole', night: 0, rim: false });
+ clockRun(t => e.spin(6 * t), D);
+ globe(p, { x: 1460, y: 460, r: 50, kind: 'moon', light: 180, c: .5 });
+ const arr = (lab0, x, len, t0) => { const f = forceArrow(p, { label: lab0, o: 0 }); show(f, t0, .2); prog(q => f.set(x, E[1], Math.max(1, len * q), 0), t0, .9, out); return f; };
+ arr('strong pull', E[0] + R + 70, 200, m('near'));
+ arr('medium', E[0] - 70, 140, m('far')); arr('weak', E[0] - R - 150, 80, m('far', .6));
+ lab(p, 'HIGH TIDE', 1000, 380, m('hi'), { fill: INK.blue, size: 34 }); lab(p, 'HIGH TIDE', 180, 380, m('hi', .4), { fill: INK.blue, size: 34 });
+ lab(p, 'LOW TIDE', E[0], E[1] - R - 40, m('lo'), { anchor: 'middle', fill: INK.note, size: 34 });
+ lab(p, 'LOW TIDE', E[0], E[1] + R + 70, m('lo', .3), { anchor: 'middle', fill: INK.note, size: 34 });
+ lab(p, 'moon', 1460, 560, .5, { anchor: 'middle' });
+ }],
+ ['tideday', 'Two tides a day', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 51 }); heading(p, 'TIDES');
+ const E = [480, 470], R = 170;
+ mk('ellipse', { cx: E[0], cy: E[1], rx: R + 60, ry: R - 4, fill: '#6fb7ff', 'fill-opacity': .55 }, p);
+ const e = globe(p, { x: E[0], y: E[1], r: R, kind: 'pole', night: 0, rim: false });
+ pen(p, 'moon →', { x: 830, y: 470, size: 34, o: 1 });
+ // Earth turns under the bulges; our beach (the pin) turns with it. psi: degrees turned since high tide,
+ // 15 degrees per hour; the water level there goes as cos(2 psi): high facing toward or away from the moon.
+ const pin = G(p, { x: E[0], y: E[1] }); mk('circle', { cx: R + 4, r: 12, fill: '#e5533d', stroke: INK.note, 'stroke-width': 3 }, pin);
+ const psi = t => keyf(t, [[m('beach'), 0], [m('h1'), 0], [m('l1'), 90], [m('h2'), 180], [m('l2'), 270], [m('two') + 2, 360]]);
+ lab(p, 'our beach', E[0] + R + 30, E[1] + 50, m('beach'), { fill: '#ff8f7a' });
+ const B = [1000, 640, 520, 300];
+ const gb = G(p, { o: 0 }); show(gb, m('beach'));
+ path(gb, `M${B[0]} ${B[1]}H${B[0] + B[2]}M${B[0]} ${B[1]}V${B[1] - B[3]}`, { stroke: INK.note, 'stroke-width': 3 });
+ pen(gb, 'water level at our beach', { x: B[0], y: B[1] - B[3] - 20, size: 28, o: 1 });
+ [['0 h', 0], ['6 h', .25], ['12 h', .5], ['18 h', .75], ['24 h', 1]].forEach(([s, k]) => pen(gb, s, { x: B[0] + B[2] * k, y: B[1] + 40, size: 24, anchor: 'middle', o: 1 }));
+ const lvl = a => B[1] - B[3] / 2 - B[3] * .36 * Math.cos(deg(2 * a));
+ const curve = path(gb, '', { stroke: '#6fb7ff', 'stroke-width': 5 }), dot = G(gb); mk('circle', { r: 9, fill: '#ff8f7a' }, dot);
+ clockRun(t => {
+ const a = psi(t); e.spin(a); put(pin, { r: -a });
+ const pts = []; for (let k = 0; k <= Math.ceil(a / 6); k++) { const b = Math.min(a, k * 6); pts.push(`${(B[0] + B[2] * b / 360).toFixed(1)} ${lvl(b).toFixed(1)}`); }
+ curve.setAttribute('d', 'M' + pts.join('L')); put(dot, { x: B[0] + B[2] * a / 360, y: lvl(a) });
+ }, D);
+ [['h1', 'high'], ['l1', 'low'], ['h2', 'high'], ['l2', 'low']].forEach(([k, s], i) =>
+ lab(gb, s, B[0] + B[2] * i / 4, (s === 'high' ? lvl(0) - 20 : lvl(90) + 40), m(k), { anchor: 'middle', size: 26, fill: s === 'high' ? INK.blue : INK.note }));
+ lab(p, '2 high + 2 low tides a day\nabout 6 hours apart', 1000, 160, m('two'), { fill: INK.hl, size: 36 });
+ }],
+ ['spring', 'Spring and neap tides', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 52 }); heading(p, 'TIDES');
+ sunBody(p, { x: -150, y: 450, r: 200 });
+ // new moon: the moon's and sun's pulls point the same way, so the bulge grows big
+ const L = G(p, { o: 0 }); show(L, .3);
+ const E1 = [560, 450];
+ const b1 = put(mk('ellipse', { cx: E1[0], cy: E1[1], rx: 130, ry: 126, fill: '#6fb7ff', 'fill-opacity': .55 }, L), {});
+ tw(b1, { a_rx: 200, a_ry: 120 }, m('spr') - .4, 1.4, soft);
+ const e1 = globe(L, { x: E1[0], y: E1[1], r: 120, kind: 'pole', night: 0, rim: false });
+ moonDot(L, E1[0] - 260, E1[1], 30);
+ const grow = (f, x, y, len, a, t0) => { put(f, { o: 0 }); show(f, t0, .2); prog(q => f.set(x, y, Math.max(1, len * q), a), t0, .8, out); };
+ const f1 = forceArrow(L, { label: 'moon', size: 24 }), f2 = forceArrow(L, { label: 'sun', size: 24, color: SKY.sun });
+ f1.set(E1[0] - 210, E1[1] - 160, 1, 180); f2.set(E1[0] - 210, E1[1] + 160, 1, 180);
+ grow(f1, E1[0] - 210, E1[1] - 160, 120, 180, m('line')); grow(f2, E1[0] - 210, E1[1] + 160, 70, 180, m('line') + .5);
+ pen(L, 'NEW MOON: pulls line up', { x: E1[0] - 60, y: 210, size: 30, anchor: 'middle', o: 1 });
+ hlAt(p, 'SPRING TIDES', E1[0] - 60, 760, m('spr'));
+ lab(p, 'the water "springs" up', E1[0] - 60, 820, m('name'), { anchor: 'middle', size: 28 });
+ // quarter moon: the pulls are at right angles, so the bulges stay small
+ const N = G(p, { o: 0 }); show(N, m('right') - .3);
+ const E2 = [1240, 420];
+ const b2 = put(mk('ellipse', { cx: E2[0], cy: E2[1], rx: 128, ry: 128, fill: '#6fb7ff', 'fill-opacity': .45 }, N), {});
+ tw(b2, { a_rx: 140, a_ry: 160 }, m('neap') - .4, 1.4, soft);
+ const e2 = globe(N, { x: E2[0], y: E2[1], r: 120, kind: 'pole', night: 0, rim: false });
+ clockRun(t => { e1.spin(8 * t); e2.spin(8 * t); }, D);
+ moonDot(N, E2[0], E2[1] + 250, 30);
+ const f3 = forceArrow(N, { label: 'moon', size: 24 }), f4 = forceArrow(N, { label: 'sun', size: 24, color: SKY.sun });
+ f3.set(E2[0] + 170, E2[1] + 60, 1, 90); f4.set(E2[0] - 170, E2[1] - 40, 1, 180);
+ grow(f3, E2[0] + 170, E2[1] + 60, 120, 90, m('right')); grow(f4, E2[0] - 170, E2[1] - 40, 70, 180, m('right') + .5);
+ pen(N, 'QUARTER MOON: right angle', { x: E2[0], y: 210, size: 30, anchor: 'middle', o: 1 });
+ hlAt(p, 'NEAP TIDES', E2[0], 760, m('neap'), { color: INK.def });
+ lab(p, 'smaller tides', E2[0], 820, m('neap', .6), { anchor: 'middle', size: 28 });
+ }],
+ ['q5', 'Quick check: tides', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 53 });
+ sunBody(p, { x: -150, y: 450, r: 200 });
+ globe(p, { x: 460, y: 450, r: 100, kind: 'pole', light: 180, rim: false });
+ moonDot(p, 720, 450, 30);
+ pen(p, 'this week: the moon is here', { x: 600, y: 300, size: 30, anchor: 'middle', o: 1 });
+ }, { ask: done => quiz({ x: 880, y: 140, w: 680, cls: 'side' }, [{
+ id: 'c-tide', prompt: ['Sun, Earth and moon are lined up like this (a full moon). What kind of tides will we get?'],
+ build: choice([['Spring tides: extra high and extra low'], ['Neap tides: smaller than usual'], ['No tides at all']], 0,
+ 'Lined up, the sun and moon pull along the same line, so their effects add up, at full moon as well as at new moon.',
+ [null, 'Neap tides come at first and last quarter, when the pulls are at right angles.', 'The moon still pulls on the oceans, so there are always tides.']),
+ }], done) }],
+ ['wrap', 'Summary', (m, D) => {
+ const p = panel(0); spaceBg(p, { seed: 60, o: .7 });
+ pen(p, 'MY NOTES', { x: 160, y: 140, size: 48, fill: INK.def, o: 1 });
+ [['Rotation (1 day) gives day and night; revolution (1 year) goes around the sun.', 'w1'],
+ ["Seasons come from Earth's 23.44° tilt, not its distance from the sun.", 'w2'],
+ ['Phases show how much of the sunlit half we see; eclipses need a perfect line-up.', 'w3'],
+ ["The moon's gravity, helped by the sun, raises the tides.", 'w4']].forEach(([str, mark], i) => {
+ const g = G(p, { x: -16, y: 270 + i * 140, o: 0 });
+ mk('circle', { cx: 190, cy: -12, r: 28, fill: INK.hl }, g);
+ T(g, String(i + 1), { x: 190, y: 0, size: 32, fill: INK.ink, weight: 700, anchor: 'middle', font: HAND });
+ T(g, str, { x: 250, size: 36, font: HAND, fill: INK.note });
+ tw(g, { o: 1, x: 0 }, m(mark), .6);
+ });
+ const k = kid(p, { x: 1480, y: 880, s: .6, face: -1 }), dg = dog(p, { x: 1360, y: 884, s: .5, face: -1 });
+ alive(D, k, dg);
+ ['w1', 'w2', 'w3', 'w4'].forEach(w => { prog(q => k.pose('stand', 'point', q), m(w) - .3, .4); prog(q => k.pose('point', 'stand', q), m(w) + 1.4, .5); });
+ }],
+ ['final1', 'Practice: Earth and the seasons', () => { const p = panel(0); spaceBg(p, { seed: 70, o: .5 }); }, { ask: done => quiz(SCREEN, FINAL1, done, 'Chapter practice, set 1 of 2') }],
+ ['final2', 'Practice: moon, eclipses and tides', () => { const p = panel(0); spaceBg(p, { seed: 71, o: .5 }); }, { ask: done => quiz(SCREEN, FINAL2, done, 'Chapter practice, set 2 of 2') }],
+ ['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],
+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));
+
+/* ---------- practice ---------- */
+const FINAL1 = [
+ { id: 'p-axis', prompt: ['What is the imaginary line through the North and South Poles that Earth spins around?'],
+ build: choice([['its axis'], ['the equator'], ['its orbit'], ['magnetic north']], 0, 'Earth rotates around its axis, once about every 24 hours.',
+ [null, 'The equator runs around the middle of Earth, halfway between the poles.', 'The orbit is the path Earth follows around the sun.', 'Magnetic north is where a compass points, not a line Earth spins around.']) },
+ { id: 'p-year', prompt: ['What motion does Earth complete once every year?'],
+ build: choice([['one revolution around the sun'], ['one rotation on its axis'], ['one wobble of its tilt']], 0, 'One trip around the sun takes 365¼ days: a year.',
+ [null, 'One rotation takes about a day, not a year.', "Earth's axis doesn't wobble from season to season; it keeps pointing the same way."]) },
+ { id: 'p-summer', prompt: ['Why is it summer in the northern hemisphere in June?'],
+ build: choice([['The north leans toward the sun, so sunlight is higher and days are longer.'], ['Earth is closest to the sun in June.'], ['The sun gives off more light in June.']], 0,
+ 'Higher, more direct sunlight for more hours a day warms the north.',
+ [null, 'Earth is actually farthest from the sun in early July, and closest in January.', 'The sun shines about the same all year; what changes is how the light reaches us.']) },
+ { id: 'p-tilt', prompt: ['If Earth were tilted more than 23.44°, how would the seasons change?'],
+ build: choice([['They would be more extreme.'], ['They would be milder.'], ['They would stay the same.']], 0,
+ 'Summer sunlight would be even more direct and days even longer; winters would be darker and colder.',
+ [null, 'Less tilt would make seasons milder; more tilt does the opposite.', 'The tilt is what causes seasons, so changing it changes them.']) },
+ { id: 'p-solstice', prompt: ['Solstice or equinox?'],
+ build: grid([
+ { parts: ['Day and night are both about 12 hours everywhere.'], ans: ['eq'], why: 'At an equinox the sun is right over the equator.' },
+ { parts: ['The longest day of the year in the north.'], ans: ['sol'], why: 'The June solstice, when the north leans most toward the sun.' },
+ { parts: ['The axis leans neither toward nor away from the sun.'], ans: ['eq'], why: 'That is what makes day and night equal.' },
+ { parts: ['Around December 21.'], ans: ['sol'], why: 'The December (winter) solstice.' },
+ ], [['sol', 'Solstice', INK.hl], ['eq', 'Equinox', INK.def]], { multi: false, text: true }) },
+];
+const FINAL2 = [
+ { id: 'p-spin', prompt: ['The moon takes 27.3 days to orbit Earth. How long does it take to spin once on its axis?'],
+ build: choice([['27.3 days'], ['1 day'], ['29.5 days'], ["It doesn't spin."]], 0, 'The same time as one orbit, which is why one face always points at us.',
+ [null, 'That is how long Earth takes to spin, not the moon.', '29.5 days is the cycle of phases, not one spin.', 'If it never spun, we would see all of its sides as it orbited.']) },
+ { id: 'p-wax', prompt: ['Each night the lit part of the moon looks bigger. The moon is …'],
+ build: choice([['waxing'], ['waning'], ['in a lunar eclipse']], 0, 'Waxing means growing: from new moon to full.',
+ [null, 'Waning means shrinking, from full back to new.', 'An eclipse lasts a few hours, not night after night.']) },
+ { id: 'p-solar', prompt: ['During a solar eclipse, where is the moon?'],
+ build: choice([['between the sun and Earth'], ["in Earth's shadow"], ['at right angles to the sun']], 0, 'The moon blocks the sun and its shadow falls on Earth.',
+ [null, "That is a lunar eclipse: Earth's shadow on the moon.", 'At right angles we see a quarter moon, not an eclipse.']) },
+ { id: 'p-tides', prompt: ['How does the moon affect the water on Earth?'],
+ build: choice([["Its gravity pulls the oceans into two bulges, making high and low tides."], ['Its light warms the water so it rises.'], ['It only affects lakes, not oceans.']], 0,
+ 'One bulge faces the moon, the other is on the far side; Earth turns under both.',
+ [null, "Moonlight is only reflected sunlight and far too weak; it's gravity that raises the tides.", 'Gravity pulls on all water, but the effect is easiest to see on the huge oceans.']) },
+ { id: 'p-count', prompt: ['How many high tides do most beaches get each day?'],
+ build: choice([['2'], ['1'], ['4']], 0, 'Earth turns under two bulges a day: two highs and two lows.',
+ [null, 'There are two bulges, one facing the moon and one on the far side.', 'Four is the total of highs and lows together: two of each.']) },
+];
+document.fonts.load('30px "Patrick Hand"').then(boot);
+</script>
+</body>
+</html>
diff --git a/site/science/img/CREDITS.md b/site/science/img/CREDITS.md
index b746caa..842392c 100644
--- a/site/science/img/CREDITS.md
+++ b/site/science/img/CREDITS.md
@@ -10,3 +10,14 @@
| earth.png | [North Pole (orthographic projection with shade)](https://commons.wikimedia.org/wiki/File:North_Pole_(orthographic_projection_with_shade).svg) | Ecrusized (Wikimedia Commons) | Public domain | Land outline only (borders, graticule, rivers and shade removed), turned 160°, reduced to 96 × 96 cells, recoloured (ocean, land, Greenland and polar ice), scaled ×8 |
| runner*.png | [Pixel Vehicle Pack](https://opengameart.org/content/pixel-vehicle-pack) (`woman`, `woman_walk1`, `woman_walk2`) | Kenney | CC0 1.0 | Top recoloured orange, scaled ×8 |
| tree.png, house.png, dolphin.png, walrus.png, light_red.png, light_green.png, building.png, feather.png, duck.png, stone.png | Papermorph (drawn for this book) | — | Same as the project | — |
+
+## Sample chapter 19 (Sun, Earth and Moon)
+
+All source images are NASA works in the public domain.
+
+- earth_side, earth_pole, earth_big: NASA Earth Observatory, "Whole world - land and oceans" (Blue Marble).
+- moon_near: NASA/GSFC/Arizona State University, LRO WAC nearside mosaic.
+- moon_far: NASA, LRO farside mosaic.
+- sun: NASA/SDO and the HMI science team.
+- solar_eclipse: NASA/Carla Thomas, total solar eclipse of 21 August 2017.
+- lunar_eclipse: NASA Glenn Research Center / Jordan Cochran, total lunar eclipse of 14 March 2025.
diff --git a/site/science/img/earth_big.webp b/site/science/img/earth_big.webp
new file mode 100644
index 0000000..7450550
Binary files /dev/null and b/site/science/img/earth_big.webp differ
diff --git a/site/science/img/earth_pole.webp b/site/science/img/earth_pole.webp
new file mode 100644
index 0000000..836b2fd
Binary files /dev/null and b/site/science/img/earth_pole.webp differ
diff --git a/site/science/img/earth_side.json b/site/science/img/earth_side.json
new file mode 100644
index 0000000..6b9f74c
--- /dev/null
+++ b/site/science/img/earth_side.json
@@ -0,0 +1 @@
+{"w": 256, "h": 256, "n": 120, "cols": 12, "step": 3}
\ No newline at end of file
diff --git a/site/science/img/earth_side.webp b/site/science/img/earth_side.webp
new file mode 100644
index 0000000..c2b7052
Binary files /dev/null and b/site/science/img/earth_side.webp differ
diff --git a/site/science/img/lunar_eclipse.jpg b/site/science/img/lunar_eclipse.jpg
new file mode 100644
index 0000000..e6f8067
Binary files /dev/null and b/site/science/img/lunar_eclipse.jpg differ
diff --git a/site/science/img/moon_far.webp b/site/science/img/moon_far.webp
new file mode 100644
index 0000000..a88d781
Binary files /dev/null and b/site/science/img/moon_far.webp differ
diff --git a/site/science/img/moon_near.webp b/site/science/img/moon_near.webp
new file mode 100644
index 0000000..48eb7b8
Binary files /dev/null and b/site/science/img/moon_near.webp differ
diff --git a/site/science/img/solar_eclipse.jpg b/site/science/img/solar_eclipse.jpg
new file mode 100644
index 0000000..863c264
Binary files /dev/null and b/site/science/img/solar_eclipse.jpg differ
diff --git a/site/science/img/sun.webp b/site/science/img/sun.webp
new file mode 100644
index 0000000..6e44019
Binary files /dev/null and b/site/science/img/sun.webp differ
diff --git a/site/science/index.html b/site/science/index.html
index 0297ffc..9083a5c 100644
--- a/site/science/index.html
+++ b/site/science/index.html
@@ -118,6 +118,8 @@ main#contents { padding-bottom: 80px; }
@keyframes step { 0%, 20%, 100% { fill-opacity: 1; } 10% { fill-opacity: .3; } }
.unit-art .hop, .unit-art .ride { offset-rotate: 0deg; }
.seen .unit-art .hop { animation: art-fade .4s ease-out 2s forwards, along 3.4s linear 2s infinite; }
+.unit-art .orbit { offset-rotate: 0deg; }
+.seen .unit-art .orbit { animation: art-fade .4s ease-out 2s forwards, along 9s linear 2s infinite; }
.seen .unit-art .ride { animation: art-fade .4s ease-out 2s forwards, along 4s ease-in-out 2s infinite alternate; }
@keyframes along { from { offset-distance: 0%; } to { offset-distance: 100%; } }
.unit-art .pie { stroke: currentColor; stroke-linecap: butt; stroke-dasharray: 0 100; }
@@ -169,6 +171,9 @@ main#contents { padding-bottom: 80px; }
/* ---------- page-to-page motion ---------- */
@view-transition { navigation: auto; }
+/* Firefox flickers through view transitions (the header blinks for several frames): it switches without one, and the
+ contents still rise in. -moz-orient exists only in Firefox. */
+@supports (-moz-orient: inline) { @view-transition { navigation: none; } }
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: var(--ease); }
::view-transition-old(lesson), ::view-transition-new(lesson) { height: 100%; object-fit: cover; }
::view-transition-old(lesson) { animation-duration: .18s; }
@@ -225,9 +230,12 @@ main#contents { padding-bottom: 80px; }
'use strict';
// Physics only: the book's chapters 9–17 (units 3–4) keep their original numbers. START gives the first unit and
// chapter numbers; chapters are numbered in order from there. Add a chapter here when its lesson is ready.
+// A unit's optional third entry { unit, chapter, sample } numbers it from elsewhere in the book; a sample chapter, made
+// to show another look, is labelled as one and not counted with the book's chapters.
const START = { unit: 3, chapter: 9 };
const UNITS = [ // [unit title, [[chapter title, minutes], ...]]
['Motion, Forces, and Work', [['Motion', 18], ['Force and Newton’s Laws of Motion', 13], ['Gravity, Friction, and More Forces in Everyday Life', 15], ['Work and Machines', 14]]],
+ ['Outer Space: the Sun, Earth and Moon', [['The Sun-Earth-Moon System', 14]], { unit: 5, chapter: 19, sample: true }],
];
const HUES = ['#f4a48c', '#86c9e8', '#f3c95c', '#e8a0c8', '#8fd6b0', '#bba8ee', '#f0b45a'];
const id = n => 'ch' + String(n).padStart(2, '0');
@@ -242,9 +250,11 @@ const done = new Set(Array.isArray(P.done) ? P.done.filter(n => Number.isInteger
// Contents.
let n = START.chapter - 1, total = 0, i = 0; // i staggers the entrance, in reading order
const esc = s => s.replace(/&/g, '&amp;').replace(/</g, '&lt;');
-document.getElementById('units').innerHTML = UNITS.map(([name, chs], u) => {
- return `<section class="unit" style="--c:${HUES[u % HUES.length]};--i:${i++}"><svg class="unit-art" viewBox="0 0 600 180" aria-hidden="true">${UNIT_ART[u] || ''}</svg><h2><span>Unit ${u + START.unit}</span>${esc(name)}</h2><div class="grid">` +
- chs.map(([t, min]) => { n++; total++;
+const samples = new Set();
+document.getElementById('units').innerHTML = UNITS.map(([name, chs, o = {}], u) => {
+ if (o.chapter) n = o.chapter - 1;
+ return `<section class="unit" style="--c:${HUES[u % HUES.length]};--i:${i++}"><svg class="unit-art" viewBox="0 0 600 180" aria-hidden="true">${UNIT_ART[u] || ''}</svg><h2><span>Unit ${o.unit ?? u + START.unit}${o.sample ? ' · Sample chapter, another look' : ''}</span>${esc(name)}</h2><div class="grid">` +
+ chs.map(([t, min]) => { n++; if (o.sample) samples.add(n); else total++;
const cls = 'ch' + (done.has(n) ? ' done' : '') + (P.last === n ? ' last' : '');
return `<a class="${cls}" id="${id(n)}" href="${id(n)}/" style="--i:${i++}"><b>${n}</b><span>${esc(t)}</span><small>${min} min</small></a>`;
}).join('') + '</div></section>';
@@ -252,10 +262,10 @@ document.getElementById('units').innerHTML = UNITS.map(([name, chs], u) => {
// A unit's sketch draws itself the first time the unit scrolls into view.
const seen = new IntersectionObserver(es => es.forEach(e => { if (e.isIntersecting) { e.target.classList.add('seen'); seen.unobserve(e.target); } }), { threshold: .25 });
document.querySelectorAll('.unit').forEach(u => seen.observe(u));
-const finished = [...done].filter(k => k >= START.chapter && k <= n).length;
+const finished = [...done].filter(k => k >= START.chapter && k <= n && !samples.has(k)).length;
document.getElementById('prog').innerHTML = finished ? `<b>${finished}</b> of ${total} finished` : `${total} chapter${total === 1 ? '' : 's'}`;
const pl = (k, w) => `${k} ${w}${k === 1 ? '' : 's'}`;
-document.getElementById('meta').textContent = `${pl(total, 'chapter')} · ${pl(UNITS.length, 'unit')} · with sound`;
+document.getElementById('meta').textContent = `${pl(total, 'chapter')}${samples.size ? ` + ${samples.size} sample` : ''} · ${pl(UNITS.filter(x => !x[2]?.sample).length, 'unit')} · with sound`;
const last = Number.isInteger(P.last) && document.getElementById(id(P.last));
if (last) {
const r = document.getElementById('resume');
@@ -300,7 +310,7 @@ function show(animate) {
heading?.focus({ preventScroll: true });
}
};
- if (animate && document.startViewTransition && !reduced) {
+ if (animate && document.startViewTransition && !reduced && !CSS.supports('-moz-orient', 'inline')) {
const transition = document.startViewTransition(apply);
// Navigation can interrupt either promise; the new view is already applied.
transition.ready.catch(() => {});
diff --git a/site/science/lib/book.css b/site/science/lib/book.css
index bc7e284..28e2072 100644
--- a/site/science/lib/book.css
+++ b/site/science/lib/book.css
@@ -9,3 +9,6 @@
:root .band .head { align-self: auto; }
:root .band .fb { align-self: auto; margin-top: 0; }
:root .band .body { min-width: 0; }
+
+/* Handwriting for the sample chapter 19 (Patrick Hand, SIL Open Font License, Google Fonts). */
+@font-face { font-family: "Patrick Hand"; src: url("fonts/PatrickHand.woff2") format("woff2"); font-display: block; }
diff --git a/site/science/lib/cast.js b/site/science/lib/cast.js
new file mode 100644
index 0000000..c0bab37
--- /dev/null
+++ b/site/science/lib/cast.js
@@ -0,0 +1,127 @@
+// Papermorph science book: the cast (load after engine.js). The notebook's owner (a kid in a yellow hoodie) and the
+// dog, flat vector figures on a simple skeleton, so any pose can be set or blended at any moment of a beat.
+// Both are drawn around the point between their feet and face +x; flip with face(-1).
+'use strict';
+const CAST = { skin: '#c98d63', skinDk: '#a8704c', hair: '#3a2a22', hoodie: '#f2c94c', hoodieDk: '#d9ab2c', jeans: '#3d5584',
+ jeansDk: '#2e4268', shoe: '#f4f1e8', sole: '#9aa3b5', glasses: '#1d2333', fur: '#f3e6cf', furDk: '#d8c3a0', patch: '#a0673f',
+ nose: '#2a2320', collar: '#e5533d' };
+
+// Poses: segment angles in degrees from hanging straight down, positive swinging forward (+x).
+// Arms [upper, fore], legs [thigh, shin]; head tilt (positive nods forward/down), look (eyes up, 0..1).
+const KID_POSE = {
+ stand: { ba: [-6, -4], fa: [8, 14], bl: [-3, 0], fl: [4, 0], head: 0, look: 0, lean: 0 },
+ point: { ba: [-8, -6], fa: [128, 118], bl: [-3, 0], fl: [4, 0], head: -8, look: .4, lean: 0 },
+ pointUp: { ba: [-8, -6], fa: [152, 160], bl: [-3, 0], fl: [4, 0], head: -18, look: 1, lean: -3 },
+ lookUp: { ba: [-10, 20], fa: [14, 40], bl: [-3, 0], fl: [4, 0], head: -20, look: 1, lean: -3 },
+ hold: { ba: [24, 80], fa: [40, 84], bl: [-3, 0], fl: [4, 0], head: 6, look: 0, lean: 0 },
+ shrug: { ba: [-34, 70], fa: [34, 70], bl: [-3, 0], fl: [4, 0], head: -6, look: .2, lean: 0 },
+ think: { ba: [-6, -4], fa: [40, 150], bl: [-3, 0], fl: [4, 0], head: -10, look: .7, lean: 0 },
+};
+const blendPose = (a, b, q) => Object.fromEntries(Object.keys(a).map(k => [k, Array.isArray(a[k]) ? a[k].map((v, i) => v + (b[k][i] - v) * q) : a[k] + (b[k] - a[k]) * q]));
+// Walking: a pose from the stride phase (radians); one stride = 2*PI. Drive it from the distance walked.
+function walkPose(ph) {
+ const s = Math.sin(ph);
+ return { ba: [24 * s, 24 * s + 18], fa: [-24 * s, -24 * s + 18], bl: [-26 * s, -26 * s - 30 * Math.max(0, s)],
+ fl: [26 * s, 26 * s - 30 * Math.max(0, -s)], head: 2, look: 0, lean: 3 };
+}
+
+const limbAt = (x, y, len, [a1, a2]) => {
+ const r = Math.PI / 180, x1 = x + len[0] * Math.sin(a1 * r), y1 = y + len[0] * Math.cos(a1 * r);
+ return [x1, y1, x1 + len[1] * Math.sin(a2 * r), y1 + len[1] * Math.cos(a2 * r)];
+};
+
+function kid(p, { x = 0, y = 0, s = 1, o = 1, face = 1, pose = 'stand' } = {}) {
+ const g = G(p, { x, y, s, o }), flip = mk('g', {}, g);
+ const H = -118, SH = -192, ARM = [48, 46], LEG = [58, 56];
+ const shadow = mk('ellipse', { cx: 0, cy: 2, rx: 46, ry: 8, fill: '#000', opacity: .22 }, flip);
+ const body = mk('g', {}, flip);
+ const limb = (c, w) => path(body, '', { stroke: c, 'stroke-width': w });
+ const bLeg = limb(CAST.jeansDk, 24), bShoe = mk('ellipse', { rx: 19, ry: 10, fill: CAST.sole }, body);
+ const bArm = limb(CAST.hoodieDk, 20), bHand = mk('circle', { r: 10, fill: CAST.skinDk }, body);
+ const fLeg = limb(CAST.jeans, 24), fShoe = mk('ellipse', { rx: 20, ry: 10, fill: CAST.shoe }, body);
+ const torso = mk('g', {}, body);
+ path(torso, `M-36 ${SH + 4}Q0 ${SH - 14} 36 ${SH + 4}L33 ${H + 6}Q0 ${H + 14} -33 ${H + 6}Z`, { fill: CAST.hoodie, stroke: 'none' });
+ path(torso, `M-14 ${SH - 2}Q0 ${SH + 16} 14 ${SH - 2}`, { stroke: CAST.hoodieDk, 'stroke-width': 4 });
+ path(torso, `M-20 ${H - 26}H20`, { stroke: CAST.hoodieDk, 'stroke-width': 4 });
+ path(torso, `M-6 ${SH + 8}v22M6 ${SH + 8}v18`, { stroke: CAST.shoe, 'stroke-width': 3 });
+ const head = mk('g', {}, body);
+ mk('circle', { cx: 0, cy: 0, r: 36, fill: CAST.skin }, head);
+ path(head, 'M-38 -2C-44 -30 -24 -50 2 -46C26 -50 44 -30 36 -8C30 -22 18 -26 8 -24C-6 -30 -22 -24 -30 -10Z', { fill: CAST.hair, stroke: 'none' });
+ mk('circle', { cx: -34, cy: 4, r: 8, fill: CAST.skinDk }, head);
+ const eyes = mk('g', {}, head);
+ const lens = (cx) => { mk('circle', { cx, cy: 2, r: 11, fill: '#ffffff', 'fill-opacity': .18, stroke: CAST.glasses, 'stroke-width': 3.5 }, head); };
+ lens(4); lens(28); path(head, 'M15 2h2M-7 0L-30 -4', { stroke: CAST.glasses, 'stroke-width': 3.5 });
+ const pupils = [mk('circle', { cx: 6, cy: 3, r: 3.6, fill: CAST.glasses }, eyes), mk('circle', { cx: 30, cy: 3, r: 3.6, fill: CAST.glasses }, eyes)];
+ const mouth = path(head, 'M12 20Q18 25 25 20', { stroke: CAST.nose, 'stroke-width': 3 });
+ const fArm = limb(CAST.hoodie, 20), fHand = mk('circle', { r: 10.5, fill: CAST.skin }, body);
+ const prop = G(body); // things held in the front hand go here, drawn around the hand
+ let cur = KID_POSE.stand, hand = [0, 0], lastKey = '';
+ const set = (P) => {
+ const key = JSON.stringify(P); if (key === lastKey) return; lastKey = key; cur = P;
+ body.setAttribute('transform', `rotate(${P.lean} 0 ${H})`);
+ const leg = (el, shoe, hx, a) => { const [kx, ky, fx, fy] = limbAt(hx, H, LEG, a); el.setAttribute('d', `M${hx} ${H}L${kx} ${ky}L${fx} ${fy}`);
+ shoe.setAttribute('cx', fx + 8); shoe.setAttribute('cy', fy + 4); };
+ leg(bLeg, bShoe, -12, P.bl); leg(fLeg, fShoe, 12, P.fl);
+ const arm = (el, hd, sx, a) => { const [ex, ey, hx, hy] = limbAt(sx, SH + 8, ARM, a); el.setAttribute('d', `M${sx} ${SH + 8}L${ex} ${ey}L${hx} ${hy}`);
+ hd.setAttribute('cx', hx); hd.setAttribute('cy', hy); return [hx, hy]; };
+ arm(bArm, bHand, -24, P.ba); hand = arm(fArm, fHand, 24, P.fa);
+ head.setAttribute('transform', `translate(4 ${SH - 40}) rotate(${P.head})`);
+ pupils.forEach(e => e.setAttribute('transform', `translate(${1 + P.look}, ${-3.5 * P.look})`));
+ prop.setAttribute('transform', `translate(${hand[0]} ${hand[1]})`);
+ };
+ Object.assign(g, { prop, mouth,
+ pose(a, b, q = 0) { const A = typeof a === 'string' ? KID_POSE[a] : a, B = typeof b === 'string' ? KID_POSE[b] : b; set(B ? blendPose(A, B, q) : A); return g; },
+ walk(dist, step = 30) { set(walkPose(dist / step * Math.PI)); return g; },
+ face(d) { flip.setAttribute('transform', d < 0 ? 'scale(-1 1)' : ''); g._face = d; return g; },
+ // The front hand in the coordinates of the kid's parent (needs the group's state x, y, s).
+ hand() { const S0 = st(g), d = g._face || 1, a = cur.lean * Math.PI / 180, hx = hand[0], hy = hand[1] - H;
+ return [S0.x + d * S0.s * (hx * Math.cos(a) - hy * Math.sin(a)), S0.y + S0.s * (H + hx * Math.sin(a) + hy * Math.cos(a))]; },
+ talk(open) { mouth.setAttribute('d', open ? 'M12 19Q18 30 25 19Z' : 'M12 20Q18 25 25 20'); return g; },
+ blink(closed) { eyes.setAttribute('transform', closed ? 'translate(0 3) scale(1 .15)' : ''); return g; },
+ });
+ g.face(face);
+ return g.pose(pose);
+}
+
+// The dog. Methods: d.wag(t) (tail from a time), d.walk(dist), d.sit(q) (0 standing .. 1 sitting), d.tilt(deg) (head).
+function dog(p, { x = 0, y = 0, s = 1, o = 1, face = 1 } = {}) {
+ const g = G(p, { x, y, s, o }), flip = mk('g', {}, g);
+ mk('ellipse', { cx: 0, cy: 2, rx: 56, ry: 8, fill: '#000', opacity: .22 }, flip);
+ const legs = [-30, -16, 22, 36].map((lx, i) => path(flip, '', { stroke: i % 2 ? CAST.fur : CAST.furDk, 'stroke-width': 13 }));
+ const torso = mk('g', {}, flip);
+ const tail = path(torso, 'M0 0C-14 -10 -22 -26 -18 -40', { stroke: CAST.fur, 'stroke-width': 10 });
+ mk('ellipse', { cx: 0, cy: -50, rx: 48, ry: 27, fill: CAST.fur }, torso);
+ path(torso, 'M-34 -66C-20 -78 4 -76 10 -64C2 -56 -24 -54 -34 -66Z', { fill: CAST.patch, stroke: 'none' });
+ const head = mk('g', {}, torso);
+ mk('circle', { cx: 0, cy: 0, r: 25, fill: CAST.fur }, head);
+ mk('ellipse', { cx: 20, cy: 7, rx: 17, ry: 12, fill: CAST.fur }, head);
+ mk('circle', { cx: 35, cy: 3, r: 5.5, fill: CAST.nose }, head);
+ const eye = mk('ellipse', { cx: 9, cy: -6, rx: 3.8, ry: 4.2, fill: CAST.nose }, head);
+ path(head, 'M18 15Q24 19 30 14', { stroke: CAST.nose, 'stroke-width': 2.5 });
+ const ear = path(head, 'M-10 -20C-26 -22 -30 0 -22 14C-16 18 -10 6 -6 -14Z', { fill: CAST.patch, stroke: 'none' });
+ path(torso, 'M34 -66Q44 -50 52 -60', { stroke: CAST.collar, 'stroke-width': 7 });
+ let st0 = { walk: 0, sit: 0, wag: 0, tilt: 0 }, last = '';
+ const apply = () => {
+ const k = JSON.stringify(st0); if (k === last) return; last = k;
+ const { walk, sit, wag, tilt } = st0, sw = Math.sin(walk);
+ torso.setAttribute('transform', `rotate(${-24 * sit} -30 -36)`);
+ legs.forEach((l, i) => {
+ const lx = [-30, -16, 22, 36][i], back = i < 2, a = (i === 0 || i === 3 ? 1 : -1) * 24 * sw * (1 - sit);
+ const top = back ? -36 + 4 * sit : -38 - 22 * sit, fx = back ? lx + 26 * sit : lx - 6 * sit, r = a * Math.PI / 180, L = -top;
+ l.setAttribute('d', back && sit > .5 ? `M${lx + 4} ${top}Q${lx + 30} ${-10} ${lx + 34} 0` : `M${lx} ${top}L${fx + L * Math.sin(r)} ${top + L * Math.cos(r)}`);
+ });
+ tail.setAttribute('transform', `translate(-44 -54) rotate(${wag})`);
+ head.setAttribute('transform', `translate(48 -84) rotate(${tilt + 24 * sit})`);
+ ear.setAttribute('transform', `rotate(${4 * Math.sin(walk * 2)})`);
+ };
+ Object.assign(g, {
+ wag(t, amp = 22) { st0.wag = amp * Math.sin(t * 14); apply(); return g; },
+ walk(dist, step = 26) { st0.walk = dist / step * Math.PI; apply(); return g; },
+ sit(q) { st0.sit = q; apply(); return g; },
+ tilt(deg) { st0.tilt = deg; apply(); return g; },
+ blink(closed) { eye.setAttribute('ry', closed ? .8 : 4.2); return g; },
+ face(d) { flip.setAttribute('transform', d < 0 ? 'scale(-1 1)' : ''); g._face = d; return g; },
+ });
+ apply(); g.face(face);
+ return g;
+}
diff --git a/site/science/lib/fonts/PatrickHand.woff2 b/site/science/lib/fonts/PatrickHand.woff2
new file mode 100644
index 0000000..eecd8e5
Binary files /dev/null and b/site/science/lib/fonts/PatrickHand.woff2 differ
diff --git a/site/science/lib/notes.js b/site/science/lib/notes.js
new file mode 100644
index 0000000..25f8d14
--- /dev/null
+++ b/site/science/lib/notes.js
@@ -0,0 +1,60 @@
+// Papermorph science book: the notebook's pen (load after engine.js).
+// Vocabulary in yellow highlighter, definitions in green, important terms in blue pen, handwritten notes and the
+// dog's speech bubbles, and force arrows that start at the point where the force acts.
+'use strict';
+const HAND = '"Patrick Hand","Comic Sans MS",cursive';
+const INK = { hl: '#f7e15a', def: '#9be38a', pink: '#f6a6c8', blue: '#7cc4ff', ink: '#1d2333', paper: '#fbf8ef',
+ force: '#ff7a59', note: '#f4f1e8' };
+// Width of a string in a font, measured once the web font has loaded (chapters boot after document.fonts.ready).
+function handW(str, size, font = HAND, weight = 400) { ctx2d.font = `${weight} ${size}px ${font}`; return ctx2d.measureText(str).width; }
+
+// A word in highlighter: the swash is one thick stroke, drawn on left to right, then the ink. hlIn(g, t0) reveals it.
+function hl(p, str, { x = 0, y = 0, size = 40, anchor = 'middle', color = INK.hl, font = HAND, weight = 400, o = 1, r = 0 } = {}) {
+ const w = handW(str, size, font, weight), x0 = anchor === 'middle' ? -w / 2 : anchor === 'end' ? -w : 0;
+ const g = G(p, { x, y, o, r }), pad = size * .3;
+ g._sw = path(g, `M${x0 - pad} ${-size * .32}Q${x0 + w / 2} ${-size * .38} ${x0 + w + pad} ${-size * .3}`,
+ { stroke: color, 'stroke-width': size * 1.12, 'stroke-linecap': 'butt', 'stroke-opacity': .95 }, { d: 0 });
+ g._t = T(g, str, { x: x0, size, fill: INK.ink, font, weight, o: 0 });
+ g._w = w;
+ return g;
+}
+function hlIn(g, t0, dur = .45) { show(g, t0, .01); draw(g._sw, t0, dur); show(g._t, t0 + dur * .5, .3); return g; }
+
+// Handwritten text; '\n' starts a new line.
+function pen(p, str, { x = 0, y = 0, size = 32, fill = INK.note, anchor = 'start', r = 0, o = 0, lh = 1.12 } = {}) {
+ const g = G(p, { x, y, r, o });
+ str.split('\n').forEach((s, i) => T(g, s, { y: i * size * lh, size, fill, font: HAND, anchor }));
+ return g;
+}
+
+// A speech bubble whose tail points at (x + tx, y + ty); the box sits centred above (x, y). Pops in with pop().
+function bubble(p, str, { x = 0, y = 0, tx = -30, ty = 60, size = 30, o = 0, s = .6 } = {}) {
+ const lines = str.split('\n'), w = Math.max(...lines.map(l => handW(l, size))) + size * 1.1, h = lines.length * size * 1.1 + size * .7;
+ const g = G(p, { x, y, o, s });
+ const bx = -w / 2, by = -h, bt = Math.max(bx + 14, Math.min(bx + w - 40, tx - 13));
+ path(g, `M${bx + 16} ${by}H${bx + w - 16}Q${bx + w} ${by} ${bx + w} ${by + 16}V${-16}Q${bx + w} 0 ${bx + w - 16} 0H${bt + 26}L${tx} ${ty}L${bt} 0H${bx + 16}Q${bx} 0 ${bx} ${-16}V${by + 16}Q${bx} ${by} ${bx + 16} ${by}Z`,
+ { fill: INK.paper, stroke: INK.ink, 'stroke-width': 3 });
+ lines.forEach((l, i) => T(g, l, { y: by + size * .35 + (i + 1) * size * 1.02, size, fill: INK.ink, font: HAND, anchor: 'middle' }));
+ return g;
+}
+
+// A force arrow: f.set(x, y, len, deg) draws it from (x, y) along screen angle deg (0 right, 90 down); the label
+// rides beside the arrow's middle. Length stands for magnitude.
+function forceArrow(p, { color = INK.force, w = 8, label = '', size = 26, o = 1 } = {}) {
+ const g = G(p, { o }), line = path(g, '', { stroke: color, 'stroke-width': w }), head = path(g, '', { fill: color, stroke: color, 'stroke-width': 2 });
+ const lab = label ? pen(g, label, { size, fill: color, anchor: 'middle', o: 1 }) : null;
+ // a dark halo keeps the label readable where the arrow crosses a picture
+ if (lab) [...lab.children].forEach(t => { t.setAttribute('stroke', '#0b1226'); t.setAttribute('stroke-width', size * .22); t.setAttribute('paint-order', 'stroke'); t.setAttribute('stroke-linejoin', 'round'); });
+ let last = '';
+ g.set = (x, y, len, deg) => {
+ const key = [x, y, len, deg].join();
+ if (key === last) return g; last = key;
+ const a = deg * Math.PI / 180, c = Math.cos(a), s = Math.sin(a), hl = Math.min(len * .45, w * 3.2);
+ const x1 = x + c * len, y1 = y + s * len, xb = x1 - c * hl, yb = y1 - s * hl;
+ line.setAttribute('d', `M${x} ${y}L${xb} ${yb}`);
+ head.setAttribute('d', `M${x1} ${y1}L${xb - s * w * 1.5} ${yb + c * w * 1.5}L${xb + s * w * 1.5} ${yb - c * w * 1.5}Z`);
+ if (lab) put(lab, { x: x + c * len / 2 - s * (size * .9), y: y + s * len / 2 + c * (size * .9) + size * .3 });
+ return g;
+ };
+ return g;
+}
diff --git a/site/science/lib/space.js b/site/science/lib/space.js
new file mode 100644
index 0000000..977121c
--- /dev/null
+++ b/site/science/lib/space.js
@@ -0,0 +1,127 @@
+// Papermorph science book: space scenes (load after engine.js).
+// Sun, Earth and Moon from NASA images (see img/CREDITS.md), lit by a night overlay that always faces away from the
+// light; sunlight rays, shadow cones and orbits drawn in code.
+'use strict';
+const SKY = { deep: '#0b1226', mid: '#16214a', star: '#dfe6ff', sun: '#ffcf5a', light: '#ffe08a', night: '#050916',
+ orbit: '#8d9bc4', axis: '#f4f1e8', umbra: '#03050b', penumbra: '#2b3150', rim: '#8cc8ff' };
+const IMG = '../img/';
+let spaceN = 0;
+const uid = k => k + (++spaceN);
+// Deterministic random numbers, so a replayed scene draws the same stars.
+function rng(seed) { return () => { seed |= 0; seed = seed + 0x6D2B79F5 | 0; let t = Math.imul(seed ^ seed >>> 15, 1 | seed);
+ t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t; return ((t ^ t >>> 14) >>> 0) / 4294967296; }; }
+const dotsPath = pts => pts.map(([x, y, r]) => `M${x - r} ${y}a${r} ${r} 0 1 0 ${2 * r} 0a${r} ${r} 0 1 0 ${-2 * r} 0`).join('');
+
+// Night sky over [x, y, w, h]: a gradient and two layers of stars, each one path.
+function spaceBg(p, { x = 0, y = 0, w = 1600, h = 900, n = 160, seed = 7, o = 1 } = {}) {
+ const g = G(p, { o }), id = uid('sky');
+ const gr = mk('radialGradient', { id, cx: '50%', cy: '40%', r: '75%' }, mk('defs', {}, g));
+ mk('stop', { offset: 0, 'stop-color': SKY.mid }, gr); mk('stop', { offset: 1, 'stop-color': SKY.deep }, gr);
+ mk('rect', { x, y, width: w, height: h, fill: `url(#${id})` }, g);
+ const R = rng(seed), big = [], small = [];
+ for (let i = 0; i < n; i++) (R() < .18 ? big : small).push([x + R() * w, y + R() * h, R() < .18 ? 2.2 : 1.2]);
+ path(g, dotsPath(small), { fill: SKY.star, "fill-opacity": .55, stroke: 'none' });
+ path(g, dotsPath(big), { fill: SKY.star, "fill-opacity": .9, stroke: 'none' });
+ return g;
+}
+
+// The sun: a soft glow and the SDO disc.
+function sunBody(p, { x = 0, y = 0, r = 90, glow = 2.4, o = 1, s = 1 } = {}) {
+ const g = G(p, { x, y, o, s }), id = uid('glow');
+ const gr = mk('radialGradient', { id }, mk('defs', {}, g));
+ [[0, .55], [.42, .28], [1, 0]].forEach(([k, a]) => mk('stop', { offset: k, 'stop-color': SKY.sun, 'stop-opacity': a }, gr));
+ g._glow = mk('circle', { r: r * glow, fill: `url(#${id})` }, g);
+ mk('image', { href: IMG + 'sun.webp', x: -r, y: -r, width: 2 * r, height: 2 * r }, g);
+ return g;
+}
+
+// The dark part of a ball of radius r lit from +x (rotate the path toward the light). c is the cosine of the angle
+// between the light and the viewer's line of sight: 1 fully lit (light behind the viewer), 0 half, -1 all dark.
+function phasePath(r, c) {
+ const k = Math.max(.001, Math.abs(c)) * r;
+ return `M0 ${-r}A${r} ${r} 0 0 0 0 ${r}A${k} ${r} 0 0 ${c > 0 ? 1 : 0} 0 ${-r}Z`;
+}
+
+// A lit ball. kind: 'earth' (spinning side view from 120 frames), 'pole' (Earth from above the North Pole),
+// 'earthBig', 'moon', 'moonFar', or a colour for a plain disc. Methods (call from clockRun/prog, pure in t):
+// b.spin(deg) eastward turn: side view picks frames (cross-fading 3 degree steps); others rotate the
+// image counterclockwise, which is eastward for the pole view
+// b.light(deg, c) light arrives from screen angle deg (0 right, 90 down); c as in phasePath
+// b.tilt(deg) lean the body and its axis (positive: north pole toward +x); the night side stays put
+// b.axis the axis group (hidden); b.body the tilted group; b.night the overlay
+const EARTH_SHEET = { w: 256, n: 120, cols: 12, step: 3 };
+function globe(p, { x = 0, y = 0, r = 100, kind = 'earth', light = 180, c = 0, tilt = 0, spin = 0, night = .78, rim = true, o = 1, s = 1 } = {}) {
+ const g = G(p, { x, y, o, s }), body = G(g, { r: tilt });
+ let frames = null, img = null;
+ if (kind === 'earth') {
+ const W = EARTH_SHEET.w;
+ frames = [0, 1].map(() => {
+ const sv = mk('svg', { x: -r, y: -r, width: 2 * r, height: 2 * r, viewBox: `0 0 ${W} ${W}` }, body);
+ mk('image', { href: IMG + 'earth_side.webp', width: W * EARTH_SHEET.cols, height: W * EARTH_SHEET.n / EARTH_SHEET.cols }, sv);
+ return sv;
+ });
+ } else if (kind.startsWith('#')) {
+ img = mk('circle', { r, fill: kind }, body);
+ } else {
+ const file = { pole: 'earth_pole', earthBig: 'earth_big', moon: 'moon_near', moonFar: 'moon_far' }[kind];
+ img = mk('image', { href: IMG + file + '.webp', x: -r, y: -r, width: 2 * r, height: 2 * r }, body);
+ }
+ const dark = G(g, { r: light }), shade = path(dark, phasePath(r + .5, c), { fill: SKY.night, "fill-opacity": night, stroke: 'none' });
+ const axisT = G(g, { r: tilt }), axis = G(axisT, { o: 0 }); // above the night side, leaning with the body
+ path(axis, `M0 ${-r * 1.38}V${r * 1.38}`, { stroke: SKY.axis, 'stroke-width': Math.max(2.5, r * .035), 'stroke-dasharray': `${r * .09} ${r * .07}` });
+ mk('circle', { cy: -r * 1.38, r: Math.max(4, r * .05), fill: SKY.axis }, axis);
+ if (rim) mk('circle', { r: r + 1.5, fill: 'none', stroke: SKY.rim, 'stroke-width': Math.max(2, r * .03), opacity: kind === 'earth' || kind === 'pole' || kind === 'earthBig' ? .55 : .18 }, g);
+ let lastF = -1, lastQ = -1, lastC = c;
+ Object.assign(g, { body, axis, night: dark, r,
+ spin(deg) {
+ if (!frames) { put(img, { r: kind === 'pole' ? -deg : deg }); return g; }
+ const f = (((deg / EARTH_SHEET.step) % EARTH_SHEET.n) + EARTH_SHEET.n) % EARTH_SHEET.n, i = Math.floor(f), q = +(f - i).toFixed(3);
+ const vb = k => { const W = EARTH_SHEET.w; return `${(k % EARTH_SHEET.cols) * W} ${Math.floor(k / EARTH_SHEET.cols) * W} ${W} ${W}`; };
+ if (i !== lastF) { frames[0].setAttribute('viewBox', vb(i)); frames[1].setAttribute('viewBox', vb((i + 1) % EARTH_SHEET.n)); lastF = i; }
+ if (q !== lastQ) { frames[1].setAttribute('opacity', q); lastQ = q; }
+ return g;
+ },
+ light(deg, cc = lastC) { put(dark, { r: deg }); if (cc !== lastC) { shade.setAttribute('d', phasePath(r + .5, cc)); lastC = cc; } return g; },
+ tilt(deg) { put(body, { r: deg }); put(axisT, { r: deg }); return g; },
+ });
+ return g.spin(spin);
+}
+
+// Parallel sunlight: n lines from x0 to x1 across [y0, y1] (left to right, or reversed when x1 < x0), each with a
+// small arrowhead. Returns the group; its paths carry {d: 0} so draw(g._lines[i], t0) runs them on.
+function sunRays(p, { x0, x1, y0, y1, n = 5, w = 4, color = SKY.light, o = 1 } = {}) {
+ const g = G(p, { o }), dir = Math.sign(x1 - x0);
+ g._lines = Array.from({ length: n }, (_, i) => {
+ const y = n === 1 ? y0 : y0 + (y1 - y0) * i / (n - 1);
+ return path(g, `M${x0} ${y}H${x1}M${x1 - 18 * dir} ${y - 10}L${x1} ${y}L${x1 - 18 * dir} ${y + 10}`, { stroke: color, 'stroke-width': w }, { d: 0 });
+ });
+ return g;
+}
+const raysOn = (g, t0, dur = .8, gap = .08) => g._lines.forEach((l, i) => draw(l, t0 + i * gap, dur));
+
+// The shadow behind a ball of radius r at (x, y) lit by a source of radius rs at distance dist along screen angle
+// ang (pointing from the source to the ball). Umbra: the cone that sees none of the source; penumbra: part of it.
+// Lengths come from similar triangles, so a smaller ball or a nearer source shortens the umbra.
+function shadowCone(p, { x = 0, y = 0, r, rs, dist, ang = 0, len = 600, o = 1 } = {}) {
+ const g = G(p, { x, y, r: ang, o });
+ const ku = (rs - r) / dist, kp = (rs + r) / dist; // narrowing of the umbra, widening of the penumbra
+ const L = Math.min(len, r / Math.max(1e-6, ku)), hu = Math.max(0, r - ku * L);
+ const pen = path(g, `M0 ${-r}L${len} ${-r - kp * len}V${r + kp * len}L0 ${r}Z`, { fill: SKY.penumbra, "fill-opacity": .55, stroke: 'none' });
+ const um = path(g, `M0 ${-r}L${L} ${-hu}V${hu}L0 ${r}Z`, { fill: SKY.umbra, "fill-opacity": .85, stroke: 'none' });
+ Object.assign(g, { umbra: um, penumbra: pen });
+ return g;
+}
+
+// Orbits: an ellipse (optionally seen at a slant, ry < rx) and points on it, angle in degrees counterclockwise from +x.
+const orbitAt = (cx, cy, rx, ry, deg) => [cx + rx * Math.cos(deg * Math.PI / 180), cy - ry * Math.sin(deg * Math.PI / 180)];
+function orbit(p, cx, cy, rx, ry, { color = SKY.orbit, w = 3, dash = '10 12', o = 1 } = {}) {
+ return path(p, `M${cx - rx} ${cy}A${rx} ${ry} 0 1 0 ${cx + rx} ${cy}A${rx} ${ry} 0 1 0 ${cx - rx} ${cy}`, { stroke: color, 'stroke-width': w, 'stroke-dasharray': dash, "stroke-opacity": o });
+}
+// A curved arrow along a circle of radius R around (cx, cy) from angle a0 to a1 (degrees, counterclockwise from +x).
+function spinArrow(p, cx, cy, R, a0, a1, { color = SKY.axis, w = 5, ry = R } = {}) {
+ const P = a => orbitAt(cx, cy, R, ry, a), [x0, y0] = P(a0), [x1, y1] = P(a1), sweep = a1 > a0 ? 0 : 1;
+ const [xb, yb] = P(a1 - Math.sign(a1 - a0) * 9), ang = Math.atan2(y1 - yb, x1 - xb);
+ const hd = (da) => [x1 - 18 * Math.cos(ang + da), y1 - 18 * Math.sin(ang + da)];
+ const [h1, h2] = [hd(.5), hd(-.5)];
+ return path(p, `M${x0} ${y0}A${R} ${ry} 0 ${Math.abs(a1 - a0) > 180 ? 1 : 0} ${sweep} ${x1} ${y1}M${h1[0]} ${h1[1]}L${x1} ${y1}L${h2[0]} ${h2[1]}`, { stroke: color, 'stroke-width': w }, { d: 0 });
+}
diff --git a/site/science/unit-art.js b/site/science/unit-art.js
index a4cebf0..99d0291 100644
--- a/site/science/unit-art.js
+++ b/site/science/unit-art.js
@@ -19,5 +19,10 @@
reset(P('M228 130H572') + Array.from({ length: 7 }, (_, i) => P(`M${250 + i * 50} 122v16`, 'a')).join('') +
`<circle class="t hop" r="8" fill="currentColor" stroke="none" style="--k:${k++};offset-path:path('M250 116Q275 84 300 116Q325 84 350 116Q375 84 400 116')"/>` +
Tx(250, 60, 'speed = distance ÷ time', 26) + P('M480 70h70m-14 -10l14 10l-14 10', 'a')),
+ // Unit 5 sample (outer space): a sun with an orbit, Earth going round it with its moon.
+ reset(C(420, 92, 30) + Array.from({ length: 8 }, (_, i) => { const a = i * Math.PI / 4; return P(`M${420 + 40 * Math.cos(a)} ${92 + 40 * Math.sin(a)}L${420 + 52 * Math.cos(a)} ${92 + 52 * Math.sin(a)}`); }).join('') +
+ P('M560 92A140 46 0 1 1 280 92A140 46 0 1 1 560 92', 'a') +
+ `<g class="t orbit" style="--k:${k++};offset-path:path('M560 92A140 46 0 1 0 280 92A140 46 0 1 0 560 92')"><circle r="11" fill="currentColor" stroke="none"/><circle cx="20" cy="-6" r="4" fill="currentColor" stroke="none" opacity=".7"/></g>` +
+ Tx(420, 30, 'sun · earth · moon', 22, 'a', 'middle')),
];
})();