An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
feat(site): The Little Horse Crosses the River, a picture book (小马过河)
yzr3be88ddbb29e
diff --git a/site/little-horse/ch01/audio/bgm/theme.mp3 b/site/little-horse/ch01/audio/bgm/theme.mp3new file mode 100644index 0000000..3830181Binary files /dev/null and b/site/little-horse/ch01/audio/bgm/theme.mp3 differdiff --git a/site/little-horse/ch01/audio/en/h01.mp3 b/site/little-horse/ch01/audio/en/h01.mp3new file mode 100644index 0000000..b3e031cBinary files /dev/null and b/site/little-horse/ch01/audio/en/h01.mp3 differdiff --git a/site/little-horse/ch01/audio/en/h02.mp3 b/site/little-horse/ch01/audio/en/h02.mp3new file mode 100644index 0000000..3f6a1efBinary files /dev/null and b/site/little-horse/ch01/audio/en/h02.mp3 differdiff --git a/site/little-horse/ch01/audio/en/h04.mp3 b/site/little-horse/ch01/audio/en/h04.mp3new file mode 100644index 0000000..d952751Binary files /dev/null and b/site/little-horse/ch01/audio/en/h04.mp3 differdiff --git a/site/little-horse/ch01/audio/en/h05.mp3 b/site/little-horse/ch01/audio/en/h05.mp3new file mode 100644index 0000000..a100ba2Binary files /dev/null and b/site/little-horse/ch01/audio/en/h05.mp3 differdiff --git a/site/little-horse/ch01/audio/en/h05b.mp3 b/site/little-horse/ch01/audio/en/h05b.mp3new file mode 100644index 0000000..e137a75Binary files /dev/null and b/site/little-horse/ch01/audio/en/h05b.mp3 differdiff --git a/site/little-horse/ch01/audio/en/h06.mp3 b/site/little-horse/ch01/audio/en/h06.mp3new file mode 100644index 0000000..fd7e918Binary files /dev/null and b/site/little-horse/ch01/audio/en/h06.mp3 differdiff --git a/site/little-horse/ch01/audio/en/h06b.mp3 b/site/little-horse/ch01/audio/en/h06b.mp3new file mode 100644index 0000000..1991d4aBinary files /dev/null and b/site/little-horse/ch01/audio/en/h06b.mp3 differdiff --git a/site/little-horse/ch01/audio/en/h06c.mp3 b/site/little-horse/ch01/audio/en/h06c.mp3new file mode 100644index 0000000..9951b87Binary files /dev/null and b/site/little-horse/ch01/audio/en/h06c.mp3 differdiff --git a/site/little-horse/ch01/audio/en/h07.mp3 b/site/little-horse/ch01/audio/en/h07.mp3new file mode 100644index 0000000..91fe3caBinary files /dev/null and b/site/little-horse/ch01/audio/en/h07.mp3 differdiff --git a/site/little-horse/ch01/audio/en/h09.mp3 b/site/little-horse/ch01/audio/en/h09.mp3new file mode 100644index 0000000..e9dc16bBinary files /dev/null and b/site/little-horse/ch01/audio/en/h09.mp3 differdiff --git a/site/little-horse/ch01/audio/en/h09b.mp3 b/site/little-horse/ch01/audio/en/h09b.mp3new file mode 100644index 0000000..28fbbc8Binary files /dev/null and b/site/little-horse/ch01/audio/en/h09b.mp3 differdiff --git a/site/little-horse/ch01/audio/en/m01.mp3 b/site/little-horse/ch01/audio/en/m01.mp3new file mode 100644index 0000000..76b3801Binary files /dev/null and b/site/little-horse/ch01/audio/en/m01.mp3 differdiff --git a/site/little-horse/ch01/audio/en/m06.mp3 b/site/little-horse/ch01/audio/en/m06.mp3new file mode 100644index 0000000..5a013dcBinary files /dev/null and b/site/little-horse/ch01/audio/en/m06.mp3 differdiff --git a/site/little-horse/ch01/audio/en/m06b.mp3 b/site/little-horse/ch01/audio/en/m06b.mp3new file mode 100644index 0000000..596b3e2Binary files /dev/null and b/site/little-horse/ch01/audio/en/m06b.mp3 differdiff --git a/site/little-horse/ch01/audio/en/m06c.mp3 b/site/little-horse/ch01/audio/en/m06c.mp3new file mode 100644index 0000000..0991d3cBinary files /dev/null and b/site/little-horse/ch01/audio/en/m06c.mp3 differdiff --git a/site/little-horse/ch01/audio/en/m06d.mp3 b/site/little-horse/ch01/audio/en/m06d.mp3new file mode 100644index 0000000..023e389Binary files /dev/null and b/site/little-horse/ch01/audio/en/m06d.mp3 differdiff --git a/site/little-horse/ch01/audio/en/mouths.js b/site/little-horse/ch01/audio/en/mouths.jsnew file mode 100644index 0000000..9e23a27--- /dev/null+++ b/site/little-horse/ch01/audio/en/mouths.js@@ -0,0 +1 @@+window.MOUTHS = {"n01":[[0.0,"A"],[0.08,"C"],[0.16,"D"],[0.3,"H"],[0.34,"C"],[0.38,"B"],[0.42,"H"],[0.46,"C"],[0.5,"B"],[0.556,"C"],[0.612,"G"],[0.668,"C"],[0.724,"B"],[0.78,"B"],[0.94,"F"],[1.1,"B"],[1.26,"D"],[1.4,"B"],[1.531,"D"],[1.663,"A"],[1.794,"H"],[1.925,"C"],[2.057,"X"],[2.7,"C"],[2.73,"B"],[2.76,"C"],[2.83,"B"],[2.9,"H"],[2.96,"C"],[3.02,"G"],[3.08,"C"],[3.14,"B"],[3.2,"D"],[3.3,"B"],[3.4,"E"],[3.487,"H"],[3.573,"B"],[3.66,"A"],[3.732,"E"],[3.804,"B"],[3.876,"C"],[3.948,"B"],[4.02,"B"],[4.105,"E"],[4.19,"B"],[4.275,"C"],[4.36,"D"],[4.53,"B"],[4.7,"B"],[4.76,"C"],[4.82,"B"],[4.88,"B"],[5.05,"E"],[5.219,"B"],[5.389,"X"],[5.635,"H"],[5.648,"C"],[5.661,"B"],[5.674,"H"],[5.687,"C"],[5.7,"B"],[5.868,"E"],[6.036,"B"],[6.204,"C"],[6.372,"X"],[7.051,"H"],[7.069,"C"],[7.087,"B"],[7.104,"H"],[7.122,"C"],[7.14,"B"],[7.24,"E"],[7.34,"B"],[7.44,"C"],[7.54,"B"],[7.647,"C"],[7.753,"B"],[7.86,"A"],[8.02,"C"],[8.18,"B"],[8.24,"C"],[8.3,"B"],[8.36,"A"],[8.432,"E"],[8.504,"B"],[8.576,"C"],[8.648,"B"],[8.72,"B"],[8.795,"C"],[8.87,"B"],[8.945,"C"],[9.02,"D"],[9.21,"H"],[9.4,"B"],[9.54,"C"],[9.68,"H"],[9.849,"E"],[10.017,"B"],[10.186,"X"],[10.72,"B"],[10.74,"C"],[10.76,"B"],[10.807,"D"],[10.853,"B"],[10.9,"B"],[10.952,"C"],[11.004,"G"],[11.056,"C"],[11.108,"B"],[11.16,"B"],[11.22,"E"],[11.28,"B"],[11.34,"C"],[11.4,"D"],[11.447,"B"],[11.495,"C"],[11.543,"F"],[11.59,"B"],[11.637,"C"],[11.685,"B"],[11.732,"C"],[11.78,"D"],[11.948,"H"],[12.117,"E"],[12.285,"B"],[12.454,"C"],[12.33,"X"]],"m01":[[0.0,"H"],[0.056,"C"],[0.112,"B"],[0.168,"H"],[0.224,"C"],[0.28,"E"],[0.479,"B"],[0.677,"C"],[0.876,"X"],[1.027,"C"],[1.06,"F"],[1.093,"B"],[1.127,"C"],[1.16,"A"],[1.24,"C"],[1.32,"B"],[1.4,"B"],[1.693,"F"],[1.987,"X"],[2.309,"C"],[2.345,"F"],[2.38,"B"],[2.427,"D"],[2.473,"B"],[2.52,"B"],[2.57,"C"],[2.62,"H"],[2.67,"A"],[2.72,"A"],[2.911,"C"],[3.103,"X"],[3.614,"F"],[3.629,"C"],[3.645,"H"],[3.66,"C"],[3.72,"F"],[3.78,"B"],[3.845,"D"],[3.91,"B"],[3.975,"C"],[4.04,"B"],[4.12,"C"],[4.2,"B"],[4.28,"B"],[4.35,"D"],[4.42,"H"],[4.49,"G"],[4.56,"B"],[4.647,"D"],[4.733,"B"],[4.82,"E"],[4.91,"G"],[5.0,"F"],[5.055,"B"],[5.11,"C"],[5.165,"B"],[5.22,"B"],[5.35,"E"],[5.48,"B"],[5.52,"C"],[5.56,"A"],[5.698,"C"],[5.836,"H"],[6.024,"X"]],"h01":[[0.0,"C"],[0.31,"B"],[0.62,"A"],[0.765,"D"],[0.91,"A"],[1.055,"D"],[1.2,"C"],[1.38,"B"],[1.433,"D"],[1.487,"B"],[1.54,"B"],[1.67,"E"],[1.8,"C"],[2.057,"B"],[2.35,"X"]],"n02":[[0.0,"H"],[0.04,"C"],[0.08,"B"],[0.12,"H"],[0.16,"C"],[0.2,"B"],[0.275,"E"],[0.35,"B"],[0.425,"C"],[0.5,"B"],[0.608,"E"],[0.716,"B"],[0.824,"C"],[0.932,"B"],[1.04,"E"],[1.15,"G"],[1.26,"F"],[1.333,"C"],[1.407,"B"],[1.48,"B"],[1.55,"C"],[1.62,"F"],[1.67,"B"],[1.72,"C"],[1.77,"B"],[1.82,"E"],[1.92,"B"],[2.02,"B"],[2.06,"C"],[2.1,"B"],[2.14,"A"],[2.233,"D"],[2.327,"B"],[2.42,"D"],[2.523,"B"],[2.626,"X"],[2.84,"G"],[2.94,"D"],[3.04,"B"],[3.14,"D"],[3.29,"B"],[3.44,"B"],[3.51,"C"],[3.58,"B"],[3.62,"F"],[3.66,"H"],[3.7,"B"],[3.74,"B"],[3.945,"E"],[4.149,"X"],[4.56,"B"],[4.6,"C"],[4.64,"B"],[4.74,"D"],[4.84,"B"],[4.94,"D"],[5.17,"B"],[5.4,"B"],[5.48,"C"],[5.56,"B"],[5.66,"D"],[5.76,"B"],[5.86,"F"],[5.924,"B"],[5.988,"C"],[6.052,"H"],[6.116,"X"],[6.56,"D"],[6.7,"B"],[6.752,"C"],[6.804,"G"],[6.856,"C"],[6.908,"B"],[6.96,"B"],[7.08,"D"],[7.2,"B"],[7.32,"B"],[7.433,"C"],[7.547,"B"],[7.66,"D"],[7.715,"B"],[7.77,"E"],[7.825,"B"],[7.88,"B"],[7.96,"C"],[8.04,"B"],[8.12,"A"],[8.303,"D"],[8.487,"B"],[8.67,"X"]],"h02":[[0.0,"F"],[0.245,"B"],[0.49,"E"],[0.735,"D"],[0.98,"B"],[0.993,"D"],[1.007,"B"],[1.02,"C"],[1.16,"B"],[1.2,"C"],[1.24,"B"],[1.28,"D"],[1.539,"B"],[1.798,"E"],[2.057,"B"],[2.316,"X"],[2.54,"C"],[2.58,"G"],[2.62,"E"],[2.65,"B"],[2.68,"H"],[2.71,"C"],[2.74,"A"],[2.87,"D"],[3.0,"A"],[3.13,"D"],[3.26,"F"],[3.315,"C"],[3.37,"B"],[3.425,"C"],[3.48,"B"],[3.525,"C"],[3.57,"B"],[3.615,"C"],[3.66,"B"],[3.71,"E"],[3.76,"D"],[4.035,"B"],[4.31,"X"]],"n03":[[0.0,"H"],[0.052,"C"],[0.104,"B"],[0.156,"H"],[0.208,"C"],[0.26,"B"],[0.325,"E"],[0.39,"B"],[0.455,"C"],[0.52,"H"],[0.596,"F"],[0.672,"B"],[0.748,"C"],[0.824,"B"],[0.9,"D"],[1.08,"H"],[1.26,"D"],[1.434,"B"],[1.608,"F"],[1.782,"B"],[1.956,"X"],[2.407,"F"],[2.445,"B"],[2.482,"E"],[2.52,"B"],[2.56,"F"],[2.6,"H"],[2.64,"B"],[2.68,"B"],[2.73,"C"],[2.78,"H"],[2.83,"A"],[2.88,"B"],[3.034,"C"],[3.189,"A"],[3.343,"X"],[3.718,"B"],[3.739,"C"],[3.759,"H"],[3.779,"A"],[3.8,"B"],[3.867,"C"],[3.933,"A"],[4.0,"H"],[4.165,"F"],[4.33,"B"],[4.495,"X"],[4.916,"H"],[4.973,"C"],[5.03,"B"],[5.086,"C"],[5.143,"B"],[5.2,"D"],[5.308,"B"],[5.416,"X"],[5.72,"B"],[5.82,"F"],[5.92,"B"],[6.02,"F"],[6.095,"B"],[6.17,"D"],[6.245,"B"],[6.32,"B"],[6.39,"C"],[6.46,"D"],[6.58,"B"],[6.7,"G"],[6.867,"E"],[7.034,"B"],[7.25,"X"]],"w-river":[[0.0,"B"],[0.112,"C"],[0.224,"G"],[0.336,"C"],[0.448,"B"],[0.55,"X"]],"w-tree":[[0.0,"B"],[0.278,"C"],[0.55,"X"]],"w-ox":[[0.0,"E"],[0.308,"B"],[0.55,"X"]],"w-rock":[[0.0,"B"],[0.185,"E"],[0.37,"B"],[0.55,"X"]],"w-flower":[[0.48,"G"],[0.52,"H"],[0.56,"F"],[0.6,"C"],[0.639,"B"],[0.729,"X"]],"w-bird":[[0.0,"A"],[0.207,"C"],[0.414,"B"],[0.55,"X"]],"w-butterfly":[[0.0,"A"],[0.11,"F"],[0.22,"B"],[0.33,"C"],[0.44,"B"],[0.55,"G"],[0.66,"H"],[0.769,"C"],[0.55,"X"]],"n04":[[0.0,"B"],[0.053,"E"],[0.107,"B"],[0.16,"G"],[0.253,"D"],[0.347,"B"],[0.44,"D"],[0.635,"F"],[0.831,"C"],[1.026,"X"],[1.267,"D"],[1.304,"B"],[1.34,"E"],[1.42,"H"],[1.5,"B"],[1.58,"E"],[1.76,"B"],[1.94,"B"],[2.12,"F"],[2.3,"B"],[2.48,"C"],[2.58,"B"],[2.68,"B"],[2.73,"C"],[2.78,"F"],[2.889,"D"],[2.999,"B"],[3.108,"C"],[3.217,"B"],[3.327,"X"],[3.654,"A"],[3.727,"F"],[3.8,"B"],[3.874,"C"],[3.947,"B"],[4.02,"B"],[4.113,"D"],[4.207,"B"],[4.3,"A"],[4.49,"C"],[4.68,"B"],[4.75,"C"],[4.82,"A"],[4.967,"D"],[5.114,"B"],[5.261,"X"],[5.82,"H"],[5.856,"C"],[5.892,"B"],[5.928,"H"],[5.964,"C"],[6.0,"B"],[6.065,"E"],[6.13,"B"],[6.195,"C"],[6.26,"B"],[6.373,"D"],[6.487,"B"],[6.6,"E"],[6.68,"G"],[6.76,"C"],[6.84,"B"],[6.92,"B"],[7.01,"E"],[7.1,"B"],[7.223,"C"],[7.345,"A"],[7.518,"X"]],"h04":[[0.0,"F"],[0.06,"B"],[0.12,"H"],[0.18,"C"],[0.24,"E"],[0.515,"B"],[0.79,"X"],[0.98,"A"],[1.04,"H"],[1.1,"C"],[1.16,"B"],[1.22,"C"],[1.28,"B"],[1.407,"C"],[1.533,"H"],[1.66,"A"],[1.945,"C"],[2.23,"X"],[2.44,"B"],[2.473,"D"],[2.507,"B"],[2.54,"C"],[2.72,"F"],[2.765,"D"],[2.81,"B"],[2.855,"C"],[2.9,"D"],[2.995,"B"],[3.09,"E"],[3.185,"B"],[3.28,"B"],[3.36,"C"],[3.44,"B"],[3.52,"B"],[3.632,"C"],[3.744,"G"],[3.856,"C"],[3.968,"B"],[4.07,"X"]],"o04":[[0.0,"A"],[0.847,"X"],[1.151,"B"],[1.196,"C"],[1.24,"F"],[1.296,"D"],[1.352,"B"],[1.408,"C"],[1.464,"B"],[1.52,"C"],[1.65,"B"],[1.78,"G"],[1.855,"C"],[1.93,"B"],[2.005,"C"],[2.08,"B"],[2.269,"D"],[2.459,"H"],[2.648,"F"],[2.837,"X"],[3.26,"C"],[3.27,"B"],[3.28,"E"],[3.31,"B"],[3.34,"H"],[3.37,"C"],[3.4,"B"],[3.46,"E"],[3.52,"A"],[3.58,"C"],[3.64,"B"],[3.7,"F"],[3.79,"A"],[3.88,"B"],[3.94,"E"],[4.0,"A"],[4.05,"C"],[4.1,"B"],[4.321,"C"],[4.542,"B"],[4.763,"X"],[5.14,"C"],[5.16,"F"],[5.18,"B"],[5.227,"D"],[5.273,"B"],[5.32,"B"],[5.367,"C"],[5.413,"B"],[5.46,"D"],[5.605,"B"],[5.75,"E"],[5.895,"B"],[6.01,"X"]],"n04b":[[0.0,"B"],[0.09,"E"],[0.18,"H"],[0.228,"C"],[0.276,"B"],[0.324,"H"],[0.372,"C"],[0.42,"B"],[0.495,"E"],[0.57,"B"],[0.645,"C"],[0.72,"B"],[0.867,"D"],[1.013,"B"],[1.16,"B"],[1.3,"E"],[1.44,"B"],[1.49,"C"],[1.54,"C"],[1.613,"B"],[1.687,"C"],[1.76,"E"],[1.85,"G"],[1.94,"B"],[1.99,"C"],[2.04,"B"],[2.13,"C"],[2.22,"G"],[2.309,"C"],[2.399,"B"],[2.489,"X"],[2.749,"B"],[2.792,"C"],[2.835,"B"],[2.877,"C"],[2.92,"B"],[3.04,"E"],[3.16,"B"],[3.346,"E"],[3.533,"B"],[3.71,"X"]],"s05":[[0.0,"H"],[0.056,"C"],[0.112,"B"],[0.168,"H"],[0.224,"C"],[0.28,"B"],[0.417,"E"],[0.554,"B"],[0.691,"C"],[0.828,"X"],[1.24,"B"],[1.375,"E"],[1.511,"A"],[1.646,"X"],[1.9,"B"],[1.967,"E"],[2.033,"B"],[2.1,"B"],[2.387,"E"],[2.673,"B"],[2.96,"C"],[2.993,"F"],[3.027,"H"],[3.06,"B"],[3.324,"F"],[3.588,"B"],[3.61,"X"]],"h05":[[0.0,"C"],[0.08,"B"],[0.16,"B"],[0.24,"C"],[0.32,"F"],[0.368,"D"],[0.416,"B"],[0.464,"C"],[0.512,"B"],[0.56,"G"],[0.67,"C"],[0.78,"B"],[0.89,"C"],[1.0,"B"],[1.183,"C"],[1.367,"A"],[1.55,"X"]],"s05b":[[0.0,"B"],[0.107,"C"],[0.213,"A"],[0.32,"D"],[0.46,"B"],[0.6,"D"],[0.764,"B"],[0.927,"C"],[1.091,"B"],[1.255,"C"],[1.419,"B"],[1.582,"X"],[2.068,"C"],[2.226,"B"],[2.385,"C"],[2.543,"B"],[2.702,"C"],[2.86,"D"],[2.98,"G"],[3.035,"B"],[3.09,"C"],[3.145,"B"],[3.2,"E"],[3.28,"G"],[3.36,"A"],[3.405,"C"],[3.45,"B"],[3.495,"C"],[3.54,"G"],[3.633,"C"],[3.727,"H"],[3.82,"C"],[3.907,"B"],[3.993,"E"],[4.08,"B"],[4.147,"C"],[4.213,"B"],[4.28,"B"],[4.352,"C"],[4.424,"G"],[4.496,"C"],[4.568,"B"],[4.64,"D"],[4.763,"B"],[4.886,"X"],[5.14,"B"],[5.308,"F"],[5.476,"B"],[5.643,"C"],[5.811,"B"],[5.69,"X"]],"n05":[[0.0,"H"],[0.052,"C"],[0.104,"B"],[0.156,"H"],[0.208,"C"],[0.26,"B"],[0.33,"E"],[0.4,"B"],[0.47,"C"],[0.54,"A"],[0.624,"F"],[0.708,"H"],[0.792,"C"],[0.876,"B"],[0.96,"A"],[1.073,"D"],[1.187,"B"],[1.3,"B"],[1.373,"C"],[1.447,"B"],[1.52,"B"],[1.703,"F"],[1.886,"G"],[2.069,"X"],[2.648,"B"],[2.684,"C"],[2.72,"B"],[2.8,"C"],[2.88,"B"],[2.96,"B"],[3.04,"F"],[3.12,"F"],[3.17,"B"],[3.22,"D"],[3.27,"B"],[3.32,"B"],[3.4,"E"],[3.48,"B"],[3.732,"E"],[4.03,"X"]],"h05b":[[0.0,"E"],[0.747,"B"],[1.494,"X"],[1.845,"C"],[1.953,"B"],[2.06,"A"],[2.108,"C"],[2.156,"B"],[2.204,"C"],[2.252,"B"],[2.3,"B"],[2.38,"E"],[2.46,"B"],[2.515,"E"],[2.57,"A"],[2.625,"C"],[2.68,"D"],[2.75,"B"],[2.82,"D"],[2.94,"B"],[3.06,"A"],[3.196,"D"],[3.333,"A"],[3.469,"D"],[3.61,"X"]],"m06":[[0.0,"F"],[0.165,"B"],[0.33,"C"],[0.496,"X"],[0.733,"C"],[0.77,"F"],[0.806,"B"],[0.843,"C"],[0.88,"A"],[0.947,"D"],[1.013,"B"],[1.08,"D"],[1.204,"H"],[1.329,"B"],[1.453,"C"],[1.578,"B"],[1.702,"C"],[1.63,"X"]],"h06":[[0.0,"D"],[0.16,"B"],[0.212,"C"],[0.264,"G"],[0.316,"C"],[0.368,"B"],[0.42,"F"],[0.513,"D"],[0.607,"B"],[0.7,"C"],[0.78,"B"],[0.86,"A"],[0.93,"C"],[1.0,"F"],[1.275,"C"],[1.66,"C"],[1.77,"C"],[1.88,"B"],[2.018,"F"],[2.155,"H"],[2.292,"B"],[2.43,"X"],[2.84,"B"],[2.88,"C"],[2.92,"B"],[2.96,"D"],[3.098,"B"],[3.235,"E"],[3.372,"B"],[3.51,"X"]],"m06b":[[0.0,"B"],[0.073,"D"],[0.147,"B"],[0.22,"B"],[0.332,"C"],[0.443,"G"],[0.555,"C"],[0.666,"B"],[0.778,"X"],[1.207,"C"],[1.333,"B"],[1.46,"C"],[1.51,"B"],[1.56,"G"],[1.625,"C"],[1.69,"B"],[1.755,"C"],[1.82,"B"],[2.026,"D"],[2.231,"H"],[2.437,"F"],[2.37,"X"]],"h06b":[[0.0,"C"],[0.46,"B"],[0.92,"F"],[0.985,"B"],[1.05,"H"],[1.115,"C"],[1.18,"E"],[1.29,"B"],[1.4,"B"],[1.493,"C"],[1.587,"B"],[1.68,"B"],[1.77,"E"],[1.86,"B"],[2.32,"F"],[2.78,"A"],[2.847,"F"],[2.913,"B"],[2.98,"B"],[3.033,"F"],[3.087,"C"],[3.14,"B"],[3.193,"C"],[3.247,"H"],[3.3,"B"],[3.427,"C"],[3.553,"B"],[3.68,"C"],[3.79,"B"],[3.9,"G"],[3.975,"C"],[4.05,"B"],[4.125,"C"],[4.2,"B"],[4.447,"C"],[4.693,"A"],[4.94,"X"],[5.26,"B"],[5.287,"C"],[5.313,"B"],[5.34,"G"],[5.44,"B"],[5.54,"C"],[5.64,"B"],[5.74,"B"],[5.788,"F"],[5.836,"B"],[5.884,"C"],[5.932,"B"],[5.98,"C"],[6.21,"B"],[6.44,"C"],[6.61,"B"],[6.88,"X"]],"m06c":[[0.0,"B"],[0.11,"E"],[0.22,"F"],[0.32,"B"],[0.42,"C"],[0.52,"B"],[0.62,"C"],[0.74,"B"],[0.86,"C"],[1.04,"B"],[1.221,"X"],[1.605,"B"],[1.65,"C"],[1.695,"A"],[1.74,"E"],[1.97,"B"],[2.2,"B"],[2.352,"D"],[2.503,"H"],[2.655,"F"],[2.806,"X"],[3.34,"B"],[3.36,"C"],[3.38,"B"],[3.4,"C"],[3.47,"F"],[3.54,"B"],[3.607,"C"],[3.673,"B"],[3.74,"D"],[3.8,"A"],[3.86,"F"],[3.92,"B"],[3.98,"F"],[4.03,"B"],[4.08,"D"],[4.13,"B"],[4.18,"B"],[4.26,"C"],[4.34,"B"],[4.518,"C"],[4.697,"B"],[4.89,"X"]],"h06c":[[0.0,"B"],[0.275,"E"],[0.55,"X"],[0.8,"C"],[1.04,"B"],[1.223,"C"],[1.407,"B"],[1.59,"X"]],"m06d":[[0.0,"A"],[0.09,"C"],[0.18,"B"],[0.385,"C"],[0.59,"H"],[0.795,"B"],[1.0,"X"],[1.254,"B"],[1.316,"F"],[1.378,"B"],[1.44,"H"],[1.494,"C"],[1.549,"B"],[1.603,"C"],[1.657,"B"],[1.711,"C"],[1.766,"B"],[1.82,"B"],[1.95,"E"],[2.08,"E"],[2.145,"B"],[2.21,"C"],[2.275,"B"],[2.34,"C"],[2.64,"B"],[2.94,"C"],[3.096,"B"],[3.252,"F"],[3.408,"B"],[3.564,"X"],[4.1,"F"],[4.113,"B"],[4.127,"C"],[4.14,"C"],[4.227,"F"],[4.313,"B"],[4.4,"F"],[4.56,"B"],[4.72,"B"],[4.833,"C"],[4.947,"B"],[5.06,"D"],[5.154,"B"],[5.248,"X"],[5.54,"B"],[5.66,"C"],[5.78,"C"],[5.86,"B"],[5.94,"G"],[5.98,"E"],[6.02,"B"],[6.06,"C"],[6.186,"F"],[6.311,"B"],[6.437,"C"],[6.562,"H"],[6.688,"G"],[6.814,"X"],[7.22,"B"],[7.26,"E"],[7.3,"D"],[7.38,"B"],[7.46,"B"],[7.755,"C"],[8.05,"X"],[8.417,"B"],[8.465,"C"],[8.512,"B"],[8.56,"C"],[8.667,"F"],[8.773,"H"],[8.88,"B"],[9.105,"F"],[9.379,"X"]],"n07":[[0.0,"H"],[0.052,"C"],[0.104,"B"],[0.156,"H"],[0.208,"C"],[0.26,"B"],[0.325,"E"],[0.39,"B"],[0.455,"C"],[0.52,"B"],[0.647,"D"],[0.773,"B"],[0.9,"A"],[1.007,"D"],[1.113,"B"],[1.22,"B"],[1.32,"E"],[1.42,"B"],[1.47,"C"],[1.52,"B"],[1.614,"C"],[1.709,"G"],[1.803,"C"],[1.897,"B"],[1.992,"X"],[2.465,"B"],[2.543,"F"],[2.622,"B"],[2.7,"D"],[2.8,"B"],[2.9,"B"],[2.97,"C"],[3.04,"H"],[3.077,"C"],[3.113,"G"],[3.15,"B"],[3.187,"C"],[3.223,"B"],[3.26,"B"],[3.367,"C"],[3.473,"B"],[3.58,"G"],[3.635,"B"],[3.69,"E"],[3.745,"B"],[3.8,"B"],[4.002,"F"],[4.205,"G"],[4.35,"X"]],"s07":[[0.0,"F"],[0.137,"B"],[0.274,"D"],[0.41,"B"],[0.547,"X"],[0.744,"B"],[0.822,"E"],[0.9,"C"],[0.94,"F"],[0.98,"F"],[1.033,"D"],[1.087,"B"],[1.14,"B"],[1.22,"E"],[1.3,"B"],[1.483,"F"],[1.667,"B"],[1.85,"X"]],"h07":[[0.0,"H"],[0.067,"C"],[0.133,"B"],[0.2,"A"],[0.26,"C"],[0.32,"B"],[0.595,"C"],[0.87,"X"]],"n07b":[[0.0,"B"],[0.05,"C"],[0.1,"B"],[0.152,"C"],[0.204,"A"],[0.256,"C"],[0.308,"B"],[0.36,"C"],[0.453,"B"],[0.547,"E"],[0.64,"B"],[0.74,"C"],[0.84,"F"],[0.955,"D"],[1.069,"B"],[1.184,"C"],[1.298,"B"],[1.413,"X"],[1.844,"E"],[1.903,"B"],[1.961,"C"],[2.02,"B"],[2.094,"D"],[2.169,"B"],[2.243,"C"],[2.317,"G"],[2.391,"F"],[2.466,"H"],[2.54,"B"],[2.7,"C"],[2.86,"A"],[3.02,"D"],[3.19,"B"],[3.36,"D"],[3.46,"B"],[3.598,"C"],[3.735,"A"],[3.872,"C"],[4.01,"X"]],"n07c":[[0.0,"B"],[0.06,"C"],[0.12,"F"],[0.176,"D"],[0.232,"B"],[0.288,"C"],[0.344,"B"],[0.4,"F"],[0.58,"D"],[0.76,"B"],[0.94,"D"],[0.99,"B"],[1.04,"B"],[1.125,"D"],[1.21,"H"],[1.295,"F"],[1.38,"D"],[1.52,"B"],[1.66,"F"],[1.73,"B"],[1.8,"H"],[1.87,"C"],[1.94,"E"],[2.07,"B"],[2.2,"B"],[2.287,"D"],[2.373,"B"],[2.46,"B"],[2.631,"C"],[2.802,"B"],[2.973,"X"],[3.4,"D"],[3.48,"B"],[3.56,"C"],[3.65,"B"],[3.74,"F"],[3.86,"D"],[3.98,"B"],[4.1,"D"],[4.15,"B"],[4.2,"B"],[4.287,"C"],[4.373,"A"],[4.46,"D"],[4.61,"B"],[4.76,"B"],[4.8,"F"],[4.84,"C"],[4.88,"B"],[4.92,"C"],[4.96,"H"],[5.0,"B"],[5.113,"D"],[5.227,"B"],[5.34,"B"],[5.494,"C"],[5.649,"B"],[5.803,"X"],[6.264,"C"],[6.302,"B"],[6.34,"B"],[6.385,"D"],[6.43,"A"],[6.475,"C"],[6.52,"B"],[6.66,"F"],[6.8,"B"],[6.94,"F"],[7.04,"A"],[7.14,"B"],[7.23,"E"],[7.32,"H"],[7.348,"C"],[7.376,"B"],[7.404,"H"],[7.432,"C"],[7.46,"B"],[7.56,"E"],[7.66,"B"],[7.76,"C"],[7.86,"B"],[7.96,"B"],[8.173,"C"],[8.387,"B"],[8.51,"X"]],"o07":[[0.0,"B"],[0.065,"E"],[0.13,"H"],[0.195,"B"],[0.26,"C"],[0.33,"F"],[0.4,"C"],[0.47,"B"],[0.54,"F"],[0.573,"D"],[0.607,"B"],[0.64,"B"],[0.787,"D"],[0.934,"H"],[1.081,"F"],[1.19,"X"]],"s07b":[[0.0,"B"],[0.085,"E"],[0.17,"H"],[0.255,"B"],[0.34,"C"],[0.43,"F"],[0.52,"C"],[0.6,"B"],[0.68,"F"],[0.727,"D"],[0.773,"B"],[0.82,"B"],[1.028,"C"],[1.237,"A"],[1.37,"X"]],"n08":[[0.0,"H"],[0.044,"C"],[0.088,"B"],[0.132,"H"],[0.176,"C"],[0.22,"B"],[0.305,"E"],[0.39,"B"],[0.475,"C"],[0.56,"A"],[0.655,"B"],[0.75,"F"],[0.845,"B"],[0.94,"B"],[1.06,"C"],[1.18,"F"],[1.23,"B"],[1.28,"C"],[1.33,"B"],[1.38,"B"],[1.55,"E"],[1.72,"B"],[1.77,"C"],[1.82,"A"],[1.972,"C"],[2.125,"H"],[2.277,"X"],[2.92,"H"],[3.007,"C"],[3.093,"B"],[3.18,"A"],[3.227,"H"],[3.273,"C"],[3.32,"D"],[3.481,"B"],[3.643,"C"],[3.804,"B"],[3.966,"X"],[4.378,"H"],[4.43,"C"],[4.483,"B"],[4.535,"C"],[4.588,"B"],[4.64,"D"],[4.752,"B"],[4.864,"X"],[5.08,"B"],[5.167,"F"],[5.253,"B"],[5.34,"F"],[5.41,"B"],[5.48,"D"],[5.55,"B"],[5.62,"B"],[5.69,"C"],[5.76,"D"],[5.88,"B"],[6.0,"G"],[6.176,"E"],[6.352,"B"],[6.55,"X"]],"w-mill":[[0.0,"A"],[0.193,"C"],[0.385,"H"],[0.55,"X"]],"w-wheel":[[0.0,"F"],[0.157,"B"],[0.314,"C"],[0.471,"H"],[0.55,"X"]],"w-sack":[[0.36,"B"],[0.447,"D"],[0.533,"B"],[0.72,"X"]],"w-duck":[[0.0,"B"],[0.179,"F"],[0.358,"B"],[0.55,"X"]],"w-sun":[[0.44,"B"],[0.504,"F"],[0.567,"B"],[0.681,"X"]],"w-cloud":[[0.0,"B"],[0.161,"H"],[0.323,"F"],[0.484,"B"],[0.55,"X"]],"w-fence":[[0.0,"G"],[0.172,"C"],[0.345,"B"],[0.517,"C"],[0.55,"X"]],"n09":[[0.0,"E"],[0.07,"B"],[0.14,"B"],[0.187,"C"],[0.233,"B"],[0.28,"F"],[0.37,"C"],[0.46,"B"],[0.602,"E"],[0.744,"A"],[0.887,"C"],[1.029,"X"],[1.345,"H"],[1.38,"C"],[1.415,"B"],[1.45,"H"],[1.485,"C"],[1.52,"B"],[1.59,"E"],[1.66,"B"],[1.73,"C"],[1.8,"A"],[1.913,"C"],[2.027,"B"],[2.14,"D"],[2.32,"H"],[2.352,"C"],[2.384,"B"],[2.416,"H"],[2.448,"C"],[2.48,"B"],[2.544,"D"],[2.608,"A"],[2.672,"C"],[2.736,"B"],[2.8,"A"],[3.0,"C"],[3.2,"B"],[3.26,"C"],[3.32,"B"],[3.407,"C"],[3.494,"G"],[3.581,"C"],[3.668,"B"],[3.755,"X"],[4.468,"B"],[4.494,"C"],[4.52,"B"],[4.568,"D"],[4.616,"A"],[4.664,"C"],[4.712,"B"],[4.76,"H"],[4.82,"F"],[4.88,"B"],[4.94,"C"],[5.0,"B"],[5.06,"D"],[5.16,"B"],[5.26,"B"],[5.32,"C"],[5.38,"F"],[5.432,"D"],[5.484,"B"],[5.536,"C"],[5.588,"B"],[5.64,"D"],[5.787,"B"],[5.934,"X"],[6.28,"B"],[6.353,"C"],[6.427,"B"],[6.5,"D"],[6.65,"B"],[6.8,"H"],[6.836,"C"],[6.872,"B"],[6.908,"H"],[6.944,"C"],[6.98,"B"],[7.132,"E"],[7.284,"B"],[7.436,"C"],[7.53,"X"]],"h09":[[0.0,"E"],[0.23,"B"],[0.46,"B"],[0.527,"E"],[0.593,"B"],[0.66,"F"],[0.82,"E"],[0.98,"B"],[1.14,"C"],[1.3,"B"],[1.38,"C"],[1.46,"F"],[1.5,"D"],[1.54,"B"],[1.58,"C"],[1.62,"B"],[1.66,"E"],[1.725,"B"],[1.79,"H"],[1.855,"C"],[1.92,"B"],[1.968,"E"],[2.016,"A"],[2.064,"C"],[2.112,"B"],[2.16,"F"],[2.25,"A"],[2.34,"B"],[2.43,"E"],[2.52,"A"],[2.727,"C"],[2.984,"X"]],"h09b":[[0.0,"B"],[0.3,"A"],[0.6,"X"],[0.906,"G"],[0.957,"E"],[1.009,"B"],[1.06,"C"],[1.41,"F"],[1.76,"C"],[1.82,"B"],[1.88,"A"],[1.947,"C"],[2.013,"B"],[2.08,"A"],[2.17,"C"],[2.26,"B"],[2.46,"C"],[2.66,"A"],[2.859,"X"],[3.26,"B"],[3.267,"E"],[3.273,"A"],[3.28,"E"],[3.534,"B"],[3.788,"X"],[3.96,"H"],[4.02,"C"],[4.08,"B"],[4.14,"G"],[4.187,"C"],[4.233,"B"],[4.28,"F"],[4.35,"B"],[4.42,"B"],[4.499,"E"],[4.577,"B"],[4.656,"C"],[4.734,"B"],[4.813,"C"],[4.891,"B"],[4.97,"X"]],"n09b":[[0.0,"D"],[0.09,"B"],[0.18,"B"],[0.3,"E"],[0.42,"B"],[0.57,"C"],[0.72,"B"],[0.793,"F"],[0.867,"E"],[0.94,"E"],[1.01,"G"],[1.08,"B"],[1.133,"C"],[1.187,"A"],[1.24,"B"],[1.296,"E"],[1.352,"B"],[1.408,"C"],[1.464,"B"],[1.52,"B"],[1.67,"C"],[1.82,"B"],[1.872,"C"],[1.924,"G"],[1.976,"C"],[2.028,"B"],[2.08,"B"],[2.104,"E"],[2.128,"B"],[2.152,"C"],[2.176,"B"],[2.2,"C"],[2.224,"B"],[2.63,"X"]],"n07d":[[0.0,"B"],[0.093,"C"],[0.187,"A"],[0.28,"A"],[0.42,"C"],[0.56,"B"],[0.748,"C"],[0.937,"A"],[1.125,"X"],[1.38,"B"],[1.465,"C"],[1.55,"F"],[1.584,"D"],[1.618,"B"],[1.652,"C"],[1.686,"B"],[1.72,"D"],[1.94,"H"],[2.16,"B"],[2.26,"C"],[2.36,"F"],[2.45,"C"],[2.54,"B"],[2.66,"E"],[2.78,"B"],[2.84,"C"],[2.9,"E"],[2.95,"B"],[3.0,"C"],[3.05,"B"],[3.1,"B"],[3.238,"C"],[3.375,"B"],[3.513,"C"],[3.65,"X"]],"q-ox":[[0.0,"B"],[0.053,"D"],[0.107,"B"],[0.16,"C"],[0.22,"F"],[0.28,"G"],[0.367,"C"],[0.453,"B"],[0.54,"B"],[0.63,"C"],[0.72,"E"],[1.076,"B"],[1.27,"X"]],"q-bird":[[0.0,"B"],[0.053,"D"],[0.107,"B"],[0.16,"C"],[0.22,"F"],[0.28,"G"],[0.367,"C"],[0.453,"B"],[0.54,"B"],[0.64,"C"],[0.74,"A"],[0.921,"C"],[1.102,"B"],[1.29,"X"]],"q-rock":[[0.0,"B"],[0.067,"D"],[0.133,"B"],[0.2,"C"],[0.26,"F"],[0.32,"G"],[0.407,"C"],[0.493,"B"],[0.58,"B"],[0.7,"C"],[0.82,"B"],[1.007,"E"],[1.194,"B"],[1.37,"X"]],"q-butterfly":[[0.0,"B"],[0.053,"D"],[0.107,"B"],[0.16,"C"],[0.22,"F"],[0.28,"G"],[0.367,"C"],[0.453,"B"],[0.54,"B"],[0.63,"C"],[0.72,"A"],[0.81,"F"],[0.9,"B"],[0.99,"C"],[1.08,"B"],[1.17,"G"],[1.26,"H"],[1.35,"C"],[1.27,"X"]],"q-done":[[0.0,"C"],[0.82,"C"],[0.88,"F"],[0.94,"G"],[1.02,"F"],[1.1,"B"],[1.18,"B"],[1.24,"C"],[1.3,"A"],[1.36,"D"],[1.669,"H"],[1.91,"X"]],"q-flower":[[0.0,"B"],[0.053,"D"],[0.107,"B"],[0.16,"C"],[0.23,"F"],[0.3,"G"],[0.38,"C"],[0.46,"B"],[0.54,"B"],[0.64,"C"],[0.74,"G"],[0.86,"H"],[0.98,"F"],[1.1,"C"],[1.22,"B"],[1.29,"X"]],"r-ox":[[0.0,"F"],[0.06,"B"],[0.12,"C"],[0.18,"B"],[0.24,"C"],[0.3,"B"],[0.36,"B"],[0.65,"C"],[0.94,"E"],[1.072,"B"],[1.254,"X"]],"r-bird":[[0.0,"F"],[0.057,"B"],[0.113,"C"],[0.17,"B"],[0.227,"C"],[0.283,"B"],[0.34,"B"],[0.4,"C"],[0.46,"A"],[0.677,"C"],[0.895,"B"],[1.01,"X"]],"r-flower":[[0.0,"F"],[0.057,"B"],[0.113,"C"],[0.17,"B"],[0.227,"C"],[0.283,"B"],[0.34,"B"],[0.4,"C"],[0.46,"G"],[0.599,"H"],[0.738,"F"],[0.877,"C"],[1.016,"B"],[1.01,"X"]],"r-butterfly":[[0.0,"F"],[0.057,"B"],[0.113,"C"],[0.17,"B"],[0.227,"C"],[0.283,"B"],[0.34,"B"],[0.39,"C"],[0.44,"A"],[0.542,"F"],[0.645,"B"],[0.747,"C"],[0.85,"B"],[0.952,"G"],[1.055,"H"],[1.157,"C"],[0.99,"X"]],"q-wheel":[[0.0,"B"],[0.067,"D"],[0.133,"B"],[0.2,"C"],[0.27,"F"],[0.34,"G"],[0.42,"C"],[0.5,"B"],[0.58,"B"],[0.7,"C"],[0.82,"F"],[0.95,"B"],[1.08,"C"],[1.21,"H"],[1.37,"X"]],"q-duck":[[0.0,"B"],[0.06,"D"],[0.12,"B"],[0.18,"C"],[0.25,"F"],[0.32,"G"],[0.393,"C"],[0.467,"B"],[0.54,"B"],[0.64,"C"],[0.74,"B"],[0.923,"F"],[1.107,"B"],[1.29,"X"]],"q-sack":[[0.0,"B"],[0.047,"D"],[0.093,"B"],[0.14,"C"],[0.21,"F"],[0.28,"G"],[0.353,"C"],[0.427,"B"],[0.5,"B"],[0.59,"C"],[0.68,"B"],[0.878,"D"],[1.077,"B"],[1.23,"X"]],"r-wheel":[[0.0,"F"],[0.057,"B"],[0.113,"C"],[0.17,"B"],[0.227,"C"],[0.283,"B"],[0.34,"B"],[0.39,"C"],[0.44,"F"],[0.604,"B"],[0.769,"C"],[0.933,"H"],[0.99,"X"]],"r-duck":[[0.0,"F"],[0.063,"B"],[0.127,"C"],[0.19,"B"],[0.253,"C"],[0.317,"B"],[0.38,"B"],[0.44,"C"],[0.5,"B"],[0.709,"F"],[0.917,"B"],[1.05,"X"]],"r-sack":[[0.0,"F"],[0.053,"B"],[0.107,"C"],[0.16,"B"],[0.213,"C"],[0.267,"B"],[0.32,"B"],[0.38,"C"],[0.44,"B"],[0.665,"D"],[0.889,"B"],[0.99,"X"]],"q-bird1":[[0.0,"B"],[0.053,"D"],[0.107,"B"],[0.16,"C"],[0.22,"F"],[0.28,"G"],[0.353,"C"],[0.427,"B"],[0.5,"B"],[0.59,"C"],[0.68,"A"],[0.838,"C"],[0.997,"B"],[1.155,"X"],[1.6,"B"],[1.627,"F"],[1.653,"B"],[1.68,"C"],[1.95,"B"],[2.23,"X"]],"q-wheel1":[[0.0,"B"],[0.053,"D"],[0.107,"B"],[0.16,"C"],[0.22,"F"],[0.28,"G"],[0.36,"C"],[0.44,"B"],[0.52,"B"],[0.62,"C"],[0.72,"F"],[0.847,"B"],[0.974,"C"],[1.101,"H"],[1.229,"X"],[1.6,"B"],[1.633,"F"],[1.667,"B"],[1.7,"C"],[1.883,"B"],[2.116,"X"]],"q-there":[[0.0,"H"],[0.155,"F"],[0.31,"B"],[0.465,"X"],[0.66,"B"],[0.695,"C"],[0.73,"B"],[0.765,"C"],[0.8,"C"],[0.88,"B"],[0.96,"C"],[1.23,"B"],[1.51,"X"]],"q-me":[[0.0,"B"],[0.447,"D"],[0.893,"B"],[1.34,"A"],[1.548,"C"],[1.806,"X"]],"q-uncle":[[0.0,"B"],[0.068,"C"],[0.136,"B"],[0.204,"C"],[0.272,"B"],[0.34,"F"],[0.39,"B"],[0.44,"H"],[0.49,"C"],[0.54,"E"],[0.95,"B"],[1.36,"H"],[1.447,"C"],[1.533,"B"],[1.62,"D"],[1.69,"B"],[1.76,"B"],[1.927,"C"],[2.093,"A"],[2.31,"X"]]};diff --git a/site/little-horse/ch01/audio/en/n01.mp3 b/site/little-horse/ch01/audio/en/n01.mp3new file mode 100644index 0000000..31748c5Binary files /dev/null and b/site/little-horse/ch01/audio/en/n01.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n02.mp3 b/site/little-horse/ch01/audio/en/n02.mp3new file mode 100644index 0000000..f80aef1Binary files /dev/null and b/site/little-horse/ch01/audio/en/n02.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n03.mp3 b/site/little-horse/ch01/audio/en/n03.mp3new file mode 100644index 0000000..e9587eeBinary files /dev/null and b/site/little-horse/ch01/audio/en/n03.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n04.mp3 b/site/little-horse/ch01/audio/en/n04.mp3new file mode 100644index 0000000..8767814Binary files /dev/null and b/site/little-horse/ch01/audio/en/n04.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n04b.mp3 b/site/little-horse/ch01/audio/en/n04b.mp3new file mode 100644index 0000000..f8f0fa7Binary files /dev/null and b/site/little-horse/ch01/audio/en/n04b.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n05.mp3 b/site/little-horse/ch01/audio/en/n05.mp3new file mode 100644index 0000000..df98a5eBinary files /dev/null and b/site/little-horse/ch01/audio/en/n05.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n07.mp3 b/site/little-horse/ch01/audio/en/n07.mp3new file mode 100644index 0000000..f0855e6Binary files /dev/null and b/site/little-horse/ch01/audio/en/n07.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n07b.mp3 b/site/little-horse/ch01/audio/en/n07b.mp3new file mode 100644index 0000000..8b332e4Binary files /dev/null and b/site/little-horse/ch01/audio/en/n07b.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n07c.mp3 b/site/little-horse/ch01/audio/en/n07c.mp3new file mode 100644index 0000000..4f0b573Binary files /dev/null and b/site/little-horse/ch01/audio/en/n07c.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n07d.mp3 b/site/little-horse/ch01/audio/en/n07d.mp3new file mode 100644index 0000000..18bc6e3Binary files /dev/null and b/site/little-horse/ch01/audio/en/n07d.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n08.mp3 b/site/little-horse/ch01/audio/en/n08.mp3new file mode 100644index 0000000..5198affBinary files /dev/null and b/site/little-horse/ch01/audio/en/n08.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n09.mp3 b/site/little-horse/ch01/audio/en/n09.mp3new file mode 100644index 0000000..5d38696Binary files /dev/null and b/site/little-horse/ch01/audio/en/n09.mp3 differdiff --git a/site/little-horse/ch01/audio/en/n09b.mp3 b/site/little-horse/ch01/audio/en/n09b.mp3new file mode 100644index 0000000..2eca31fBinary files /dev/null and b/site/little-horse/ch01/audio/en/n09b.mp3 differdiff --git a/site/little-horse/ch01/audio/en/o04.mp3 b/site/little-horse/ch01/audio/en/o04.mp3new file mode 100644index 0000000..fa5765eBinary files /dev/null and b/site/little-horse/ch01/audio/en/o04.mp3 differdiff --git a/site/little-horse/ch01/audio/en/o07.mp3 b/site/little-horse/ch01/audio/en/o07.mp3new file mode 100644index 0000000..634734cBinary files /dev/null and b/site/little-horse/ch01/audio/en/o07.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-bird.mp3 b/site/little-horse/ch01/audio/en/q-bird.mp3new file mode 100644index 0000000..ee74172Binary files /dev/null and b/site/little-horse/ch01/audio/en/q-bird.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-bird1.mp3 b/site/little-horse/ch01/audio/en/q-bird1.mp3new file mode 100644index 0000000..d705c7eBinary files /dev/null and b/site/little-horse/ch01/audio/en/q-bird1.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-butterfly.mp3 b/site/little-horse/ch01/audio/en/q-butterfly.mp3new file mode 100644index 0000000..e4558aaBinary files /dev/null and b/site/little-horse/ch01/audio/en/q-butterfly.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-done.mp3 b/site/little-horse/ch01/audio/en/q-done.mp3new file mode 100644index 0000000..756508fBinary files /dev/null and b/site/little-horse/ch01/audio/en/q-done.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-duck.mp3 b/site/little-horse/ch01/audio/en/q-duck.mp3new file mode 100644index 0000000..ce8237aBinary files /dev/null and b/site/little-horse/ch01/audio/en/q-duck.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-flower.mp3 b/site/little-horse/ch01/audio/en/q-flower.mp3new file mode 100644index 0000000..e013748Binary files /dev/null and b/site/little-horse/ch01/audio/en/q-flower.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-me.mp3 b/site/little-horse/ch01/audio/en/q-me.mp3new file mode 100644index 0000000..1316e5eBinary files /dev/null and b/site/little-horse/ch01/audio/en/q-me.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-ox.mp3 b/site/little-horse/ch01/audio/en/q-ox.mp3new file mode 100644index 0000000..315ae90Binary files /dev/null and b/site/little-horse/ch01/audio/en/q-ox.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-rock.mp3 b/site/little-horse/ch01/audio/en/q-rock.mp3new file mode 100644index 0000000..f0f47eaBinary files /dev/null and b/site/little-horse/ch01/audio/en/q-rock.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-sack.mp3 b/site/little-horse/ch01/audio/en/q-sack.mp3new file mode 100644index 0000000..5e811f8Binary files /dev/null and b/site/little-horse/ch01/audio/en/q-sack.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-there.mp3 b/site/little-horse/ch01/audio/en/q-there.mp3new file mode 100644index 0000000..64a9ac7Binary files /dev/null and b/site/little-horse/ch01/audio/en/q-there.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-uncle.mp3 b/site/little-horse/ch01/audio/en/q-uncle.mp3new file mode 100644index 0000000..3af8197Binary files /dev/null and b/site/little-horse/ch01/audio/en/q-uncle.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-wheel.mp3 b/site/little-horse/ch01/audio/en/q-wheel.mp3new file mode 100644index 0000000..6839840Binary files /dev/null and b/site/little-horse/ch01/audio/en/q-wheel.mp3 differdiff --git a/site/little-horse/ch01/audio/en/q-wheel1.mp3 b/site/little-horse/ch01/audio/en/q-wheel1.mp3new file mode 100644index 0000000..d44d65dBinary files /dev/null and b/site/little-horse/ch01/audio/en/q-wheel1.mp3 differdiff --git a/site/little-horse/ch01/audio/en/r-bird.mp3 b/site/little-horse/ch01/audio/en/r-bird.mp3new file mode 100644index 0000000..b3ebbc1Binary files /dev/null and b/site/little-horse/ch01/audio/en/r-bird.mp3 differdiff --git a/site/little-horse/ch01/audio/en/r-butterfly.mp3 b/site/little-horse/ch01/audio/en/r-butterfly.mp3new file mode 100644index 0000000..325546aBinary files /dev/null and b/site/little-horse/ch01/audio/en/r-butterfly.mp3 differdiff --git a/site/little-horse/ch01/audio/en/r-duck.mp3 b/site/little-horse/ch01/audio/en/r-duck.mp3new file mode 100644index 0000000..1c8abd2Binary files /dev/null and b/site/little-horse/ch01/audio/en/r-duck.mp3 differdiff --git a/site/little-horse/ch01/audio/en/r-flower.mp3 b/site/little-horse/ch01/audio/en/r-flower.mp3new file mode 100644index 0000000..6c2b718Binary files /dev/null and b/site/little-horse/ch01/audio/en/r-flower.mp3 differdiff --git a/site/little-horse/ch01/audio/en/r-ox.mp3 b/site/little-horse/ch01/audio/en/r-ox.mp3new file mode 100644index 0000000..9493e7dBinary files /dev/null and b/site/little-horse/ch01/audio/en/r-ox.mp3 differdiff --git a/site/little-horse/ch01/audio/en/r-sack.mp3 b/site/little-horse/ch01/audio/en/r-sack.mp3new file mode 100644index 0000000..a5f7dffBinary files /dev/null and b/site/little-horse/ch01/audio/en/r-sack.mp3 differdiff --git a/site/little-horse/ch01/audio/en/r-wheel.mp3 b/site/little-horse/ch01/audio/en/r-wheel.mp3new file mode 100644index 0000000..663b97aBinary files /dev/null and b/site/little-horse/ch01/audio/en/r-wheel.mp3 differdiff --git a/site/little-horse/ch01/audio/en/s05.mp3 b/site/little-horse/ch01/audio/en/s05.mp3new file mode 100644index 0000000..e2237efBinary files /dev/null and b/site/little-horse/ch01/audio/en/s05.mp3 differdiff --git a/site/little-horse/ch01/audio/en/s05b.mp3 b/site/little-horse/ch01/audio/en/s05b.mp3new file mode 100644index 0000000..cdefac3Binary files /dev/null and b/site/little-horse/ch01/audio/en/s05b.mp3 differdiff --git a/site/little-horse/ch01/audio/en/s07.mp3 b/site/little-horse/ch01/audio/en/s07.mp3new file mode 100644index 0000000..324f312Binary files /dev/null and b/site/little-horse/ch01/audio/en/s07.mp3 differdiff --git a/site/little-horse/ch01/audio/en/s07b.mp3 b/site/little-horse/ch01/audio/en/s07b.mp3new file mode 100644index 0000000..1d083aaBinary files /dev/null and b/site/little-horse/ch01/audio/en/s07b.mp3 differdiff --git a/site/little-horse/ch01/audio/en/scene1.mp3 b/site/little-horse/ch01/audio/en/scene1.mp3new file mode 100644index 0000000..e0f9fd4Binary files /dev/null and b/site/little-horse/ch01/audio/en/scene1.mp3 differdiff --git a/site/little-horse/ch01/audio/en/scene2.mp3 b/site/little-horse/ch01/audio/en/scene2.mp3new file mode 100644index 0000000..dd70ed0Binary files /dev/null and b/site/little-horse/ch01/audio/en/scene2.mp3 differdiff --git a/site/little-horse/ch01/audio/en/scene3.mp3 b/site/little-horse/ch01/audio/en/scene3.mp3new file mode 100644index 0000000..22dfcb9Binary files /dev/null and b/site/little-horse/ch01/audio/en/scene3.mp3 differdiff --git a/site/little-horse/ch01/audio/en/scene4.mp3 b/site/little-horse/ch01/audio/en/scene4.mp3new file mode 100644index 0000000..bcac7baBinary files /dev/null and b/site/little-horse/ch01/audio/en/scene4.mp3 differdiff --git a/site/little-horse/ch01/audio/en/scene5.mp3 b/site/little-horse/ch01/audio/en/scene5.mp3new file mode 100644index 0000000..609ec10Binary files /dev/null and b/site/little-horse/ch01/audio/en/scene5.mp3 differdiff --git a/site/little-horse/ch01/audio/en/scene6.mp3 b/site/little-horse/ch01/audio/en/scene6.mp3new file mode 100644index 0000000..3628364Binary files /dev/null and b/site/little-horse/ch01/audio/en/scene6.mp3 differdiff --git a/site/little-horse/ch01/audio/en/scene7.mp3 b/site/little-horse/ch01/audio/en/scene7.mp3new file mode 100644index 0000000..dd5e398Binary files /dev/null and b/site/little-horse/ch01/audio/en/scene7.mp3 differdiff --git a/site/little-horse/ch01/audio/en/scene8.mp3 b/site/little-horse/ch01/audio/en/scene8.mp3new file mode 100644index 0000000..57a657aBinary files /dev/null and b/site/little-horse/ch01/audio/en/scene8.mp3 differdiff --git a/site/little-horse/ch01/audio/en/scene9.mp3 b/site/little-horse/ch01/audio/en/scene9.mp3new file mode 100644index 0000000..8e7f713Binary files /dev/null and b/site/little-horse/ch01/audio/en/scene9.mp3 differdiff --git a/site/little-horse/ch01/audio/en/shots.js b/site/little-horse/ch01/audio/en/shots.jsnew file mode 100644index 0000000..1be2cf6--- /dev/null+++ b/site/little-horse/ch01/audio/en/shots.js@@ -0,0 +1,12 @@+TIMINGS.scene1 = {"dur": 25.77, "marks": {"m01.sack": 16.764}, "cues": [[0.1, "By a little river stood a stable.", 2.356], [2.7, "In it lived an old mother horse and her son, Little Horse.", 6.671], [7.051, "Little Horse stayed by his mother's side all day long.", 10.485], [10.72, "He had never gone anywhere alone.", 12.921], [13.25, "Little one, you're big now.", 15.758], [15.459, "You can help me.", 16.552], [16.764, "Will you carry this half sack of wheat to the mill?", 19.423], [19.76, "Yes, Mama!", 21.159], [20.86, "I can do it!", 22.272]], "parts": {"n01": 0, "m01": 13.15, "h01": 19.66, "load1": 22.57}};+TIMINGS.scene2 = {"dur": 15.14, "marks": {"n02.river": 5.86, "h02.think": 10.21}, "cues": [[0.1, "Little Horse trotted off with the wheat on his back, as fast as he could go.", 4.859], [4.56, "He ran, and he ran, until a river ran right across his path.", 9.179], [9.33, "Whoa!", 10.509], [10.21, "Can I get across?", 12.069], [11.77, "If only Mama were here to ask.", 14.089]], "parts": {"n02": 0, "h02": 9.23, "end2": 14.14}};+TIMINGS.scene3 = {"dur": 7.36, "marks": {}, "cues": [[0.1, "Little Horse looked all around.", 2.255], [2.407, "Who could help him?", 4.017], [3.718, "Help him look!", 5.215], [4.916, "Listen, and touch what he asks for.", 7.501]], "parts": {"n03": 0}};+TIMINGS.scene4 = {"dur": 25.881, "marks": {"o04.shins": 16.88}, "cues": [[0.1, "Not far away, an old ox stood in the water, munching grass by the bank.", 5.56], [5.82, "Little Horse ran over to him.", 7.767], [9.13, "Uncle Ox, please tell me.", 11.769], [11.47, "Can I wade across this river?", 13.409], [13.72, "Mmm.", 15.07], [14.771, "The water is very shallow.", 17.179], [16.88, "It only comes up to my shins.", 19.059], [18.76, "You can get across.", 19.959], [20.31, "So Little Horse ran to the edge of the river, ready to cross.", 24.228]], "parts": {"n04": 0, "h04": 9.03, "o04": 13.62, "n04b": 20.21, "edge4": 24.48}};+TIMINGS.scene5 = {"dur": 24.471, "marks": {"s05b.drowned": 11.42}, "cues": [[0.1, "Little Horse!", 1.539], [1.24, "Stop!", 2.199], [1.9, "Don't cross!", 3.259], [2.96, "You'll drown!", 4.151], [4.61, "Is the water very deep?", 6.729], [6.88, "Deep as anything!", 8.661], [8.848, "Yesterday, a friend of mine fell into this river, and drowned!", 13.058], [14.19, "Little Horse pulled back his hoof.", 16.458], [16.738, "He didn't know what to do.", 18.372], [18.7, "Oh.", 20.744], [20.445, "I'd better go home and ask Mama.", 22.505]], "parts": {"s05": 0, "h05": 4.51, "s05b": 6.78, "n05": 13.29, "h05b": 18.6, "home5": 22.87}};+TIMINGS.scene6 = {"dur": 36.651, "marks": {"h06b.but": 12.55, "m06d.head": 29.48, "m06d.try": 30.44}, "cues": [[0.1, "Why, you're back already?", 2.126], [2.45, "A river was in my way.", 4.309], [4.01, "I... I couldn't get across.", 6.569], [6.72, "That river?", 8.126], [7.827, "Isn't it very shallow?", 9.562], [9.87, "Yes!", 10.989], [10.69, "Uncle Ox said so too.", 12.849], [12.55, "But Squirrel said it's very deep.", 15.329], [15.03, "His friend drowned in it!", 16.949], [17.1, "So which is it, deep or shallow?", 20.105], [20.34, "Did you think about what they said?", 22.174], [23.29, "No... I didn't.", 25.329], [25.48, "My child, just listening to others isn't enough.", 29.779], [29.48, "Use your own head, and try it for yourself.", 32.899], [32.6, "Go and see.", 34.096], [33.797, "Then you'll know.", 35.008]], "parts": {"m06": 0, "h06": 2.35, "m06b": 6.62, "h06b": 9.77, "m06c": 17.0, "h06c": 22.39, "m06d": 25.38, "end6": 35.25}};+TIMINGS.scene7 = {"dur": 35.572, "marks": {"n07c.deep": 19.47, "n07c.knees": 22.334}, "cues": [[0.1, "Little Horse ran back to the river.", 2.291], [2.465, "Just as he lifted his front hoof,", 4.706], [5.01, "What?", 5.953], [5.654, "Do you want to drown?", 7.369], [7.52, "Let me try.", 8.759], [8.91, "He stepped into the water, one careful step at a time.", 13.269], [16.17, "The water wasn't as shallow as Uncle Ox had said.", 19.769], [19.47, "And it wasn't as deep as Squirrel had said.", 22.172], [22.334, "It came just up to Little Horse's knees.", 24.969], [25.32, "Step by step, he waded all the way to the other side.", 29.439], [29.59, "Told you it was shallow.", 31.018], [31.46, "Told you it was deep!", 33.104]], "parts": {"n07": 0, "s07": 4.91, "h07": 7.42, "n07b": 8.81, "wade7": 13.32, "n07c": 16.07, "n07d": 25.22, "o07": 29.49, "s07b": 31.36, "stare7": 33.47}};+TIMINGS.scene8 = {"dur": 6.72, "marks": {}, "cues": [[0.1, "Little Horse brought the wheat to the mill.", 2.576], [2.92, "Let's play again!", 4.677], [4.378, "Listen, and touch what he asks for.", 6.827]], "parts": {"n08": 0}};+TIMINGS.scene9 = {"dur": 30.261, "marks": {"n09.horse": 5.64, "h09b.hop": 17.87}, "cues": [[0.1, "On his way home, Little Horse met a little rabbit by the river.", 4.054], [4.468, "The rabbit looked at the water, and then at Little Horse.", 7.887], [8.21, "Oh, don't worry!", 9.709], [9.41, "The water only comes up to my\u2014", 11.343], [14.71, "Hmm.", 15.815], [15.516, "For you, it might be deep.", 18.169], [17.87, "Hop on!", 18.869], [18.57, "Let's find out together.", 20.029], [21.73, "And so the two of them crossed the river, together.", 25.041]], "parts": {"n09": 0, "h09": 8.11, "look9": 11.66, "h09b": 14.61, "hop9": 20.08, "n09b": 21.63, "end9": 25.26}};+MOUTHS.n04 = [[0.0, "B"], [0.053, "E"], [0.107, "B"], [0.16, "G"], [0.253, "D"], [0.347, "B"], [0.44, "D"], [0.635, "F"], [0.831, "C"], [1.026, "X"], [1.267, "D"], [1.304, "B"], [1.34, "E"], [1.42, "H"], [1.5, "B"], [1.58, "E"], [1.76, "B"], [1.94, "B"], [2.12, "F"], [2.3, "B"], [2.48, "C"], [2.58, "B"], [2.68, "B"], [2.73, "C"], [2.78, "F"], [2.889, "D"], [2.999, "B"], [3.108, "C"], [3.217, "B"], [3.327, "X"], [3.654, "A"], [3.727, "F"], [3.8, "B"], [3.874, "C"], [3.947, "B"], [4.02, "B"], [4.113, "D"], [4.207, "B"], [4.3, "A"], [4.49, "C"], [4.68, "B"], [4.75, "C"], [4.82, "A"], [4.967, "D"], [5.114, "B"], [5.261, "X"], [5.82, "H"], [5.856, "C"], [5.892, "B"], [5.928, "H"], [5.964, "C"], [6.0, "B"], [6.065, "E"], [6.13, "B"], [6.195, "C"], [6.26, "B"], [6.373, "D"], [6.487, "B"], [6.6, "E"], [6.68, "G"], [6.76, "C"], [6.84, "B"], [6.92, "B"], [7.01, "E"], [7.1, "B"], [7.223, "C"], [7.345, "A"], [7.518, "X"], [7.549, "X"]];+MOUTHS.n05 = [[-0.001, "X"], [0.8, "H"], [0.852, "C"], [0.904, "B"], [0.956, "H"], [1.008, "C"], [1.06, "B"], [1.13, "E"], [1.2, "B"], [1.27, "C"], [1.34, "A"], [1.424, "F"], [1.508, "H"], [1.592, "C"], [1.676, "B"], [1.76, "A"], [1.873, "D"], [1.987, "B"], [2.1, "B"], [2.173, "C"], [2.247, "B"], [2.32, "B"], [2.503, "F"], [2.686, "G"], [2.869, "X"], [3.448, "B"], [3.484, "C"], [3.52, "B"], [3.6, "C"], [3.68, "B"], [3.76, "B"], [3.84, "F"], [3.92, "F"], [3.97, "B"], [4.02, "D"], [4.07, "B"], [4.12, "B"], [4.2, "E"], [4.28, "B"], [4.532, "E"], [4.83, "X"]];+MOUTHS.h06c = [[-0.001, "X"], [0.8, "B"], [1.075, "E"], [1.35, "X"], [1.6, "C"], [1.84, "B"], [2.023, "C"], [2.207, "B"], [2.39, "X"]];diff --git a/site/little-horse/ch01/audio/en/timings.js b/site/little-horse/ch01/audio/en/timings.jsnew file mode 100644index 0000000..d56d01f--- /dev/null+++ b/site/little-horse/ch01/audio/en/timings.js@@ -0,0 +1,906 @@+window.TIMINGS = {+ "n01": {+ "dur": 12.8,+ "marks": {},+ "cues": [+ [+ 0.0,+ "By a little river stood a stable."+ ],+ [+ 2.7,+ "In it lived an old mother horse and her son, Little Horse."+ ],+ [+ 7.051,+ "Little Horse stayed by his mother's side all day long."+ ],+ [+ 10.72,+ "He had never gone anywhere alone."+ ]+ ]+ },+ "m01": {+ "dur": 6.16,+ "marks": {+ "sack": 3.614+ },+ "cues": [+ [+ 0.0,+ "Little one, you're big now."+ ],+ [+ 2.309,+ "You can help me."+ ],+ [+ 3.614,+ "Will you carry this half sack of wheat to the mill?"+ ]+ ]+ },+ "h01": {+ "dur": 2.56,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Yes, Mama!"+ ],+ [+ 1.2,+ "I can do it!"+ ]+ ]+ },+ "n02": {+ "dur": 8.88,+ "marks": {+ "river": 5.86+ },+ "cues": [+ [+ 0.0,+ "Little Horse trotted off with the wheat on his back, as fast as he could go."+ ],+ [+ 4.56,+ "He ran, and he ran, until a river ran right across his path."+ ]+ ]+ },+ "h02": {+ "dur": 4.56,+ "marks": {+ "think": 0.98+ },+ "cues": [+ [+ 0.0,+ "Whoa!"+ ],+ [+ 0.98,+ "Can I get across?"+ ],+ [+ 2.54,+ "If only Mama were here to ask."+ ]+ ]+ },+ "n03": {+ "dur": 7.36,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Little Horse looked all around."+ ],+ [+ 2.407,+ "Who could help him?"+ ],+ [+ 3.718,+ "Help him look!"+ ],+ [+ 4.916,+ "Listen, and touch what he asks for."+ ]+ ]+ },+ "w-river": {+ "dur": 0.88,+ "marks": {},+ "cues": [+ [+ 0.0,+ "river"+ ]+ ]+ },+ "w-tree": {+ "dur": 0.88,+ "marks": {},+ "cues": [+ [+ 0.0,+ "tree"+ ]+ ]+ },+ "w-ox": {+ "dur": 0.88,+ "marks": {},+ "cues": [+ [+ 0.0,+ "ox"+ ]+ ]+ },+ "w-rock": {+ "dur": 0.8,+ "marks": {},+ "cues": [+ [+ 0.0,+ "rock"+ ]+ ]+ },+ "w-flower": {+ "dur": 0.96,+ "marks": {},+ "cues": [+ [+ 0.1,+ "flower"+ ]+ ]+ },+ "w-bird": {+ "dur": 0.88,+ "marks": {},+ "cues": [+ [+ 0.0,+ "bird"+ ]+ ]+ },+ "w-butterfly": {+ "dur": 1.2,+ "marks": {},+ "cues": [+ [+ 0.0,+ "butterfly"+ ]+ ]+ },+ "q-ox": {+ "dur": 1.6,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Can you find the ox?"+ ]+ ]+ },+ "q-bird": {+ "dur": 1.6,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Can you find the bird?"+ ]+ ]+ },+ "q-flower": {+ "dur": 1.52,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Can you find the flower?"+ ]+ ]+ },+ "q-butterfly": {+ "dur": 1.6,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Can you find the butterfly?"+ ]+ ]+ },+ "r-ox": {+ "dur": 1.52,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Where's the ox?"+ ]+ ]+ },+ "r-bird": {+ "dur": 1.28,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Where's the bird?"+ ]+ ]+ },+ "r-flower": {+ "dur": 1.44,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Where's the flower?"+ ]+ ]+ },+ "r-butterfly": {+ "dur": 1.44,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Where's the butterfly?"+ ]+ ]+ },+ "q-wheel": {+ "dur": 1.44,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Can you find the wheel?"+ ]+ ]+ },+ "q-duck": {+ "dur": 1.44,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Can you find the duck?"+ ]+ ]+ },+ "q-sack": {+ "dur": 1.44,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Can you find the sack?"+ ]+ ]+ },+ "r-wheel": {+ "dur": 1.28,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Where's the wheel?"+ ]+ ]+ },+ "r-duck": {+ "dur": 1.28,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Where's the duck?"+ ]+ ]+ },+ "r-sack": {+ "dur": 1.36,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Where's the sack?"+ ]+ ]+ },+ "q-bird1": {+ "dur": 2.32,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Can you find the bird?"+ ],+ [+ 1.6,+ "Touch it!"+ ]+ ]+ },+ "q-wheel1": {+ "dur": 2.24,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Can you find the wheel?"+ ],+ [+ 1.6,+ "Touch it!"+ ]+ ]+ },+ "q-there": {+ "dur": 1.6,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Look!"+ ],+ [+ 0.66,+ "There it is!"+ ]+ ]+ },+ "q-me": {+ "dur": 2.0,+ "marks": {},+ "cues": [+ [+ 0.0,+ "That's me!"+ ]+ ]+ },+ "q-uncle": {+ "dur": 2.48,+ "marks": {},+ "cues": [+ [+ 0.0,+ "There's Uncle Ox!"+ ],+ [+ 1.36,+ "Let's ask him!"+ ]+ ]+ },+ "q-done": {+ "dur": 2.24,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Yay!"+ ],+ [+ 0.82,+ "You found them all!"+ ]+ ]+ },+ "n04": {+ "dur": 7.68,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Not far away, an old ox stood in the water, munching grass by the bank."+ ],+ [+ 5.82,+ "Little Horse ran over to him."+ ]+ ]+ },+ "h04": {+ "dur": 4.24,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Uncle Ox, please tell me."+ ],+ [+ 2.44,+ "Can I wade across this river?"+ ]+ ]+ },+ "o04": {+ "dur": 6.24,+ "marks": {+ "shins": 3.26+ },+ "cues": [+ [+ 0.0,+ "Mmm."+ ],+ [+ 1.151,+ "The water is very shallow."+ ],+ [+ 3.26,+ "It only comes up to my shins."+ ],+ [+ 5.14,+ "You can get across."+ ]+ ]+ },+ "n04b": {+ "dur": 3.92,+ "marks": {},+ "cues": [+ [+ 0.0,+ "So Little Horse ran to the edge of the river, ready to cross."+ ]+ ]+ },+ "s05": {+ "dur": 4.16,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Little Horse!"+ ],+ [+ 1.24,+ "Stop!"+ ],+ [+ 1.9,+ "Don't cross!"+ ],+ [+ 2.96,+ "You'll drown!"+ ]+ ]+ },+ "h05": {+ "dur": 1.92,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Is the water very deep?"+ ]+ ]+ },+ "s05b": {+ "dur": 6.16,+ "marks": {+ "drowned": 4.64+ },+ "cues": [+ [+ 0.0,+ "Deep as anything!"+ ],+ [+ 2.068,+ "Yesterday, a friend of mine fell into this river, and drowned!"+ ]+ ]+ },+ "n05": {+ "dur": 4.16,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Little Horse pulled back his hoof."+ ],+ [+ 2.648,+ "He didn't know what to do."+ ]+ ]+ },+ "h05b": {+ "dur": 3.92,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Oh."+ ],+ [+ 1.845,+ "I'd better go home and ask Mama."+ ]+ ]+ },+ "m06": {+ "dur": 2.0,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Why, you're back already?"+ ]+ ]+ },+ "h06": {+ "dur": 3.92,+ "marks": {},+ "cues": [+ [+ 0.0,+ "A river was in my way."+ ],+ [+ 1.66,+ "I... I couldn't get across."+ ]+ ]+ },+ "m06b": {+ "dur": 2.8,+ "marks": {},+ "cues": [+ [+ 0.0,+ "That river?"+ ],+ [+ 1.207,+ "Isn't it very shallow?"+ ]+ ]+ },+ "h06b": {+ "dur": 6.88,+ "marks": {+ "but": 2.78+ },+ "cues": [+ [+ 0.0,+ "Yes!"+ ],+ [+ 0.92,+ "Uncle Ox said so too."+ ],+ [+ 2.78,+ "But Squirrel said it's very deep."+ ],+ [+ 5.26,+ "His friend drowned in it!"+ ]+ ]+ },+ "m06c": {+ "dur": 5.04,+ "marks": {},+ "cues": [+ [+ 0.0,+ "So which is it, deep or shallow?"+ ],+ [+ 3.34,+ "Did you think about what they said?"+ ]+ ]+ },+ "h06c": {+ "dur": 1.84,+ "marks": {},+ "cues": [+ [+ 0.0,+ "No... I didn't."+ ]+ ]+ },+ "m06d": {+ "dur": 9.52,+ "marks": {+ "head": 4.1,+ "try": 5.06+ },+ "cues": [+ [+ 0.0,+ "My child, just listening to others isn't enough."+ ],+ [+ 4.1,+ "Use your own head, and try it for yourself."+ ],+ [+ 7.22,+ "Go and see."+ ],+ [+ 8.417,+ "Then you'll know."+ ]+ ]+ },+ "n07": {+ "dur": 4.56,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Little Horse ran back to the river."+ ],+ [+ 2.465,+ "Just as he lifted his front hoof,"+ ]+ ]+ },+ "s07": {+ "dur": 2.16,+ "marks": {},+ "cues": [+ [+ 0.0,+ "What?"+ ],+ [+ 0.744,+ "Do you want to drown?"+ ]+ ]+ },+ "h07": {+ "dur": 1.04,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Let me try."+ ]+ ]+ },+ "n07b": {+ "dur": 4.16,+ "marks": {},+ "cues": [+ [+ 0.0,+ "He stepped into the water, one careful step at a time."+ ]+ ]+ },+ "n07c": {+ "dur": 8.8,+ "marks": {+ "deep": 3.4,+ "knees": 6.264+ },+ "cues": [+ [+ 0.0,+ "The water wasn't as shallow as Uncle Ox had said."+ ],+ [+ 3.4,+ "And it wasn't as deep as Squirrel had said."+ ],+ [+ 6.264,+ "It came just up to Little Horse's knees."+ ]+ ]+ },+ "n07d": {+ "dur": 3.92,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Step by step, he waded all the way to the other side."+ ]+ ]+ },+ "o07": {+ "dur": 1.52,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Told you it was shallow."+ ]+ ]+ },+ "s07b": {+ "dur": 1.76,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Told you it was deep!"+ ]+ ]+ },+ "n08": {+ "dur": 6.72,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Little Horse brought the wheat to the mill."+ ],+ [+ 2.92,+ "Let's play again!"+ ],+ [+ 4.378,+ "Listen, and touch what he asks for."+ ]+ ]+ },+ "w-mill": {+ "dur": 0.88,+ "marks": {},+ "cues": [+ [+ 0.0,+ "mill"+ ]+ ]+ },+ "w-wheel": {+ "dur": 0.96,+ "marks": {},+ "cues": [+ [+ 0.0,+ "wheel"+ ]+ ]+ },+ "w-sack": {+ "dur": 0.72,+ "marks": {},+ "cues": [+ [+ 0.1,+ "sack"+ ]+ ]+ },+ "w-duck": {+ "dur": 0.8,+ "marks": {},+ "cues": [+ [+ 0.0,+ "duck"+ ]+ ]+ },+ "w-sun": {+ "dur": 0.88,+ "marks": {},+ "cues": [+ [+ 0.1,+ "sun"+ ]+ ]+ },+ "w-cloud": {+ "dur": 0.96,+ "marks": {},+ "cues": [+ [+ 0.0,+ "cloud"+ ]+ ]+ },+ "w-fence": {+ "dur": 0.88,+ "marks": {},+ "cues": [+ [+ 0.0,+ "fence"+ ]+ ]+ },+ "n09": {+ "dur": 7.76,+ "marks": {+ "horse": 5.64+ },+ "cues": [+ [+ 0.0,+ "On his way home, Little Horse met a little rabbit by the river."+ ],+ [+ 4.468,+ "The rabbit looked at the water, and then at Little Horse."+ ]+ ]+ },+ "h09": {+ "dur": 3.2,+ "marks": {},+ "cues": [+ [+ 0.0,+ "Oh, don't worry!"+ ],+ [+ 1.3,+ "The water only comes up to my—"+ ]+ ]+ },+ "h09b": {+ "dur": 5.12,+ "marks": {+ "hop": 3.26+ },+ "cues": [+ [+ 0.0,+ "Hmm."+ ],+ [+ 0.906,+ "For you, it might be deep."+ ],+ [+ 3.26,+ "Hop on!"+ ],+ [+ 3.96,+ "Let's find out together."+ ]+ ]+ },+ "n09b": {+ "dur": 3.28,+ "marks": {},+ "cues": [+ [+ 0.0,+ "And so the two of them crossed the river, together."+ ]+ ]+ }+};diff --git a/site/little-horse/ch01/audio/en/w-bird.mp3 b/site/little-horse/ch01/audio/en/w-bird.mp3new file mode 100644index 0000000..100c911Binary files /dev/null and b/site/little-horse/ch01/audio/en/w-bird.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-butterfly.mp3 b/site/little-horse/ch01/audio/en/w-butterfly.mp3new file mode 100644index 0000000..30ef7b7Binary files /dev/null and b/site/little-horse/ch01/audio/en/w-butterfly.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-cloud.mp3 b/site/little-horse/ch01/audio/en/w-cloud.mp3new file mode 100644index 0000000..1076612Binary files /dev/null and b/site/little-horse/ch01/audio/en/w-cloud.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-duck.mp3 b/site/little-horse/ch01/audio/en/w-duck.mp3new file mode 100644index 0000000..df86293Binary files /dev/null and b/site/little-horse/ch01/audio/en/w-duck.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-fence.mp3 b/site/little-horse/ch01/audio/en/w-fence.mp3new file mode 100644index 0000000..75493abBinary files /dev/null and b/site/little-horse/ch01/audio/en/w-fence.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-flower.mp3 b/site/little-horse/ch01/audio/en/w-flower.mp3new file mode 100644index 0000000..80e136cBinary files /dev/null and b/site/little-horse/ch01/audio/en/w-flower.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-mill.mp3 b/site/little-horse/ch01/audio/en/w-mill.mp3new file mode 100644index 0000000..fffdd4dBinary files /dev/null and b/site/little-horse/ch01/audio/en/w-mill.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-ox.mp3 b/site/little-horse/ch01/audio/en/w-ox.mp3new file mode 100644index 0000000..1fe308bBinary files /dev/null and b/site/little-horse/ch01/audio/en/w-ox.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-river.mp3 b/site/little-horse/ch01/audio/en/w-river.mp3new file mode 100644index 0000000..04267abBinary files /dev/null and b/site/little-horse/ch01/audio/en/w-river.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-rock.mp3 b/site/little-horse/ch01/audio/en/w-rock.mp3new file mode 100644index 0000000..c267567Binary files /dev/null and b/site/little-horse/ch01/audio/en/w-rock.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-sack.mp3 b/site/little-horse/ch01/audio/en/w-sack.mp3new file mode 100644index 0000000..9b649efBinary files /dev/null and b/site/little-horse/ch01/audio/en/w-sack.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-sun.mp3 b/site/little-horse/ch01/audio/en/w-sun.mp3new file mode 100644index 0000000..04776dfBinary files /dev/null and b/site/little-horse/ch01/audio/en/w-sun.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-tree.mp3 b/site/little-horse/ch01/audio/en/w-tree.mp3new file mode 100644index 0000000..4d00366Binary files /dev/null and b/site/little-horse/ch01/audio/en/w-tree.mp3 differdiff --git a/site/little-horse/ch01/audio/en/w-wheel.mp3 b/site/little-horse/ch01/audio/en/w-wheel.mp3new file mode 100644index 0000000..0e26acdBinary files /dev/null and b/site/little-horse/ch01/audio/en/w-wheel.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/birds.mp3 b/site/little-horse/ch01/audio/sfx/birds.mp3new file mode 100644index 0000000..9874317Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/birds.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/chime.mp3 b/site/little-horse/ch01/audio/sfx/chime.mp3new file mode 100644index 0000000..9708ec9Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/chime.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/hoof.mp3 b/site/little-horse/ch01/audio/sfx/hoof.mp3new file mode 100644index 0000000..1cfb111Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/hoof.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/hop.mp3 b/site/little-horse/ch01/audio/sfx/hop.mp3new file mode 100644index 0000000..8881f3dBinary files /dev/null and b/site/little-horse/ch01/audio/sfx/hop.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/mill.mp3 b/site/little-horse/ch01/audio/sfx/mill.mp3new file mode 100644index 0000000..9fa87dcBinary files /dev/null and b/site/little-horse/ch01/audio/sfx/mill.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/pop.mp3 b/site/little-horse/ch01/audio/sfx/pop.mp3new file mode 100644index 0000000..152bf00Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/pop.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/quack.mp3 b/site/little-horse/ch01/audio/sfx/quack.mp3new file mode 100644index 0000000..23c4bc9Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/quack.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/river.mp3 b/site/little-horse/ch01/audio/sfx/river.mp3new file mode 100644index 0000000..1d91de5Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/river.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/skid.mp3 b/site/little-horse/ch01/audio/sfx/skid.mp3new file mode 100644index 0000000..6778283Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/skid.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/slosh.mp3 b/site/little-horse/ch01/audio/sfx/slosh.mp3new file mode 100644index 0000000..6331510Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/slosh.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/splash.mp3 b/site/little-horse/ch01/audio/sfx/splash.mp3new file mode 100644index 0000000..7003042Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/splash.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/squeak.mp3 b/site/little-horse/ch01/audio/sfx/squeak.mp3new file mode 100644index 0000000..8b83b8dBinary files /dev/null and b/site/little-horse/ch01/audio/sfx/squeak.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/sting.mp3 b/site/little-horse/ch01/audio/sfx/sting.mp3new file mode 100644index 0000000..48b6ae6Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/sting.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/thud.mp3 b/site/little-horse/ch01/audio/sfx/thud.mp3new file mode 100644index 0000000..41e5a96Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/thud.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/trot.mp3 b/site/little-horse/ch01/audio/sfx/trot.mp3new file mode 100644index 0000000..ec708abBinary files /dev/null and b/site/little-horse/ch01/audio/sfx/trot.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/whoosh.mp3 b/site/little-horse/ch01/audio/sfx/whoosh.mp3new file mode 100644index 0000000..6c63e5eBinary files /dev/null and b/site/little-horse/ch01/audio/sfx/whoosh.mp3 differdiff --git a/site/little-horse/ch01/audio/sfx/wind.mp3 b/site/little-horse/ch01/audio/sfx/wind.mp3new file mode 100644index 0000000..d832696Binary files /dev/null and b/site/little-horse/ch01/audio/sfx/wind.mp3 differdiff --git a/site/little-horse/ch01/index.html b/site/little-horse/ch01/index.htmlnew file mode 100644index 0000000..b0121c8--- /dev/null+++ b/site/little-horse/ch01/index.html@@ -0,0 +1,68 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>The Little Horse Crosses the River</title>+<link rel="stylesheet" href="../lib/engine.css">+<link rel="expect" href="#bar" blocking="render">+</head>+<body>+<!-- The Little Horse Crosses the River (小马过河): one beat per scene. Order matters: engine, sets and baked pieces,+ kit, cast, the audio data, shared helpers, then the scenes. -->+<script src="../lib/engine.js"></script>+<script src="../img/sets/sets.js"></script>+<script src="../img/puppets/baked.js" onerror="0"></script>+<script src="../lib/paper.js"></script>+<script src="../lib/cast.js"></script>+<script src="audio/en/timings.js"></script>+<script src="audio/en/mouths.js"></script>+<script src="audio/en/shots.js"></script>+<script src="../lib/shared.js"></script>+<script src="../lib/find.js"></script>+<script src="scene1.js"></script>+<script src="scene2.js"></script>+<script src="scene3.js"></script>+<script src="scene4.js"></script>+<script src="scene5.js"></script>+<script src="scene6.js"></script>+<script src="scene7.js"></script>+<script src="scene8.js"></script>+<script src="scene9.js"></script>+<script>+'use strict';+// film: the two point-and-read stops are its only questions, so music and effects play and the help leaves out+// question keys.+const CHAPTER = { number: 1, title: 'The Little Horse Crosses the River', minutes: 4, language: 'en', film: true, questionKeys: false };+try { if (localStorage.getItem('captions') === null) setCaptions(true, false); } catch {} // captions on at the first visit; the reader's own choice is kept++// The two stops are "listen and find" (lib/find.js): Little Horse asks for one thing at a time; every thing in the+// picture answers a tap with its name. Only things that move are asked for, so their hop and wiggle can be seen.+// At the river he is looking for help: the ox comes last, and finding him leads into scene 4 ("There's Uncle Ox!").+const FIND_RIVER = ['bird', 'flower', 'butterfly', 'ox'].map((w, i) => ({ word: w, clip: 'q-' + w + (i ? '' : '1') }));+const FIND_MILL = ['wheel', 'duck', 'sack'].map((w, i) => ({ word: w, clip: 'q-' + w + (i ? '' : '1') }));+const BEATS = [+ ['scene1', 'Home', (m, D) => scene1(panel(0), D), { lead: false, pre: PRE1 }],+ ['scene2', 'Off to the mill', (m, D) => scene2(panel(0), D), { lead: false, pre: PRE2 }],+ ['scene3', 'By the river', (m, D) => scene3(panel(0), D), { lead: false, pre: PRE3, ask: done => findWords(RIVER_THINGS, FIND_RIVER, done, { end: 'q-uncle' }), video: false }],+ ['scene4', 'Uncle Ox', (m, D) => scene4(panel(0), D), { lead: false, pre: PRE4 }],+ ['scene5', 'Squirrel', (m, D) => scene5(panel(0), D), { lead: false, pre: PRE5 }],+ ['scene6', 'Ask Mama', (m, D) => scene6(panel(0), D), { lead: false, pre: PRE6 }],+ ['scene7', 'Let me try', (m, D) => scene7(panel(0), D), { lead: false, pre: PRE7 }],+ ['scene8', 'At the mill', (m, D) => scene8(panel(0), D), { lead: false, pre: PRE8, ask: done => findWords(MILL_THINGS, FIND_MILL, done), video: PRE8 + 3.6 }], // the video keeps "brought the wheat to the mill." and skips the game+ ['scene9', 'The little rabbit', (m, D) => scene9(panel(0), D), { lead: false, pre: PRE9 }],+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));++// music: one looping theme under every scene (books/little-horse/MUSIC.md), up in the lead-ins, silent for the stare+// at the end of scene 7; ?bgm= sets its level by ear. Beds: river and mill tile every 9.5 s, birds every 9.6 s.+music('audio/bgm/theme.mp3', undefined, +(new URLSearchParams(location.search).get('bgm') || .4));+window.MUSIC_UP_IN_PRE = true;+window.MUSIC_OFF = { scene7: t => t > PRE7 + 32.7, // faded out by the stare (33.47): "deep!" ends at 32.7+ scene9: t => t > PRE9 + TIMINGS.scene9.dur - 2 }; // the film fades out under the last picture+SFX_BED.river = 10; SFX_BED.birds = 10; SFX_BED.mill = 10; SFX_BED.wind = 8;+// Build every puppet and prop once at load, off screen, so their bitmaps are ready before the first beat needs them.+paperWarm(g => { horsePuppet(g); motherPuppet(g); oxPuppet(g); squirrelPuppet(g); rabbitPuppet(g); prop(g, SACK); millWheel(g); });+boot();+</script>+</body>+</html>diff --git a/site/little-horse/ch01/scene1.js b/site/little-horse/ch01/scene1.jsnew file mode 100644index 0000000..fc4afaf--- /dev/null+++ b/site/little-horse/ch01/scene1.js@@ -0,0 +1,153 @@+/* scene1.js — Home (the stable). The valley and the stable; Mother and Little Horse side by side, a foal glued to+ his mother; she asks him to carry the half sack of wheat to the mill, he says yes, she swings the sack onto his+ back with her teeth, and he turns proud to the road. Beat clock = PRE1 + the scene-clip word times. */+'use strict';+const PRE1 = 2.0;+const s1_S = 1.05; // the loose sack, the size of the one drawn on Little Horse's back+const s1_SACK = [688, 780 - 75 * s1_S]; // its tie, sitting on the ground beside the stable door+const s1_LY = 786; // Little Horse stands on the near side of her, a little lower+// A whole-body turn from a to b over four frames, through a thin squash (never quite 0).+const s1_turn = (q, t0, a, b) => { const v = tween(q, t0, 4 / FPS, a, b); return Math.abs(v) < .12 ? .12 * Math.sign(b) : v; };+// A paper bird: two wing positions on twos.+const s1_BIRD = (up) => `<g filter="url(#paper)"><ellipse rx="9" ry="4" fill="#6b5a4a"/><circle cx="8" cy="-2" r="3.6" fill="#6b5a4a"/>+ <path d="${up ? 'M-2,-1 C-8,-16 -18,-20 -26,-18 C-16,-12 -10,-6 -4,0 Z M2,-1 C6,-15 14,-21 22,-20 C14,-12 8,-6 4,0 Z' : 'M-2,0 C-10,6 -18,12 -26,16 C-16,6 -10,2 -4,-1 Z M2,0 C8,6 14,12 22,14 C14,6 8,2 4,-1 Z'}" fill="#5a4a3c"/></g>`;+// Walking along route keys, but after each stop the legs square up one hoof at a time (lifted and set down on its rest+// place) instead of all four sliding back together: the planted hooves stay put.+function s1_walk(q, keys, s) {+ const r = route(q, keys, s);+ let stop = null;+ for (let i = 1; i < keys.length; i++) if (keys[i - 1][1] !== keys[i][1] && q >= keys[i][0]) stop = keys[i][0];+ if (stop === null || q - stop >= .8) return { ...r, legs: {} };+ const g = gait(r.d, 'walk', HORSE_GEO.L, HORSE_GEO.H), legs = {};+ ['nf', 'ff', 'nh', 'fh'].sort((a, b) => g[b][1] - g[a][1] || Math.abs(g[b][0]) - Math.abs(g[a][0])).forEach((k, i) => {+ const t0 = stop + i * .14, u = span(q, t0, t0 + .18), lift = Math.abs(g[k][0]) > 2 || g[k][1] > 0 ? 9 * Math.sin(Math.PI * Math.min(1, Math.max(0, (q - t0) / .18))) : 0;+ legs[k] = [-g[k][0] * u, -g[k][1] * u + lift];+ });+ return { ...r, stand: 0, legs };+}++function scene1(p, D) {+ const P = PRE1, T = (c, t = 0) => clipAt('scene1', P, c, t);+ const cam = setCam(p, 'stable', { x: 800, y: 420, z: .9 });+ const ma = motherPuppet(cam.stage), lh = horsePuppet(cam.stage); // he is on the near side of her, his head under her chin+ const sack = prop(cam.stage, SACK); // after the puppets: in front of Mother's muzzle and Little Horse's back+ const birds = [0, 1, 2].map(i => ({ up: prop(cam.stage, s1_BIRD(true)), dn: prop(cam.stage, s1_BIRD(false)), i }));++ // Times on the beat clock.+ const GAG = T('n01', 7.0), GRAZE = T('n01', 8.9), ALONE = T('n01', 10.2);+ const M01 = T('m01'), THIS = T('m01', 17.19 - 13.15), HALF = T('m01', 17.43 - 13.15), MILL = T('m01', 18.37 - 13.15);+ const BIG = T('m01', 14.07 - 13.15), HELP = T('m01', 15.39 - 13.15);+ const H01 = T('h01'), CAN = T('h01', 1.2), LOAD = T('load1');+ // The hand-over: Mother turns to the sack, head down, grip, lift, turn round, a step to him lowering it onto his back.+ const FETCH = H01 + 1.95, DOWN = LOAD - .1, GRIP = DOWN + .55, LIFT = GRIP + .17, SWING = LIFT + .42, LOWER = SWING + 4 / FPS, LAND = LOWER + .45;+ const PROUD = LAND + .5, READY = PROUD + .35;++ // Cameras: a drift in over the valley, then closer and closer on the two of them.+ cam.to({ x: 830, y: 560, z: 1.25 }, .15, T('n01', 2.6) - .15)+ .cut({ x: 950, y: 600, z: 2.0 }, T('n01', 2.62)).to({ x: 975, y: 595, z: 2.2 }, T('n01', 2.62), 4) // the two of them+ .cut({ x: 910, y: 610, z: 1.6 }, T('n01', 6.78)).to({ x: 960, y: 610, z: 1.65 }, GAG, 2) // the step together+ .cut({ x: 1030, y: 565, z: 2.6 }, T('n01', 10.65)).to({ x: 1040, y: 565, z: 2.85 }, T('n01', 10.65), 2.4) // never alone+ .cut({ x: 990, y: 590, z: 2.1 }, M01 - .1) // "Little one"+ .cut({ x: 1150, y: 545, z: 3.2 }, BIG - .06) // his eager face, ears up: "you're big now"+ .cut({ x: 1030, y: 545, z: 3.0 }, HELP - .08) // her close-up, his face below; her eyes go to the sack+ .cut({ x: 700, y: 712, z: 3.2 }, HALF - .05) // insert: the sack by the door+ .cut({ x: 1150, y: 545, z: 3.2 }, MILL - .02) // "to the mill?": his eyes go to the road+ .cut({ x: 1080, y: 600, z: 2.25 }, H01 - .12) // him, rearing, hooves and all+ .cut({ x: 925, y: 615, z: 2.0 }, FETCH) // the hand-over: she turns on the cut+ .to({ x: 1130, y: 600, z: 2.0 }, PROUD - .2, D + .6 - PROUD + .2); // then him, setting off+ cam.soft(T('n01', 10.65), true).soft(M01 - .1, false).soft(BIG - .06, true).soft(HALF - .05, false).soft(MILL - .02, true).soft(FETCH, false);++ sfx('scene1', 0, 'birds', .5); sfx('scene1', 0, 'wind', .25);+ sfx('scene1', GAG + .45, 'hoof', .25); sfx('scene1', GAG + .95, 'hoof', .2);+ sfx('scene1', H01 + .78, 'hoof', .45);+ sfx('scene1', FETCH + .6, 'hoof', .2); sfx('scene1', FETCH + 1.05, 'hoof', .2);+ sfx('scene1', SWING, 'whoosh', .35); sfx('scene1', LAND, 'thud', .8);+ sfx('scene1', READY + .55, 'hoof', .3); sfx('scene1', READY + 1.0, 'hoof', .3);++ stopClock(D, (q, f) => {+ cam.apply(q, f);+ const breath = k => 1.2 * Math.sin((q + k) * 2 * Math.PI / 3.1);++ // ---- birds: three across the sky while the camera drifts in ----+ for (const b of birds) {+ const u = (q - .2 - b.i * .35) / 5.2, on = u > 0 && u < 1, flap = (f + b.i) % 4 < 2;+ vis(b.up, on && flap); vis(b.dn, on && !flap);+ const x = 300 + 1100 * u + b.i * 70, y = 250 - 90 * u + 26 * Math.sin(u * 5 + b.i) - b.i * 30;+ tf(b.up, `translate(${x.toFixed(0)},${y.toFixed(0)}) scale(${(1 - .15 * b.i).toFixed(2)})`); tf(b.dn, b.up._t);+ }++ // ---- Mother ----+ const mr = s1_walk(q, [[0, 800], [GAG, 800], [GAG + 1.3, 860], [FETCH + .3, 860], [FETCH + 1.25, 808], [LOWER, 808], [LAND, 840]], 1.3);+ const mTurn = q < FETCH ? 1 : q < SWING ? s1_turn(q, FETCH, 1, -1) : s1_turn(q, SWING, -1, 1);+ // grazing in the wide shot; then her head comes up and nuzzles his mane+ let mNeck = 80 + 3 * Math.sin(q * 1.3), mNod = -8, mTilt = 8, mLook = 0, mBrow = -.2, mChew = q * 1.6, mEar = 0;+ if (q >= 4.1) { const u = span(q, 4.1, 4.9); mNeck = 80 + (20 + 3 * Math.sin(q * 1.4) - 80) * u; mNod = -8 + (8 + 3 * Math.sin(q * .9) + 8) * u; mTilt = 8 * (1 - u); mChew = u < .5 ? q * 1.6 : 0; }+ if (q >= GAG - .4) mNeck = tween(q, GAG - .4, .4, 20, -2), mNod = 6;+ if (q >= GRAZE) mNeck = tween(q, GRAZE, .5, -2, -30), mNod = tween(q, GRAZE, .5, 6, -12), mTilt = tween(q, GRAZE, .5, 0, -3), mChew = q > GRAZE + .6 ? q * 1.6 : 0; // stretches up to nibble the willow+ if (q >= ALONE) mNeck = tween(q, ALONE, .5, -30, 16), mNod = tween(q, ALONE, .5, -12, 8), mTilt = tween(q, ALONE, .5, -3, 0), mChew = 0; // down first; then her muzzle to his mane+ if (q >= M01 - .4) mNeck = tween(q, M01 - .4, .4, 16, 4), mNod = tween(q, M01 - .4, .4, 8, 6); // to talk to him+ if (q >= THIS) mLook = tween(q, THIS, .2, 0, -1); // eyes go to the sack+ if (q >= MILL) mLook = tween(q, MILL, .2, -1, 1), mNeck = tween(q, MILL, .4, 4, -6), mNod = tween(q, MILL, .4, 6, -4); // and to the road+ if (q >= H01 - .2) mLook = tween(q, H01 - .2, .2, 1, .7), mNeck = tween(q, H01 - .2, .35, -6, -22), mNod = tween(q, H01 - .2, .35, -4, -10), mBrow = tween(q, H01, .3, -.2, -.7); // he rears: she draws her head back and up, delighted+ if (q >= FETCH) mLook = 0, mBrow = -.2, mNeck = tween(q, FETCH, .4, -22, 4), mNod = tween(q, FETCH, .4, -10, 4);+ if (q >= DOWN) mNeck = tween(q, DOWN, .5, 4, 74), mNod = tween(q, DOWN, .5, 4, -6), mTilt = tween(q, DOWN, .5, 0, 9);+ if (q >= LIFT) mNeck = tween(q, LIFT, .38, 74, -8), mNod = tween(q, LIFT, .38, -6, 2), mTilt = tween(q, LIFT, .38, 9, -2);+ if (q >= LOWER) mNeck = tween(q, LOWER, .45, -8, 8), mNod = tween(q, LOWER, .45, 2, 6), mTilt = tween(q, LOWER, .45, -2, 0);+ if (q >= LAND + .1) mNeck = tween(q, LAND + .1, .4, 8, -12), mNod = tween(q, LAND + .1, .4, 6, 6), mLook = .4, mBrow = tween(q, LAND + .1, .4, -.2, -.5); // proud of him+ const mMouth = q >= GRIP && q < LAND + .05 ? 'A' : lips(q, 'scene1', P, 'm01');+ ma.pose({ x: mr.x, y: 780, s: 1.3, turn: mTurn, d: mr.d, stand: mr.stand, legs: mr.legs, gait: 'walk', neck: mNeck, nod: mNod, tilt: mTilt,+ chew: mChew, mouth: mMouth, look: mLook, brow: mBrow, ear: mEar, lid: 0, bob: breath(.7),+ tail: 6 * Math.sin(q * 1.1) + (q > 3.2 && q < 4 ? 14 * Math.sin((q - 3.2) * 16) : 0),+ shut: blinking(q, [1.6, 5.9, 9.9, T('n01', 9.3), T('m01', 1.9), T('m01', 5.3), H01 + 1.5, PROUD + .3]) }, f);++ // ---- Little Horse ----+ const lr = s1_walk(q, [[0, 965], [GAG + .3, 965], [GAG + 1.55, 1025], [READY + .3, 1025], [READY + 1.7, 1135]], 1.05); // and off he goes+ let lNeck = 8, lNod = -10, lLook = -.6, lEar = 0, lBrow = 0, lTilt = 0, lBob = breath(0), lLegs = {}, lShut = false;+ if (q >= GAG - .1) lLook = tween(q, GAG - .1, .2, -.6, -1), lEar = -.6; // she moves: he is with her at once+ if (q >= GAG + .3) lNeck = tween(q, GAG + .3, .3, 8, -2), lNod = -4;+ if (q >= GRAZE + .4) lNeck = tween(q, GRAZE + .4, .5, -2, -34), lNod = tween(q, GRAZE + .4, .5, -4, -14), lTilt = tween(q, GRAZE + .4, .5, 0, -6), lLook = -1, lEar = -.8; // copies her a beat late: stretches up, too small to reach+ if (q >= ALONE + .45) lNeck = tween(q, ALONE + .45, .5, -34, 4), lTilt = tween(q, ALONE + .45, .5, -6, 0), lNod = tween(q, ALONE + .45, .5, -14, -6), lLook = 0, lEar = .3; // down after her+ if (q >= ALONE + 1.1) lShut = q < M01 - .5; // eyes shut, content, under her nuzzle+ if (q >= M01 - .4) lLook = tween(q, M01 - .4, .2, 0, -1), lNod = -12, lNeck = 4, lEar = .1; // "Little one": looks up at her+ if (q >= BIG) lNeck = tween(q, BIG, .3, 4, -6), lBrow = tween(q, BIG, .2, 0, -.6), lTilt = -2, lEar = tween(q, BIG + .15, 2 / FPS, .1, -1); // "big now": ears snap up, eager, stands taller+ if (q >= THIS + .1) lLook = -1, lNeck = tween(q, THIS + .1, .3, -6, 6), lNod = 0, lEar = .2; // follows her eyes to the sack+ if (q >= MILL + .1) lLook = tween(q, MILL + .1, .2, -1, 1), lNeck = tween(q, MILL + .1, .3, 6, -6), lNod = -6, lBrow = -.8, lEar = tween(q, MILL + .25, 2 / FPS, .2, -1); // the road, the mill: wide-eyed, ears snap up+ if (q >= H01) { // "Yes, Mama!": rears with joy+ const up = span(q, H01 - .05, H01 + .25) * (1 - span(q, H01 + .6, H01 + .8));+ lTilt = -12 * up; lLegs = { nf: [18 * up, 40 * up], ff: [14 * up, 32 * up] }; lNeck = -8 - 6 * up; lNod = -6; lEar = -1; lBrow = -.8;+ lLook = q < H01 + .7 ? -1 : 0;+ }+ if (q >= CAN) lNeck = -10, lNod = -8 + 3 * Math.sin((q - CAN) * 9) * (1 - span(q, CAN, CAN + 1)), lTilt = -3, lEar = -1, lLook = .4, lBrow = .5; // "I can do it!": determined+ if (q >= FETCH + .3) lLook = tween(q, FETCH + .3, .2, .4, -1), lNeck = -6, lTilt = 0, lBrow = -.3; // watches her fetch it+ if (q >= SWING) lNeck = tween(q, SWING, .3, -6, 10), lNod = 4, lEar = .4, lShut = between(q, LOWER + .2, LAND + .25); // braces for it+ if (q >= LAND) { // the weight lands: wobble, brace+ const w = Math.exp(-(q - LAND) * 5) * Math.sin((q - LAND) * 26);+ lTilt = 4 * w; lBob = 7 * Math.exp(-(q - LAND) * 4) + breath(0); lNeck = 10 + 6 * w; lBrow = .7;+ lLegs = { nf: [-6 * span(q, LAND, LAND + .1), 0], nh: [8 * span(q, LAND, LAND + .1), 0] };+ }+ if (q >= PROUD) lNeck = tween(q, PROUD, .35, 10, -12), lNod = tween(q, PROUD, .35, 4, -6), lTilt = tween(q, PROUD, .35, 0, -3), lEar = -1, lBrow = .3, lLook = tween(q, PROUD, .2, -1, -.6),+ lLegs = { nf: [-6, 0], nh: [8, 0] }, lBob = breath(0);+ if (q >= READY) lLook = tween(q, READY, .2, -.6, 1), lNeck = -14, lLegs = { nf: [-6 * (1 - span(q, READY, READY + .3)), 0], nh: [8 * (1 - span(q, READY, READY + .3)), 0] };+ const tuck = q < FETCH ? -14 : 0; // tail tucked in while he is pressed to her+ lh.pose({ x: lr.x, y: s1_LY, s: 1.05, d: lr.d, stand: lr.stand, gait: 'walk', neck: lNeck, nod: lNod, tilt: lTilt, look: lLook, ear: lEar,+ brow: lBrow, legs: { ...lr.legs, ...lLegs }, bob: lBob, sack: q >= LAND, chew: between(q, GRAZE + .9, ALONE + .45) ? q * 1.8 : 0, mouth: lips(q, 'scene1', P, 'h01'),+ tail: tuck + 5 * Math.sin(q * 1.7 + 1) + (between(q, 6, 7.2) || between(q, LAND + .6, LAND + 1.4) ? 14 * Math.sin(q * 14) : 0),+ shut: lShut || blinking(q, [3.1, 7.1, T('n01', 5.0), T('m01', 2.6), MILL + .6, CAN + .8]) }, f);++ // ---- the sack: on the ground, in Mother's teeth, onto his back ----+ let sx = s1_SACK[0], sy = s1_SACK[1], rot = 0, sq = 1;+ if (q >= GRIP && q < LAND) {+ [sx, sy] = ma.at('mouth');+ sy += 2;+ if (q < LIFT) rot = -4 * span(q, GRIP, LIFT); // the tug+ else rot = 16 * Math.sin((q - LIFT) * 9) * Math.exp(-(q - LIFT) * 1.5) * mTurn; // it swings from her teeth+ if (q >= LOWER) { // onto his back+ const [bx, by] = lh.at('back'), u = span(q, LOWER, LAND);+ sx += (bx + 2 * s1_S - sx) * u; sy += (by - 35 * s1_S - sy) * u; rot *= 1 - u;+ sq = 1 - .25 * span(q, LAND - 2 / FPS, LAND);+ }+ }+ vis(sack, q < LAND);+ tf(sack, `translate(${sx.toFixed(1)},${sy.toFixed(1)}) rotate(${rot.toFixed(1)}) scale(${s1_S},${(s1_S * sq).toFixed(3)}) translate(-2,35)`);+ });+}diff --git a/site/little-horse/ch01/scene2.js b/site/little-horse/ch01/scene2.jsnew file mode 100644index 0000000..8ea77a3--- /dev/null+++ b/site/little-horse/ch01/scene2.js@@ -0,0 +1,148 @@+/* scene2.js — Off to the mill: a follow shot down the road, then the river across his path.+ Shots (beat clock, PRE2 1.0 + clip times):+ A 0.00–2.40 road, medium follow: Little Horse trotting right, sack on, happy+ B 2.40–4.30 road, close follow on the sack and his face ("with the wheat on his back")+ C 4.30–6.80 road, wide low follow, he gains on the camera ("He ran, and he ran")+ D 6.80–9.45 river, wide, drifting in: he trots in from the left past the tree; the river right across his path,+ Uncle Ox in it, not far away; he sees it ("right across his path"): ears up, brow up+ H 9.45–10.15 river, insert low on the hooves: the skid, front legs braced, dust; he stops at x 400 (the tree end)+ E 10.15–12.75 river, his close-up with the water ahead, the ox out of frame: "Whoa!", "Can I get across?"+ E' 12.75–14.45 cut out to the bank, the river and the ox: on "Mama" a torn-paper thought picture pops up beside his head+ (Mother at the stable door, small), held through "to ask", then it pops away; the frame stays+ E2 14.45–end head low over the water: the bank, the river and the ox for the+ last frame: Little Horse at x 400 facing right, worried; Ox at 1060 facing left */+'use strict';+const PRE2 = 1.0;+const s2_T = { mama: [12.95, 14.45], hooves: 9.45, cut: 6.8, wide: 4.3, close: 2.4, ride: 9.55, stop: 10.05, cu: 10.15 };+const s2_L = HORSE_GEO.L, s2_S = 1.05;+// Road: trot cycles done by time t (2.0 Hz, picking up to 2.4 Hz by "as fast as he could go").+const s2_roadCyc = t => t <= 2 ? 2 * Math.max(0, t) : t <= 4.5 ? 4 + 2 * (t - 2) + .08 * (t - 2) ** 2 : 9.5 + 2.4 * (t - 4.5);+const s2_roadX = t => 300 + s2_S * s2_L * s2_roadCyc(t);+// River: in from the left at 1.9 Hz, then a skid of 50 px with the hooves braced (sliding, decelerating).+const s2_HZ = 1.895, s2_X0 = -55; // stops at x 400+const s2_rivCyc = t => s2_HZ * Math.min(s2_T.ride, Math.max(s2_T.cut, t)) - s2_HZ * s2_T.cut;+function s2_rivX(t) {+ if (t < s2_T.ride) return s2_X0 + s2_S * s2_L * s2_rivCyc(t);+ const u = Math.min(1, (t - s2_T.ride) / (s2_T.stop - s2_T.ride)), x1 = s2_X0 + s2_S * s2_L * s2_rivCyc(s2_T.ride);+ return x1 + 50 * (1 - (1 - u) ** 2);+}+// A thought picture popping open at t0 (a few frames of overshoot) and shut at t1 (one big frame, then gone).+const s2_pop = (q, t0, t1) => q < t0 || q >= t1 + 1 / FPS ? 0 : q >= t1 ? 1.1 : [.4, 1.12, .95, 1][Math.min(3, Math.floor((q - t0) * FPS + 1e-6))];+// A torn sheet w × h around (0, 0), its edges wandering a little, the same every time.+function s2_torn(w, h, seed) {+ const pts = [], n = 9;+ const side = (x0, y0, x1, y1, k) => { for (let i = 0; i < n; i++) { const u = i / n; pts.push([x0 + (x1 - x0) * u + 4 * jit(seed, k + i), y0 + (y1 - y0) * u + 4 * jit(seed, k + 40 + i)]); } };+ side(-w / 2, -h / 2, w / 2, -h / 2, 0); side(w / 2, -h / 2, w / 2, h / 2, 100); side(w / 2, h / 2, -w / 2, h / 2, 200); side(-w / 2, h / 2, -w / 2, -h / 2, 300);+ return 'M' + pts.map(p => p.map(v => v.toFixed(1)).join(',')).join(' L') + ' Z';+}+// A paper puff of dust for the skid.+const s2_PUFF = '<g filter="url(#paper)"><circle r="16" fill="#dccaa0"/><circle cx="9" cy="-6" r="10" fill="#e6d7b2"/></g>';++function scene2(p, D) {+ const at = t => PRE2 + t; // clip time -> beat clock+ // ---- sound: beds, a hoof on every diagonal pair's landing, the skid+ sfx('scene2', 0, 'birds', .45); sfx('scene2', 0, 'wind', .25); sfx('scene2', s2_T.cut, 'river', .5);+ for (const [cyc, t0, t1, vol] of [[s2_roadCyc, 0, s2_T.cut, .22], [s2_rivCyc, s2_T.cut, s2_T.ride, .3]]) {+ let last = Math.floor(cyc(t0) * 2);+ for (let t = t0; t < t1; t += 1 / 120) { const k = Math.floor(cyc(t) * 2); if (k > last) { sfx('scene2', +t.toFixed(3), 'hoof', vol); last = k; } }+ }+ sfx('scene2', s2_T.ride, 'skid', .7); sfx('scene2', s2_T.stop, 'hoof', .45);++ // ---- the road+ const road = setCam(p, 'road', { x: s2_roadX(0) + 150, y: 650, z: 1.4 });+ const lhR = horsePuppet(road.stage);+ road.to({ x: t => s2_roadX(t) + 150 }, 0, 0.001);+ road.cut({ x: t => s2_roadX(t) + 60, y: 560, z: 2.3 }, s2_T.close);+ // the wide: the camera falls behind, so he runs from left of centre to right of it+ road.cut({ x: t => s2_roadX(t) + 480 - 640 * span(t, s2_T.wide, s2_T.cut + .4), y: 505, z: .88 }, s2_T.wide);++ // ---- the river+ const riv = setCam(p, 'river', { x: 720, y: 540, z: 1.12 });+ const ox = oxPuppet(riv.stage), lh = horsePuppet(riv.stage);+ const puffs = Array.from({ length: 9 }, () => prop(riv.stage, s2_PUFF));+ // ---- the thought of Mama: a torn-paper picture over the water beside his head, Mother at the stable door+ const VX = 622, VY = 330, mamaV = mk('g', {}, riv.stage), mamaIn = mk('g', {}, mamaV);+ mamaIn.innerHTML = `<clipPath id="s2clip"><path d="${s2_torn(196, 140, 22)}"/></clipPath>+ <g filter="url(#paper)"><path d="${s2_torn(210, 154, 21)}" fill="#fbf6ea"/></g>+ <g clip-path="url(#s2clip)"><g filter="url(#paper)"><rect x="-120" y="-90" width="240" height="180" fill="#e6ecd8"/>+ <path d="M-120,10 C-60,0 40,14 120,4 L120,90 L-120,90 Z" fill="#b8cfa4"/><path d="M-120,52 C-40,48 40,56 120,50 L120,90 L-120,90 Z" fill="#c9b27a"/>+ <path d="M-120,-40 L-14,-40 L-14,54 L-120,54 Z" fill="#a8754a"/><path d="M-128,-38 L-60,-78 L4,-38 Z" fill="#d9b25e"/>+ <path d="M-82,-14 L-38,-14 L-38,54 L-82,54 Z" fill="#5a3b24"/><path d="M-60,-14 L-60,54" stroke="#46301d" stroke-width="3"/></g>+ <g class="mom"></g></g>`;+ bakeAll(mamaIn);+ const mom = motherPuppet(mamaIn.querySelector('.mom'));+ const trail = [[521, 433, 4], [530, 422, 6], [541, 411, 8]].map(([x, y, r]) =>+ prop(riv.stage, `<g filter="url(#paper)"><circle cx="${x}" cy="${y}" r="${r + 3}" fill="#8a6a46"/><circle cx="${x}" cy="${y}" r="${r}" fill="#fbf6ea"/></g>`));+ sfx('scene2', s2_T.mama[0], 'pop', .45); sfx('scene2', s2_T.mama[1], 'pop', .35);+ riv.to({ x: 560, y: 560, z: 1.4 }, s2_T.cut + .1, 2.6); // drifts in on the bank as he comes+ riv.cut({ x: 455, y: 660, z: 3.2 }, s2_T.hooves); // H: the hooves skidding+ riv.cut({ x: 410, y: 575, z: 2.2 }, s2_T.cu).soft(s2_T.cu, true); // E: "Whoa!", the water ahead, the ox out of frame+ riv.to({ y: 600 }, 11.05, .8); // "Can I get across?": the frame tips down to the water+ riv.cut({ x: 560, y: 545, z: 1.45 }, 12.75); // on "If only": out to the bank, the river and the ox, with room for the thought of Mama+ riv.soft(s2_T.hooves, true);+ const hBlinks = [1.7, 4.9, 7.6, 12.3, 15.65], oxBlinks = [7.5, 11.2, 14.6, 16.3];+ stopClock(D, (q, f) => {+ const onRoad = q < s2_T.cut;+ vis(road.root, onRoad); vis(riv.root, !onRoad);+ (onRoad ? road : riv).apply(q, f);++ // ---- road pose: happy trot, a nod in step with the gait, tail streaming+ if (q < s2_T.cut) {+ const c = s2_roadCyc(q);+ lhR.pose({ x: s2_roadX(q), y: 815, s: s2_S, d: s2_L * c, stand: 0, gait: 'trot', sack: true,+ nod: 3 * Math.sin(4 * Math.PI * c), neck: -4, ear: -.6 + .1 * Math.sin(4 * Math.PI * c), look: .4,+ tail: 24 + 6 * Math.sin(4 * Math.PI * c + 1), shut: blinking(q, hBlinks) }, f);+ return;+ }++ // ---- river: Uncle Ox in the shallows, chewing, unbothered; facing left; his eye goes to Little Horse at the skid+ ox.pose({ x: 1060, y: WATER + 50, s: 1.4, turn: -1, chew: q * 1.1, grass: true, neck: 6, lid: .35, brow: -.15,+ look: between(q, 9.9, 12.2) ? 1 : .2, ear: .3 * Math.sin(q * .9) + (between(q, 9.7, 10.2) ? -.6 : 0),+ tail: 6 * Math.sin(q * 1.3), shut: blinking(q, oxBlinks) }, f);++ // ---- Little Horse: trot in, skid, teeter, then the worried close-up+ // The kit's brow: + slants it down to the nose (cross), - lifts its inner end (surprised, worried).+ const x = s2_rivX(q), skid = span(q, s2_T.ride, s2_T.ride + .17), settle = span(q, s2_T.stop + .25, s2_T.stop + .7);+ const brace = skid * (1 - settle); // front legs thrust forward, hind tucked under, body thrown back+ const teeter = q < s2_T.stop ? 0 : 4 * Math.sin(Math.PI * Math.min(1, (q - s2_T.stop) / .55)) * (1 - span(q, s2_T.stop + .55, s2_T.stop + .9));+ const mouth = lips(q, 'scene2', PRE2, 'h02');+ // the face through the lines (beat clock: Whoa 10.23, Can I get across 11.21, If only 12.77, Mama 12.97, ask 13.99)+ const sees = span(q, 8.4, 8.75); // "right across his path": ears up, brow up+ const away = span(q, 12.6, 12.95) * (1 - span(q, 14.1, 14.4)); // head up, eyes up to the thought of Mama+ const water = span(q, 10.95, 11.4) * (1 - span(q, 12.5, 12.7)) + span(q, 14.1, 14.4); // looking down at the water+ const gloom = span(q, 14.1, 14.6);+ const breathe = q > s2_T.stop + .9 ? 1.2 * Math.sin(2 * Math.PI * (q - s2_T.stop) / 2.6) : 0;+ const sigh = -3 * Math.sin(Math.PI * span(q, 14.6, 15.5));+ const c = s2_rivCyc(q);+ lh.pose({ x, y: 700, s: s2_S, d: s2_L * c, stand: skid, gait: 'trot', sack: true,+ tilt: -13 * brace + teeter, bob: breathe + sigh,+ legs: { nf: [34 * brace, 0], ff: [28 * brace, 0], nh: [18 * brace, 0], fh: [14 * brace, 0] },+ neck: -4 - 16 * brace + 18 * water - 2 * away + 4 * gloom,+ nod: q < s2_T.ride ? 3 * Math.sin(4 * Math.PI * c) : 5 * water + 2 * away,+ ear: -.6 * (1 - sees) - .9 * sees * (1 - brace) + .9 * brace + (q > s2_T.stop + .5 ? .3 * away + 1.0 * gloom : 0),+ brow: -Math.min(1, .7 * sees + .3 * brace + .3 * Math.max(water, away, gloom)),+ look: .4 + .5 * water + .5 * away,+ tail: q < s2_T.ride ? 24 + 6 * Math.sin(4 * Math.PI * c + 1) : 24 * (1 - skid) + 10 * brace - 6 * gloom,+ mouth, shut: blinking(q, hBlinks) }, f);++ // ---- the thought of Mama: pops on "Mama", held through "to ask"; she looks his way, breathes, blinks+ const [m0, m1] = s2_T.mama, sc = s2_pop(q, m0, m1);+ trail.forEach((t, i) => vis(t, q >= m0 - .2 + i * .07 && q < m1));+ vis(mamaV, sc > 0);+ if (sc > 0) {+ tf(mamaV, `translate(${VX + jit(f, 61) * .4},${VY + jit(f, 62) * .4}) rotate(2) scale(${sc})`);+ mom.pose({ x: 22, y: 58, s: .33, turn: -1, neck: 6 + 6 * span(q, m0 + .4, m0 + .9), look: .4, brow: -.2,+ bob: .8 * Math.sin(q * 2.4), tail: 4 * Math.sin(q * 1.7), shut: blinking(q, [m0 + .95]) }, f);+ }++ // ---- dust from the skid: puffs thrown up at the hooves, drifting on and fading+ puffs.forEach((g, i) => {+ const tb = s2_T.ride + .05 + i * .055, age = (q - tb) / .9;+ if (age < 0 || age > 1) { vis(g, false); return; }+ vis(g, true);+ const fore = i % 3 !== 2, hx = s2_rivX(tb) + s2_S * (fore ? 70 : -40) + 6 * jit(i, 40);+ tf(g, `translate(${(hx + (fore ? 55 : -25) * age).toFixed(1)},${(698 - 46 * age - 6 * (i % 2)).toFixed(1)}) scale(${(.45 + 1.15 * age).toFixed(3)})`);+ g.setAttribute('opacity', (Math.min(1, age * 6) * (1 - age) * .9).toFixed(2));+ });+ });+}diff --git a/site/little-horse/ch01/scene3.js b/site/little-horse/ch01/scene3.jsnew file mode 100644index 0000000..c3f7ca3--- /dev/null+++ b/site/little-horse/ch01/scene3.js@@ -0,0 +1,150 @@+/* scene3.js — By the river: the first stop, a "listen and find" game (lib/find.js).+ n03 "Little Horse looked all around. Who could help him? Help him look! Listen, and touch what he asks for."+ Wide river shot; on "looked all around" Little Horse turns round to the tree and the flowers and back to the river,+ worried; the camera eases in to the game's frame (every thing in, none under another's word). Then he asks for one+ thing at a time (bird, flower, butterfly, ox; find.js speaks and moves his mouth through findMouth()), with his+ chin up and eyes to us while he asks, searching about between asks, glancing at each thing as it is found; finding+ Uncle Ox ends it ("There's Uncle Ox! Let's ask him!"). The picture lives on meanwhile: the ox chews in the river+ facing him, a kingfisher hops along the branch, a butterfly flutters over the flowers.+ Squirrel is hidden in the crown (not built) until scene 5. */+'use strict';+const PRE3 = 1.0;+let RIVER_THINGS = []; // filled by scene3 each time it builds; findWords (lib/find.js) reads it+sfx('scene3', 0, 'river', .5);+sfx('scene3', 0, 'birds', .4);+sfx('scene3', 1.8, 'hoof', .25); // the turn round, and back+sfx('scene3', 3.05, 'hoof', .25);++const s3_LH = 400; // Little Horse at the tree end of the bank, where scene 2 leaves him; the rock is clear in front of him+const s3_OX = 1060, s3_OXY = WATER + 50; // the ox where scenes 4 and 5 have him, facing Little Horse, water at his shins+const s3_TAP = { x: 700, y: 470, z: 1.2 }; // the tapping frame: tree to far bank, ground to crown+// the top of the tree's low branch at x (sets.js: 430 at x 262 rising to 412 at the tip, 440)+const s3_branchY = x => 412 + 18 * Math.max(0, (440 - x) / 178) ** 1.5 + 3;+// A cut-out turned over: from face a to face b over four frames on twos, never quite flat+const s3_turn = (q, t0, a, b) => { const k = Math.floor((q - t0) * FPS + 1e-6); return k < 0 ? a : k >= 4 ? b : [.5 * a, .12 * a, .12 * b, .5 * b][k]; };+const s3_bump = (q, t0, d) => q < t0 || q > t0 + d ? 0 : Math.sin(Math.PI * (q - t0) / d);++// A kingfisher, feet at (0, 0), facing right; bright against the branch and the crown.+function s3_bird(parent) {+ const g = mk('g', {}, parent), body = mk('g', {}, g);+ prop(body, `<g filter="url(#paper)"><path d="M-14,-15 L-38,-7 L-36,-1 L-12,-8 Z" fill="#1d6a90"/>+ <ellipse cx="0" cy="-16" rx="21" ry="13" fill="#2f95c0"/><path d="M-16,-12 C-8,-1 12,0 20,-12 C14,-4 -4,-2 -16,-12 Z" fill="#e8873a"/>+ <path d="M-12,-10 C-2,-3 12,-4 19,-13 L18,-9 C10,0 -6,0 -12,-10 Z" fill="#e8873a"/></g>+ <path d="M-3,-5 l-3,6 M5,-5 l1,6" stroke="#d2553a" stroke-width="3" stroke-linecap="round"/>`);+ const head = prop(body, `<g filter="url(#paper)"><circle cx="13" cy="-29" r="12" fill="#2f95c0"/><path d="M5,-24 C10,-18 20,-18 24,-24 C18,-21 10,-21 5,-24 Z" fill="#f6efe0"/>+ <ellipse cx="11" cy="-27" rx="5" ry="3" fill="#e8873a"/><path d="M22,-32 L46,-27 L22,-24 Z" fill="#2a1a10"/></g><circle cx="17" cy="-31" r="2.8" fill="#1a120c"/><circle cx="18" cy="-32" r="1" fill="#fff"/>`);+ const wing = prop(body, `<g filter="url(#paper)"><path d="M-14,-20 Q2,-30 14,-18 Q0,-9 -14,-20 Z" fill="#1d6a90"/><circle cx="-4" cy="-19" r="1.6" fill="#8fd3ea"/><circle cx="3" cy="-21" r="1.6" fill="#8fd3ea"/></g>`);+ return { g, pose(x, y, s, { dir = 1, hop = 0, peck = 0, look = 0, flap = 0 } = {}) {+ tf(g, `translate(${x.toFixed(1)},${(y - hop).toFixed(1)}) scale(${(s * dir).toFixed(3)},${s})`);+ tf(body, `rotate(${(peck * 30).toFixed(1)},4,-6)`);+ tf(head, `rotate(${(look * 14).toFixed(1)},12,-22)`);+ tf(wing, flap ? `rotate(${flap > 0 ? -55 : 15},-12,-20)` : '');+ } };+}+// Where the kingfisher is at q: every 2.8 s it hops to a new place along the branch (every third time a flutter+// with open wings), then pecks, looks about, or turns round.+function s3_birdAt(q) {+ const P = 2.8, k = Math.floor(q / P), u = q - k * P;+ const X = i => i <= 1 ? 398 : 372 + 60 * (.5 + .5 * jit(i, 61)); // the outer branch, over his back: clear of his head and of the butterfly's word+ const fly = k % 3 === 0, a = X(k - 1), b = X(k), dur = fly ? .7 : .35, moves = Math.abs(b - a) > 6;+ const dir = moves ? Math.sign(b - a) : k % 2 ? 1 : -1;+ if (moves && u < dur) {+ const w = u / dur;+ return { x: a + (b - a) * ease(w), hop: (fly ? 48 : 14) * Math.sin(Math.PI * w), dir, flap: fly ? onTwos(q) : 0 };+ }+ const turned = k % 3 === 2 && u > 1.9 ? -dir : dir;+ return { x: b, dir: turned, peck: k % 2 && u > 1.1 && u < 1.45 ? 1 : 0, look: u > 1.6 && u < 2.3 ? (k % 2 ? -1 : 1) : 0 };+}+// A butterfly seen from above, wings on twos.+function s3_butterfly(parent) {+ const g = mk('g', {}, parent), wings = [-1, 1].map(d => prop(g, `<g filter="url(#paper)"><path d="M0,0 C${12 * d},-34 ${44 * d},-32 ${38 * d},-6 C${34 * d},6 ${12 * d},4 0,0 Z" fill="#f08a24"/>+ <path d="M0,2 C${16 * d},8 ${30 * d},16 ${20 * d},30 C${10 * d},32 ${2 * d},18 0,2 Z" fill="#f5b23e"/><path d="M${30 * d},-24 C${40 * d},-22 ${42 * d},-12 ${38 * d},-6" stroke="#3b2a1e" stroke-width="4" fill="none"/>+ <circle cx="${24 * d}" cy="-16" r="4.5" fill="#f6efe0"/><circle cx="${34 * d}" cy="-12" r="2.6" fill="#f6efe0"/></g>`));+ prop(g, `<g filter="url(#paper)"><rect x="-3.5" y="-16" width="7" height="34" rx="3.5" fill="#3b2a1e"/></g><path d="M-2,-15 q-6,-12 -12,-14 M2,-15 q6,-12 12,-14" stroke="#3b2a1e" stroke-width="2" fill="none"/>`);+ return { g, pose(x, y, s, open, tilt) { tf(g, `translate(${x.toFixed(1)},${y.toFixed(1)}) rotate(${tilt.toFixed(1)}) scale(${s})`); wings.forEach(w => tf(w, `scale(${open},1)`)); } };+}+// just above the flower heads (its hit box clear of their middle), low enough that its long word (above it) stays+// under the kingfisher on the branch+const s3_flyAt = q => ({ x: 160 + 50 * Math.sin(.62 * q) + 10 * Math.sin(1.9 * q + 1), y: 612 + 6 * Math.sin(1.15 * q) + 3 * Math.sin(2.7 * q) });+// A clump of five paper flowers on short stems, big enough to find, base at (0, 0) on the bank top; each nods in the+// breeze on its own beat. Returns { g, pose(q) }.+const s3_FLOWERS = [[-44, -30, '#e0523f'], [-20, -44, '#f6efe0'], [4, -26, '#f2c140'], [26, -40, '#ee8fb0'], [48, -26, '#e0523f']];+function s3_flowers(parent, x, y) {+ const g = mk('g', { transform: `translate(${x} ${y})` }, parent);+ const petals = (cx, cy, c) => Array.from({ length: 5 }, (_, i) => { const a = i * Math.PI * 2 / 5 - Math.PI / 2; return `<circle cx="${(cx + 8 * Math.cos(a)).toFixed(1)}" cy="${(cy + 8 * Math.sin(a)).toFixed(1)}" r="7" fill="${c}"/>`; }).join('');+ const heads = s3_FLOWERS.map(([hx, hy, c], i) => prop(g, `<g filter="url(#paper)"><path d="M${hx * .4},8 Q${hx * .8},${hy * .5} ${hx},${hy}" stroke="#4f7c3e" stroke-width="4" fill="none"/>+ <path d="M${hx * .55},${hy * .35} q${i % 2 ? 14 : -14},-4 ${i % 2 ? 18 : -18},-14 q${i % 2 ? -10 : 10},2 ${i % 2 ? -18 : 18},14 Z" fill="#5d8c47"/>+ ${petals(hx, hy, c)}<circle cx="${hx}" cy="${hy}" r="5" fill="${c === '#f2c140' ? '#e0823a' : '#f2c140'}"/></g>`));+ return { g, pose(q) { heads.forEach((h, i) => tf(h, `rotate(${(3 * Math.sin(q * 1.4 + i * 1.3)).toFixed(1)},${(s3_FLOWERS[i][0] * .4).toFixed(1)},8)`)); } };+}++function scene3(p, D) {+ const cam = setCam(p, 'river');+ cam.to(s3_TAP, 3.4, 2.6); // in from the wide shot on "Who could help him?"+ const st = cam.stage;+ // transparent shapes over things painted into the set+ const spot = (word, x, y, w, h, extra = {}) => ({ g: mk('rect', { x, y, width: w, height: h, fill: 'transparent' }, st), word, ...extra });+ // the river: the open water between the bank and the ox's nose; its word goes below (to the frame's foot, over+ // the water), clear of both faces and of the counter's card at the right+ const river = spot('river', 664, 724, 236, 180, { side: 'below', at: () => [780, 780] });+ // the tree: its crown and the top of the trunk (a tap on Little Horse must not say "tree"); its word to the right,+ // in the sky above the branch, so it covers neither the kingfisher nor his ears+ const tree = spot('tree', 95, 185, 250, 260, { side: 'right', at: () => [230, 330] });+ const flowers = s3_flowers(st, 160, 704); // over the set's own small flowers, in front of them+ const flower = { g: flowers.g, word: 'flower', side: 'below', at: () => [160, 680] };+ const bird = s3_bird(st), fly = s3_butterfly(st);+ const ox = oxPuppet(st), lh = horsePuppet(st);+ let B = s3_birdAt(0), F = s3_flyAt(0);+ // the painted rock is left out: it lies behind his legs. Little Horse answers a tap on himself ("That's me!"), his+ // word below him, on the bank, clear of the kingfisher above.+ RIVER_THINGS = [river, tree, flower,+ { g: ox.g, word: 'ox', at: () => [900, 560] },+ { g: bird.g, word: 'bird', at: () => [B.x, 390] },+ { g: fly.g, word: 'butterfly', at: () => [F.x, F.y] },+ { g: lh.g, word: 'horse', clip: 'q-me', talk: true, side: 'below', at: () => [s3_LH + 100, 470] }];+ const thingAt = g => RIVER_THINGS.find(t => t.g === g)?.at();++ // Little Horse turns round once, for the scripted look round. While the page waits he stays facing the river (turned+ // round, his head would sit in front of the trunk and the kingfisher). He asks with his head up and his eyes to us,+ // searches about between asks (worried, not playing), and glances at each thing as it is found.+ const turns = [[1.75, -1], [3.0, 1]];+ const faceAt = q => { let a = 1, f = 1; for (const [t0, to] of turns) { if (t0 > q) break; f = s3_turn(q, t0, a, to); a = to; } return f; };+ let saw = null, sawQ = -1e9; // the thing just found (find.js) and when, on the beat clock++ stopClock(D, (q, f) => {+ cam.apply(q, f);+ const wait = q > D, g = typeof findSaw === 'function' ? findSaw() : null;+ if (g !== saw) { saw = g; if (g) sawQ = q; }+ const asking = wait && typeof FIND !== 'undefined' && !!FIND.saying;+ const turn = faceAt(q), breathe = Math.sin(q * 2.2), at = saw && thingAt(saw);+ // where he looks: worried at the water; up ahead; the tree, the flowers; then searching about+ let neck, look, nod = 0;+ const behind = at && at[0] < s3_LH; // behind him: the eyes go back and an ear turns to it+ if (at) { neck = at[1] < 500 ? -14 : at[1] > 640 ? 10 : 0; look = behind ? -.9 : .9; nod = 5 * s3_bump(q, sawQ + .3, .5); }+ else if (asking) { neck = -6; look = 0; nod = -5; } // to us: chin up, eyes in the middle+ else if (q < 1.45) { neck = 7; look = .5; }+ else if (q < 1.75) { neck = -4; look = 1; }+ else if (q < 2.6) { neck = -16; look = .8; }+ else if (q < 3.05) { neck = 9; look = .6; }+ else { const k = Math.floor((q - 3.05) / 1.7) % 4; neck = [-2, 9, -10, 4][k]; look = [1, .7, -.8, .3][k]; }+ const ear = asking ? -.2 : at ? (behind ? .7 : -.4) : .25 + (Math.floor(q * 10) % 37 < 2 ? .7 : 0); // a little back: worried+ lh.pose({ x: s3_LH, y: 700, s: 1.05, turn, sack: true, neck: neck + 1.2 * breathe, nod, look, ear,+ mouth: wait && typeof findMouth === 'function' ? findMouth() : 'X',+ bob: 1.2 * breathe, brow: at ? -.4 : -.6, // worried throughout; eased a little as each thing is found+ tail: 6 * Math.sin(q * 1.3) + 10 * s3_bump(q % 6.1, 4.8, .5),+ shut: blinking(q, [.9, 3.6, 6.2]) || (wait && !asking && q % 3.7 < 2 / FPS) }, f);+ // Uncle Ox chews in the river facing Little Horse, a short rest every 5 s; slow blinks, a tail flick. Found, he+ // stops chewing and lifts his head (find.js hops and shakes his g itself, on top of this pose).+ const rest = Math.min(.8, Math.max(0, q % 5 - 4.2)), chewing = 1.4 * (q - .8 * Math.floor(q / 5) - rest);+ const oxSeen = saw === ox.g ? q - sawQ : 1e9;+ ox.pose({ x: s3_OX, y: s3_OXY, s: 1.4, turn: -1, grass: true, chew: (rest > 0 && rest < .8) || oxSeen < 2 ? 0 : chewing,+ neck: 4 + 2 * Math.sin(q * .8) - 8 * s3_bump(oxSeen, 0, 2), nod: 1.5 * Math.sin(chewing * Math.PI * 2),+ ear: s3_bump(q % 4.4, 3.9, .35) * .8, tail: 8 * Math.sin(q * .9),+ shut: blinking(q, [2.3, 5.4]) || (wait && (q + 1.3) % 5.3 < 2 / FPS) }, f);+ B = s3_birdAt(q);+ bird.pose(B.x, s3_branchY(B.x), 1.15, B);+ F = s3_flyAt(q);+ flowers.pose(q);+ fly.pose(F.x, F.y, 1, [1, .65, .3, .65][Math.floor(q * FPS / 2) % 4], 12 * Math.sin(q * 1.3));+ });+}diff --git a/site/little-horse/ch01/scene4.js b/site/little-horse/ch01/scene4.jsnew file mode 100644index 0000000..ed8efb5--- /dev/null+++ b/site/little-horse/ch01/scene4.js@@ -0,0 +1,105 @@+/* scene4.js — Uncle Ox. The water is shallow FOR THE OX: he stands in it calmly chewing, and the insert on "shins" shows+ the waterline low on his lower leg. Little Horse runs over, asks, believes, and ends at the bank edge with his near+ fore hoof hanging over the water (scene 5 cuts in on Squirrel's shout).+ Staging: the ox faces Little Horse (turn -1) at x 1060 (scenes 2-5), his hooves 50 px under the waterline so it sits+ on his shins (the opaque water hides the hooves). Little Horse waits at the tree end of the bank (x 400, where scene 3+ leaves him), runs over to x 470 to talk, then runs to the bank lip (x 560) and lifts a hoof. */+'use strict';+const PRE4 = 1.0;+function scene4(p, D) {+ const W = (clip, t = 0) => clipAt('scene4', PRE4, clip, t); // beat-clock time of a word in the scene clip+ const OX = { x: 1060, y: WATER + 50, s: 1.4, turn: -1 }, LHS = 1.05;+ const cam = setCam(p, 'river', { x: 1070, y: 525, z: 1.9 });++ // ---- shots ----+ const tFace = W('n04', 3.4), tTwo = W('n04', 5.72), tAsk = W('h04', -.08), tSize = W('h04', 2.35), tOx = W('o04', -.65),+ tShin = W('o04', 3.2), tBack = W('o04', 5.0), tHop = W('o04', 6.0), tFollow = W('n04b', .45), tEdge = W('n04b', 2.15);+ const LH_CLOSE = { x: 515, y: 470, z: 3.3 }; // his head on the right third, the ox just out of frame+ cam.to({ z: 2.05 }, 0, tFace) // 1 the old ox chewing in the shallows+ .cut({ x: 850, y: 545, z: 3.2 }, tFace).to({ z: 3.4 }, tFace, tTwo - tFace) // 2 munching: the tuft in his mouth+ .cut({ x: 740, y: 560, z: 1.45 }, tTwo) // 3 two-shot: Little Horse runs over+ .cut(LH_CLOSE, tAsk) // 4 Little Horse's close-up, looking up: "Uncle Ox, please tell me."+ .cut({ x: 650, y: 515, z: 2.0 }, tSize) // 5 two-shot, the big ox and the small foal: "Can I wade across…?"+ .cut({ x: 925, y: 525, z: 2.8 }, tOx).to({ z: 2.95 }, tOx, tShin - tOx) // 6 the ox: a slow blink, then his answer+ .cut({ x: 1035, y: 682, z: 3.2 }, tShin).to({ z: 3.45 }, tShin, tBack - tShin) // 7 insert: water at his shins+ .cut(LH_CLOSE, tBack) // 8 the foal's ears perk: "You can get across."+ .cut({ x: 700, y: 545, z: 1.8 }, tHop) // 9 two-shot: a happy rear, then the run to the edge+ .to({ x: 680, y: 560, z: 1.95 }, tFollow, 1.4)+ .cut({ x: 720, y: 535, z: 2.25 }, tEdge).to({ z: 2.4 }, tEdge, D + .6 - tEdge); // 8 the hoof over the water, held+ cam.soft(tFace, true).soft(tTwo, false).soft(tAsk, true).soft(tSize, false).soft(tOx, true).soft(tHop, false).soft(tEdge, true);++ // ---- puppets ----+ const ox = oxPuppet(cam.stage), lh = horsePuppet(cam.stage);+ // ripples where the ox's front legs meet the water: they mark the waterline on the leg+ const ripple = () => prop(cam.world, `<g filter="url(#paper)"><path d="M-22,0 Q0,9 22,0" stroke="#d6eef3" stroke-width="3.5" fill="none" stroke-linecap="round"/></g>`);+ const rings = [ripple(), ripple(), ripple(), ripple()];+ // in the insert the set's opaque water gives way to a see-through band, so the legs under the waterline show+ let crest = 'M700,724'; for (let x = 700; x < 1400; x += 40) crest += ' q10,-5 20,0 q10,5 20,0';+ const band = prop(cam.world, `<g filter="url(#paperBig)"><path d="${crest} L1400,1060 L700,1060 Z" fill="#6fa6b8" fill-opacity=".7"/>+ ${Array.from({ length: 12 }, (_, i) => `<path d="M${720 + i * 56},${748 + (i % 4) * 18} q16,-5 32,0" stroke="#b8dde6" stroke-width="3" fill="none"/>`).join('')}</g>`);+ // the film's depth mark: a dashed waterline across his legs while the insert says "shins"+ const line = prop(cam.world, `<path d="M820,${WATER} H1270" stroke="#f2fbff" stroke-width="4" stroke-dasharray="14 9" stroke-linecap="round" fill="none"/>`);++ // the ox speaks only inside the phrases of his clip; between them he chews+ const talk = []; { let a = null; for (const [t, k] of MOUTHS.o04 || []) { if (k !== 'X' && a === null) a = t; if (k === 'X' && a !== null) { talk.push([W('o04', a), W('o04', t)]); a = null; } } }+ const speaking = q => talk.some(([a, b]) => q >= a - .05 && q < b);+ // a slow, heavy blink: the lids sink, shut, and lift again+ const heavy = (q, times) => Math.max(0, ...times.map(t => q < t ? span(q, t - .3, t) : 1 - span(q, t + .2, t + .5)));++ const lhRoute = [[0, 400], [W('n04', 6.3), 400], [W('n04', 7.6), 470], [W('n04b', .45), 470], [W('n04b', 1.75), 560]];+ const tLift = W('n04b', 2.65);++ sfx('scene4', 0, 'river', .5);+ sfx('scene4', 0, 'birds', .35);+ sfx('scene4', lhRoute[1][0], 'trot', .45);+ sfx('scene4', lhRoute[3][0], 'trot', .4);+ sfx('scene4', lhRoute[4][0], 'skid', .25);+ sfx('scene4', tShin + .1, 'slosh', .3);++ stopClock(D, (q, f) => {+ cam.apply(q, f);++ // Uncle Ox: chewing with heavy lids; notices the foal as he runs over and slowly lifts his head to him+ const om = lips(q, 'scene4', PRE4, 'o04'), talking = speaking(q);+ const raise = span(q, W('n04', 6.9), W('n04', 8.6)) - span(q, W('o04', 6.4), W('o04', 7.6)) * .7;+ const bl = heavy(q, [W('n04', 1.5), W('n04', 4.9), W('h04', 3.3), W('o04', -.35), W('o04', 2.55), W('n04b', 1.9), W('edge4', .7)]);+ const up = span(q, W('o04', -.3), W('o04', .3)) - span(q, W('o04', 6.2), W('o04', 7.2)); // head lifted to the foal while he speaks+ const gulp = span(q, W('o04', .55), W('o04', .75)) - span(q, W('o04', .75), W('o04', .95)); // swallows the tuft after "Mmm."+ ox.pose({ ...OX, grass: q < W('o04', .65),+ chew: talking ? 0 : q * .85 + .01, mouth: talking ? om : 'X', jaw: talking ? Math.min(1, (JAW[om] || 0) * 1.6) : undefined,+ neck: 12 - 15 * raise - 9 * up + 2 * Math.sin(q * .85 * Math.PI * 2) * (talking ? 0 : 1),+ nod: 5 * gulp + 6 * (span(q, W('o04', 1.6), W('o04', 2.0)) - span(q, W('o04', 2.3), W('o04', 2.8))) // "very shallow": a slow nod+ + 5 * (span(q, W('o04', 5.1), W('o04', 5.4)) - span(q, W('o04', 5.8), W('o04', 6.3))), // "You can get across."+ look: q < W('n04', 6.4) ? -.2 * Math.sin(q * .7) : .8,+ ear: .6 * (span(q, W('n04', 6.4), W('n04', 6.6)) - span(q, W('n04', 6.7), W('n04', 7.0))) + .15 * Math.sin(q * .9),+ brow: talking && q < W('o04', .6) ? -.25 : 0, // "Mmm." considering+ lid: .45 + .55 * bl, shut: bl > .97,+ tail: 10 * Math.sin(q * 1.3), bob: 1.2 * Math.sin(q * 1.4) }, f);+ const insert = between(q, tShin, tBack);+ vis(line, insert); vis(band, insert); cam.show('water', !insert);+ const legs = [ox.at('nfHoof'), ox.at('ffHoof')];+ rings.forEach((g, i) => {+ const u = (q / 1.6 + i * .5) % 1, [x] = legs[i >> 1];+ tf(g, `translate(${(x + 4).toFixed(1)},${WATER + 1}) scale(${(1 + .8 * u).toFixed(3)},1)`);+ g.setAttribute('opacity', (Math.min(1, u * 4) * (1 - u) * .9).toFixed(2));+ });++ // Little Horse+ const r = route(q, lhRoute, LHS), hm = lips(q, 'scene4', PRE4, 'h04');+ const asking = between(q, W('h04'), W('o04')), oxTalks = between(q, W('o04'), W('n04b'));+ const glance = span(q, W('h04', 3.25), W('h04', 3.45)) - span(q, W('h04', 3.85), W('h04', 4.15)); // "this river?"+ const hop = span(q, W('o04', 6.1), W('o04', 6.3)) - span(q, W('o04', 6.55), W('o04', 6.9)); // happy little rear+ const lift = span(q, tLift, tLift + .55), look = span(q, W('n04b', 2.0), W('n04b', 2.5));+ const sway = .5 + .5 * Math.sin(q * 2.2);+ lh.pose({ x: r.x, y: 700, s: LHS, d: r.d, stand: r.stand, gait: 'trot', sack: true, mouth: hm,+ neck: (asking ? -5 : 0) + 10 * glance + 12 * look,+ nod: (asking ? -9 : 0) + 8 * glance + 10 * look - 5 * hop,+ tilt: -7 * hop,+ legs: hop > 0 ? { nf: [6 * hop, 16 * hop], ff: [4 * hop, 12 * hop] } : lift > 0 ? { nf: [16 + 20 * lift, 26 * lift + .8 * lift * Math.sin(q * 9)] } : {},+ ear: q < W('n04', 6.0) ? 0 : oxTalks ? -.4 - .6 * span(q, W('o04', 5.1), W('o04', 5.3)) : asking ? -.3 : q > W('n04b') ? -.8 : -.5,+ brow: asking ? -.6 : oxTalks ? -.35 + .15 * span(q, W('o04', 5.1), W('o04', 5.5)) : -.25 * look, // negative: polite, worried+ look: q < W('n04b', 2.0) ? .7 : .2,+ shut: blinking(q, [3, W('n04', 7.95), W('h04', 2.1), W('o04', 1.2), W('o04', 3.6), W('o04', 6.6), W('n04b', 2.3), W('edge4', .5), W('edge4', 1.5)]),+ tail: 8 * Math.sin(q * 2.1) + (r.stand < 1 ? 14 : 0), bob: 1.2 * Math.sin(q * 2.5) - (q > tLift ? 1.5 * sway : 0) }, f);+ });+}diff --git a/site/little-horse/ch01/scene5.js b/site/little-horse/ch01/scene5.jsnew file mode 100644index 0000000..02b49fc--- /dev/null+++ b/site/little-horse/ch01/scene5.js@@ -0,0 +1,240 @@+/* scene5.js — Squirrel. The shout from the tree; on "Stop!" Little Horse has turned to face him (on the cut) and asks,+ looking down at him; "Deep as anything!" is shown in a torn-paper picture over Squirrel's head (the river cut side-on,+ Squirrel at his size on the bed, the water far over his head); "and drowned!"; he turns back to the river (wide) and+ pulls back his hoof; the look back and forth; home. Beat clock = PRE5 + the scene clip's word times+ (content/little-horse/ch01/narration.en.words.txt). Uncle Ox stands where scene 4 left him (x 1060, facing left,+ water at his shins). Every shot is at zoom 3.5 or less (Firefox). */+'use strict';+const PRE5 = 1.6;++const s5_T = t => PRE5 + t; // scene-clip time to beat clock+// The squirrel's leap: from the branch seat to the rock's left shoulder (clear of the horse's tail).+const s5_FROM = [380, 412], s5_TO = [438, 663], s5_UP = .5, s5_LAND = 1.2;+const s5_LIP = [658, 719]; // the bank's lip, where he waits while Little Horse goes+const s5_FACE = 575; // Little Horse facing Squirrel (left): chest clear of him+const s5_VIG = [268, 398]; // the torn-paper picture, over Squirrel's head, left of the horse's face+const s5_V = {+ wide: { x: 600, y: 560, z: 1.4 }, // tree, branch, rock, the edge, the ox+ sqIn: { x: 490, y: 545, z: 2.9 }, // Squirrel lands and shouts; Little Horse whole, his face hearing it+ lhIn: { x: 470, y: 530, z: 2.8 }, // "Stop!": Little Horse has turned to him, looking down; Squirrel below+ sqCU: { x: 455, y: 548, z: 3.5 }, // Squirrel's close-up on the rock, the horse's face over him+ sqR: { x: 400, y: 600, z: 3.5 }, // Squirrel on the rock when the horse faces the river again+ twoB: { x: 400, y: 520, z: 2.2 }, // the two-shot from Squirrel's side: tiny squirrel, the huge horse's face over him+ vigIn: { x: 332, y: 420, z: 3.0 }, // into the picture, the horse's face beside it+ lhL: { x: 470, y: 455, z: 3.5 }, // Little Horse's close-up, facing left+ sqTight: { x: 446, y: 658, z: 3.5 }, // Squirrel's close-up for his line: face and paw centred, the tear readable (a cut, no zoom)+ two: { x: 590, y: 560, z: 2.0 }, // horse, squirrel and the ox's head+ edge: { x: 560, y: 662, z: 3.5 }, // the hoof at the edge+ lhCU: { x: 696, y: 490, z: 3.5 }, // Little Horse's close-up, facing the river+ ox: { x: 840, y: 530, z: 2.8 }, // Uncle Ox chewing, Little Horse's face beside him+ end: { x: 600, y: 560, z: 1.9 }, // the bank: he leaves left; Squirrel and the ox stay+};++/* The torn-paper picture: a sheet torn w × h around (0, 0), the same every time; inside it, the river cut side-on with+ the bed showing, drawn at the film's scale but deep (as scene 6's thought bubble draws it), so Squirrel at his own+ size stands on the bed with the water far over his head. */+function s5_torn(w, h, seed) {+ const pts = [], n = 9;+ const side = (x0, y0, x1, y1, k) => { for (let i = 0; i < n; i++) { const u = i / n; pts.push([x0 + (x1 - x0) * u + 4 * jit(seed, k + i), y0 + (y1 - y0) * u + 4 * jit(seed, k + 40 + i)]); } };+ side(-w / 2, -h / 2, w / 2, -h / 2, 0); side(w / 2, -h / 2, w / 2, h / 2, 100); side(w / 2, h / 2, -w / 2, h / 2, 200); side(-w / 2, h / 2, -w / 2, -h / 2, 300);+ return 'M' + pts.map(p => p.map(v => v.toFixed(1)).join(',')).join(' L') + ' Z';+}+const s5_SURF = -52, s5_BED = 80; // in the picture: the waterline and the bed under him+function s5_picture(stage) {+ const W = 250, H = 214, outer = mk('g', {}, stage), g = mk('g', {}, outer);+ const wave = Array.from({ length: 8 }, (_, i) => `Q${-160 + i * 40 + 10},${s5_SURF - 4} ${-160 + i * 40 + 20},${s5_SURF} T${-160 + i * 40 + 40},${s5_SURF}`).join(' ');+ g.innerHTML = `<clipPath id="s5clip"><path d="${s5_torn(W - 14, H - 14, 6)}"/></clipPath>+ <g filter="url(#paper)"><path d="${s5_torn(W, H, 5)}" fill="#fbf6ea"/></g>+ <g clip-path="url(#s5clip)">+ <g filter="url(#paper)"><rect x="-140" y="-120" width="280" height="240" fill="#dcecef"/>+ <path d="M-140,${s5_SURF - 14} C-60,${s5_SURF - 26} 40,${s5_SURF - 8} 140,${s5_SURF - 20} L140,${s5_SURF} L-140,${s5_SURF} Z" fill="#b8cfa4"/>+ <rect x="-140" y="${s5_SURF}" width="280" height="200" fill="#b9dcea"/></g>+ <g class="s5sq"></g>+ <g class="s5wave"><g filter="url(#paper)"><path d="M-160,${s5_SURF} ${wave} L160,200 L-160,200 Z" fill="#5f9fc0" opacity=".32"/></g></g>+ <g filter="url(#paper)"><path d="M-140,${s5_BED + 6} C-80,${s5_BED - 2} -30,${s5_BED + 2} 30,${s5_BED} C80,${s5_BED - 2} 110,${s5_BED + 4} 140,${s5_BED + 2} L140,140 L-140,140 Z" fill="#c9ad74"/>+ <ellipse cx="-88" cy="${s5_BED + 4}" rx="12" ry="6" fill="#9a958c"/><ellipse cx="74" cy="${s5_BED + 3}" rx="9" ry="5" fill="#857f74"/></g>+ <g class="s5line"><path d="M-160,${s5_SURF} ${wave}" stroke="#ffffff" stroke-width="4" fill="none"/></g>+ <g class="s5air"></g>+ </g>`;+ const sq = squirrelPuppet(g.querySelector('.s5sq'));+ const wv = g.querySelector('.s5wave'), ln = g.querySelector('.s5line'), air = g.querySelector('.s5air');+ const bubs = Array.from({ length: 3 }, (_, i) => mk('circle', { r: 3 + i, fill: '#f4fbff', 'fill-opacity': .4, stroke: '#ffffff', 'stroke-width': 2 }, air));+ bakeAll(g);+ // two small puffs from his head up to the picture+ const trail = [[414, 574, 5], [374, 542, 7]].map(([x, y, r]) =>+ prop(stage, `<g filter="url(#paper)"><circle cx="${x}" cy="${y}" r="${r + 2.5}" fill="#8a6a46"/><circle cx="${x}" cy="${y}" r="${r}" fill="#fbf6ea"/></g>`));+ return (q, f, t0, t1) => {+ trail.forEach((t, i) => vis(t, q >= t0 - .2 + i * .08 && q < t1));+ const sc = q < t0 || q >= t1 ? 0 : [.4, 1.12, .95, 1][Math.min(3, Math.floor((q - t0) * FPS + 1e-6))];+ vis(outer, sc > 0);+ if (!sc) return;+ tf(outer, `translate(${s5_VIG[0] + jit(f, 61) * .4},${s5_VIG[1] + jit(f, 62) * .4}) rotate(-2) scale(${sc})`);+ const t = q - t0;+ // Squirrel on the bed, paddling gently, cheeks puffed, holding his breath+ sq.pose({ x: 4, y: s5_BED, s: .6, paw: -60 + 25 * Math.sin(t * 6), pawF: -40 + 25 * Math.sin(t * 6 + 1.6), brow: -.8, ear: -.3,+ tail: 10 * Math.sin(t * 3), tail2: 10 * Math.sin(t * 3 + 1), hop: 3 + 3 * Math.sin(t * 4), headR: -10, mouth: 'B', shut: blinking(q, [t0 + .9]) }, f);+ const dx = (-(t * 24) % 40).toFixed(1);+ tf(wv, `translate(${dx},0)`); tf(ln, `translate(${dx},0)`);+ bubs.forEach((b, i) => { // air bubbles from his mouth up to the surface+ const v = ((t / 1.4 + i / 3) % 1 + 1) % 1, y0 = s5_BED - 52;+ b.setAttribute('cx', (26 + 5 * Math.sin(v * 9 + i * 2)).toFixed(1)); b.setAttribute('cy', (y0 - v * (y0 - s5_SURF)).toFixed(1));+ b.setAttribute('opacity', v < .92 ? '1' : '0');+ });+ };+}++function scene5(p, D) {+ const cam = setCam(p, 'river', s5_V.wide), V = s5_V, T = s5_T;+ const tPic = T(7.0), tPicOff = T(8.85), tTurnBack = T(13.35);+ const shots = [+ [s5_LAND, V.sqIn], [T(1.24), V.lhIn], [T(2.9), V.sqCU], [T(4.4), V.twoB], [T(7.3), V.vigIn], [tPicOff, V.sqTight],+ [T(11.9), V.lhL], [T(12.35), V.sqTight], [T(13.29), V.two], [T(14.25), V.edge], [T(15.75), V.two], [T(16.6), V.lhCU],+ [T(17.0), V.ox], [T(17.55), V.lhCU], [T(17.95), V.sqR], [T(18.5), V.lhCU], [T(20.3), V.end],+ ];+ for (const [t, v] of shots) cam.cut(v, t);+ cam.to({ y: 470 }, tPic - .15, .3); // up a little as the picture opens over him+ cam.to({ x: 560 }, T(20.5), 3.4); // the bank, drifting with him a little+ for (const [t, on] of [[s5_LAND, true], [T(4.4), false], [tPicOff, true], [T(13.29), false], [T(16.6), true], [T(20.3), false]]) cam.soft(t, on);++ const ox = oxPuppet(cam.stage), lh = horsePuppet(cam.stage), sq = squirrelPuppet(cam.stage); // Squirrel nearest+ // a rustle in the tree: leaves shaken loose as he goes, falling left of his path+ const leaves = [[330, 430, .2], [362, 420, .35], [312, 440, .55], [350, 446, .7]].map(([x, y, t0], i) => ({ x, y, t0, i,+ g: prop(cam.stage, `<g filter="url(#paper)"><path d="M0,-9 C7,-6 8,4 0,9 C-8,4 -7,-6 0,-9 Z" fill="${['#71a056', '#83b264', '#5f8e48', '#94bb7c'][i]}"/><path d="M0,-8 L0,8" stroke="#4f7c3e" stroke-width="1.6"/></g>`) }));+ const picture = s5_picture(cam.stage);++ sfx('scene5', 0, 'river', .45); sfx('scene5', 0, 'birds', .35);+ sfx('scene5', .15, 'squeak', .35); sfx('scene5', s5_UP, 'whoosh', .7); sfx('scene5', s5_LAND, 'hop', .7);+ sfx('scene5', T(1.24), 'sting', .35); // "Stop!"+ sfx('scene5', tPic, 'pop', .4); // the picture opens+ sfx('scene5', T(15.3), 'hoof', .45); // the hoof set back down on the bank+ [[T(21.1), .22], [T(21.65), .22], [T(22.2), .2], [T(22.75), .15], [T(23.3), .1]].forEach(([t, v]) => sfx('scene5', t, 'hoof', v)); // slow steps away+ sfx('scene5', T(23.65), 'hop', .3); // Squirrel back up on his rock++ const lhBlinks = [0.9, T(.5), T(4.4), T(7.9), T(9.9), T(12.2), T(15.9), T(17.4), T(19.0), T(21.6), T(23.4)];+ const sqBlinks = [T(4.9), T(6.4), T(9.3), T(15.6), T(18.4), T(19.8), T(22.0), T(23.6)];+ const oxBlinks = [1.7, T(3.3), T(8.8), T(13.0), T(16.9), T(20.9), T(24.0)];++ stopClock(D, (q, f) => {+ cam.apply(q, f);+ const st = q - PRE5; // scene-clip time++ /* ---------- Uncle Ox: in the shallows facing the bank (x 1060), unbothered ---------- */+ // As scene 4 left him: head lifted toward the foal, no grass, chewing. Mid-scene he dips for a fresh tuft and munches on.+ const dip = span(q, T(14.6), T(15.2)) - span(q, T(15.5), T(16.1));+ ox.pose({ x: 1060, y: WATER + 50, s: 1.4, turn: -1, chew: q * .85 + .01, grass: q > T(15.4),+ neck: 7.5 + 22 * dip + 2 * Math.sin(q * .85 * Math.PI * 2), nod: 6 * dip,+ lid: .45 + .1 * span(q, T(17), T(17.4)), look: q < T(4) ? .8 - .5 * span(q, T(2), T(4)) : between(q, T(17.0), T(17.55)) ? .6 : .3,+ ear: .3 * Math.sin(q * 1.3) ** 8, tail: 12 * Math.sin(q * 1.6), shut: blinking(q, oxBlinks) }, f);++ /* ---------- Squirrel ---------- */+ let sx = s5_FROM[0], sy = s5_FROM[1], stretch = 0, lean = 0, tail = 4 * Math.sin(q * 3.1), tail2 = 6 * Math.sin(q * 2.3 + 1);+ let paw = 0, pawF = 0, headR = 0, brow = 0, ear = 0, hop = 0, sturn = 1, tear = false;+ if (q < s5_UP) { // crouch on the branch, ready+ const c = span(q, .1, s5_UP);+ stretch = -.7 * c; lean = 14 * c; tail = -10 * c + 4 * Math.sin(q * 9); headR = 6 * c;+ } else if (q < s5_LAND) { // the leap: an arc, stretched out, tail streaming+ const u = (q - s5_UP) / (s5_LAND - s5_UP);+ sx = s5_FROM[0] + (s5_TO[0] - s5_FROM[0]) * u;+ sy = s5_FROM[1] + (s5_TO[1] - s5_FROM[1]) * u - 520 * u * (1 - u);+ stretch = 1; lean = 28 - 30 * u; tail = -48 + 20 * u; tail2 = -12; paw = -70; pawF = -60; headR = -8 + 16 * u;+ } else {+ sx = s5_TO[0]; sy = s5_TO[1];+ const k = (q - s5_LAND) * FPS; // landing squash, then up+ stretch = k < 2 ? -1 : k < 4 ? .35 : 0;+ if (k < 4) { tail = -20 + 8 * k; lean = 10; }+ }+ const up = st > 1.3 && st < 13.3 ? -14 : 0; // while the horse faces him, his face is high above: look up+ if (st > 0 && st < 4.4) { // "Little Horse! Stop! Don't cross! You'll drown!"+ paw = st < 1.24 ? -95 - 15 * Math.sin(st * 14) : st < 2.9 ? -125 : -150;+ pawF = st < 1.24 ? -40 : st < 2.9 ? -115 : -150;+ lean = st < 2.9 ? 8 : 4; brow = -.7; ear = -1; headR = up;+ hop = (between(st, 1.24, 1.6) ? 10 * Math.sin(Math.PI * (st - 1.24) / .36) : 0) + (between(st, 1.9, 2.2) ? 6 * Math.sin(Math.PI * (st - 1.9) / .3) : 0);+ tail2 = 10 * Math.sin(st * 8);+ } else if (st >= 4.4 && st < 6.78) { // listening to the question, looking up at him+ paw = tween(q, T(4.4), .3, -150, -20); pawF = tween(q, T(4.4), .3, -150, -10);+ headR = -18 + 4 * span(q, T(5.4), T(5.8)); brow = -.4; ear = -.4;+ } else if (st >= 6.78 && st < 11.42) { // "Deep as anything!" (the picture) … "a friend of mine fell into this river,"+ const big = st < 7.2, pic = st >= 7.2 && st < 8.85;+ paw = big ? -80 - 12 * Math.sin(st * 6) : pic ? -150 : st < 10.3 ? -40 : tween(q, T(10.3), .4, -40, -65); // arms wide, points up at the picture, then at the river+ pawF = big ? -60 + 15 * Math.sin(st * 6 + 1) : pic ? -30 : -10;+ lean = big ? 10 : pic ? 2 : 8 + 6 * span(q, T(10.3), T(10.8));+ hop = big && between(st, 6.8, 7.2) ? 9 * Math.sin(Math.PI * (st - 6.8) / .4) : 0;+ tail = big ? -10 : tail; tail2 = big ? 11 * Math.sin(st * 11) : tail2; // bristling+ brow = big || pic ? -.8 : -.6 - .3 * span(q, T(10.6), T(11.3)); ear = big ? -1 : 0;+ headR = big ? -12 : pic ? -22 : tween(q, T(9.6), .6, -12, 6);+ } else if (st >= 11.42) { // "and drowned!": the tear, the wipe, the tail falls+ const s = span(q, T(11.42), T(12.3));+ tear = st > 11.95 && st < 13.25; ear = .9 * s; brow = -1; headR = 6 + 10 * s; lean = 14 + 6 * s;+ tail = -12 - 26 * s; tail2 = 10 * s;+ const w = st - 12.6; // wipes his eye with his paw (the tear shows between strokes)+ paw = w < 0 ? -40 : w < .65 ? -100 - 18 * Math.max(0, Math.sin(w * 12)) : w < .9 ? tween(q, T(13.25), .25, -100, -20) : -20;+ pawF = -10;+ if (st > 15.8) { headR = 16 - 22 * span(q, T(15.8), T(16.2)); } // looks up at the horse again+ if (between(st, 17.95, 18.6)) { headR = -2 + 14 * Math.sin((st - 17.95) * 14) * (1 - span(q, T(18.4), T(18.6))); ear = -.3; } // nods hard: deep!+ if (st >= 18.7) { // out of his way (off camera, during the sigh): down to the lip; back on the rock when he has gone+ const a = span(q, T(18.7), T(18.95)), b = span(q, T(18.95), T(19.5));+ const c = span(q, T(22.7), T(23.4)), d = span(q, T(23.4), T(23.65));+ const gx = b > 0 ? 500 + (s5_LIP[0] - 500) * b : 438 + 62 * a;+ sx = c > 0 ? (d > 0 ? 500 - 62 * d : s5_LIP[0] - (s5_LIP[0] - 500) * c) : gx;+ const ground = x => x < 600 ? 700 : RIVER_BED(x);+ sy = d > 0 ? 700 - 37 * d - 40 * Math.sin(Math.PI * d) : c > 0 ? ground(sx) : b > 0 ? ground(sx) : 663 + 37 * a - 30 * Math.sin(Math.PI * a);+ const run = (between(q, T(18.95), T(19.5)) || between(q, T(22.7), T(23.4)));+ hop = run ? 7 * Math.abs(Math.sin(q * 18)) : 0; lean = run ? 18 : 6; stretch = run ? .3 : 0;+ sturn = q < T(20.7) ? 1 : 1 - 2 * span(q, T(20.7), T(20.95)); // turns to watch him go+ headR = 2; tail = -24 + 8 * Math.sin(q * 2); tail2 = 6 * Math.sin(q * 2.6); paw = -20; pawF = -10; brow = -.5; ear = .3;+ }+ if (st < 13.3) headR += up * .6;+ }+ tail2 = Math.max(-12, Math.min(12, tail2)); // keep the plume's two pieces joined at the pin+ sq.pose({ x: sx, y: sy, s: .6, turn: sturn, stretch, lean, tail, tail2, paw, pawF, headR, brow, ear, hop, tear,+ mouth: lips(q, 'scene5', PRE5, 's05', 's05b'), shut: blinking(q, sqBlinks) }, f);++ /* ---------- the leaves, the picture ---------- */+ for (const L of leaves) {+ const u = q - L.t0, on = u > 0 && u < 3;+ vis(L.g, on);+ if (on) tf(L.g, `translate(${(L.x + 14 * Math.sin(u * 3 + L.i) - 16 * u).toFixed(1)},${(L.y + 70 * u).toFixed(1)}) rotate(${(40 * Math.sin(u * 4 + L.i * 2)).toFixed(0)})`);+ }+ picture(q, f, tPic, tPicOff);++ /* ---------- Little Horse (brows negative = worried) ---------- */+ // As scene 4 left him: x 560 facing the river, near fore hoof over the water, looking down at it.+ const o = { x: 560, y: 700, s: 1.05, turn: 1, sack: true, neck: 12, nod: 10, look: .2, brow: -.25, ear: -.8,+ tail: 4 * Math.sin(q * 1.4) - 38 * span(q, s5_LAND, s5_LAND + .3), lid: 0 }; // the thump behind him: the tail clamps+ let nf = [36, 26];+ if (q > T(0) && q < T(1.24)) o.ear = -.8 + .5 * span(q, T(0), T(.3)); // an ear swivels back to the voice+ if (q >= T(1.24) && q < tTurnBack) {+ // "Stop!": on the cut he has turned round to face Squirrel, and looks down at him+ Object.assign(o, { x: s5_FACE, y: 702, turn: -1, neck: 4, nod: 12, look: .5, brow: -.8, ear: -.4, tail: -10 + 3 * Math.sin(q * 1.4) });+ nf = null;+ if (q < T(1.6)) o.tilt = -3 * (1 - span(q, T(1.24), T(1.6))); // still rocking from the turn+ if (q > T(2.9) && q < T(4.4)) { o.brow = -1; o.ear = .4; o.nod = 12 + 5 * (span(q, T(3.1), T(3.25)) - span(q, T(3.3), T(3.5))); } // "drown!": a gulp+ if (between(q, tPic, tPicOff)) { o.neck = tween(q, tPic, .3, 4, -8); o.nod = tween(q, tPic, .3, 12, -2); o.look = .9; o.brow = -1; o.ear = -.6; } // he sees the picture+ if (q >= tPicOff) { o.neck = -14; o.nod = -8; o.look = .5; o.ear = .3; o.brow = -1; } // listening, head up (out of Squirrel's close-up)+ if (q >= T(11.9) && q < T(12.35)) { o.nod = -8 + 14 * span(q, T(11.95), T(12.1)); o.ear = .9; o.look = .7; } // "drowned": he gulps, ears flat+ } else if (q >= tTurnBack) {+ // turns back to the river in the wide shot, puts a hoof out over the water … and "pulled back his hoof"+ const k = span(q, tTurnBack, tTurnBack + .35);+ Object.assign(o, { x: s5_FACE - 15 * k, turn: -1 + 2 * k, brow: -1, ear: .6, neck: 10, nod: 8, look: .5 });+ const out = span(q, T(13.75), T(14.1)), back = span(q, T(14.6), T(15.3));+ nf = back > 0 ? [36 - 44 * back, 26 * (1 - back) + 10 * Math.sin(Math.PI * back)] : [36 * out, 26 * out];+ }+ if (q >= T(16.6)) { // "He didn't know what to do": to the ox, to Squirrel, ears sinking+ const back = q >= T(17.55);+ Object.assign(o, { look: back ? -1 : 1, neck: back ? -10 : -2, nod: back ? 10 : -6, brow: -1, ear: .2 + .5 * span(q, T(16.6), T(18.4)) });+ nf = [-8, 0];+ }+ if (q >= T(18.5)) { // "Oh." — the sigh; "I'd better go home and ask Mama."+ const s = span(q, T(18.6), T(19.4));+ Object.assign(o, { look: -1 + 1.3 * s, neck: -6 + 28 * s, ear: .7 + .3 * s, lid: .3 * s, brow: -1 + .2 * s, nod: 8 - 4 * s,+ tilt: 1.5 * Math.sin(Math.PI * span(q, T(18.6), T(19.3))) }); // the breath out+ }+ if (q >= T(20.3)) { // turns round in the wide shot and walks off left, head low+ o.turn = 1 - 2 * span(q, T(20.5), T(20.85));+ const r = route(q, [[T(20.9), 560], [T(24.6), -140]], 1.05);+ Object.assign(o, { x: r.x, d: r.d, stand: r.stand, gait: 'walk', neck: 44, nod: 6, ear: 1, lid: .3, look: .3, brow: -.8, tail: -6, tilt: 0 }); // head under the branch+ nf = null;+ }+ lh.pose({ ...o, legs: nf ? { nf } : {}, mouth: lips(q, 'scene5', PRE5, 'h05', 'h05b'), shut: blinking(q, lhBlinks) }, f);+ });+}diff --git a/site/little-horse/ch01/scene6.js b/site/little-horse/ch01/scene6.jsnew file mode 100644index 0000000..d2d009d--- /dev/null+++ b/site/little-horse/ch01/scene6.js@@ -0,0 +1,277 @@+/* scene6.js — Ask Mama (the stable). Little Horse walks home slowly, head low, the sack still on his back; Mother comes+ out to meet him. "Why, you're back already?" — his embarrassed "I couldn't get across" — her "Isn't it very+ shallow?" — his eager "Uncle Ox said so too" (a torn-paper memory over his head: the ox chewing in the water), then+ "But Squirrel said it's very deep" (a second one: Squirrel shouting, a tear on "drowned") — her gentle question,+ pushed in on "Did you think about what they said?" — his small "No... I didn't." She nuzzles him: "Use your own+ head": a paper thought bubble opens over him with the river cut side-on, one waterline across all three: on the+ shallow shelf the ox (water on his shins), the foal at his knees with a "?", Squirrel in the deep part under the+ water. The camera walks along the waterline from the ox to the foal to Squirrel; on "Go" the "?" turns "!" and his+ eyes light; the bubble pops, he nods; on the cut he has turned for the road and trots off right. Mother watches+ him go. Times are the beat clock (storyboard, scene 6). */+'use strict';+const PRE6 = 3.6;+const s6_c = c => PRE6 + c; // clip time (narration.en.words.txt) -> beat clock++/* ---------- timeline (beat clock) ---------- */+const S6 = {+ stop: 3.9, // he stops in front of her+ yes: s6_c(9.77), uncle: s6_c(10.69), but: s6_c(12.55), squirrel: s6_c(12.75), drown: s6_c(15.51), it: s6_c(16.21),+ deep: s6_c(18.54), shallow: s6_c(19.2), think: s6_c(20.34),+ hole: s6_c(22.39), no: s6_c(23.19), didnt: s6_c(24.23),+ child: s6_c(25.38), use: s6_c(29.48), tryIt: s6_c(30.44), self: s6_c(31.32),+ go: s6_c(32.6), see: s6_c(32.84), know: s6_c(33.68),+ bubOn: s6_c(29.48) + .22, // the puffs rise on "Use", the bubble is open on "head"+ bubOff: s6_c(32.84) + .3, // after "Go and see": the bubble pops+ turn: s6_c(34.26) + .78, // the cut to the wide: he has turned for the road+ run: s6_c(34.26) + .9, // and trots off right+};+S6.vig1 = S6.uncle - .05; S6.vig2 = S6.squirrel - .05; S6.vigOff = S6.it + .55;++/* ---------- sounds ---------- */+sfx('scene6', 0, 'birds', .5);+// hooves: one soft knock every half stride of the walk (d in the puppet's own units, a stride is 74)+function s6_steps(keys, s, t0, t1, vol) {+ let last = null;+ for (let f = Math.round(t0 * FPS); f <= t1 * FPS; f++) {+ const q = f / FPS, r = route(q, keys, s), n = Math.floor(Math.abs(r.x - keys[0][1]) / s / 37);+ if (last !== null && n > last) sfx('scene6', +q.toFixed(3), 'hoof', vol);+ last = n;+ }+}+const S6_LHK = [[-2, 1800], [S6.stop, 1080]];+const S6_MAK = [[1.3, 560], [3.5, 690], [s6_c(25.5), 690], [s6_c(26.4), 765], [S6.bubOn + .1, 765], [S6.bubOn + .9, 715]];+s6_steps(S6_LHK, 1.05, 0, S6.stop, .28);+s6_steps(S6_MAK, 1.3, 1.3, S6.bubOn + 1, .2);+sfx('scene6', S6.bubOn + .5, 'hoof', .2); // her half step back (s6_steps counts only forward steps)+sfx('scene6', S6.vig1, 'pop', .45);+sfx('scene6', S6.vig2, 'pop', .45);+sfx('scene6', S6.vigOff, 'pop', .35);+sfx('scene6', S6.bubOn, 'pop', .7);+sfx('scene6', S6.go, 'chime', .35);+sfx('scene6', S6.bubOff, 'pop', .7);+sfx('scene6', S6.run, 'trot', .5);++/* ---------- little helpers ---------- */+// eased keys [[t, v], …]: holds the first and last values, eases between neighbours+function s6_k(q, ks) {+ if (q <= ks[0][0]) return ks[0][1];+ for (let i = 1; i < ks.length; i++) if (q < ks[i][0]) return ks[i - 1][1] + (ks[i][1] - ks[i - 1][1]) * span(q, ks[i - 1][0], ks[i][0]);+ return ks[ks.length - 1][1];+}+const s6_bump = (q, t, dur, amp) => q > t && q < t + dur ? amp * Math.sin(Math.PI * (q - t) / dur) : 0;+// a paper piece popping open at t0 (a few frames of overshoot) and shut at t1 (one big frame, then gone)+const s6_pop = (q, t0, t1) => q < t0 || q >= t1 + 1 / FPS ? 0 : q >= t1 ? 1.1 : [.4, 1.12, .95, 1][Math.min(3, Math.floor((q - t0) * FPS + 1e-6))];++/* ---------- the memories: torn-paper vignettes over his head while he tells it ---------- */+// A torn sheet w × h around (0, 0): its edges wander a little, the same every time.+function s6_torn(w, h, seed) {+ const pts = [], n = 9;+ const side = (x0, y0, x1, y1, k) => { for (let i = 0; i < n; i++) { const u = i / n; pts.push([x0 + (x1 - x0) * u + 4 * jit(seed, k + i), y0 + (y1 - y0) * u + 4 * jit(seed, k + 40 + i)]); } };+ side(-w / 2, -h / 2, w / 2, -h / 2, 0); side(w / 2, -h / 2, w / 2, h / 2, 100); side(w / 2, h / 2, -w / 2, h / 2, 200); side(-w / 2, h / 2, -w / 2, -h / 2, 300);+ return 'M' + pts.map(p => p.map(v => v.toFixed(1)).join(',')).join(' L') + ' Z';+}+function s6_vignette(stage, x, y, w, h, seed, bg) {+ const outer = mk('g', {}, stage), g = mk('g', {}, outer), id = 's6v' + seed;+ g.innerHTML = `<clipPath id="${id}"><path d="${s6_torn(w - 14, h - 14, seed + 1)}"/></clipPath>+ <g filter="url(#paper)"><path d="${s6_torn(w, h, seed)}" fill="#fbf6ea"/></g>+ <g clip-path="url(#${id})"><g filter="url(#paper)">${bg}</g><g class="in"></g><g class="front"></g></g>`;+ bakeAll(g);+ return { outer, inner: g.querySelector('.in'), front: g.querySelector('.front'),+ place(q, f, t0, t1) { const sc = s6_pop(q, t0, t1); vis(outer, sc > 0); tf(outer, `translate(${x},${y}) rotate(${(-3 + seed % 7).toFixed(1)}) scale(${sc || .01})`); return sc > 0; } };+}++/* ---------- the thought bubble: the river cut side-on, in Little Horse's head ----------+ Inside it the puppets are at S6_K of their size and the river is drawn in their units around the waterline (y 0):+ a sloping bed, so the ox stands on a shallow shelf (water 50 units up his legs: his shins, well under his knee pins at+ 106), the foal on the middle at 67 (his knee pins), Squirrel in the deep part at 130 (over his head: at s .7, a little over his+ true .6 so he reads in the bubble, he is 91 tall). */+const S6_BX = 1150, S6_BY = 230, S6_K = .48, S6_MX = -14, S6_MY = 41; // bubble centre; where the river's (0, 0) sits in it+const S6_W = (x, y) => [S6_BX + S6_MX + S6_K * x, S6_BY + S6_MY + S6_K * y]; // the river's units -> world+const S6_OX = -380, S6_FOAL = 170, S6_SQ = 430;+function s6_bubble(stage) {+ const rx = 330, ry = 168, n = 22;+ const ring = (dr, fill) => Array.from({ length: n }, (_, i) => {+ const a = i * 2 * Math.PI / n, r = 36 + 8 * (i % 3 === 0);+ return `<circle cx="${(rx * Math.cos(a)).toFixed(1)}" cy="${(ry * Math.sin(a)).toFixed(1)}" r="${r + dr}" fill="${fill}"/>`;+ }).join('') + `<ellipse rx="${rx + dr}" ry="${ry + dr}" fill="${fill}"/>`;+ const wave = Array.from({ length: 20 }, (_, i) => `Q${-1000 + i * 100 + 25},-7 ${-1000 + i * 100 + 50},0 T${-1000 + i * 100 + 100},0`).join(' ');+ const outer = mk('g', {}, stage), g = mk('g', {}, outer), M = `translate(${S6_MX},${S6_MY}) scale(${S6_K})`;+ g.innerHTML = `<clipPath id="s6clip"><ellipse rx="320" ry="160"/></clipPath>+ <g filter="url(#paper)">${ring(4, '#8a6a46')}${ring(0, '#fbf6ea')}</g>+ <g clip-path="url(#s6clip)">+ <g filter="url(#paper)"><rect x="-340" y="-180" width="680" height="360" fill="#dcecef"/>+ <path d="M-340,10 C-200,-20 -120,0 -40,-12 C60,-26 160,-4 340,-22 L340,180 L-340,180 Z" fill="#b8cfa4"/>+ <g transform="${M}"><rect x="-800" y="0" width="1600" height="400" fill="#b9dcea"/></g></g>+ <g class="s6mini" transform="${M}"></g>+ <g transform="${M}">+ <g class="s6wave"><g filter="url(#paper)"><path d="M-1000,0 ${wave} L1000,400 L-1000,400 Z" fill="#5f9fc0" opacity=".3"/></g></g>+ <g filter="url(#paper)"><path d="M-800,50 L-230,50 C-150,50 -140,67 -60,67 L300,67 C350,67 340,130 390,130 L510,130 C565,130 575,-24 640,-24 L800,-24 L800,400 L-800,400 Z" fill="#c9ad74"/>+ <path d="M-800,70 L-240,70 M-50,86 L290,86 M400,148 L500,148" stroke="#b0925a" stroke-width="6" fill="none"/>+ <path d="M600,-24 L800,-24 L800,-40 C720,-46 650,-40 600,-24 Z" fill="#8fb36e"/></g>+ <g class="s6line"><path d="M-1000,0 ${wave}" stroke="#ffffff" stroke-width="7" fill="none"/></g>+ <g class="s6air"></g>+ </g>+ </g>+ <g class="s6q"></g><g class="s6x"></g>`;+ const mini = g.querySelector('.s6mini');+ const ox = oxPuppet(mini), lh = horsePuppet(mini), sq = squirrelPuppet(mini);+ const wv = g.querySelector('.s6wave'), ln = g.querySelector('.s6line');+ const air = g.querySelector('.s6air'), bubs = Array.from({ length: 3 }, () => mk('circle', { r: 6, fill: '#f4fbff', 'fill-opacity': .4, stroke: '#ffffff', 'stroke-width': 3.5 }, air));+ const mark = (sel, ch) => { const e = g.querySelector(sel); e.innerHTML = `<g filter="url(#paper)"><text x="0" y="0" text-anchor="middle" font-family="Georgia, serif" font-weight="bold" font-size="80" fill="#c8322f" stroke="#7a1e1c" stroke-width="2">${ch}</text></g>`; return e; };+ const qm = mark('.s6q', '?'), xm = mark('.s6x', '!');+ bakeAll(g);+ // the trail of three small puffs from his head up to the bubble+ const trail = [[1014, 462, 6], [1025, 445, 9], [1038, 425, 12]].map(([x, y, r]) =>+ prop(stage, `<g filter="url(#paper)"><circle cx="${x}" cy="${y}" r="${r + 3}" fill="#8a6a46"/><circle cx="${x}" cy="${y}" r="${r}" fill="#fbf6ea"/></g>`));+ // paper bits when it pops+ const bits = Array.from({ length: 8 }, (_, i) => ({ a: i * Math.PI / 4 + .3, g: prop(stage, `<g filter="url(#paper)"><path d="M-9,-6 L8,-8 L10,5 L-7,8 Z" fill="${i % 2 ? '#fbf6ea' : '#e9dcc0'}"/></g>`) }));+ return (q, f) => {+ trail.forEach((t, i) => vis(t, q >= S6.bubOn - .25 + i * .08 && q < S6.bubOff));+ const sc = s6_pop(q, S6.bubOn, S6.bubOff);+ vis(outer, sc > 0);+ tf(outer, `translate(${S6_BX + jit(f, 61) * .4},${S6_BY + jit(f, 62) * .4}) scale(${sc || .01})`);+ const u = (q - S6.bubOff) / .45;+ bits.forEach(({ a, g: b }, i) => {+ vis(b, u >= 0 && u < 1);+ if (u < 0 || u >= 1) return;+ const r = 120 + 200 * ease(u), x = S6_BX + r * 1.5 * Math.cos(a), y = S6_BY + r * .8 * Math.sin(a) + 120 * u * u;+ tf(b, `translate(${x.toFixed(1)},${y.toFixed(1)}) rotate(${(i * 47 + 300 * u).toFixed(0)})`); b.setAttribute('opacity', (1 - u).toFixed(2));+ });+ if (!sc) return;+ const t = q - S6.bubOn, got = q >= S6.go;+ ox.pose({ x: S6_OX, y: 50, s: 1.4, turn: 1, chew: t * 1.4, grass: true, lid: .35, look: .4, shut: blinking(q, [S6.bubOn + 1.1, S6.bubOn + 2.6]), tail: 6 * Math.sin(t * 2) }, f);+ lh.pose({ x: S6_FOAL, y: 67, s: 1.05, brow: got ? -1 : -.6, ear: got ? -1 : .2 + .2 * Math.sin(t * 3), neck: got ? -10 : -4, nod: got ? 0 : 4 * Math.sin(t * 2.2),+ look: got ? .8 : .3 * Math.sin(t * 1.4), shut: blinking(q, [S6.bubOn + 1.8]), sack: true, tail: (got ? 14 : 0) + 8 * Math.sin(t * 2.6) }, f);+ sq.pose({ x: S6_SQ, y: 130, s: .7, turn: -1, paw: -40 + 20 * Math.sin(t * 5), pawF: -30 + 20 * Math.sin(t * 5 + 1.5), brow: -.8, ear: -.4,+ tail: 10 * Math.sin(t * 3), tail2: 12 * Math.sin(t * 3 + 1), hop: 2 * Math.sin(t * 4), mouth: 'B' }, f);+ const dx = (-(t * 40) % 100).toFixed(1);+ tf(wv, `translate(${dx},0)`); tf(ln, `translate(${dx},0)`);+ bubs.forEach((b, i) => { // air bubbles from Squirrel's mouth up to the surface+ const v = ((t / 1.6 + i / 3) % 1 + 1) % 1, x = S6_SQ - 25 + 6 * Math.sin(v * 9 + i * 2), y = 74 - v * 74;+ b.setAttribute('cx', x.toFixed(1)); b.setAttribute('cy', y.toFixed(1)); b.setAttribute('opacity', v < .92 ? '1' : '0');+ });+ const [mx, my] = S6_W(S6_FOAL + 40, -300); // over the foal's head+ vis(qm, !got); vis(xm, got);+ const tilt = got ? 0 : 6 * Math.sin(t * 2), jump = got ? -10 * (1 - span(q, S6.go, S6.go + .25)) : 3 * Math.sin(t * 3);+ tf(qm, `translate(${mx - S6_BX},${(my - S6_BY + jump).toFixed(1)}) rotate(${tilt.toFixed(1)})`);+ tf(xm, `translate(${mx - S6_BX},${(my - S6_BY + jump).toFixed(1)}) scale(${(1 + .25 * (1 - span(q, S6.go, S6.go + .2))).toFixed(2)})`);+ };+}++/* ---------- shots ---------- */+const S6_WIDE = { x: 960, y: 520, z: 1.25 }; // the yard and the stable: he comes home, she comes out+const S6_TWO = { x: 885, y: 560, z: 2.0 }; // the two of them+const S6_LH = { x: 960, y: 560, z: 2.95 }; // him, her face whole at the left+const S6_MA = { x: 855, y: 505, z: 3.0 }; // her, his face whole at the right+const S6_MEM1 = { x: 1000, y: 455, z: 2.4 }; // him with the first memory over his head+const S6_MEM2 = { x: 1060, y: 452, z: 2.6 }; // closer, both memories+// True singles: the listener is off screen (not drawn) while the speaker has the frame to herself / himself.+const S6_MA1 = { x: 845, y: 505, z: 3.1 }; // Mother alone, looking right at him off screen+const S6_LH1 = { x: 985, y: 575, z: 3.4 }; // Little Horse alone, head low, looking left at her off screen+const S6_BUB = { x: 1100, y: 330, z: 1.45 }; // the whole bubble over him, both faces below it+const S6_IN1 = { x: 940, y: 215, z: 3.2 }; // in the bubble: the ox on his shelf, water on his shins+const S6_IN2 = { x: 1240, y: 205, z: 3.2 }; // along the waterline: the foal, water at his knees, the "?"+const S6_IN3 = { x: 1335, y: 262, z: 3.5 }; // and down to Squirrel in the deep part, under the line+const S6_CLOSE2 = { x: 900, y: 545, z: 2.4 }; // the two, close+const S6_END = { x: 900, y: 560, z: 1.8 }; // the yard: he trots off for the road, she watches++function scene6(p, D) {+ const cam = setCam(p, 'stable', S6_WIDE);+ const ma = motherPuppet(cam.stage), lh = horsePuppet(cam.stage);+ // the memories: Uncle Ox chewing in the river (water on his shins), Squirrel on his rock shouting+ const v1 = s6_vignette(cam.stage, 1080, 352, 200, 128, 3, `<rect x="-110" y="-70" width="220" height="140" fill="#dcecef"/><path d="M-110,0 C-40,-12 40,4 110,-8 L110,70 L-110,70 Z" fill="#b8cfa4"/><path d="M-110,38 H110 V70 H-110 Z" fill="#b9dcea"/>`);+ const v1ox = oxPuppet(v1.inner);+ v1.front.innerHTML = `<g filter="url(#paper)"><path d="M-110,40 C-60,36 0,44 110,38 L110,70 L-110,70 Z" fill="#5f9fc0" opacity=".45"/><path d="M-110,40 C-60,36 0,44 110,38" stroke="#fff" stroke-width="3" fill="none"/></g>`;+ const v2 = s6_vignette(cam.stage, 1238, 392, 150, 160, 8, `<rect x="-80" y="-85" width="160" height="170" fill="#e6ecd8"/><path d="M-80,40 C-30,30 30,44 80,36 L80,85 L-80,85 Z" fill="#6aaed0"/><path d="M-50,50 C-50,22 -20,12 10,14 C40,16 52,34 50,52 Z" fill="#9a958c"/>`);+ const v2sq = squirrelPuppet(v2.inner);+ bakeAll(v1.front);+ const bubble = s6_bubble(cam.stage);++ cam.to({ x: 930 }, 0, S6.stop) // drifting with him as he comes in+ .cut(S6_TWO, 3.4) // "Why, you're back already?" (Mother, medium)+ .cut(S6_LH, s6_c(2.2)) // "A river was in my way. I... I couldn't get across."+ .cut(S6_MA, s6_c(6.45)) // "That river? Isn't it very shallow?"+ .cut(S6_MEM1, s6_c(9.6)) // "Yes! Uncle Ox said so too." (the ox memory)+ .cut(S6_MEM2, S6.but - .1) // "But Squirrel said it's very deep. His friend drowned in it!"+ .cut(S6_MA1, S6.vigOff + .1) // her single: "So which is it, deep or shallow?"+ .to({ x: 835, y: 500, z: 3.5 }, S6.think, 1.6) // a slight push: "Did you think about what they said?"+ .cut(S6_LH1, S6.hole - .1) // his single: the hole, "No... I didn't."+ .cut(S6_CLOSE2, S6.child - .15) // "My child..." she nuzzles him+ .cut(S6_BUB, S6.use - .05) // "Use your own head": the bubble+ .to(S6_IN1, S6.tryIt - .15, .55) // "and try it": the ox's shins+ .to(S6_IN2, S6.tryIt + .45, .5) // along the waterline to the foal's knees, the "?"+ .to(S6_IN3, S6.self, .5) // "for yourself": Squirrel under the line+ .cut(S6_BUB, S6.go - .1) // "Go": "!", his eyes light; "and see": the pop+ .cut(S6_CLOSE2, S6.bubOff + .1) // straight after the pop: "Then you'll know." He nods+ .cut(S6_END, S6.turn); // the wide: he has turned for the road, trots off; she watches+ cam.soft(s6_c(2.2), true).soft(S6.child - .15, false).soft(S6.bubOff + .1, true).soft(S6.turn, false);++ const MA_BLINK = [.4, 3.0, 6.9, 9.6, 14.7, 17.9, 22.4, 26.3, 33.9, 36.9, 38.2, 40.5];+ const LH_BLINK = [1.2, 4.5, 8.2, 12.3, 15.4, 21.4, 24.6, 27.3, 35.1, S6.bubOff, 39.3];+ stopClock(D, (q, f) => {+ cam.apply(q, f);++ /* ---- Mother ---- */+ const mr = route(q, S6_MAK, 1.3), mTalk = lips(q, 'scene6', PRE6, 'm06', 'm06b', 'm06c', 'm06d');+ const nuzzle = span(q, s6_c(26.3), s6_c(26.9)) * (1 - span(q, S6.bubOn - .5, S6.bubOn + .2));+ ma.pose({ x: mr.x, y: 780, s: 1.3, d: (mr.x - 560) / 1.3, stand: mr.stand, gait: 'walk', mouth: mTalk,+ bob: 1.2 * Math.sin(q * 2 * Math.PI / 3.4),+ neck: s6_k(q, [[0, 4], [.7, -6], [1.3, -2], [3.5, -4], [3.8, -10], [5.6, -6], [6.4, 6], [10.2, 4], [11.4, -2], [13.2, 2], [16.4, 6], [18.8, 10],+ [20.6, 8], [21.6, 12], [S6.think, 12], [S6.think + 1.5, 16], [s6_c(25.0), 16], [s6_c(25.6), 8]]) * (1 - nuzzle) + 3 * nuzzle+ + s6_k(q, [[S6.bubOn - .5, 0], [S6.bubOn + .2, -10], [S6.turn, -10], [S6.run + .4, -14]]),+ nod: s6_bump(q, s6_c(7.6), 1.6, -7) + s6_k(q, [[s6_c(16.9), 0], [s6_c(17.6), 8], [s6_c(25.3), 8], [s6_c(25.8), 0]])+ + s6_bump(q, S6.didnt + .2, .8, 7) + 7 * nuzzle + s6_bump(q, S6.go, .6, 5) + s6_bump(q, S6.know + .1, .6, 5) + s6_bump(q, D - .9, 1.0, 7),+ // negative brows lift: surprised, concerned, gentle; never the down-to-the-nose stern one+ brow: s6_k(q, [[0, -.2], [.7, -.7], [3.4, -.7], [3.8, -1], [5.6, -.9], [6.6, -.5], [10.0, -.6], [13.2, -.3], [16.4, -.4], [18.8, -.8], [20.6, -.4],+ [S6.think, -.35], [S6.child, -.3], [S6.use, -.4], [S6.know, -.3]]),+ lid: 0,+ ear: s6_k(q, [[0, .1], [.7, -.8], [5.6, -.5], [6.6, .1], [10.0, -.3], [13.2, 0], [16.4, .2], [18.8, .5], [20.6, 0], [S6.child, .3], [S6.bubOn, -.2], [S6.run, -.6]])+ + .08 * Math.sin(q * 1.7),+ // she looks at him; on "deep" her eyes go away (left), on "shallow" back to him (right)+ look: s6_k(q, [[0, 0], [.7, 1], [S6.deep - .1, 1], [S6.deep + .05, -1], [S6.shallow - .1, -1], [S6.shallow + .05, 1], [S6.child, 1], [S6.child + .4, .7], [S6.bubOn, 1]]),+ tail: s6_k(q, [[0, 0], [1.3, 6], [3.5, 0]]) + 5 * Math.sin(q * 1.3 + 1),+ shut: blinking(q, MA_BLINK) || between(q, s6_c(26.6), s6_c(28.0)) }, f); // eyes shut, tender, while she nuzzles++ /* ---- Little Horse ---- */+ const out = q >= S6.run, u = q - S6.run, V = 300, TA = .4;+ const xr = out ? 1080 + (u < TA ? .5 * V / TA * u * u : .5 * V * TA + V * (u - TA)) : route(q, S6_LHK, 1.05).x;+ const stand = out ? Math.max(0, 1 - u / .2) : route(q, S6_LHK, 1.05).stand;+ const turn = q < S6.turn ? -1 : 1; // he turns on the cut to the wide+ const hTalk = lips(q, 'scene6', PRE6, 'h06', 'h06b', 'h06c');+ lh.pose({ x: xr, y: 780, s: 1.05, turn, d: out ? (xr - 1080) / 1.05 : (1800 - xr) / 1.05, stand, gait: out ? 'trot' : 'walk', mouth: hTalk, sack: true,+ bob: 1 * Math.sin(q * 2 * Math.PI / 2.9 + 2),+ neck: s6_k(q, [[0, 24], [S6.stop, 22], [s6_c(2.3), 18], [s6_c(3.2), 24], [s6_c(6.6), 20], [s6_c(7.6), 12], [S6.yes - .1, 12], [S6.yes + .2, -8], [S6.but - .2, -6],+ [S6.but + .3, 4], [S6.drown - .5, 2], [S6.drown, -4], [s6_c(17.0), 2], [S6.think, 4], [S6.think + 1.5, 10], [S6.hole, 14], [S6.no, 26], [S6.child, 22],+ [s6_c(26.4), 14], [S6.bubOn - .3, 14], [S6.bubOn + .3, -6], [S6.go, -6], [S6.go + .25, -14], [S6.turn, -10], [S6.run + .3, -4]]),+ nod: s6_bump(q, s6_c(5.5), .7, 5) + s6_bump(q, S6.didnt, .7, 6) + s6_bump(q, S6.bubOff + .05, .45, 15) + s6_bump(q, S6.know + .3, .4, 8),+ tilt: s6_bump(q, S6.yes, .7, -5) + s6_bump(q, S6.go, .5, -3),+ legs: { nf: [s6_bump(q, S6.yes, .5, 6), s6_bump(q, S6.yes, .5, 20) + s6_bump(q, S6.go + .1, .4, 14)] },+ ear: s6_k(q, [[0, .8], [S6.yes - .1, .6], [S6.yes + .15, -.8], [S6.but, -.6], [S6.but + .4, .6], [S6.think, .4], [S6.think + 1.5, .7], [S6.hole, .9], [S6.no, 1],+ [S6.child + .5, .6], [S6.bubOn, .1], [S6.go, .1], [S6.go + .2, -1], [S6.run + .5, -.8]]) + .1 * Math.sin(q * 2.1),+ // negative brows lift (worried, sad, surprised); positive only for the set-off+ brow: s6_k(q, [[0, -.6], [S6.yes, -.5], [S6.yes + .2, -.4], [S6.but + .2, -.5], [S6.but + .6, -1], [s6_c(17.0), -.7], [S6.think, -.6], [S6.no, -.9],+ [S6.child + .5, -.6], [S6.bubOn + .3, -.3], [S6.go, -.3], [S6.go + .2, -1], [S6.know, -.6], [S6.turn, .3]]),+ lid: s6_k(q, [[0, .2], [S6.stop, .15], [S6.yes, .15], [S6.yes + .2, 0], [S6.no, 0], [S6.no + .4, .15], [S6.child + .2, .15], [S6.bubOn, 0]]),+ // eyes: to Mother (+1) while she speaks, to the ground and away (-) when ashamed, up and back to the bubble+ look: s6_k(q, [[0, 0], [3.0, .6], [s6_c(2.4), -.6], [s6_c(6.6), .5], [S6.yes, 1], [s6_c(17.0), 1], [S6.hole - .1, 1], [S6.hole + .2, -.9], [S6.hole + .55, .3],+ [S6.no, -.7], [S6.child, .3], [S6.bubOn + .2, -.8], [S6.go - .1, -.8], [S6.go + .1, 1], [S6.turn, .6]]),+ tail: s6_k(q, [[0, -10], [S6.yes, -4], [S6.yes + .3, 10], [S6.but, 4], [S6.but + .5, -8], [S6.go, -2], [S6.go + .3, 12]]) + 5 * Math.sin(q * 1.9),+ shut: blinking(q, LH_BLINK) || between(q, s6_c(26.6), s6_c(28.3)) }, f);++ /* ---- the memories ---- */+ if (v1.place(q, f, S6.vig1, S6.vigOff)) {+ const t = q - S6.vig1;+ v1ox.pose({ x: -6, y: 56, s: .3, turn: 1, chew: t * 1.4, grass: true, lid: .35, tail: 6 * Math.sin(t * 2), shut: blinking(q, [S6.vig1 + 1.6, S6.vig1 + 4.2]) }, f);+ }+ if (v2.place(q, f, S6.vig2, S6.vigOff)) {+ const t = q - S6.vig2, cry = q >= S6.drown;+ v2sq.pose({ x: -6, y: 18, s: .68, turn: 1, lean: 8 + 3 * Math.sin(t * 6), paw: -100 + 25 * Math.sin(t * 7), pawF: -80 + 25 * Math.sin(t * 7 + 1), brow: -1,+ ear: -.6, tail: 12 * Math.sin(t * 5), tail2: 14 * Math.sin(t * 5 + 1), hop: Math.abs(5 * Math.sin(t * 6)), mouth: onTwos(q) > 0 ? 'D' : 'C', tear: cry,+ shut: blinking(q, [S6.vig2 + 1.3]) }, f);+ }++ vis(lh.g, !between(q, S6.vigOff + .1, S6.hole - .1)); // the singles+ vis(ma.g, !between(q, S6.hole - .1, S6.child - .15));+ bubble(q, f);+ });+}diff --git a/site/little-horse/ch01/scene7.js b/site/little-horse/ch01/scene7.jsnew file mode 100644index 0000000..1aac92c--- /dev/null+++ b/site/little-horse/ch01/scene7.js@@ -0,0 +1,276 @@+/* scene7.js — Let me try (river): Little Horse comes back, Squirrel shouts, "Let me try", the careful wade, the water+ at his knees, the far bank, and the two advisers' stare. Beat clock = PRE7 + scene-clip time (narration.en.words.txt). */+'use strict';+const PRE7 = 1.0;+const s7_T = c => PRE7 + c; // scene-clip time → beat clock+const s7_K = TIMINGS.scene7.marks['n07c.knees']; // "It came just up to Little Horse's knees."+const s7_GAIT = { walk: [{ nh: 0, nf: .25, fh: .5, ff: .75 }, .64], trot: [{ nh: 0, ff: 0, fh: .5, nf: .5 }, .5] }; // cast.js GAITS (L 74)++// Where a leg (hip → knee → hoof) crosses the waterline, or null when the hoof is dry.+function s7_atWater(pup, k) {+ const h = pup.at(k + 'Hoof'), kn = pup.at(k + 'k'), hp = pup.at(k);+ if (h[1] <= WATER) return null;+ const [a, b] = kn[1] <= WATER ? [kn, h] : [hp, kn];+ const u = Math.min(1, Math.max(0, (WATER - a[1]) / (b[1] - a[1] || 1)));+ return a[0] + (b[0] - a[0]) * u;+}+// Swing progress 0..1 of a leg at distance d (cast.js gait), or -1 while its hoof is planted.+const s7_swing = (d, k, g = 'walk') => { const [ph, b] = s7_GAIT[g], r = ((d / 74 + ph[k]) % 1 + 1) % 1; return r < b ? -1 : (r - b) / (1 - b); };++// Ripples on the waterline: a foam collar round each wading leg and two crests running out from it, plus thrown drops.+function s7_water(parent, n) {+ const legs = Array.from({ length: n }, () => {+ const g = mk('g', {}, parent);+ return { g, crest2: mk('path', { fill: 'none', stroke: '#f6fcf8', 'stroke-width': 3.2, 'stroke-linecap': 'round' }, g),+ crest: mk('path', { fill: 'none', stroke: '#f6fcf8', 'stroke-width': 3.2, 'stroke-linecap': 'round' }, g),+ drops: [0, 1, 2].map(() => mk('circle', { r: 4, fill: '#d8eef2', stroke: '#9ccad6', 'stroke-width': 1 }, g)) };+ });+ // each item: { x, w (leg width at the line), u (ripple phase), a (strength 0..1), sw (swing progress or -1), dir }+ return items => legs.forEach((L, i) => {+ const it = items[i]; vis(L.g, !!it); if (!it) return;+ const { x, w, u, a, sw, dir } = it;+ [[L.crest, u], [L.crest2, (u + .5) % 1]].forEach(([el, v]) => {+ const r = w * .5 + 3 + 40 * v, hgt = (-6 * a * (1 - .5 * v)).toFixed(1);+ el.setAttribute('d', `M${(x - r - 18).toFixed(1)},${WATER + 1} q9,${hgt} 18,0 M${(x + r).toFixed(1)},${WATER + 1} q9,${hgt} 18,0`);+ el.setAttribute('opacity', ((1 - v) * a).toFixed(2));+ });+ L.drops.forEach((c, j) => {+ const on = sw >= 0 && sw < .8 && a > .3; vis(c, on); if (!on) return;+ const v = sw / .8, h = (22 + 10 * j) * a * Math.sin(Math.PI * v);+ c.setAttribute('cx', (x + dir * (6 + (12 + 9 * j) * v)).toFixed(1)); c.setAttribute('cy', (WATER - h).toFixed(1));+ c.setAttribute('r', (3.6 - .8 * j).toFixed(1));+ });+ });+}++// Drops flung off when he shakes himself dry, around (cx, cy), u 0..1.+function s7_shakeDrops(parent) {+ const D = Array.from({ length: 14 }, (_, i) => ({ a: -Math.PI * (.08 + .84 * ((i * 7) % 14) / 13), v: 120 + 70 * ((i * 5) % 3), r: 3 + (i % 3),+ e: mk('circle', { fill: '#d8eef2', stroke: '#9ccad6', 'stroke-width': 1 }, parent) }));+ return (u, cx, cy) => D.forEach((d, i) => {+ const uu = u - (i % 4) * .06, on = uu > 0 && uu < 1; vis(d.e, on); if (!on) return;+ d.e.setAttribute('cx', (cx + Math.cos(d.a) * d.v * uu * 1.6).toFixed(1));+ d.e.setAttribute('cy', (cy + Math.sin(d.a) * d.v * uu + 260 * uu * uu).toFixed(1));+ d.e.setAttribute('r', (d.r * (1 - .4 * uu)).toFixed(1));+ });+}++// The dashed waterline (scene 9's language): drawn in from x0 to x1 at y as u goes 0..1, with a slow ripple.+function s7_dash(parent) {+ const g = mk('g', { 'pointer-events': 'none' }, parent);+ const line = mk('path', { fill: 'none', stroke: '#f4fbff', 'stroke-width': 4, 'stroke-dasharray': '12 8', 'stroke-linecap': 'round' }, g);+ return (on, x0, x1, y, u, q) => {+ vis(g, on); if (!on) return;+ const xe = x0 + (x1 - x0) * Math.max(.001, u);+ let d = `M${x0.toFixed(0)},${y}`;+ for (let x = x0 + 10; x <= xe; x += 10) d += ` L${x.toFixed(0)},${(y + 2 * Math.sin(x / 15 + q * 4)).toFixed(1)}`;+ line.setAttribute('d', d);+ };+}++/* A torn-paper vignette over Squirrel: the river cut side-on with him standing on its bed, the water (and the dashed+ waterline) over his head, air bubbles rising. Drawn around (0, 0) in its own units: waterline y -20, bed y 80; the+ little squirrel is at his true size (s .6, 78 tall), so the water is 22 over his head. */+function s7_vignette(parent) {+ const outer = mk('g', {}, parent), W = 140, H = 92;+ // torn edge: a jagged outline from seeded noise+ const torn = (dw, dh) => { const pts = []; const n = 44; for (let i = 0; i < n; i++) { const a = i / n * 2 * Math.PI, j = 1 + .035 * jit(i, 7 + dw);+ const x = Math.cos(a), y = Math.sin(a), k = 1 / Math.max(Math.abs(x) / (W + dw), Math.abs(y) / (H + dh)) ** 1 * .985;+ pts.push(`${(x * k * j).toFixed(1)},${(y * k * j).toFixed(1)}`); } return `M${pts.join(' L')} Z`; };+ const wave = Array.from({ length: 8 }, (_, i) => `Q${-160 + i * 40 + 10},-25 ${-160 + i * 40 + 20},-20 T${-160 + i * 40 + 40},-20`).join(' ');+ outer.innerHTML = `<clipPath id="s7clip"><path d="${torn(0, 0)}"/></clipPath>+ <g filter="url(#paper)"><path d="${torn(7, 7)}" fill="#fbf6ea"/></g>+ <g clip-path="url(#s7clip)">+ <g filter="url(#paper)"><rect x="-160" y="-110" width="320" height="220" fill="#dcecef"/>+ <path d="M-160,-34 C-100,-48 -40,-38 20,-46 C80,-54 120,-40 160,-48 L160,-20 L-160,-20 Z" fill="#b8cfa4"/>+ <rect x="-160" y="-20" width="320" height="130" fill="#b9dcea"/>+ <path d="M-160,80 C-80,76 40,84 160,78 L160,110 L-160,110 Z" fill="#c9ad74"/></g>+ <g class="s7sq"></g>+ <g filter="url(#paper)"><path d="M-160,-20 ${wave} L160,110 L-160,110 Z" fill="#5f9fc0" opacity=".32"/></g>+ <path d="M-150,-20 L150,-20" stroke="#f4fbff" stroke-width="4" stroke-dasharray="12 8" stroke-linecap="round"/>+ <g class="s7air"></g>+ </g>`;+ const sq = squirrelPuppet(outer.querySelector('.s7sq'));+ const air = outer.querySelector('.s7air'), bubs = Array.from({ length: 3 }, () => mk('circle', { r: 4.5, fill: '#f4fbff', 'fill-opacity': .4, stroke: '#ffffff', 'stroke-width': 2.5 }, air));+ bakeAll(outer);+ return (q, f, sc, x, y) => {+ vis(outer, sc > 0); if (!(sc > 0)) return;+ tf(outer, `translate(${x},${y}) scale(${sc.toFixed(3)})`);+ sq.pose({ x: 10, y: 80, s: .6, turn: 1, paw: -40 + 25 * Math.sin(q * 6), pawF: -30 + 25 * Math.sin(q * 6 + 1.5), brow: -1, ear: -.5,+ tail: 10 * Math.sin(q * 3), tail2: 12 * Math.sin(q * 3 + 1), hop: 3 + 3 * Math.sin(q * 4), mouth: 'B', shut: false }, f);+ bubs.forEach((b, i) => {+ const v = ((q / 1.4 + i / 3) % 1 + 1) % 1;+ b.setAttribute('cx', (34 + 5 * Math.sin(v * 9 + i * 2)).toFixed(1)); b.setAttribute('cy', (28 - v * 48).toFixed(1)); b.setAttribute('opacity', v < .94 ? '1' : '0');+ });+ };+}++function scene7(p, D) {+ const T = s7_T;+ // the river camera, with one extra k = 1 layer just in front of the water for the ripples and the dashed waterline+ const cam = paperCam(p, 'river', { x: 800, y: 470, z: 1.05 }, { after: 'tree', stages: ['water'] });+ const ox = oxPuppet(cam.stage), lh = horsePuppet(cam.stage), sq = squirrelPuppet(cam.stage); // the Ox behind, Squirrel's rock nearest us+ const ripples = s7_water(cam.stageAt.water, 8), shake = s7_shakeDrops(cam.stageAt.water), dash = s7_dash(cam.stageAt.water);+ const vign = s7_vignette(cam.root); // over the picture, in frame coordinates+ // A see-through copy of the set's water (books/little-horse/art/sets.js) for the depth shots: with the set's opaque+ // water hidden, the legs under the line show faintly through it, so the child sees how much leg is under.+ let s7crest = 'M560,724'; for (let x = 560; x <= 1360; x += 40) s7crest += ' q10,-5 20,0 q10,5 20,0';+ const glass = prop(cam.stageAt.water, `<g filter="url(#paper)" opacity=".7"><path d="${s7crest} L1360,1060 L560,1060 Z" fill="#6fa6b8"/>+ <path d="M560,744 C800,752 1100,738 1360,748 L1360,1060 L560,1060 Z" fill="#5d93a8" fill-opacity=".6"/>+ ${Array.from({ length: 16 }, (_, i) => `<path d="M${600 + i * 46},${742 + (i % 4) * 16} q16,-5 32,0" stroke="#b8dde6" stroke-width="3" fill="none"/>`).join('')}</g>`);+ cam.stageAt.water.insertBefore(glass, cam.stageAt.water.firstChild); // under the ripples and the dashed line++ /* ---------- places (REWORK2) ----------+ Uncle Ox grazes in OPEN WATER facing the far bank (x OX, y WATER + 50: his legs and the waterline in view, clear of+ the far-bank mound). Little Horse's hooves are hidden by the water too, so the bed under him drops as he goes in+ until the water is at his knee pins (y WATER + KNEE) where he stops (DEEP), with clear air before the Ox's tail.+ While the foal crosses on (out of shot, during Squirrel's cutaway) the Ox turns and wades back to the near shallows+ (OX2), so the two never share a frame there and the stare can be nose to nose. */+ const LH_S = 1.05, X0 = 20, EDGE = 650, DEEP = 730, FAR = 1580, KNEE = 66, OX = 1150, OX2 = 830, OX_Y = WATER + 50;+ const SQ_ROCK = [470, 650], SQ_LIP = [572, 700];+ const lhY = x => x <= EDGE ? RIVER_BED(x) : x <= DEEP ? RIVER_BED(EDGE) + (WATER + KNEE - RIVER_BED(EDGE)) * ease((x - EDGE) / (DEEP - EDGE))+ : Math.min(WATER + KNEE, x < 1000 ? WATER + KNEE : RIVER_BED(x));+ const g7 = c => c < 4 || c > 25.4 ? 'trot' : 'walk'; // trot in; walk the careful wade; trot on, sure now (switched while standing)+ const keys = [[T(-1), X0], [T(2.1), EDGE], [T(9.0), EDGE]];+ { // one hoof at a time: a pause at each hoof's highest lift (quarter strides)+ const d0 = (EDGE - X0) / LH_S, stops = [];+ for (let n = Math.ceil((d0 / 74 - .07) / .25 + 1e-6); ; n++) { const x = EDGE + ((.07 + .25 * n) * 74 - d0) * LH_S; if (x >= DEEP - 8) break; stops.push(x); }+ const dt = (T(16.6) - T(9.0)) / (stops.length + 1);+ stops.forEach((x, i) => keys.push([T(9.0) + dt * (i + 1), x]));+ keys.push([T(16.6), DEEP], [T(25.6), DEEP], [T(27.0), 1350], [T(28.3), FAR]);+ }+ const lhAt = q => route(q, keys, LH_S);+ const oxAt = q => route(q, [[T(25.7), OX], [T(29.2), OX2]], 1.4);++ // a slosh at each lift of the near fore hoof in the water (one a stride), a splash at the first step in+ {+ let last = null, first = true;+ for (let q = T(9.0); q < T(28.4); q += 1 / 24) {+ const r = lhAt(q), now = s7_swing(r.d, 'nf', g7(q - PRE7)) >= 0, seen = q < T(25.6) || q > T(27.0);+ if (last === false && now && seen && r.stand < .5 && lhY(r.x) > WATER + 2) {+ if (first) { sfx('scene7', +q.toFixed(2), 'splash', .35); first = false; }+ else sfx('scene7', +q.toFixed(2), 'slosh', q > T(25) ? .3 : .22);+ }+ last = now;+ }+ }++ /* ---------- the shots ---------- */+ const lhx = q => lhAt(q).x;+ const SQV = T(20.75), KN = PRE7 + s7_K;+ cam.to({ x: 760, z: 1.25 }, T(-1), 3.2) // wide: he trots back to the river+ .cut({ x: 600, y: 590, z: 2.2 }, T(2.2)) // medium: at the edge, the hoof lifts; "What?"+ .cut({ x: 478, y: 600, z: 3.5 }, T(5.45)) // Squirrel: "Do you want to drown?"+ .cut({ x: 565, y: 530, z: 2.8 }, T(7.3)) // Little Horse, calm: "Let me try."+ .cut({ x: q => lhx(q) + 90, y: 600, z: 2.2 }, T(8.75)) // he steps in+ .cut({ x: q => lhx(q) + 40, y: 690, z: 3.4 }, T(10.5)) // insert: the hooves, one careful step+ .cut({ x: 890, y: 560, z: 1.3 }, T(12.45)) // wide: Squirrel hops down to the lip; the Ox grazing+ .to({ x: 930, y: 580, z: 1.45 }, T(13.6), 3.4)+ .cut({ x: 1025, y: 615, z: 1.85 }, T(17.65)) // "Uncle Ox": one waterline, his shins, the foal's knees+ .cut({ x: 650, y: 600, z: 2.8 }, SQV) // "Squirrel": the vignette, the water over his head+ .cut({ x: 765, y: 632, z: 2.5 }, KN) // "knees": his face dips to the water, comes up delighted+ .cut({ x: 525, y: 625, z: 3.2 }, T(25.6)) // Squirrel watches him go, hops back up (cutaway)+ .cut({ x: 1640, y: 590, z: 2.2 }, T(27.0)) // the far bank: out, shake, a proud look back+ .cut({ x: 650, y: 560, z: 2.6 }, T(29.55)) // Ox, back in the near shallows: "Told you it was shallow."+ .cut({ x: 485, y: 600, z: 3.4 }, T(31.3)) // Squirrel: "Told you it was deep!"+ .cut({ x: 610, y: 545, z: 3.2 }, T(33.4)) // the stare: the Ox looks at Squirrel…+ .cut({ x: 470, y: 600, z: 3.5 }, T(34.0)) // …Squirrel looks at the Ox…+ .cut({ x: 535, y: 575, z: 2.9 }, T(34.6)); // …both faces, eyes meeting, held+ [[T(2.2), true], [T(8.75), false], [T(10.5), true], [T(12.45), false], [T(17.65), true]].forEach(([t, on]) => cam.soft(t, on));++ /* ---------- sound ---------- */+ sfx('scene7', 0, 'river', .5); sfx('scene7', 0, 'birds', .4);+ sfx('scene7', .05, 'trot', .4);+ sfx('scene7', T(4.88), 'squeak', .35);+ sfx('scene7', T(13.75), 'hop', .25); sfx('scene7', T(25.95), 'hop', .22);+ sfx('scene7', SQV + .2, 'pop', .3);+ sfx('scene7', T(28.4), 'splash', .3); // the shake++ const blinkLH = [T(1.6), T(6.5), T(11.9), T(15.2), T(19.9), T(22.6), T(26.2), T(31.5)];+ const blinkOx = [T(.9), T(5.7), T(9.6), T(14.4), T(18.9), T(22.8), T(27.9), T(31.0), T(35.2)];+ const blinkSq = [T(2.6), T(8.1), T(12.8), T(16.6), T(19.6), T(25.3), T(33.0), T(35.45)];++ stopClock(D, (q, f) => {+ cam.apply(q, f);+ const c = q - PRE7;+ const seeThrough = between(q, T(17.65), SQV) || between(q, KN, T(25.6)); // the two-shot and the knees shot+ cam.show('water', !seeThrough); vis(glass, seeThrough);++ /* Little Horse */+ const r = lhAt(q), y = lhY(r.x);+ const turn = c < 6.3 ? 1 : c < 7.75 ? -1 : c < 28.85 ? 1 : tween(c, 28.85, .3, 1, -1); // turns on the cuts, and on the far bank+ const lift = c < 4.95 ? tween(c, 3.0, .45, 0, 1) : tween(c, 4.95, .15, 1, 0);+ const wading = between(c, 8.8, 25.6), shaking = between(c, 28.3, 28.8), sh = shaking ? Math.sin((c - 28.3) * 2 * Math.PI * 5) : 0;+ const proud = c > 29.15, delighted = between(c, 23.95, 29.4);+ const startle = between(c, 4.95, 5.6);+ let neck = c < 2.1 ? -4 : c < 4.9 ? 12 : c < 6.3 ? 4 : 14;+ if (c > 7.4 && c < 8.8) neck = 10;+ if (wading) neck = c > 16.6 ? 6 : 16;+ if (between(c, 22.5, 23.95)) neck = tween(c, 22.5, .45, 6, 34); // "It came just up to…": head and eyes dip to the water+ else if (between(c, 23.95, 25.6)) neck = tween(c, 23.95, .35, 34, -10); // …"knees": up, delighted, held+ else if (c >= 25.6) neck = proud ? -12 : -4;+ const dip = between(c, 22.7, 23.95);+ lh.pose({ x: r.x, y, s: LH_S, d: r.d, stand: r.stand, gait: g7(c), turn, sack: true,+ neck: neck + sh * 6 + (startle ? -8 : 0), nod: between(c, 7.55, 8.15) ? 10 * Math.sin((c - 7.55) / .6 * Math.PI) : dip ? 8 : 0,+ tilt: (startle ? -4 : 0) + sh * 4 + (proud ? -3 : 0) + (between(c, 24.0, 24.4) ? -5 * Math.sin((c - 24) / .4 * Math.PI) : 0),+ legs: { nf: [16 * lift, 30 * lift] },+ ear: startle ? .7 : shaking ? sh : delighted || proud ? -1 : wading ? -.5 : c > 7.4 ? -.4 : -.2,+ // brow: + cross/determined, - worried/surprised/happy-lifted (REWORK1)+ brow: startle ? -1 : between(c, 5.6, 7.3) ? -.5 : c > 7.3 && c < 8.8 ? .35 : delighted ? -.5 : dip ? -.3 : wading ? .2 : 0,+ lid: between(c, 7.3, 8.6) ? .15 : 0,+ look: startle ? -1 : between(c, 5.6, 6.3) ? -1 : between(c, 6.3, 8.8) ? .3 : dip ? .2 : wading ? .4 : 0,+ tail: shaking ? sh * 25 : delighted || proud ? 14 * Math.sin(c * 5) : 4 * Math.sin(c * 1.3),+ mouth: lips(q, 'scene7', PRE7, 'h07'), shut: blinking(q, blinkLH) || (shaking && sh > .6) }, f);++ /* Uncle Ox: grazing in open water facing the far bank; wades back to the near shallows while the foal crosses on+ (both out of shot); speaks and stares from there. Grass while he munches only. */+ const o = oxAt(q), oxTalk = lips(q, 'scene7', PRE7, 'o07'), oxSpeaks = between(c, 29.4, 31.1), stare = c > 33.4;+ ox.pose({ x: o.x, y: OX_Y, s: 1.4, turn: c < 25.7 ? 1 : -1, d: o.d, stand: o.stand, gait: 'walk',+ grass: !oxSpeaks && !stare, chew: !oxSpeaks && !stare ? q * 1.4 : 0,+ mouth: oxSpeaks ? oxTalk : 'X', neck: stare ? tween(c, 33.5, .4, 6, 14) : c < 25.7 ? 12 : 6, lid: stare ? .05 : .3,+ look: stare ? 1 : c < 25.7 ? -.3 : .5, brow: stare ? .25 : 0,+ tail: 6 * Math.sin(c * .9), ear: .2 * Math.sin(c * .7), shut: blinking(q, blinkOx) }, f);++ /* Squirrel: on the rock; hops down to the bank lip to watch the wade, back up while the foal crosses on */+ const sqTalk = lips(q, 'scene7', PRE7, 's07', 's07b');+ const down = span(c, 13.4, 13.9) * (1 - span(c, 25.95, 26.45));+ const sx = SQ_ROCK[0] + (SQ_LIP[0] - SQ_ROCK[0]) * down, sy = SQ_ROCK[1] + (SQ_LIP[1] - SQ_ROCK[1]) * down;+ const leap = between(c, 13.4, 13.9) ? Math.sin((c - 13.4) / .5 * Math.PI) : between(c, 25.95, 26.45) ? Math.sin((c - 25.95) / .5 * Math.PI) : 0;+ const shout = between(c, 4.85, 7.4), atLip = between(c, 19.7, 22.4), worried = between(c, 8.8, 22.4), crossed = between(c, 31.1, 33.4);+ const hop = between(c, 4.85, 5.3) ? 24 * Math.sin((c - 4.85) / .45 * Math.PI) : 28 * leap;+ const amazed = between(c, 24.0, 31.1);+ // at the lip: looks down at the water, then at the foal, a worried nod+ const lipHead = atLip ? (c < 20.4 ? 22 : c < 20.9 ? -8 : -8 + 12 * Math.sin((c - 20.9) * 9)) : 0;+ sq.pose({ x: sx, y: sy, s: .6, hop, stretch: leap * .4 + (between(c, 4.85, 5.3) ? .3 : 0),+ paw: shout ? -45 : atLip ? -150 : worried ? -95 : crossed ? 80 : stare ? 20 : amazed ? -20 : 0,+ pawF: shout ? -30 : atLip ? -140 : worried ? -100 : crossed ? 70 : stare ? 15 : amazed ? -15 : 0,+ lean: shout ? 6 : atLip ? 10 : worried ? 8 + 2 * Math.sin(c * 3) : crossed ? -5 : stare ? 4 : 0,+ headR: crossed ? -12 : stare ? 4 : atLip ? lipHead : worried ? 4 : between(c, 7.2, 8.8) ? -14 : amazed ? -6 : 0,+ brow: shout || worried ? -1 : crossed ? .6 : amazed ? -.6 : stare ? .3 : 0, ear: shout ? -.6 : amazed ? -.8 : 0,+ tail: 6 * Math.sin(c * 2.3) + (shout ? 10 : 0), tail2: 8 * Math.sin(c * 3.1 + 1) + (worried ? 6 * Math.sin(c * 9) : 0),+ mouth: sqTalk, shut: blinking(q, blinkSq) || (crossed && between(c, 32.15, 32.55)) }, f);++ /* the dashed waterline across both in the two-shot, and across his knees */+ if (between(q, T(17.75), SQV)) dash(true, 600, 1460, WATER, span(q, T(17.75), T(18.2)), q);+ else if (between(q, KN + .3, T(25.6))) dash(true, 560, 960, WATER, span(q, KN + .3, KN + .8), q);+ else dash(false);+ // the vignette over Squirrel: pops open, the water over his head; in frame coordinates of the SQV shot+ const vs = between(q, SQV + .2, KN) ? Math.min(1, (q - SQV - .2) / .2) * (1 + .08 * Math.max(0, 1 - (q - SQV - .4) / .2)) : 0;+ vign(q, f, vs * 2.2, 430, 230); // in the sky above Squirrel, clear of the foal's head++ /* the water round every leg that stands in it */+ const items = [];+ for (const k of ['nf', 'ff', 'nh', 'fh']) {+ const x = s7_atWater(lh, k);+ items.push(x == null ? null : { x, w: (k[1] === 'f' ? 14 : 18) * LH_S, u: ((q / 1.3 + 'nfnhffh'.indexOf(k) * .17) % 1), a: r.stand < .5 ? 1 : .55,+ sw: r.stand < .5 && (wading || between(c, 27.0, 28.3)) ? s7_swing(r.d, k, g7(c)) : -1, dir: turn > 0 ? 1 : -1 });+ }+ for (const k of ['nf', 'ff', 'nh', 'fh']) {+ const x = s7_atWater(ox, k);+ items.push(x == null ? null : { x, w: 26, u: ((q / 2.1 + 'nfnhffh'.indexOf(k) * .23) % 1), a: o.stand < .5 ? .9 : .5, sw: -1, dir: 1 });+ }+ ripples(items);+ const back = lh.at('back');+ shake(between(c, 28.3, 29.2) ? (c - 28.3) / .9 : -1, back[0], back[1] + 20);+ });+}diff --git a/site/little-horse/ch01/scene8.js b/site/little-horse/ch01/scene8.jsnew file mode 100644index 0000000..0f6b35e--- /dev/null+++ b/site/little-horse/ch01/scene8.js@@ -0,0 +1,147 @@+/* scene8.js — At the mill, the second "listen and find" stop (lib/find.js). Little Horse walks up to the mill door,+ kneels so the sack slides off his back, catches its tie in his teeth and sets it down by the door with a thud, then+ stands proud by it ("Little Horse brought the wheat to the mill." — the video keeps the beat to PRE8 + 3.6, this+ proud hold with a small nod). On "Let's play again! Listen, and touch what he asks for." he steps back and the camera+ pulls out to the wide picture, still from then on, while he asks for the wheel, the duck and the sack; every thing+ answers a tap (mill, wheel, sack, duck, sun, cloud, fence, and Little Horse himself: "That's me!").+ Shots (beat clock, PRE8 3.2): 0 medium follow on the walk-in, door and wheel's edge in frame; 3.1 push in on him and+ the sack, held to 6.8; 6.9–8.8 pull out to the wide set (s8_WIDE). While the game waits he talks with findMouth(),+ looks out at the child while he asks, and glances at the thing just found (findSaw()). */+'use strict';+const PRE8 = 3.2;+let MILL_THINGS = []; // the things to tap, filled by scene8++// A white paper duck floating, facing right, drawn around its waterline (0, 0).+const s8_duck = (body, wing, beak) => `<g filter="url(#paper)">+ <path d="M-46,-4 C-56,-18 -54,-36 -42,-32 C-32,-27 -24,-31 -10,-33 C8,-35 20,-31 25,-22 C31,-13 30,-3 22,0 L-40,0 Z" fill="${body}"/>+ <path d="M8,-24 C8,-44 14,-62 29,-63 C43,-64 49,-52 45,-42 C41,-34 32,-30 27,-21 Z" fill="${body}"/>+ <path d="M42,-53 C52,-55 61,-51 63,-46 C57,-42 49,-42 42,-45 Z" fill="${beak}"/>+ <path d="M-32,-19 C-22,-28 0,-28 9,-17 C-4,-9 -22,-9 -32,-19 Z" fill="${wing}"/>+ <path d="M-58,3 q14,-6 29,0 q14,-6 29,0 q14,-6 29,0 q14,-6 29,0" stroke="#d6eef3" stroke-width="4" fill="none"/></g>+ <circle cx="33" cy="-50" r="3.4" fill="#2a1a10"/><circle cx="34.2" cy="-51.4" r="1.1" fill="#fff"/>`;++// Little Horse's walk in, his steps back from the door, and the sack's fall from his back to the door.+const s8_IN = [[-1.2, 520], [2.4, 900]], s8_BACK = [[6.8, 900], [8.5, 680]];+// He kneels forward (rump up, chest down) so the sack slides off along his back and over his shoulder (SLIDE); he+// catches its tie in his teeth as it slides past his neck (GRIP), straightens and sets it down beside the door, clear+// of his forelegs (LAND, thud), lets go and looks at it. Every head angle stays within about ±60°.+const s8_SLIDE = 2.6, s8_GRIP = 2.95, s8_LAND = 3.5;+const s8_WIDE = { x: 830, y: 540, z: 1.1 }; // every thing in frame, as big as the fence and the sky allow, the ducks low in the frame's right+const s8_SACK_X = 1046, s8_SACK_S = 1.05; // where the sack's tie is set down (its bottom on the ground, y 780), its size++function scene8(p, D) {+ const cam = paperCam(p, 'mill', { x: 770, y: 600, z: 1.75 }, { stages: ['pond'] }); // ducks swim in front of the pond's water+ cam.to({ x: 905, y: 610, z: 1.8 }, 0, 2.5) // follow him to the door+ .to({ x: 925, y: 640, z: 2.0 }, 3.1, 1.8) // push in on him and the sack, held through his proud moment+ .to(s8_WIDE, 6.9, 1.9) // the wide picture; still from 8.8 on, through the game+ .shake(3.0, .17, 4);+ const sky = cam.world.firstChild; // the sky layer's own group, so the sun and cloud shapes ride its parallax++ // the pictures, back to front+ const wheelWrap = mk('g', {}, cam.stage), wheel = millWheel(wheelWrap);+ const lh = horsePuppet(cam.stage);+ const sack = prop(cam.stage, SACK); // moved behind him once his teeth hold its tie+ const ducks = mk('g', {}, cam.stageAt.pond);+ const duck = prop(ducks, s8_duck('#f7f2e6', '#e2dccb', '#e8902e')), duckling = prop(ducks, s8_duck('#f2cf5a', '#e2b844', '#e8902e'));++ // things painted into the baked set: transparent shapes over them (the wheel's rotating bitmap would make its box+ // breathe, so its target is a still circle and the wheel copies the circle's hop)+ const clear = { fill: 'transparent' };+ const mill = mk('path', { d: 'M845,780 L845,488 L790,488 L1040,330 L1160,400 L1160,780 Z', ...clear }, cam.stage);+ const wheelHit = mk('circle', { cx: 1340, cy: 650, r: 176, ...clear }, cam.stage);+ const fence = mk('rect', { x: 112, y: 684, width: 474, height: 108, ...clear }, cam.stage);+ const sun = mk('circle', { cx: 520, cy: 150, r: 58, ...clear }, sky);+ const cloud = mk('path', { d: 'M161,141 C150,115 176,97 198,108 C203,79 242,73 260,95 C275,68 322,75 324,106 C350,97 372,119 359,141 Z', ...clear }, sky);+ MILL_THINGS = [+ { g: mill, word: 'mill' },+ { g: wheelHit, word: 'wheel' },+ { g: sack, word: 'sack', side: 'below' }, // above it would lie over Little Horse's face+ { g: ducks, word: 'duck' },+ { g: sun, word: 'sun' },+ { g: cloud, word: 'cloud' },+ { g: fence, word: 'fence' },+ { g: lh.g, word: 'horse', clip: 'q-me', talk: true }, // he giggles "That's me!"+ ];++ // sound: the mill race under the whole scene, a hoof at every other footfall, the thud, a quack as the ducks come in+ sfx('scene8', 0, 'mill', .5);+ for (const keys of [s8_IN, s8_BACK]) {+ let last = null;+ for (let t = Math.max(0, keys[0][0]); t <= keys[1][0] + .2; t += 1 / 24) {+ const n = Math.floor(route(t, keys, 1.05).d * 2 / 74);+ if (last !== null && n !== last) sfx('scene8', +t.toFixed(2), 'hoof', .25);+ last = n;+ }+ }+ sfx('scene8', s8_LAND, 'thud', .45);+ sfx('scene8', 8.6, 'quack', .3); // as the duck paddles into the wide picture++ // a living foal: blinks and ear flicks at their own uneven moments, a breath, a slow look round the yard+ const blink = q => { const k = Math.floor(q / 3.4), t0 = k * 3.4 + 1.7 + 1.1 * jit(k, 41); return blinking(q, jit(k, 42) > .4 ? [t0, t0 + .33] : [t0]); };+ const flick = q => { const k = Math.floor(q / 5.3), t0 = k * 5.3 + 2.6 + 1.4 * jit(k, 43), u = (q - t0) / .3; return u > 0 && u < 1 ? Math.sin(Math.PI * u) : 0; };+ const gaze = q => { // neck angle while he stands proud: forward, down at his sack, up at the wheel, forward+ const c = ((q - 7) % 11 + 11) % 11;+ return c < 3 ? -10 : c < 3.6 ? tween(c, 3, .6, -10, 14) : c < 5.6 ? 14 : c < 6.3 ? tween(c, 5.6, .7, 14, -18) : c < 8.6 ? -18 : tween(c, 8.6, .8, -18, -10);+ };++ stopClock(D, (q, f) => {+ cam.apply(q, f);+ wheel(q);+ const hop = getComputedStyle(wheelHit).translate; // the hop and the hint's shake find.js gives the wheel's circle+ tf(wheelWrap, hop === 'none' ? '' : `translate(${hop.split(' ').map(parseFloat).map(v => v || 0).join(',')})`);++ // Little Horse+ const rIn = route(q, s8_IN, 1.05), rB = route(q, s8_BACK, 1.05);+ const x = rIn.x + rB.x - 900, d = rIn.d - rB.d, walking = q < 2.7 || between(q, 6.7, 8.8);+ const stand = q < 5 ? rIn.stand : rB.stand;+ const crouch = tween(q, 2.4, .35, 0, 16) - tween(q, s8_GRIP, .5, 0, 6) - tween(q, s8_LAND + .1, .4, 0, 10); // kneels, then bends to set it down+ const breath = 1.2 * Math.sin(2 * Math.PI * q / 3.4);+ let neck, nod = 0, tilt = 0, ear, look = 0, brow = 0, jaw = null;+ if (q < 2.4) { neck = -4; ear = -.5; }+ else if (q < s8_GRIP) { neck = tween(q, 2.4, .35, -4, 40); nod = tween(q, 2.4, .35, 0, -25); tilt = tween(q, 2.4, .35, 0, 9); ear = .3; look = -.6; brow = -.3; jaw = between(q, 2.7, s8_GRIP - .05) ? .55 : 0; } // kneels; the sack slides; mouth open to catch it+ else if (q < s8_LAND) { // catches it, straightens, lowers it to the door+ const u = span(q, s8_GRIP + .05, s8_LAND);+ neck = 40 + 17 * u; nod = -25 + 7 * u; tilt = 9 * (1 - u); ear = .2; brow = .35; jaw = 0;+ }+ else if (q < 4.2) { neck = tween(q, s8_LAND + .1, .35, 57, 32); nod = tween(q, s8_LAND + .1, .35, -18, 0); tilt = tween(q, s8_LAND + .1, .35, 0, 3); ear = -.2; look = .8; brow = -.1; jaw = q < s8_LAND + .12 ? 0 : null; } // lets go, looks at it+ else if (q < 6.8) { neck = tween(q, 4.2, .5, 32, -12) + 9 * Math.sin(Math.PI * span(q, 5.6, 6.2)); tilt = tween(q, 4.2, .5, 3, -3); ear = -.6; brow = -.25; } // chin up, then a small proud nod: done!+ else if (q < 8.8) { neck = tween(q, 6.8, .4, -12, -6); tilt = -3; ear = -.4; brow = -.2; } // steps back to see it all+ else { neck = gaze(q); tilt = -2.5 + .6 * Math.sin(q * .9); ear = -.4; brow = -.2; }+ // the game: he asks with his head up and his eyes on the child, then glances at what was just found+ const saw = findSaw();+ if (FIND.saying) { neck = -8 + 2 * Math.sin(q * 5); look = 0; ear = -.6; brow = -.3; }+ else if (saw) {+ const r = saw.getBoundingClientRect(), [ex, ey] = lh.at('eye'), m = cam.stage.getScreenCTM().inverse();+ const tx = (r.left + r.width / 2) * m.a + m.e, ty = (r.top + r.height / 2) * m.d + m.f;+ look = Math.sign(tx - ex) || 0; neck = Math.max(-18, Math.min(20, (ty - ey) / 8)); ear = -.5;+ }+ const walkNod = walking ? 3 * Math.sin(4 * Math.PI * d / 74) * (1 - stand) : 0;+ lh.pose({ x, y: 780, s: 1.05, d, stand, gait: 'walk', bob: crouch + breath, tilt, neck: neck + 2 * Math.sin(q * .5), nod: nod + walkNod, jaw, mouth: findMouth(),+ ear: ear + .9 * flick(q), look, brow, lid: q > 8.8 && !FIND.saying ? .1 : 0, tail: 10 * Math.sin(q * 1.3) + 14 * flick(q + 1.9),+ sack: q < s8_SLIDE, shut: blink(q) || between(q, s8_LAND, s8_LAND + 2 / FPS) }, f);++ // the sack: in his teeth by its tie (filling out from its flat shape on his back), swinging, then set down by the door+ vis(sack, q >= s8_SLIDE);+ if ((q < s8_GRIP) !== (sack.nextSibling === null)) q < s8_GRIP ? cam.stage.appendChild(sack) : cam.stage.insertBefore(sack, lh.g); // over his back while it slides, behind his head once in his teeth+ if (q >= s8_SLIDE) {+ const S = s8_SACK_S, k = q - s8_LAND, sq = k > 0 && k < .25 ? Math.sin(Math.PI * k / .25) : 0; // the squash on landing+ let X = s8_SACK_X, Y = 780 - 75 * S * (1 - .12 * sq), rot = 0, ys = 1 - .12 * sq, xs = 1 + .1 * sq;+ if (q < s8_GRIP) { // sliding off: from where it lay on his back to his open mouth, faster and faster, tipping forward+ const [bx, by] = lh.at('back'), [mx, my] = lh.at('mouth'), u = ((q - s8_SLIDE) / (s8_GRIP - s8_SLIDE)) ** 2;+ const tx = bx + 2 * S, ty = by - 36 * S; // the tie where it lay+ X = tx + (mx - tx) * u; Y = ty + (my + 2 - ty) * u - 14 * Math.sin(Math.PI * u);+ ys = .66 + .34 * u; rot = 30 * Math.sin(Math.PI * u * .9);+ } else if (q < s8_LAND) {+ const [mx, my] = lh.at('mouth'), u = span(q, s8_LAND - .17, s8_LAND); // the last frames ease onto the spot+ rot = (-14 * Math.sin(Math.PI * span(q, s8_GRIP, s8_LAND)) + 12 * Math.exp(-(q - s8_GRIP) * 8)) * (1 - u); // the catch jerk, then it trails the swing+ X = mx + (X - mx) * u; Y = my + 2 + (Y - my - 2) * u;+ }+ tf(sack, `translate(${X.toFixed(1)},${Y.toFixed(1)}) rotate(${rot.toFixed(1)}) scale(${(S * xs).toFixed(3)},${(S * ys).toFixed(3)}) translate(-2,35)`);+ }++ // the ducks bob, facing the mill; the duckling paddles after its mother (kept out of the close shots)+ const dx = tween(q, 6.8, 2.4, 1530, 1320) + 22 * Math.sin(q * .23); // they paddle in from off the right for the wide picture+ tf(duck, `translate(${dx.toFixed(1)},${(808 + 2.5 * Math.sin(q * 2.1)).toFixed(1)}) rotate(${(3 * Math.sin(q * 1.7)).toFixed(1)}) scale(-1.35,1.35)`);+ tf(duckling, `translate(${(dx + 120 + 10 * Math.sin(q * .5)).toFixed(1)},${(812 + 2 * Math.sin(q * 2.9 + 1)).toFixed(1)}) rotate(${(4 * Math.sin(q * 2.3 + .5)).toFixed(1)}) scale(-.75,.75)`);+ });+}diff --git a/site/little-horse/ch01/scene9.js b/site/little-horse/ch01/scene9.jsnew file mode 100644index 0000000..5c32e5f--- /dev/null+++ b/site/little-horse/ch01/scene9.js@@ -0,0 +1,158 @@+/* scene9.js — The little rabbit (river, going home): the end gag. Little Horse nearly tells the rabbit the river's depth+ by his own legs, looks at its tiny ones, and carries it across on his back. Beat clock = PRE9 + scene9's clip times.+ Uncle Ox stands in the far-side shallows facing left (behind Little Horse); Squirrel on the rock at 470. */+'use strict';+const PRE9 = 1.5;+const s9_T = (clip, t = 0) => clipAt('scene9', PRE9, clip, t);++// Eased keys [[t, v], …]: v holds before the first and after the last key, eases between neighbours.+function s9_kf(q, keys) {+ if (q <= keys[0][0]) return keys[0][1];+ for (let i = 1; i < keys.length; i++) {+ const [t0, a] = keys[i - 1], [t1, b] = keys[i];+ if (q < t1) return a + (b - a) * ease((q - t0) / (t1 - t0));+ }+ return keys[keys.length - 1][1];+}+// A long walk at an even pace (ease in and out over r s only), from a to b between t0 and t1, for a puppet of scale s:+// x, the distance walked in its own units (d) and stand, like route().+function s9_glide(q, t0, t1, a, b, s, r = .5) {+ const T = t1 - t0, v = (b - a) / (T - r), t = Math.min(T, Math.max(0, q - t0));+ const x = a + (t < r ? v * t * t / (2 * r) : t > T - r ? (b - a) - v * (T - t) ** 2 / (2 * r) : v * (t - r / 2));+ const stand = q < t0 ? 1 : q < t1 ? Math.max(0, 1 - (q - t0) / .25) : Math.min(1, (q - t1) / .25);+ return { x, d: Math.abs(x - a) / s, stand };+}+// A rabbit hop from a to b (points) over u 0..1: height leads, the sideways move comes late, so it clears what is+// between (his neck and mane). Returns [x, y].+function s9_hop(a, b, u, h) {+ const ux = ease(Math.min(1, Math.max(0, (u - .3) / .7))), uy = Math.sin(Math.PI / 2 * Math.min(1, u / .55));+ const top = Math.min(a[1], b[1]) - h;+ const y = u < .55 ? a[1] + (top - a[1]) * uy : top + (b[1] - top) * ease((u - .55) / .45);+ return [a[0] + (b[0] - a[0]) * ux, y];+}++function scene9(p, D) {+ // The river is the rabbit's: they meet at the far bank's lip; Uncle Ox grazes on the near bank (left, head kept under the tree's branch) with Squirrel.+ const SH = 1.05, SR = .55, OX = -250, RX = 1340, STOP = 1500, BANK = 605; // ox well clear of the trunk; all four hooves on land at 605+ const tRab = s9_T('n09', 2.2), tWater = s9_T('n09', 5.2), tLH = s9_T('n09', 6.28), tH09 = s9_T('h09'); // "little rabbit", "then at Little Horse"+ const tMy = s9_T('h09', 2.52), tLook = s9_T('look9'), tIns = tMy + 1.2, tBack = tIns + 2.5, tHmm = s9_T('h09b');+ const tFor = s9_T('h09b', .85), tHop = s9_T('h09b', 3.26);+ const tSquat = s9_T('hop9', .05), tJump = tSquat + .3, tLand = tJump + .7, tGo = tLand + .15;+ const tReact = s9_T('n09b', 2.5), tWide = s9_T('end9', .15), tBank = s9_T('end9', 1.2), tCard = tBank + .6;+ const B = RIVER_BED;+ const walkIn = q => route(q, [[0, 1760], [4.9, STOP]], SH);+ const wade = q => s9_glide(q, tGo, tBank, STOP, BANK, SH);+ const s9_x = q => q >= tGo ? wade(q).x : walkIn(q).x;+ const CLOSE = { x: 1390, y: 576, z: 2.6 }; // his close-up, the rabbit's ears at the bottom++ const cam = setCam(p, 'river', { x: 1200, y: 450, z: 1 });+ cam.to({ x: 1330, y: 480, z: 1.15 }, .3, 3.6) // wide, drifting in on the far bank+ .cut({ x: RX + 30, y: 655, z: 3.5 }, tRab) // the rabbit at the water's lip+ .cut({ x: 1425, y: 572, z: 2.2 }, tLH) // "then at Little Horse": the two of them, his face in+ .to({ z: 2.35 }, tLH + .2, 1.3)+ .cut(CLOSE, tH09) // "Oh, don't worry! … up to my—": head and eyes drop+ .cut({ x: 1415, y: 640, z: 3.5 }, tIns) // insert: his legs, the rabbit, the waterline+ .cut(CLOSE, tBack) // back to him: slow blink, "Hmm."+ .cut({ x: 1450, y: 572, z: 2.15 }, tFor) // the two-shot: "Hop on!", the hop+ .cut({ x: q => s9_x(q) - 60, y: 600, z: 2 }, s9_T('n09b')) // the two of them crossing, water at his knees+ .cut({ x: 190, y: 565, z: 2.2 }, tReact) // Squirrel and Uncle Ox on the near bank+ .cut({ x: 560, y: 450, z: 1 }, tWide) // the wide: up the bank, then the hold+ .to({ z: .95 }, tWide + .3, 3);+ cam.soft(tRab, true).soft(tWide, false);++ const st = cam.stage;+ const ox = oxPuppet(st), sq = squirrelPuppet(st), lh = horsePuppet(st), rb = rabbitPuppet(st);+ // The ghost waterline in the insert: the river at his knee, drawn over the rabbit standing beside him.+ const ghost = mk('g', { 'pointer-events': 'none' }, st);+ const gFill = mk('path', { fill: '#7fb3d6', opacity: .28 }, ghost), gLine = mk('path', { fill: 'none', stroke: '#e9f4fb', 'stroke-width': 3.5, 'stroke-dasharray': '10 7', 'stroke-linecap': 'round' }, ghost);+ const card = endCard(p, tCard, 'The End', { x: 800, y: 150, size: 72 });++ // sound: beds, hooves in, the hops, the wade, the climb+ sfx('scene9', 0, 'river', .5); sfx('scene9', 0, 'birds', .4);+ [.3, .95, 1.6, 2.3, 3.0, 3.8].forEach(t => sfx('scene9', t, 'hoof', .25));+ sfx('scene9', tJump, 'hop', .5); sfx('scene9', tLand, 'pop', .3);+ let tWet = tGo, tDry = tGo; while (wade(tWet).x > 1320) tWet += .02; while (wade(tDry).x > 690) tDry += .02; // into and out of the water+ sfx('scene9', tWet, 'splash', .4);+ for (let t = tWet + .8; t < tDry; t += .8) sfx('scene9', +t.toFixed(2), 'slosh', .3);+ [tDry + .1, tBank - .3].forEach(t => sfx('scene9', +t.toFixed(2), 'hoof', .3));+ sfx('scene9', tCard, 'chime', .45);++ stopClock(D, (q, f) => {+ cam.apply(q, f);+ card(q);++ /* ---- Uncle Ox on the near bank by the tree: grazing, then head up to watch them come; a nod at the end ---- */+ const watching = q > tReact - .3;+ ox.pose({ x: OX, y: 700, s: 1.4, turn: 1, grass: !watching, chew: watching ? 0 : q * 1.4,+ neck: watching ? s9_kf(q, [[tReact - .3, 24], [tReact + .3, 12], [tCard + .2, 12], [tCard + .6, 22], [tCard + 1, 12]]) : 24 + 2 * Math.sin(q * 1.3),+ look: watching ? 1 : 0, ear: watching ? -.3 : 0,+ shut: blinking(q, [2.2, 6.9, 12.5, 17.8, 23.6, tReact + .8, tCard + 2.1]) }, f);++ /* ---- Squirrel on the rock: tail alive; cheers them across, claps at the end ---- */+ const wave = q > tReact - .3 && q < tCard, clap = q >= tCard && q < tCard + 1.5;+ sq.pose({ x: 470, y: 648, s: .6, turn: 1, tail: 6 * Math.sin(q * 2.2), tail2: 8 * Math.sin(q * 2.2 - .8),+ paw: wave ? -95 + 28 * Math.sin(q * 10) : clap ? -55 + 18 * onTwos(q) : 0,+ pawF: clap ? -55 - 18 * onTwos(q) : 0, lean: wave ? -6 : clap ? 4 : 0,+ headR: wave || clap ? -8 : 0, mouth: wave || clap ? 'C' : 'X',+ hop: clap && q < tCard + 1.6 ? 8 * Math.max(0, Math.sin((q - tCard) * 6)) : 0,+ shut: blinking(q, [1.4, 5.1, 10.8, 16.5, 22.6, tReact + .5, tCard + 2.4]) }, f);++ /* ---- Little Horse: walks in, talks, catches himself, kneels, wades home and climbs the near bank ---- */+ // on the bank he turns round to look back at the river he crossed (in the wide)+ const hTurn = s9_kf(q, [[tBank + .1, -1], [tBank + .45, 1]]);+ const r1 = walkIn(q), r2 = wade(q), crossing = q >= tGo;+ const x = crossing ? r2.x : r1.x, stand = crossing ? r2.stand : r1.stand;+ const crouch = s9_kf(q, [[tHop + .1, 0], [tHop + .7, 34], [tLand + .05, 34], [tGo + .35, 0]]);+ const dir = hTurn > 0 ? 1 : -1, front = x + dir * 46 * SH, hind = x - dir * 46 * SH, y0 = (B(front) + B(hind)) / 2;+ const slope = Math.atan2(B(front) - B(hind), 92 * SH) * 180 / Math.PI; // facing left: front lower = tilt ++ const lf = (y0 - B(front)) / SH, lb = (y0 - B(hind)) / SH, cl = crouch / SH;+ const lift = s9_kf(q, [[s9_T('h09', 1.4), 0], [s9_T('h09', 1.8), 15], [tIns + .3, 15], [tIns + .65, 0]]);+ const hm = lips(q, 'scene9', PRE9, 'h09', 'h09b');+ lh.pose({ x, y: y0 + crouch, s: SH, turn: hTurn, d: r1.d + r2.d, stand, gait: 'walk', sack: false, cloth: true,+ tilt: slope * .25 + crouch * .2 + s9_kf(q, [[tH09 - .1, 0], [tH09 + .3, -3], [tMy, -3], [tMy + .3, 0]]),+ bob: 1.2 * Math.sin(q * 2.4) * stand,+ legs: { nf: [0, lf + cl + lift], ff: [0, lf + cl], nh: [0, lb + cl], fh: [0, lb + cl] },+ neck: s9_kf(q, [[tRab - .5, 0], [tRab - .1, -20], [tLH - .05, -10], [tLH + .3, 12], [tH09 - .1, 12], [tH09 + .25, -14], [tMy, -14], [tMy + .35, 12],+ [tIns, 12], [tIns + .01, -18], [tBack - .01, -18], [tBack, 12], [tFor - .1, 12], [tFor + .3, 16], [tHop - .1, 16], [tHop + .5, 22],+ [tLand, 22], [tGo, 6], [tReact, 4], [tBank - .3, -4], [tBank + .3, -20]]),+ nod: s9_kf(q, [[tMy, 0], [tMy + .35, 14], [tIns, 14], [tIns + .01, 0], [tBack - .01, 0], [tBack, 12], [tFor + .3, 12], [tHop, 10], [tHop + .4, 2], [tJump, 0], [tLand + .3, -4], [tGo, 0]]),+ look: s9_kf(q, [[tLH, .4], [tH09, .4], [tH09 + .2, 1], [tMy, 1], [tMy + .3, .8], [tFor + .2, .6],+ [tSquat, .6], [tJump + .2, -1], [tLand + .2, -1], [tGo, .7]]),+ brow: s9_kf(q, [[tH09 - .1, 0], [tH09 + .2, .2], [tMy, .2], [tMy + .25, -.8], [tHmm + 1.2, -.8], [tHop - .1, -.5], [tHop + .1, -.2]]),+ ear: s9_kf(q, [[4.6, 0], [5.0, -.5], [tMy, -.6], [tMy + .25, .4], [tHop - .1, .3], [tHop + .1, -.6]]),+ tail: q < tBank ? 7 * Math.sin(q * 2.1) : q < tCard + 1.5 ? -12 + 6 * Math.sin(q * 5) : -12, // tucked: clear of Squirrel+ mouth: q >= tMy + .7 && q < tLook + .4 ? 'B' : hm,+ shut: between(q, tBack + .2, tBack + .2 + 5 / FPS) || blinking(q, [2.6, 6.2, 9.4, tFor + 1.2, tGo + 1.4, tReact + 1.0, tCard + 1.3, tCard + 3.2]) }, f);++ /* ---- the rabbit: at the water's lip; looks down, then up at him; hops to his side, up onto his back, rides home ---- */+ const back = lh.at('back'), seat = [back[0], back[1] + 3];+ const side = s9_kf(q, [[s9_T('h09b', 4.0), RX], [s9_T('h09b', 4.45), RX + 45], [s9_T('h09b', 4.75), RX + 65], [s9_T('h09b', 5.2), STOP - 30]]);+ const sideHop = [s9_T('h09b', 4.0), s9_T('h09b', 4.75)].reduce((a, t0) => a + (between(q, t0, t0 + .45) ? 16 * Math.sin((q - t0) / .45 * Math.PI) : 0), 0);+ let rx = side, ry = 706 - sideHop, lean = s9_kf(q, [[tSquat, 0], [tJump - .05, 14]]);+ if (q >= tJump && q < tLand) { [rx, ry] = s9_hop([STOP - 30, 706], seat, (q - tJump) / (tLand - tJump), 70); lean = -16 + 22 * (q - tJump) / (tLand - tJump); }+ else if (q >= tLand) { [rx, ry] = seat; lean = s9_kf(q, [[tLand, 12], [tLand + .25, 0]]); }+ const squat = q >= tSquat && q < tJump ? 5 * Math.sin((q - tSquat) / .3 * Math.PI) : 0;+ const happyHop = between(q, tHop + .1, tHop + .5) ? 14 * Math.sin((q - tHop - .1) / .4 * Math.PI) : 0;+ rb.pose({ x: rx, y: ry - happyHop + squat, s: SR,+ turn: q < tLH ? -1 : q < s9_T('n09b') ? 1 : hTurn,+ headR: s9_kf(q, [[tWater, 0], [tWater + .3, 20], [tLH, 20], [tLH + .01, -28], [tFor, -26], [s9_T('h09b', 1.7), -20], [s9_T('h09b', 2.0), 8],+ [tHop - .1, 8], [tHop + .05, -18], [tSquat, -10], [tLand + .3, 0], [tReact, 6], [tBank, -10]]) + (q > tLand ? 3 * Math.sin(q * 3.1) : 0),+ ears: s9_kf(q, [[tH09, 0], [tH09 + .4, -6], [tFor, -6], [tFor + .3, 10], [s9_T('h09b', 1.7), 10], [s9_T('h09b', 2.1), 40],+ [tHop - .1, 40], [tHop + .1, -10], [tLand, 25], [tLand + .3, -8]])+ + (q < tLH ? 7 * Math.max(0, Math.sin(q * 11)) : 4 * Math.sin(q * 3.7)) + (q > tGo ? 5 * Math.sin(q * 9) * (1 - stand) : 0),+ ear2: q < tLH ? 9 * Math.max(0, Math.sin(q * 7 + 1)) : 3 * Math.sin(q * 2.9),+ look: q < tLH ? .5 : q > tBank ? .6 : 0, lean, sniff: q < tWater || between(q, tIns, tBack),+ shut: blinking(q, [3.1, tRab + .9, tLH + .6, s9_T('h09', 1.6), tIns + .55, s9_T('h09b', 2.6), tGo + 2.2, tCard + .7, tCard + 2.7]) }, f);++ /* ---- the ghost waterline at his knee, drawn in across the insert ---- */+ const gu = span(q, tIns + .25, tIns + .75);+ vis(ghost, q >= tIns + .25 && q < tBack);+ if (q >= tIns + .25 && q < tBack) {+ const ky = lh.at('nfk')[1], x0 = 1160, x1 = x0 + 480 * gu, ph = q * 5;+ let d = `M${x0},${ky}`;+ for (let xx = x0 + 10; xx <= x1; xx += 10) d += ` L${xx},${(ky + 2.5 * Math.sin(xx / 14 + ph)).toFixed(1)}`;+ gLine.setAttribute('d', d);+ gFill.setAttribute('d', `${d} L${x1},706 L${x0},706 Z`);+ }+ });+}diff --git a/site/little-horse/img/cover.webp b/site/little-horse/img/cover.webpnew file mode 100644index 0000000..b38b97aBinary files /dev/null and b/site/little-horse/img/cover.webp differdiff --git a/site/little-horse/img/puppets/01fd3594.webp b/site/little-horse/img/puppets/01fd3594.webpnew file mode 100644index 0000000..bb0bfcfBinary files /dev/null and b/site/little-horse/img/puppets/01fd3594.webp differdiff --git a/site/little-horse/img/puppets/038175ef.webp b/site/little-horse/img/puppets/038175ef.webpnew file mode 100644index 0000000..a2b34e5Binary files /dev/null and b/site/little-horse/img/puppets/038175ef.webp differdiff --git a/site/little-horse/img/puppets/03f57793.webp b/site/little-horse/img/puppets/03f57793.webpnew file mode 100644index 0000000..15d6f73Binary files /dev/null and b/site/little-horse/img/puppets/03f57793.webp differdiff --git a/site/little-horse/img/puppets/04210ec8.webp b/site/little-horse/img/puppets/04210ec8.webpnew file mode 100644index 0000000..1708927Binary files /dev/null and b/site/little-horse/img/puppets/04210ec8.webp differdiff --git a/site/little-horse/img/puppets/077b6dad.webp b/site/little-horse/img/puppets/077b6dad.webpnew file mode 100644index 0000000..c8d031eBinary files /dev/null and b/site/little-horse/img/puppets/077b6dad.webp differdiff --git a/site/little-horse/img/puppets/0937ae31.webp b/site/little-horse/img/puppets/0937ae31.webpnew file mode 100644index 0000000..eb71a0aBinary files /dev/null and b/site/little-horse/img/puppets/0937ae31.webp differdiff --git a/site/little-horse/img/puppets/0ebca4ca.webp b/site/little-horse/img/puppets/0ebca4ca.webpnew file mode 100644index 0000000..ab8e2e2Binary files /dev/null and b/site/little-horse/img/puppets/0ebca4ca.webp differdiff --git a/site/little-horse/img/puppets/0fcf6ddd.webp b/site/little-horse/img/puppets/0fcf6ddd.webpnew file mode 100644index 0000000..1275fdaBinary files /dev/null and b/site/little-horse/img/puppets/0fcf6ddd.webp differdiff --git a/site/little-horse/img/puppets/0fe23b50.webp b/site/little-horse/img/puppets/0fe23b50.webpnew file mode 100644index 0000000..fbcf34fBinary files /dev/null and b/site/little-horse/img/puppets/0fe23b50.webp differdiff --git a/site/little-horse/img/puppets/0ffd0147.webp b/site/little-horse/img/puppets/0ffd0147.webpnew file mode 100644index 0000000..2e42e11Binary files /dev/null and b/site/little-horse/img/puppets/0ffd0147.webp differdiff --git a/site/little-horse/img/puppets/12ee84a0.webp b/site/little-horse/img/puppets/12ee84a0.webpnew file mode 100644index 0000000..17402c8Binary files /dev/null and b/site/little-horse/img/puppets/12ee84a0.webp differdiff --git a/site/little-horse/img/puppets/14373c23.webp b/site/little-horse/img/puppets/14373c23.webpnew file mode 100644index 0000000..059e7beBinary files /dev/null and b/site/little-horse/img/puppets/14373c23.webp differdiff --git a/site/little-horse/img/puppets/16d0d7f3.webp b/site/little-horse/img/puppets/16d0d7f3.webpnew file mode 100644index 0000000..493a5e2Binary files /dev/null and b/site/little-horse/img/puppets/16d0d7f3.webp differdiff --git a/site/little-horse/img/puppets/18687f9f.webp b/site/little-horse/img/puppets/18687f9f.webpnew file mode 100644index 0000000..8c71a12Binary files /dev/null and b/site/little-horse/img/puppets/18687f9f.webp differdiff --git a/site/little-horse/img/puppets/1bebd487.webp b/site/little-horse/img/puppets/1bebd487.webpnew file mode 100644index 0000000..2bb8c81Binary files /dev/null and b/site/little-horse/img/puppets/1bebd487.webp differdiff --git a/site/little-horse/img/puppets/1c910ac2.webp b/site/little-horse/img/puppets/1c910ac2.webpnew file mode 100644index 0000000..10f69f0Binary files /dev/null and b/site/little-horse/img/puppets/1c910ac2.webp differdiff --git a/site/little-horse/img/puppets/203db0e3.webp b/site/little-horse/img/puppets/203db0e3.webpnew file mode 100644index 0000000..038a575Binary files /dev/null and b/site/little-horse/img/puppets/203db0e3.webp differdiff --git a/site/little-horse/img/puppets/271b9ea4.webp b/site/little-horse/img/puppets/271b9ea4.webpnew file mode 100644index 0000000..5c6cf27Binary files /dev/null and b/site/little-horse/img/puppets/271b9ea4.webp differdiff --git a/site/little-horse/img/puppets/276fc025.webp b/site/little-horse/img/puppets/276fc025.webpnew file mode 100644index 0000000..7320fc1Binary files /dev/null and b/site/little-horse/img/puppets/276fc025.webp differdiff --git a/site/little-horse/img/puppets/2a3cbd11.webp b/site/little-horse/img/puppets/2a3cbd11.webpnew file mode 100644index 0000000..dccf2a4Binary files /dev/null and b/site/little-horse/img/puppets/2a3cbd11.webp differdiff --git a/site/little-horse/img/puppets/2a52b383.webp b/site/little-horse/img/puppets/2a52b383.webpnew file mode 100644index 0000000..b25ae32Binary files /dev/null and b/site/little-horse/img/puppets/2a52b383.webp differdiff --git a/site/little-horse/img/puppets/2d1d09c1.webp b/site/little-horse/img/puppets/2d1d09c1.webpnew file mode 100644index 0000000..5df84c9Binary files /dev/null and b/site/little-horse/img/puppets/2d1d09c1.webp differdiff --git a/site/little-horse/img/puppets/2df36e97.webp b/site/little-horse/img/puppets/2df36e97.webpnew file mode 100644index 0000000..182967dBinary files /dev/null and b/site/little-horse/img/puppets/2df36e97.webp differdiff --git a/site/little-horse/img/puppets/2ee3d858.webp b/site/little-horse/img/puppets/2ee3d858.webpnew file mode 100644index 0000000..5a82878Binary files /dev/null and b/site/little-horse/img/puppets/2ee3d858.webp differdiff --git a/site/little-horse/img/puppets/2fdf704c.webp b/site/little-horse/img/puppets/2fdf704c.webpnew file mode 100644index 0000000..3587961Binary files /dev/null and b/site/little-horse/img/puppets/2fdf704c.webp differdiff --git a/site/little-horse/img/puppets/344d0f53.webp b/site/little-horse/img/puppets/344d0f53.webpnew file mode 100644index 0000000..cebc683Binary files /dev/null and b/site/little-horse/img/puppets/344d0f53.webp differdiff --git a/site/little-horse/img/puppets/34d5ca94.webp b/site/little-horse/img/puppets/34d5ca94.webpnew file mode 100644index 0000000..5abac51Binary files /dev/null and b/site/little-horse/img/puppets/34d5ca94.webp differdiff --git a/site/little-horse/img/puppets/356d9aeb.webp b/site/little-horse/img/puppets/356d9aeb.webpnew file mode 100644index 0000000..4bc6091Binary files /dev/null and b/site/little-horse/img/puppets/356d9aeb.webp differdiff --git a/site/little-horse/img/puppets/37ebb5c4.webp b/site/little-horse/img/puppets/37ebb5c4.webpnew file mode 100644index 0000000..9381331Binary files /dev/null and b/site/little-horse/img/puppets/37ebb5c4.webp differdiff --git a/site/little-horse/img/puppets/382f18ab.webp b/site/little-horse/img/puppets/382f18ab.webpnew file mode 100644index 0000000..5d0b9cdBinary files /dev/null and b/site/little-horse/img/puppets/382f18ab.webp differdiff --git a/site/little-horse/img/puppets/3bfbc080.webp b/site/little-horse/img/puppets/3bfbc080.webpnew file mode 100644index 0000000..699dfe5Binary files /dev/null and b/site/little-horse/img/puppets/3bfbc080.webp differdiff --git a/site/little-horse/img/puppets/3d2fde21.webp b/site/little-horse/img/puppets/3d2fde21.webpnew file mode 100644index 0000000..6a8215aBinary files /dev/null and b/site/little-horse/img/puppets/3d2fde21.webp differdiff --git a/site/little-horse/img/puppets/3d37dd6b.webp b/site/little-horse/img/puppets/3d37dd6b.webpnew file mode 100644index 0000000..7b275c2Binary files /dev/null and b/site/little-horse/img/puppets/3d37dd6b.webp differdiff --git a/site/little-horse/img/puppets/3e5c2c61.webp b/site/little-horse/img/puppets/3e5c2c61.webpnew file mode 100644index 0000000..1b58936Binary files /dev/null and b/site/little-horse/img/puppets/3e5c2c61.webp differdiff --git a/site/little-horse/img/puppets/418f9b4c.webp b/site/little-horse/img/puppets/418f9b4c.webpnew file mode 100644index 0000000..f0f8a8bBinary files /dev/null and b/site/little-horse/img/puppets/418f9b4c.webp differdiff --git a/site/little-horse/img/puppets/4462e8a4.webp b/site/little-horse/img/puppets/4462e8a4.webpnew file mode 100644index 0000000..088c43bBinary files /dev/null and b/site/little-horse/img/puppets/4462e8a4.webp differdiff --git a/site/little-horse/img/puppets/45d2ab11.webp b/site/little-horse/img/puppets/45d2ab11.webpnew file mode 100644index 0000000..2d4f072Binary files /dev/null and b/site/little-horse/img/puppets/45d2ab11.webp differdiff --git a/site/little-horse/img/puppets/4645b708.webp b/site/little-horse/img/puppets/4645b708.webpnew file mode 100644index 0000000..fd87084Binary files /dev/null and b/site/little-horse/img/puppets/4645b708.webp differdiff --git a/site/little-horse/img/puppets/47c16ea9.webp b/site/little-horse/img/puppets/47c16ea9.webpnew file mode 100644index 0000000..2610904Binary files /dev/null and b/site/little-horse/img/puppets/47c16ea9.webp differdiff --git a/site/little-horse/img/puppets/484f04af.webp b/site/little-horse/img/puppets/484f04af.webpnew file mode 100644index 0000000..bb702a4Binary files /dev/null and b/site/little-horse/img/puppets/484f04af.webp differdiff --git a/site/little-horse/img/puppets/49d07daa.webp b/site/little-horse/img/puppets/49d07daa.webpnew file mode 100644index 0000000..1765e5cBinary files /dev/null and b/site/little-horse/img/puppets/49d07daa.webp differdiff --git a/site/little-horse/img/puppets/49f4bc26.webp b/site/little-horse/img/puppets/49f4bc26.webpnew file mode 100644index 0000000..5b9cc41Binary files /dev/null and b/site/little-horse/img/puppets/49f4bc26.webp differdiff --git a/site/little-horse/img/puppets/5361ed06.webp b/site/little-horse/img/puppets/5361ed06.webpnew file mode 100644index 0000000..0bf6c09Binary files /dev/null and b/site/little-horse/img/puppets/5361ed06.webp differdiff --git a/site/little-horse/img/puppets/53f78562.webp b/site/little-horse/img/puppets/53f78562.webpnew file mode 100644index 0000000..ff1f33dBinary files /dev/null and b/site/little-horse/img/puppets/53f78562.webp differdiff --git a/site/little-horse/img/puppets/542f2dc6.webp b/site/little-horse/img/puppets/542f2dc6.webpnew file mode 100644index 0000000..084260bBinary files /dev/null and b/site/little-horse/img/puppets/542f2dc6.webp differdiff --git a/site/little-horse/img/puppets/54cdadf6.webp b/site/little-horse/img/puppets/54cdadf6.webpnew file mode 100644index 0000000..f6202a8Binary files /dev/null and b/site/little-horse/img/puppets/54cdadf6.webp differdiff --git a/site/little-horse/img/puppets/577b00ca.webp b/site/little-horse/img/puppets/577b00ca.webpnew file mode 100644index 0000000..15cb6edBinary files /dev/null and b/site/little-horse/img/puppets/577b00ca.webp differdiff --git a/site/little-horse/img/puppets/581eb337.webp b/site/little-horse/img/puppets/581eb337.webpnew file mode 100644index 0000000..55f7699Binary files /dev/null and b/site/little-horse/img/puppets/581eb337.webp differdiff --git a/site/little-horse/img/puppets/59845bc9.webp b/site/little-horse/img/puppets/59845bc9.webpnew file mode 100644index 0000000..e870631Binary files /dev/null and b/site/little-horse/img/puppets/59845bc9.webp differdiff --git a/site/little-horse/img/puppets/5ab001de.webp b/site/little-horse/img/puppets/5ab001de.webpnew file mode 100644index 0000000..7127c59Binary files /dev/null and b/site/little-horse/img/puppets/5ab001de.webp differdiff --git a/site/little-horse/img/puppets/5e8da735.webp b/site/little-horse/img/puppets/5e8da735.webpnew file mode 100644index 0000000..a86cce0Binary files /dev/null and b/site/little-horse/img/puppets/5e8da735.webp differdiff --git a/site/little-horse/img/puppets/5ff6a76c.webp b/site/little-horse/img/puppets/5ff6a76c.webpnew file mode 100644index 0000000..a1864adBinary files /dev/null and b/site/little-horse/img/puppets/5ff6a76c.webp differdiff --git a/site/little-horse/img/puppets/60967317.webp b/site/little-horse/img/puppets/60967317.webpnew file mode 100644index 0000000..543e350Binary files /dev/null and b/site/little-horse/img/puppets/60967317.webp differdiff --git a/site/little-horse/img/puppets/6201939c.webp b/site/little-horse/img/puppets/6201939c.webpnew file mode 100644index 0000000..9a74f26Binary files /dev/null and b/site/little-horse/img/puppets/6201939c.webp differdiff --git a/site/little-horse/img/puppets/679d8805.webp b/site/little-horse/img/puppets/679d8805.webpnew file mode 100644index 0000000..dc3abf5Binary files /dev/null and b/site/little-horse/img/puppets/679d8805.webp differdiff --git a/site/little-horse/img/puppets/68de22c5.webp b/site/little-horse/img/puppets/68de22c5.webpnew file mode 100644index 0000000..1513b6cBinary files /dev/null and b/site/little-horse/img/puppets/68de22c5.webp differdiff --git a/site/little-horse/img/puppets/6995afe5.webp b/site/little-horse/img/puppets/6995afe5.webpnew file mode 100644index 0000000..b37ce43Binary files /dev/null and b/site/little-horse/img/puppets/6995afe5.webp differdiff --git a/site/little-horse/img/puppets/699ebcfe.webp b/site/little-horse/img/puppets/699ebcfe.webpnew file mode 100644index 0000000..896d593Binary files /dev/null and b/site/little-horse/img/puppets/699ebcfe.webp differdiff --git a/site/little-horse/img/puppets/6b2146f1.webp b/site/little-horse/img/puppets/6b2146f1.webpnew file mode 100644index 0000000..b02d8b3Binary files /dev/null and b/site/little-horse/img/puppets/6b2146f1.webp differdiff --git a/site/little-horse/img/puppets/6df4fdfa.webp b/site/little-horse/img/puppets/6df4fdfa.webpnew file mode 100644index 0000000..9d98ebbBinary files /dev/null and b/site/little-horse/img/puppets/6df4fdfa.webp differdiff --git a/site/little-horse/img/puppets/72fe8473.webp b/site/little-horse/img/puppets/72fe8473.webpnew file mode 100644index 0000000..2c87e35Binary files /dev/null and b/site/little-horse/img/puppets/72fe8473.webp differdiff --git a/site/little-horse/img/puppets/742821ad.webp b/site/little-horse/img/puppets/742821ad.webpnew file mode 100644index 0000000..85a284bBinary files /dev/null and b/site/little-horse/img/puppets/742821ad.webp differdiff --git a/site/little-horse/img/puppets/75334a0e.webp b/site/little-horse/img/puppets/75334a0e.webpnew file mode 100644index 0000000..07bdd6eBinary files /dev/null and b/site/little-horse/img/puppets/75334a0e.webp differdiff --git a/site/little-horse/img/puppets/76c907a3.webp b/site/little-horse/img/puppets/76c907a3.webpnew file mode 100644index 0000000..a7aed69Binary files /dev/null and b/site/little-horse/img/puppets/76c907a3.webp differdiff --git a/site/little-horse/img/puppets/7da74571.webp b/site/little-horse/img/puppets/7da74571.webpnew file mode 100644index 0000000..850bb46Binary files /dev/null and b/site/little-horse/img/puppets/7da74571.webp differdiff --git a/site/little-horse/img/puppets/7e750142.webp b/site/little-horse/img/puppets/7e750142.webpnew file mode 100644index 0000000..2ec1767Binary files /dev/null and b/site/little-horse/img/puppets/7e750142.webp differdiff --git a/site/little-horse/img/puppets/7ee33c75.webp b/site/little-horse/img/puppets/7ee33c75.webpnew file mode 100644index 0000000..79befa8Binary files /dev/null and b/site/little-horse/img/puppets/7ee33c75.webp differdiff --git a/site/little-horse/img/puppets/816587e0.webp b/site/little-horse/img/puppets/816587e0.webpnew file mode 100644index 0000000..831ededBinary files /dev/null and b/site/little-horse/img/puppets/816587e0.webp differdiff --git a/site/little-horse/img/puppets/83e2a14e.webp b/site/little-horse/img/puppets/83e2a14e.webpnew file mode 100644index 0000000..1e5cf76Binary files /dev/null and b/site/little-horse/img/puppets/83e2a14e.webp differdiff --git a/site/little-horse/img/puppets/87bb58e0.webp b/site/little-horse/img/puppets/87bb58e0.webpnew file mode 100644index 0000000..f1522f0Binary files /dev/null and b/site/little-horse/img/puppets/87bb58e0.webp differdiff --git a/site/little-horse/img/puppets/89ac3b7a.webp b/site/little-horse/img/puppets/89ac3b7a.webpnew file mode 100644index 0000000..f8bbd8fBinary files /dev/null and b/site/little-horse/img/puppets/89ac3b7a.webp differdiff --git a/site/little-horse/img/puppets/8ad47a2b.webp b/site/little-horse/img/puppets/8ad47a2b.webpnew file mode 100644index 0000000..91b498bBinary files /dev/null and b/site/little-horse/img/puppets/8ad47a2b.webp differdiff --git a/site/little-horse/img/puppets/8e9cf204.webp b/site/little-horse/img/puppets/8e9cf204.webpnew file mode 100644index 0000000..1435a3fBinary files /dev/null and b/site/little-horse/img/puppets/8e9cf204.webp differdiff --git a/site/little-horse/img/puppets/92e09cf9.webp b/site/little-horse/img/puppets/92e09cf9.webpnew file mode 100644index 0000000..27bfc71Binary files /dev/null and b/site/little-horse/img/puppets/92e09cf9.webp differdiff --git a/site/little-horse/img/puppets/949c256f.webp b/site/little-horse/img/puppets/949c256f.webpnew file mode 100644index 0000000..ae3d0dbBinary files /dev/null and b/site/little-horse/img/puppets/949c256f.webp differdiff --git a/site/little-horse/img/puppets/9605a4e2.webp b/site/little-horse/img/puppets/9605a4e2.webpnew file mode 100644index 0000000..f746421Binary files /dev/null and b/site/little-horse/img/puppets/9605a4e2.webp differdiff --git a/site/little-horse/img/puppets/9b69e8ea.webp b/site/little-horse/img/puppets/9b69e8ea.webpnew file mode 100644index 0000000..7628ee9Binary files /dev/null and b/site/little-horse/img/puppets/9b69e8ea.webp differdiff --git a/site/little-horse/img/puppets/9bac4108.webp b/site/little-horse/img/puppets/9bac4108.webpnew file mode 100644index 0000000..18e8396Binary files /dev/null and b/site/little-horse/img/puppets/9bac4108.webp differdiff --git a/site/little-horse/img/puppets/9c5337a3.webp b/site/little-horse/img/puppets/9c5337a3.webpnew file mode 100644index 0000000..84e790cBinary files /dev/null and b/site/little-horse/img/puppets/9c5337a3.webp differdiff --git a/site/little-horse/img/puppets/9df51f84.webp b/site/little-horse/img/puppets/9df51f84.webpnew file mode 100644index 0000000..0f97c3cBinary files /dev/null and b/site/little-horse/img/puppets/9df51f84.webp differdiff --git a/site/little-horse/img/puppets/9ebc84c0.webp b/site/little-horse/img/puppets/9ebc84c0.webpnew file mode 100644index 0000000..97139d4Binary files /dev/null and b/site/little-horse/img/puppets/9ebc84c0.webp differdiff --git a/site/little-horse/img/puppets/9f2bd4d6.webp b/site/little-horse/img/puppets/9f2bd4d6.webpnew file mode 100644index 0000000..73c7f3aBinary files /dev/null and b/site/little-horse/img/puppets/9f2bd4d6.webp differdiff --git a/site/little-horse/img/puppets/a1924c9f.webp b/site/little-horse/img/puppets/a1924c9f.webpnew file mode 100644index 0000000..f6b6329Binary files /dev/null and b/site/little-horse/img/puppets/a1924c9f.webp differdiff --git a/site/little-horse/img/puppets/a30df306.webp b/site/little-horse/img/puppets/a30df306.webpnew file mode 100644index 0000000..5bf3f8dBinary files /dev/null and b/site/little-horse/img/puppets/a30df306.webp differdiff --git a/site/little-horse/img/puppets/a3a9b22c.webp b/site/little-horse/img/puppets/a3a9b22c.webpnew file mode 100644index 0000000..d10f603Binary files /dev/null and b/site/little-horse/img/puppets/a3a9b22c.webp differdiff --git a/site/little-horse/img/puppets/a616e77b.webp b/site/little-horse/img/puppets/a616e77b.webpnew file mode 100644index 0000000..fd34734Binary files /dev/null and b/site/little-horse/img/puppets/a616e77b.webp differdiff --git a/site/little-horse/img/puppets/a974e71c.webp b/site/little-horse/img/puppets/a974e71c.webpnew file mode 100644index 0000000..4d96d34Binary files /dev/null and b/site/little-horse/img/puppets/a974e71c.webp differdiff --git a/site/little-horse/img/puppets/ad6a6ca8.webp b/site/little-horse/img/puppets/ad6a6ca8.webpnew file mode 100644index 0000000..1067e93Binary files /dev/null and b/site/little-horse/img/puppets/ad6a6ca8.webp differdiff --git a/site/little-horse/img/puppets/adcec47b.webp b/site/little-horse/img/puppets/adcec47b.webpnew file mode 100644index 0000000..98a3a1fBinary files /dev/null and b/site/little-horse/img/puppets/adcec47b.webp differdiff --git a/site/little-horse/img/puppets/b1cf264c.webp b/site/little-horse/img/puppets/b1cf264c.webpnew file mode 100644index 0000000..c46ea90Binary files /dev/null and b/site/little-horse/img/puppets/b1cf264c.webp differdiff --git a/site/little-horse/img/puppets/b2ab3699.webp b/site/little-horse/img/puppets/b2ab3699.webpnew file mode 100644index 0000000..32e2badBinary files /dev/null and b/site/little-horse/img/puppets/b2ab3699.webp differdiff --git a/site/little-horse/img/puppets/b6da230b.webp b/site/little-horse/img/puppets/b6da230b.webpnew file mode 100644index 0000000..e2dcdf8Binary files /dev/null and b/site/little-horse/img/puppets/b6da230b.webp differdiff --git a/site/little-horse/img/puppets/b71f1bdf.webp b/site/little-horse/img/puppets/b71f1bdf.webpnew file mode 100644index 0000000..014129dBinary files /dev/null and b/site/little-horse/img/puppets/b71f1bdf.webp differdiff --git a/site/little-horse/img/puppets/b7f3fb74.webp b/site/little-horse/img/puppets/b7f3fb74.webpnew file mode 100644index 0000000..b850d26Binary files /dev/null and b/site/little-horse/img/puppets/b7f3fb74.webp differdiff --git a/site/little-horse/img/puppets/b8dae16b.webp b/site/little-horse/img/puppets/b8dae16b.webpnew file mode 100644index 0000000..bb1b2c9Binary files /dev/null and b/site/little-horse/img/puppets/b8dae16b.webp differdiff --git a/site/little-horse/img/puppets/b98f679a.webp b/site/little-horse/img/puppets/b98f679a.webpnew file mode 100644index 0000000..00b594eBinary files /dev/null and b/site/little-horse/img/puppets/b98f679a.webp differdiff --git a/site/little-horse/img/puppets/b9e43a76.webp b/site/little-horse/img/puppets/b9e43a76.webpnew file mode 100644index 0000000..63d863fBinary files /dev/null and b/site/little-horse/img/puppets/b9e43a76.webp differdiff --git a/site/little-horse/img/puppets/ba4be902.webp b/site/little-horse/img/puppets/ba4be902.webpnew file mode 100644index 0000000..dcdf752Binary files /dev/null and b/site/little-horse/img/puppets/ba4be902.webp differdiff --git a/site/little-horse/img/puppets/ba8420f1.webp b/site/little-horse/img/puppets/ba8420f1.webpnew file mode 100644index 0000000..d3a28fbBinary files /dev/null and b/site/little-horse/img/puppets/ba8420f1.webp differdiff --git a/site/little-horse/img/puppets/baked.js b/site/little-horse/img/puppets/baked.jsnew file mode 100644index 0000000..e6a8d0d--- /dev/null+++ b/site/little-horse/img/puppets/baked.js@@ -0,0 +1 @@+window.BAKED = {"d3275443": "d3275443.webp", "816587e0": "816587e0.webp", "12ee84a0": "12ee84a0.webp", "ddc5ab3d": "ddc5ab3d.webp", "ba4be902": "ba4be902.webp", "f9f543fe": "f9f543fe.webp", "f80e123a": "f80e123a.webp", "bb8a745b": "bb8a745b.webp", "f56f041c": "f56f041c.webp", "df63c719": "df63c719.webp", "271b9ea4": "271b9ea4.webp", "3d37dd6b": "3d37dd6b.webp", "577b00ca": "577b00ca.webp", "45d2ab11": "45d2ab11.webp", "faca984d": "faca984d.webp", "92e09cf9": "92e09cf9.webp", "a616e77b": "a616e77b.webp", "b2ab3699": "b2ab3699.webp", "75334a0e": "75334a0e.webp", "484f04af": "484f04af.webp", "68de22c5": "68de22c5.webp", "4462e8a4": "4462e8a4.webp", "d674ceb2": "d674ceb2.webp", "47c16ea9": "47c16ea9.webp", "418f9b4c": "418f9b4c.webp", "356d9aeb": "356d9aeb.webp", "87bb58e0": "87bb58e0.webp", "9f2bd4d6": "9f2bd4d6.webp", "b98f679a": "b98f679a.webp", "e23f7073": "e23f7073.webp", "0fcf6ddd": "0fcf6ddd.webp", "59845bc9": "59845bc9.webp", "54cdadf6": "54cdadf6.webp", "03f57793": "03f57793.webp", "3e5c2c61": "3e5c2c61.webp", "b1cf264c": "b1cf264c.webp", "0937ae31": "0937ae31.webp", "dc4ba00e": "dc4ba00e.webp", "fb9371dc": "fb9371dc.webp", "0fe23b50": "0fe23b50.webp", "1c910ac2": "1c910ac2.webp", "76c907a3": "76c907a3.webp", "6df4fdfa": "6df4fdfa.webp", "9bac4108": "9bac4108.webp", "0ebca4ca": "0ebca4ca.webp", "1bebd487": "1bebd487.webp", "01fd3594": "01fd3594.webp", "18687f9f": "18687f9f.webp", "a3a9b22c": "a3a9b22c.webp", "04210ec8": "04210ec8.webp", "5361ed06": "5361ed06.webp", "7e750142": "7e750142.webp", "49f4bc26": "49f4bc26.webp", "382f18ab": "382f18ab.webp", "e3d64510": "e3d64510.webp", "038175ef": "038175ef.webp", "dab431e1": "dab431e1.webp", "d7afe458": "d7afe458.webp", "2d1d09c1": "2d1d09c1.webp", "b8dae16b": "b8dae16b.webp", "7da74571": "7da74571.webp", "2a3cbd11": "2a3cbd11.webp", "344d0f53": "344d0f53.webp", "9c5337a3": "9c5337a3.webp", "9605a4e2": "9605a4e2.webp", "adcec47b": "adcec47b.webp", "3d2fde21": "3d2fde21.webp", "34d5ca94": "34d5ca94.webp", "83e2a14e": "83e2a14e.webp", "cab5b6c4": "cab5b6c4.webp", "ee714495": "ee714495.webp", "581eb337": "581eb337.webp", "c1658de5": "c1658de5.webp", "2a52b383": "2a52b383.webp", "077b6dad": "077b6dad.webp", "dfe57356": "dfe57356.webp", "0ffd0147": "0ffd0147.webp", "60967317": "60967317.webp", "53f78562": "53f78562.webp", "ca42e4d8": "ca42e4d8.webp", "9ebc84c0": "9ebc84c0.webp", "6b2146f1": "6b2146f1.webp", "542f2dc6": "542f2dc6.webp", "72fe8473": "72fe8473.webp", "679d8805": "679d8805.webp", "a1924c9f": "a1924c9f.webp", "8e9cf204": "8e9cf204.webp", "5ff6a76c": "5ff6a76c.webp", "4645b708": "4645b708.webp", "949c256f": "949c256f.webp", "49d07daa": "49d07daa.webp", "b6da230b": "b6da230b.webp", "da29d998": "da29d998.webp", "2fdf704c": "2fdf704c.webp", "ad6a6ca8": "ad6a6ca8.webp", "b9e43a76": "b9e43a76.webp", "8ad47a2b": "8ad47a2b.webp", "699ebcfe": "699ebcfe.webp", "37ebb5c4": "37ebb5c4.webp", "ba8420f1": "ba8420f1.webp", "14373c23": "14373c23.webp", "d4cb8697": "d4cb8697.webp", "5ab001de": "5ab001de.webp", "ef25217c": "ef25217c.webp", "6201939c": "6201939c.webp", "89ac3b7a": "89ac3b7a.webp", "b7f3fb74": "b7f3fb74.webp", "2ee3d858": "2ee3d858.webp", "6995afe5": "6995afe5.webp", "bf135915": "bf135915.webp", "5e8da735": "5e8da735.webp", "9df51f84": "9df51f84.webp", "d5087b6e": "d5087b6e.webp", "a974e71c": "a974e71c.webp", "2df36e97": "2df36e97.webp", "fafabc6e": "fafabc6e.webp", "b71f1bdf": "b71f1bdf.webp", "fbf3e163": "fbf3e163.webp", "16d0d7f3": "16d0d7f3.webp", "203db0e3": "203db0e3.webp", "e7d30f65": "e7d30f65.webp", "276fc025": "276fc025.webp", "3bfbc080": "3bfbc080.webp", "7ee33c75": "7ee33c75.webp", "e1d184f7": "e1d184f7.webp", "742821ad": "742821ad.webp", "a30df306": "a30df306.webp", "9b69e8ea": "9b69e8ea.webp"};diff --git a/site/little-horse/img/puppets/bb8a745b.webp b/site/little-horse/img/puppets/bb8a745b.webpnew file mode 100644index 0000000..56c3ed2Binary files /dev/null and b/site/little-horse/img/puppets/bb8a745b.webp differdiff --git a/site/little-horse/img/puppets/bf135915.webp b/site/little-horse/img/puppets/bf135915.webpnew file mode 100644index 0000000..9abbec6Binary files /dev/null and b/site/little-horse/img/puppets/bf135915.webp differdiff --git a/site/little-horse/img/puppets/c1658de5.webp b/site/little-horse/img/puppets/c1658de5.webpnew file mode 100644index 0000000..512abe9Binary files /dev/null and b/site/little-horse/img/puppets/c1658de5.webp differdiff --git a/site/little-horse/img/puppets/ca42e4d8.webp b/site/little-horse/img/puppets/ca42e4d8.webpnew file mode 100644index 0000000..9f9f8ccBinary files /dev/null and b/site/little-horse/img/puppets/ca42e4d8.webp differdiff --git a/site/little-horse/img/puppets/cab5b6c4.webp b/site/little-horse/img/puppets/cab5b6c4.webpnew file mode 100644index 0000000..f1fb162Binary files /dev/null and b/site/little-horse/img/puppets/cab5b6c4.webp differdiff --git a/site/little-horse/img/puppets/d3275443.webp b/site/little-horse/img/puppets/d3275443.webpnew file mode 100644index 0000000..bbbb3d0Binary files /dev/null and b/site/little-horse/img/puppets/d3275443.webp differdiff --git a/site/little-horse/img/puppets/d4cb8697.webp b/site/little-horse/img/puppets/d4cb8697.webpnew file mode 100644index 0000000..58a4873Binary files /dev/null and b/site/little-horse/img/puppets/d4cb8697.webp differdiff --git a/site/little-horse/img/puppets/d5087b6e.webp b/site/little-horse/img/puppets/d5087b6e.webpnew file mode 100644index 0000000..8764edbBinary files /dev/null and b/site/little-horse/img/puppets/d5087b6e.webp differdiff --git a/site/little-horse/img/puppets/d674ceb2.webp b/site/little-horse/img/puppets/d674ceb2.webpnew file mode 100644index 0000000..44f1716Binary files /dev/null and b/site/little-horse/img/puppets/d674ceb2.webp differdiff --git a/site/little-horse/img/puppets/d7afe458.webp b/site/little-horse/img/puppets/d7afe458.webpnew file mode 100644index 0000000..a1ea66dBinary files /dev/null and b/site/little-horse/img/puppets/d7afe458.webp differdiff --git a/site/little-horse/img/puppets/da29d998.webp b/site/little-horse/img/puppets/da29d998.webpnew file mode 100644index 0000000..0ebcb3cBinary files /dev/null and b/site/little-horse/img/puppets/da29d998.webp differdiff --git a/site/little-horse/img/puppets/dab431e1.webp b/site/little-horse/img/puppets/dab431e1.webpnew file mode 100644index 0000000..745959bBinary files /dev/null and b/site/little-horse/img/puppets/dab431e1.webp differdiff --git a/site/little-horse/img/puppets/dc4ba00e.webp b/site/little-horse/img/puppets/dc4ba00e.webpnew file mode 100644index 0000000..ea93156Binary files /dev/null and b/site/little-horse/img/puppets/dc4ba00e.webp differdiff --git a/site/little-horse/img/puppets/ddc5ab3d.webp b/site/little-horse/img/puppets/ddc5ab3d.webpnew file mode 100644index 0000000..8ae6759Binary files /dev/null and b/site/little-horse/img/puppets/ddc5ab3d.webp differdiff --git a/site/little-horse/img/puppets/df63c719.webp b/site/little-horse/img/puppets/df63c719.webpnew file mode 100644index 0000000..5ad98abBinary files /dev/null and b/site/little-horse/img/puppets/df63c719.webp differdiff --git a/site/little-horse/img/puppets/dfe57356.webp b/site/little-horse/img/puppets/dfe57356.webpnew file mode 100644index 0000000..b716a72Binary files /dev/null and b/site/little-horse/img/puppets/dfe57356.webp differdiff --git a/site/little-horse/img/puppets/e1d184f7.webp b/site/little-horse/img/puppets/e1d184f7.webpnew file mode 100644index 0000000..1428ef1Binary files /dev/null and b/site/little-horse/img/puppets/e1d184f7.webp differdiff --git a/site/little-horse/img/puppets/e23f7073.webp b/site/little-horse/img/puppets/e23f7073.webpnew file mode 100644index 0000000..8de1110Binary files /dev/null and b/site/little-horse/img/puppets/e23f7073.webp differdiff --git a/site/little-horse/img/puppets/e3d64510.webp b/site/little-horse/img/puppets/e3d64510.webpnew file mode 100644index 0000000..e62a301Binary files /dev/null and b/site/little-horse/img/puppets/e3d64510.webp differdiff --git a/site/little-horse/img/puppets/e7d30f65.webp b/site/little-horse/img/puppets/e7d30f65.webpnew file mode 100644index 0000000..0e42875Binary files /dev/null and b/site/little-horse/img/puppets/e7d30f65.webp differdiff --git a/site/little-horse/img/puppets/ee714495.webp b/site/little-horse/img/puppets/ee714495.webpnew file mode 100644index 0000000..a2c349eBinary files /dev/null and b/site/little-horse/img/puppets/ee714495.webp differdiff --git a/site/little-horse/img/puppets/ef25217c.webp b/site/little-horse/img/puppets/ef25217c.webpnew file mode 100644index 0000000..c8b312cBinary files /dev/null and b/site/little-horse/img/puppets/ef25217c.webp differdiff --git a/site/little-horse/img/puppets/f56f041c.webp b/site/little-horse/img/puppets/f56f041c.webpnew file mode 100644index 0000000..d335f23Binary files /dev/null and b/site/little-horse/img/puppets/f56f041c.webp differdiff --git a/site/little-horse/img/puppets/f80e123a.webp b/site/little-horse/img/puppets/f80e123a.webpnew file mode 100644index 0000000..eff04a1Binary files /dev/null and b/site/little-horse/img/puppets/f80e123a.webp differdiff --git a/site/little-horse/img/puppets/f9f543fe.webp b/site/little-horse/img/puppets/f9f543fe.webpnew file mode 100644index 0000000..f56234eBinary files /dev/null and b/site/little-horse/img/puppets/f9f543fe.webp differdiff --git a/site/little-horse/img/puppets/faca984d.webp b/site/little-horse/img/puppets/faca984d.webpnew file mode 100644index 0000000..4cbe20fBinary files /dev/null and b/site/little-horse/img/puppets/faca984d.webp differdiff --git a/site/little-horse/img/puppets/fafabc6e.webp b/site/little-horse/img/puppets/fafabc6e.webpnew file mode 100644index 0000000..040880dBinary files /dev/null and b/site/little-horse/img/puppets/fafabc6e.webp differdiff --git a/site/little-horse/img/puppets/fb9371dc.webp b/site/little-horse/img/puppets/fb9371dc.webpnew file mode 100644index 0000000..33b2907Binary files /dev/null and b/site/little-horse/img/puppets/fb9371dc.webp differdiff --git a/site/little-horse/img/puppets/fbf3e163.webp b/site/little-horse/img/puppets/fbf3e163.webpnew file mode 100644index 0000000..831f351Binary files /dev/null and b/site/little-horse/img/puppets/fbf3e163.webp differdiff --git a/site/little-horse/img/sets/mill/far-soft.webp b/site/little-horse/img/sets/mill/far-soft.webpnew file mode 100644index 0000000..19fa84dBinary files /dev/null and b/site/little-horse/img/sets/mill/far-soft.webp differdiff --git a/site/little-horse/img/sets/mill/far.webp b/site/little-horse/img/sets/mill/far.webpnew file mode 100644index 0000000..1393a6fBinary files /dev/null and b/site/little-horse/img/sets/mill/far.webp differdiff --git a/site/little-horse/img/sets/mill/fence-soft.webp b/site/little-horse/img/sets/mill/fence-soft.webpnew file mode 100644index 0000000..0833922Binary files /dev/null and b/site/little-horse/img/sets/mill/fence-soft.webp differdiff --git a/site/little-horse/img/sets/mill/fence.webp b/site/little-horse/img/sets/mill/fence.webpnew file mode 100644index 0000000..cc5c8daBinary files /dev/null and b/site/little-horse/img/sets/mill/fence.webp differdiff --git a/site/little-horse/img/sets/mill/front-soft.webp b/site/little-horse/img/sets/mill/front-soft.webpnew file mode 100644index 0000000..820f476Binary files /dev/null and b/site/little-horse/img/sets/mill/front-soft.webp differdiff --git a/site/little-horse/img/sets/mill/front.webp b/site/little-horse/img/sets/mill/front.webpnew file mode 100644index 0000000..d34d81cBinary files /dev/null and b/site/little-horse/img/sets/mill/front.webp differdiff --git a/site/little-horse/img/sets/mill/ground-soft.webp b/site/little-horse/img/sets/mill/ground-soft.webpnew file mode 100644index 0000000..ffd325fBinary files /dev/null and b/site/little-horse/img/sets/mill/ground-soft.webp differdiff --git a/site/little-horse/img/sets/mill/ground.webp b/site/little-horse/img/sets/mill/ground.webpnew file mode 100644index 0000000..aaf49bcBinary files /dev/null and b/site/little-horse/img/sets/mill/ground.webp differdiff --git a/site/little-horse/img/sets/mill/hills-soft.webp b/site/little-horse/img/sets/mill/hills-soft.webpnew file mode 100644index 0000000..691167aBinary files /dev/null and b/site/little-horse/img/sets/mill/hills-soft.webp differdiff --git a/site/little-horse/img/sets/mill/hills.webp b/site/little-horse/img/sets/mill/hills.webpnew file mode 100644index 0000000..2a89cd2Binary files /dev/null and b/site/little-horse/img/sets/mill/hills.webp differdiff --git a/site/little-horse/img/sets/mill/house-soft.webp b/site/little-horse/img/sets/mill/house-soft.webpnew file mode 100644index 0000000..e55906aBinary files /dev/null and b/site/little-horse/img/sets/mill/house-soft.webp differdiff --git a/site/little-horse/img/sets/mill/house.webp b/site/little-horse/img/sets/mill/house.webpnew file mode 100644index 0000000..0028682Binary files /dev/null and b/site/little-horse/img/sets/mill/house.webp differdiff --git a/site/little-horse/img/sets/mill/mid-soft.webp b/site/little-horse/img/sets/mill/mid-soft.webpnew file mode 100644index 0000000..c138914Binary files /dev/null and b/site/little-horse/img/sets/mill/mid-soft.webp differdiff --git a/site/little-horse/img/sets/mill/mid.webp b/site/little-horse/img/sets/mill/mid.webpnew file mode 100644index 0000000..5179ae7Binary files /dev/null and b/site/little-horse/img/sets/mill/mid.webp differdiff --git a/site/little-horse/img/sets/mill/pond-soft.webp b/site/little-horse/img/sets/mill/pond-soft.webpnew file mode 100644index 0000000..ef16443Binary files /dev/null and b/site/little-horse/img/sets/mill/pond-soft.webp differdiff --git a/site/little-horse/img/sets/mill/pond.webp b/site/little-horse/img/sets/mill/pond.webpnew file mode 100644index 0000000..17fe18eBinary files /dev/null and b/site/little-horse/img/sets/mill/pond.webp differdiff --git a/site/little-horse/img/sets/mill/sky-soft.webp b/site/little-horse/img/sets/mill/sky-soft.webpnew file mode 100644index 0000000..ec89ea5Binary files /dev/null and b/site/little-horse/img/sets/mill/sky-soft.webp differdiff --git a/site/little-horse/img/sets/mill/sky.webp b/site/little-horse/img/sets/mill/sky.webpnew file mode 100644index 0000000..d11e824Binary files /dev/null and b/site/little-horse/img/sets/mill/sky.webp differdiff --git a/site/little-horse/img/sets/mill/trees-soft.webp b/site/little-horse/img/sets/mill/trees-soft.webpnew file mode 100644index 0000000..9b8e4e1Binary files /dev/null and b/site/little-horse/img/sets/mill/trees-soft.webp differdiff --git a/site/little-horse/img/sets/mill/trees.webp b/site/little-horse/img/sets/mill/trees.webpnew file mode 100644index 0000000..648c052Binary files /dev/null and b/site/little-horse/img/sets/mill/trees.webp differdiff --git a/site/little-horse/img/sets/river/back.webp b/site/little-horse/img/sets/river/back.webpnew file mode 100644index 0000000..a53f361Binary files /dev/null and b/site/little-horse/img/sets/river/back.webp differdiff --git a/site/little-horse/img/sets/river/bank-soft.webp b/site/little-horse/img/sets/river/bank-soft.webpnew file mode 100644index 0000000..2320dd3Binary files /dev/null and b/site/little-horse/img/sets/river/bank-soft.webp differdiff --git a/site/little-horse/img/sets/river/bank.webp b/site/little-horse/img/sets/river/bank.webpnew file mode 100644index 0000000..8e8bcc0Binary files /dev/null and b/site/little-horse/img/sets/river/bank.webp differdiff --git a/site/little-horse/img/sets/river/far-soft.webp b/site/little-horse/img/sets/river/far-soft.webpnew file mode 100644index 0000000..eb80036Binary files /dev/null and b/site/little-horse/img/sets/river/far-soft.webp differdiff --git a/site/little-horse/img/sets/river/far.webp b/site/little-horse/img/sets/river/far.webpnew file mode 100644index 0000000..5edf222Binary files /dev/null and b/site/little-horse/img/sets/river/far.webp differdiff --git a/site/little-horse/img/sets/river/farbank-soft.webp b/site/little-horse/img/sets/river/farbank-soft.webpnew file mode 100644index 0000000..ec4a600Binary files /dev/null and b/site/little-horse/img/sets/river/farbank-soft.webp differdiff --git a/site/little-horse/img/sets/river/farbank.webp b/site/little-horse/img/sets/river/farbank.webpnew file mode 100644index 0000000..690840aBinary files /dev/null and b/site/little-horse/img/sets/river/farbank.webp differdiff --git a/site/little-horse/img/sets/river/front-soft.webp b/site/little-horse/img/sets/river/front-soft.webpnew file mode 100644index 0000000..4f0adacBinary files /dev/null and b/site/little-horse/img/sets/river/front-soft.webp differdiff --git a/site/little-horse/img/sets/river/front.webp b/site/little-horse/img/sets/river/front.webpnew file mode 100644index 0000000..0f0cbcdBinary files /dev/null and b/site/little-horse/img/sets/river/front.webp differdiff --git a/site/little-horse/img/sets/river/hills-soft.webp b/site/little-horse/img/sets/river/hills-soft.webpnew file mode 100644index 0000000..5a4f279Binary files /dev/null and b/site/little-horse/img/sets/river/hills-soft.webp differdiff --git a/site/little-horse/img/sets/river/hills.webp b/site/little-horse/img/sets/river/hills.webpnew file mode 100644index 0000000..fdc18d8Binary files /dev/null and b/site/little-horse/img/sets/river/hills.webp differdiff --git a/site/little-horse/img/sets/river/mid-soft.webp b/site/little-horse/img/sets/river/mid-soft.webpnew file mode 100644index 0000000..e066620Binary files /dev/null and b/site/little-horse/img/sets/river/mid-soft.webp differdiff --git a/site/little-horse/img/sets/river/mid.webp b/site/little-horse/img/sets/river/mid.webpnew file mode 100644index 0000000..1535aa1Binary files /dev/null and b/site/little-horse/img/sets/river/mid.webp differdiff --git a/site/little-horse/img/sets/river/shore.webp b/site/little-horse/img/sets/river/shore.webpnew file mode 100644index 0000000..69790e7Binary files /dev/null and b/site/little-horse/img/sets/river/shore.webp differdiff --git a/site/little-horse/img/sets/river/sky-soft.webp b/site/little-horse/img/sets/river/sky-soft.webpnew file mode 100644index 0000000..ac5c22fBinary files /dev/null and b/site/little-horse/img/sets/river/sky-soft.webp differdiff --git a/site/little-horse/img/sets/river/sky.webp b/site/little-horse/img/sets/river/sky.webpnew file mode 100644index 0000000..04d5257Binary files /dev/null and b/site/little-horse/img/sets/river/sky.webp differdiff --git a/site/little-horse/img/sets/river/tree-soft.webp b/site/little-horse/img/sets/river/tree-soft.webpnew file mode 100644index 0000000..1f0a955Binary files /dev/null and b/site/little-horse/img/sets/river/tree-soft.webp differdiff --git a/site/little-horse/img/sets/river/tree.webp b/site/little-horse/img/sets/river/tree.webpnew file mode 100644index 0000000..6f6871aBinary files /dev/null and b/site/little-horse/img/sets/river/tree.webp differdiff --git a/site/little-horse/img/sets/river/water.webp b/site/little-horse/img/sets/river/water.webpnew file mode 100644index 0000000..7dbb891Binary files /dev/null and b/site/little-horse/img/sets/river/water.webp differdiff --git a/site/little-horse/img/sets/road/far-soft.webp b/site/little-horse/img/sets/road/far-soft.webpnew file mode 100644index 0000000..9949fb1Binary files /dev/null and b/site/little-horse/img/sets/road/far-soft.webp differdiff --git a/site/little-horse/img/sets/road/far.webp b/site/little-horse/img/sets/road/far.webpnew file mode 100644index 0000000..1000981Binary files /dev/null and b/site/little-horse/img/sets/road/far.webp differdiff --git a/site/little-horse/img/sets/road/fields-soft.webp b/site/little-horse/img/sets/road/fields-soft.webpnew file mode 100644index 0000000..67a0e4cBinary files /dev/null and b/site/little-horse/img/sets/road/fields-soft.webp differdiff --git a/site/little-horse/img/sets/road/fields.webp b/site/little-horse/img/sets/road/fields.webpnew file mode 100644index 0000000..9542280Binary files /dev/null and b/site/little-horse/img/sets/road/fields.webp differdiff --git a/site/little-horse/img/sets/road/front-soft.webp b/site/little-horse/img/sets/road/front-soft.webpnew file mode 100644index 0000000..4541bb5Binary files /dev/null and b/site/little-horse/img/sets/road/front-soft.webp differdiff --git a/site/little-horse/img/sets/road/front.webp b/site/little-horse/img/sets/road/front.webpnew file mode 100644index 0000000..def6611Binary files /dev/null and b/site/little-horse/img/sets/road/front.webp differdiff --git a/site/little-horse/img/sets/road/ground-soft.webp b/site/little-horse/img/sets/road/ground-soft.webpnew file mode 100644index 0000000..4b7f56dBinary files /dev/null and b/site/little-horse/img/sets/road/ground-soft.webp differdiff --git a/site/little-horse/img/sets/road/ground.webp b/site/little-horse/img/sets/road/ground.webpnew file mode 100644index 0000000..c8ae11bBinary files /dev/null and b/site/little-horse/img/sets/road/ground.webp differdiff --git a/site/little-horse/img/sets/road/hills-soft.webp b/site/little-horse/img/sets/road/hills-soft.webpnew file mode 100644index 0000000..cb40b9bBinary files /dev/null and b/site/little-horse/img/sets/road/hills-soft.webp differdiff --git a/site/little-horse/img/sets/road/hills.webp b/site/little-horse/img/sets/road/hills.webpnew file mode 100644index 0000000..4080badBinary files /dev/null and b/site/little-horse/img/sets/road/hills.webp differdiff --git a/site/little-horse/img/sets/road/mid-soft.webp b/site/little-horse/img/sets/road/mid-soft.webpnew file mode 100644index 0000000..03cedceBinary files /dev/null and b/site/little-horse/img/sets/road/mid-soft.webp differdiff --git a/site/little-horse/img/sets/road/mid.webp b/site/little-horse/img/sets/road/mid.webpnew file mode 100644index 0000000..48fecb7Binary files /dev/null and b/site/little-horse/img/sets/road/mid.webp differdiff --git a/site/little-horse/img/sets/road/sky-soft.webp b/site/little-horse/img/sets/road/sky-soft.webpnew file mode 100644index 0000000..5f3fda9Binary files /dev/null and b/site/little-horse/img/sets/road/sky-soft.webp differdiff --git a/site/little-horse/img/sets/road/sky.webp b/site/little-horse/img/sets/road/sky.webpnew file mode 100644index 0000000..b01d224Binary files /dev/null and b/site/little-horse/img/sets/road/sky.webp differdiff --git a/site/little-horse/img/sets/road/trees-soft.webp b/site/little-horse/img/sets/road/trees-soft.webpnew file mode 100644index 0000000..a72c7e2Binary files /dev/null and b/site/little-horse/img/sets/road/trees-soft.webp differdiff --git a/site/little-horse/img/sets/road/trees.webp b/site/little-horse/img/sets/road/trees.webpnew file mode 100644index 0000000..a3086afBinary files /dev/null and b/site/little-horse/img/sets/road/trees.webp differdiff --git a/site/little-horse/img/sets/sets.js b/site/little-horse/img/sets/sets.jsnew file mode 100644index 0000000..3bd7fc0--- /dev/null+++ b/site/little-horse/img/sets/sets.js@@ -0,0 +1 @@+window.SETS = {"stable": [{"name": "sky", "k": 0.1, "box": [-300, -80, 2200, 720], "soft": true}, {"name": "far", "k": 0.25, "box": [-400, 140, 2400, 600], "soft": true}, {"name": "mid", "k": 0.42, "box": [-400, 260, 2400, 520], "soft": true}, {"name": "hills", "k": 0.6, "box": [-400, 400, 2400, 440], "soft": true}, {"name": "trees", "k": 0.82, "box": [-300, 300, 2200, 520], "soft": true}, {"name": "brook", "k": 0.9, "box": [-300, 690, 2200, 80], "soft": true}, {"name": "house", "k": 0.96, "box": [60, 270, 920, 520], "soft": true}, {"name": "willow", "k": 0.97, "box": [880, 120, 520, 680], "soft": true}, {"name": "fence", "k": 0.99, "box": [1160, 660, 680, 140], "soft": true}, {"name": "ground", "k": 1, "box": [-300, 740, 2200, 320], "soft": true}, {"name": "front", "k": 1.25, "box": [-300, 800, 2200, 200], "soft": true}], "road": [{"name": "sky", "k": 0.1, "box": [-300, -80, 5000, 720], "soft": true}, {"name": "far", "k": 0.25, "box": [-400, 140, 5200, 600], "soft": true}, {"name": "mid", "k": 0.42, "box": [-400, 260, 5200, 520], "soft": true}, {"name": "hills", "k": 0.6, "box": [-400, 400, 5200, 440], "soft": true}, {"name": "fields", "k": 0.8, "box": [-300, 690, 5000, 110], "soft": true}, {"name": "trees", "k": 0.9, "box": [-400, 200, 5200, 600], "soft": true}, {"name": "ground", "k": 1, "box": [-300, 740, 5000, 320], "soft": true}, {"name": "front", "k": 1.3, "box": [-900, 780, 6500, 220], "soft": true}], "river": [{"name": "sky", "k": 0.1, "box": [-500, -80, 3000, 720], "soft": true}, {"name": "far", "k": 0.25, "box": [-600, 140, 3200, 600], "soft": true}, {"name": "mid", "k": 0.42, "box": [-600, 260, 3200, 520], "soft": true}, {"name": "hills", "k": 0.6, "box": [-600, 400, 3200, 440], "soft": true}, {"name": "farbank", "k": 0.85, "box": [-600, 480, 3200, 240], "soft": true}, {"name": "back", "k": 0.95, "box": [-600, 680, 3200, 60], "soft": false}, {"name": "bank", "k": 1, "box": [-500, 600, 3000, 460], "soft": true}, {"name": "tree", "k": 1, "box": [20, 60, 480, 660], "soft": true}, {"name": "water", "k": 1, "box": [540, 700, 840, 360], "soft": false}, {"name": "shore", "k": 1, "box": [-500, 690, 3000, 370], "soft": false}, {"name": "front", "k": 1.3, "box": [-900, 800, 3800, 220], "soft": true}], "mill": [{"name": "sky", "k": 0.1, "box": [-300, -80, 2200, 720], "soft": true}, {"name": "far", "k": 0.25, "box": [-400, 140, 2400, 600], "soft": true}, {"name": "mid", "k": 0.42, "box": [-400, 260, 2400, 520], "soft": true}, {"name": "hills", "k": 0.6, "box": [-400, 400, 2400, 440], "soft": true}, {"name": "trees", "k": 0.82, "box": [-300, 300, 2200, 520], "soft": true}, {"name": "house", "k": 0.97, "box": [620, 300, 820, 500], "soft": true}, {"name": "fence", "k": 0.99, "box": [100, 670, 500, 130], "soft": true}, {"name": "ground", "k": 1, "box": [-300, 740, 1500, 320], "soft": true}, {"name": "pond", "k": 1, "box": [1140, 730, 760, 330], "soft": true}, {"name": "front", "k": 1.25, "box": [-300, 800, 2200, 200], "soft": true}]};diff --git a/site/little-horse/img/sets/stable/brook-soft.webp b/site/little-horse/img/sets/stable/brook-soft.webpnew file mode 100644index 0000000..e3d9f26Binary files /dev/null and b/site/little-horse/img/sets/stable/brook-soft.webp differdiff --git a/site/little-horse/img/sets/stable/brook.webp b/site/little-horse/img/sets/stable/brook.webpnew file mode 100644index 0000000..5813d71Binary files /dev/null and b/site/little-horse/img/sets/stable/brook.webp differdiff --git a/site/little-horse/img/sets/stable/far-soft.webp b/site/little-horse/img/sets/stable/far-soft.webpnew file mode 100644index 0000000..30b6d21Binary files /dev/null and b/site/little-horse/img/sets/stable/far-soft.webp differdiff --git a/site/little-horse/img/sets/stable/far.webp b/site/little-horse/img/sets/stable/far.webpnew file mode 100644index 0000000..fffa633Binary files /dev/null and b/site/little-horse/img/sets/stable/far.webp differdiff --git a/site/little-horse/img/sets/stable/fence-soft.webp b/site/little-horse/img/sets/stable/fence-soft.webpnew file mode 100644index 0000000..263eef5Binary files /dev/null and b/site/little-horse/img/sets/stable/fence-soft.webp differdiff --git a/site/little-horse/img/sets/stable/fence.webp b/site/little-horse/img/sets/stable/fence.webpnew file mode 100644index 0000000..87fd9b7Binary files /dev/null and b/site/little-horse/img/sets/stable/fence.webp differdiff --git a/site/little-horse/img/sets/stable/front-soft.webp b/site/little-horse/img/sets/stable/front-soft.webpnew file mode 100644index 0000000..16ef7adBinary files /dev/null and b/site/little-horse/img/sets/stable/front-soft.webp differdiff --git a/site/little-horse/img/sets/stable/front.webp b/site/little-horse/img/sets/stable/front.webpnew file mode 100644index 0000000..ace870bBinary files /dev/null and b/site/little-horse/img/sets/stable/front.webp differdiff --git a/site/little-horse/img/sets/stable/ground-soft.webp b/site/little-horse/img/sets/stable/ground-soft.webpnew file mode 100644index 0000000..8499c19Binary files /dev/null and b/site/little-horse/img/sets/stable/ground-soft.webp differdiff --git a/site/little-horse/img/sets/stable/ground.webp b/site/little-horse/img/sets/stable/ground.webpnew file mode 100644index 0000000..020dfefBinary files /dev/null and b/site/little-horse/img/sets/stable/ground.webp differdiff --git a/site/little-horse/img/sets/stable/hills-soft.webp b/site/little-horse/img/sets/stable/hills-soft.webpnew file mode 100644index 0000000..f52e935Binary files /dev/null and b/site/little-horse/img/sets/stable/hills-soft.webp differdiff --git a/site/little-horse/img/sets/stable/hills.webp b/site/little-horse/img/sets/stable/hills.webpnew file mode 100644index 0000000..99ed8e3Binary files /dev/null and b/site/little-horse/img/sets/stable/hills.webp differdiff --git a/site/little-horse/img/sets/stable/house-soft.webp b/site/little-horse/img/sets/stable/house-soft.webpnew file mode 100644index 0000000..cca2d8fBinary files /dev/null and b/site/little-horse/img/sets/stable/house-soft.webp differdiff --git a/site/little-horse/img/sets/stable/house.webp b/site/little-horse/img/sets/stable/house.webpnew file mode 100644index 0000000..197c054Binary files /dev/null and b/site/little-horse/img/sets/stable/house.webp differdiff --git a/site/little-horse/img/sets/stable/mid-soft.webp b/site/little-horse/img/sets/stable/mid-soft.webpnew file mode 100644index 0000000..8af9553Binary files /dev/null and b/site/little-horse/img/sets/stable/mid-soft.webp differdiff --git a/site/little-horse/img/sets/stable/mid.webp b/site/little-horse/img/sets/stable/mid.webpnew file mode 100644index 0000000..8e546dbBinary files /dev/null and b/site/little-horse/img/sets/stable/mid.webp differdiff --git a/site/little-horse/img/sets/stable/sky-soft.webp b/site/little-horse/img/sets/stable/sky-soft.webpnew file mode 100644index 0000000..1379d21Binary files /dev/null and b/site/little-horse/img/sets/stable/sky-soft.webp differdiff --git a/site/little-horse/img/sets/stable/sky.webp b/site/little-horse/img/sets/stable/sky.webpnew file mode 100644index 0000000..c78c143Binary files /dev/null and b/site/little-horse/img/sets/stable/sky.webp differdiff --git a/site/little-horse/img/sets/stable/trees-soft.webp b/site/little-horse/img/sets/stable/trees-soft.webpnew file mode 100644index 0000000..a44c01cBinary files /dev/null and b/site/little-horse/img/sets/stable/trees-soft.webp differdiff --git a/site/little-horse/img/sets/stable/trees.webp b/site/little-horse/img/sets/stable/trees.webpnew file mode 100644index 0000000..348ab20Binary files /dev/null and b/site/little-horse/img/sets/stable/trees.webp differdiff --git a/site/little-horse/img/sets/stable/willow-soft.webp b/site/little-horse/img/sets/stable/willow-soft.webpnew file mode 100644index 0000000..f234134Binary files /dev/null and b/site/little-horse/img/sets/stable/willow-soft.webp differdiff --git a/site/little-horse/img/sets/stable/willow.webp b/site/little-horse/img/sets/stable/willow.webpnew file mode 100644index 0000000..3864244Binary files /dev/null and b/site/little-horse/img/sets/stable/willow.webp differdiff --git a/site/little-horse/img/still-ch01.webp b/site/little-horse/img/still-ch01.webpnew file mode 100644index 0000000..b38b97aBinary files /dev/null and b/site/little-horse/img/still-ch01.webp differdiff --git a/site/little-horse/index.html b/site/little-horse/index.htmlnew file mode 100644index 0000000..821f501--- /dev/null+++ b/site/little-horse/index.html@@ -0,0 +1,62 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>The Little Horse Crosses the River</title>+<meta name="description" content="A Chinese folk tale (小马过河) as a paper cut-out film, all drawn in code, with English voices and two stops where a child touches the picture to hear its words.">+<link rel="stylesheet" href="lib/book.css"><!-- only for --progress-key, if the book sets one -->+<!-- A picture book's cover and episode list. A starting point, not a design: give it the book's own look. -->+<style>+ :root { --ink: #2f2418; --soft: #6b5a46; --paper: #fbf5e8; --card: #fffaf0; --line: #e4d6bb; --accent: #2f5aa8;+ --ui: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif; --serif: "Iowan Old Style", Palatino, Georgia, serif; color-scheme: light; }+ * { box-sizing: border-box; }+ body { margin: 0; background: var(--paper); color: var(--ink); font: 18px/1.6 var(--ui); }+ header { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px; align-items: center; max-width: 1180px; margin: 0 auto; padding: 48px 24px 24px; }+ header img { width: 100%; height: auto; border-radius: 10px; box-shadow: 0 14px 40px #4a33182e; }+ h1 { margin: 0 0 8px; font: 700 clamp(34px, 4.6vw, 56px)/1.05 var(--serif); }+ .lede { font-size: 20px; color: var(--soft); }+ main { max-width: 1000px; margin: 0 auto; padding: 8px 24px 80px; }+ .episodes { list-style: none; padding: 0; margin: 18px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }+ .episodes a { display: flex; flex-direction: column; height: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 10px;+ overflow: hidden; color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s; }+ .episodes a:hover, .episodes a:focus-visible { border-color: var(--accent); transform: translateY(-2px); }+ .episodes img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }+ .episodes small { margin: 12px 16px 0; color: var(--soft); font-size: 13px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }+ .episodes b { margin: 2px 16px 4px; font: 700 21px/1.25 var(--serif); }+ .episodes span { margin: 0 16px 16px; color: var(--soft); font-size: 15px; line-height: 1.5; }+ .watched small::after { content: " · ✓ watched"; color: var(--accent); }+ @media (max-width: 760px) { header { grid-template-columns: 1fr; padding-top: 28px; } .episodes { grid-template-columns: 1fr; } }+</style>+</head>+<body>+<header>+ <img src="img/cover.webp" width="1400" height="788" alt="Little Horse, a chestnut paper foal with a red saddle cloth, standing in the river with the water at his knees.">+ <div>+ <h1>The Little Horse Crosses the River</h1>+ <p class="lede">小马过河 — a Chinese folk tale for young children learning English. Uncle Ox says the river is shallow; Squirrel says it is deep. Little Horse has to find out for himself.</p>+ <p class="lede">Paper puppets in a layered spring valley, all drawn in code. Twice the film stops so a child can touch the picture and hear the words.</p>+ </div>+</header>+<main>+ <ul class="episodes" id="episodes"></ul>+</main>+<script>+'use strict';+// One entry per finished episode, in order: its folder, title, a still (16:9) with alt text, and one line.+const EPISODES = [+ { ch: 'ch01', title: 'The Little Horse Crosses the River', minutes: 4, still: 'img/still-ch01.webp', alt: 'Little Horse at the river bank with Uncle Ox in the shallows.', line: 'Is the river deep or shallow? It depends on who is asking.' },+];+// The player records finished episodes under the same key as here (engine progress(): lib/book.css --progress-key,+// else this folder's path).+const key = getComputedStyle(document.documentElement).getPropertyValue('--progress-key').trim().replace(/^["']|["']$/g, '')+ || 'animebook:progress:' + new URL('.', location.href).pathname;+let done = [];+try { done = JSON.parse(localStorage.getItem(key) || '{}').done || []; } catch {}+const esc = s => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');+document.getElementById('episodes').innerHTML = EPISODES.map((e, i) => `<li${done.includes(+e.ch.slice(2)) ? ' class="watched"' : ''}>+ <a href="${e.ch}/"><img src="${esc(e.still)}" alt="${esc(e.alt)}" loading="lazy">+ <small>Film · ${e.minutes} minute${e.minutes == 1 ? "" : "s"}</small><b>${esc(e.title)}</b><span>${esc(e.line)}</span></a></li>`).join('');+</script>+</body>+</html>diff --git a/site/little-horse/lib/book.css b/site/little-horse/lib/book.cssnew file mode 100644index 0000000..1d09772--- /dev/null+++ b/site/little-horse/lib/book.css@@ -0,0 +1,15 @@+/* This book's own settings, imported by engine.css. The engine files next to this one are the same in every book+ and are replaced when the engine is updated; this file is not.+ Settings (uncomment to use):+:root {+ --math-font: "Avenir Next", Arial, sans-serif; face for numbers and formulas (default: a serif, see engine.js)+ --progress-key: "progress"; localStorage key shared with the cover (default: one per book folder)+ --page: #e9e5d8; --board: #fbfaf5; --panel: #fff; --edge: #d8d2c0; a light board: the palette at the top of+ --chalk: #1d1d1f; --dim: #6a6a6e; --faint: #c4bfae; engine.css, redefined; the stage, cards,+ --task: #e2589b; --quiz: #1f6fc5; --good: #3f8a1d; --bad: #d9473a; bar and COL follow (#rrggbb for the ink+ --on-fill: #fff; --vignette: rgba(90, 70, 30, .08); color-scheme: light; and board colours COL reads)+ --rule: #ece8e0; --track: #e6e2d5; --track-ask: #cfdeeb; and the shades between them+ --bar-edge: #eae6da; --hover: #efede6; --veil: #e9e5d8;+}+ Style overrides go here too. They come before the engine's rules, so make each selector more specific than the+ engine's, e.g. ':root .card.band' for '.card.band'. */diff --git a/site/little-horse/lib/cast.js b/site/little-horse/lib/cast.jsnew file mode 100644index 0000000..eeb36d9--- /dev/null+++ b/site/little-horse/lib/cast.js@@ -0,0 +1,291 @@+/* cast.js — the animals of The Little Horse Crosses the River, on paper.js: Little Horse, Mother, Uncle Ox (a water+ buffalo), Squirrel and a little rabbit. All are drawn in profile facing right, at the point on the ground under the+ body (0, 0); `turn` -1 faces left, and a turn tweened through 0 squashes the whole figure flat and out mirrored,+ as a cut-out turned over on the table.++ The four-legged ones share one rig (beast): each leg is two pieces on pins and is solved to put its hoof on a point,+ so a hoof planted on the ground stays exactly there while the body rides over it. Walking and trotting come from the+ distance covered, not the clock: pose({ d }) with d in the puppet's own units, and the scene moves x by d·s in the+ facing direction (x = x0 + turn·s·d), so the feet never slide. `stand` (0..1) blends every leg back to its rest+ place for a stop.++ at(name) gives a named point of the drawn pose in the puppet's parent's coordinates ('mouth', 'back', 'eye',+ 'head'; a leg's hip 'nf' 'ff' 'nh' 'fh', its knee or hock 'nfk' …, its hoof 'nfHoof' …; Squirrel: 'mouth', 'paw',+ 'eye', 'top'; Rabbit: 'eye', 'top'), so a sack in a mouth or water at a knee lands where the picture is.+ brow: positive tips the brow down to the nose (cross, determined), negative lifts it (worried, surprised). */+'use strict';++// How far a jaw opens for each mouth shape of the cues.+const JAW = { X: 0, A: 0, B: .25, C: .45, D: .9, E: .6, F: .3, G: .2, H: .35 };+const tri = x => 1 - Math.abs(((x % 2) + 2) % 2 - 1); // 0..1..0 every 2+const frac = x => x - Math.floor(x);+const deg = r => r * 180 / Math.PI;++const pf = (body, id = '') => `<g${id ? ` data-p="${id}"` : ''} filter="url(#paper)">${body}</g>`;+const mark = (id, x, y) => `<g data-p="${id}" transform="translate(${x} ${y})"></g>`;++/* ---------- the four-legged rig ----------+ geo: { hips: { nf: [x, y], ff, nh, fh }, up, low, L (stride), H (hoof lift), neck: [x, y] pivot, head: [x, y] pivot,+ jaw: [x, y] pivot, ear: [x, y], tail: [x, y], body: [x, y] tilt centre, rest: { nf: dx, … } hoof under hip }+ Legs: nf near fore, ff far fore, nh near hind, fh far hind. A fore knee folds forward, a hind hock backward. */+function legSVG(id, up, low, wUp, wLow, col, hoof, sock = null) {+ const u = `<path d="M${-wUp / 2},-6 C${-wUp / 2},${up * .5} ${-wLow / 2 - 1},${up * .8} ${-wLow / 2},${up + 4} L${wLow / 2},${up + 4} C${wLow / 2 + 1},${up * .8} ${wUp / 2},${up * .5} ${wUp / 2},-6 Z" fill="${col}"/>`;+ const l = `<path d="M${-wLow / 2},-3 L${-wLow / 2 + 1},${low - 14} L${wLow / 2 - 1},${low - 14} L${wLow / 2},-3 Z" fill="${col}"/>`+ + (sock ? `<path d="M${-wLow / 2 + 1},${low - 34} L${-wLow / 2 + 1},${low - 12} L${wLow / 2 - 1},${low - 12} L${wLow / 2 - 1},${low - 34} Z" fill="${sock}"/>` : '')+ + `<path d="M${-wLow / 2 - 2},${low - 15} L${wLow / 2 + 4},${low - 15} L${wLow / 2 + 7},${low} L${-wLow / 2 - 3},${low} Z" fill="${hoof}"/>`;+ return `<g data-p="${id}">${pf(u)}<g data-p="${id}k" transform="translate(0 ${up})">${pf(l)}${pinAt(0, 0)}${mark(id + 'Hoof', 1, low)}</g>${pinAt(0, 0)}</g>`;+}++// Two-bone reach from a hip to a hoof point (dx, dy from the hip, y down): the upper and lower piece angles in degrees+// (SVG rotate, 0 = straight down). bend +1 puts the joint forward (a fore knee), -1 backward (a hind hock).+function reach2(dx, dy, up, low, bend) {+ let D = Math.hypot(dx, dy); D = Math.min(up + low - .5, Math.max(Math.abs(up - low) + 1, D));+ const phi0 = Math.atan2(dx, dy), b = Math.acos(Math.max(-1, Math.min(1, (up * up + D * D - low * low) / (2 * up * D))));+ const p1 = phi0 + bend * b, kx = up * Math.sin(p1), ky = up * Math.cos(p1);+ const p2 = Math.atan2(dx - kx, dy - ky);+ return [-deg(p1), -deg(p2 - p1)];+}++// Where each hoof is, relative to its rest place, at walk distance d: [dx, lift]. Walk: one hoof at a time (lateral+// sequence); trot: diagonal pairs.+const GAITS = {+ walk: { phase: { nh: 0, nf: .25, fh: .5, ff: .75 }, beta: .64, bob: 2.5 },+ trot: { phase: { nh: 0, ff: 0, fh: .5, nf: .5 }, beta: .5, bob: 6 },+};+function gait(d, kind, L, H) {+ const G = GAITS[kind], out = {}, u0 = d / L;+ for (const k of ['nf', 'ff', 'nh', 'fh']) {+ const r = frac(u0 + G.phase[k]), b = G.beta, s = L * b;+ if (r < b) out[k] = [s / 2 - s * (r / b), 0];+ else { const w = (r - b) / (1 - b); out[k] = [-s / 2 + s * ease(w), H * Math.sin(Math.PI * w)]; }+ }+ out.bob = kind === 'trot' ? -G.bob * Math.abs(Math.sin(2 * Math.PI * u0)) : -G.bob * (1 - Math.cos(4 * Math.PI * u0)) / 2;+ return out;+}++const REST_BEAST = { x: 0, y: 0, s: 1, turn: 1, d: 0, gait: 'walk', stand: 1, bob: 0, tilt: 0, neck: 0, nod: 0, mouth: 'X',+ jaw: null, shut: false, lid: 0, look: 0, brow: 0, ear: 0, tail: 0, legs: {}, sack: false, cloth: true, grass: false, chew: 0, tear: false };++function beast(parent, svg, geo, rest) {+ const g = mk('g', {}, parent);+ g.innerHTML = svg;+ bakeAll(g);+ const P = pieces(g), R = { ...REST_BEAST, ...rest };+ const legs = ['nf', 'ff', 'nh', 'fh'];+ const pup = {+ g, P,+ pose(o, f) {+ o = { ...R, ...o };+ const j = k => jit(f, k);+ const gt = gait(o.d, o.gait, geo.L, geo.H), st = Math.max(0, Math.min(1, o.stand));+ const bob = o.bob + gt.bob * (1 - st);+ const tn = Math.sign(o.turn || 1) * Math.max(.34, Math.abs(o.turn)); // flips through, never a sliver+ tf(g, `translate(${(o.x + j(1) * .7).toFixed(1)},${(o.y + j(2) * .5).toFixed(1)}) scale(${(o.s * tn).toFixed(4)},${o.s.toFixed(4)})`);+ // the body (with neck, head, tail) tilts about its centre and rides the bob; legs hang from the tilted hips+ const [cx, cy] = geo.body, a = o.tilt * Math.PI / 180, ca = Math.cos(a), sa = Math.sin(a);+ tf(P.trunk, `translate(0,${bob.toFixed(1)}) rotate(${(o.tilt + j(3) * .3).toFixed(2)},${cx},${cy})`);+ for (const k of legs) {+ const [hx0, hy0] = geo.hips[k], hx = cx + (hx0 - cx) * ca - (hy0 - cy) * sa, hy = cy + (hx0 - cx) * sa + (hy0 - cy) * ca + bob;+ const [gx, gl] = gt[k], extra = o.legs[k] || [0, 0];+ const fx = hx0 + geo.rest[k] + gx * (1 - st) + extra[0], fy = -(gl * (1 - st)) - extra[1];+ const [a1, a2] = reach2(fx - hx, fy - hy, geo.up, geo.low, k[1] === 'f' ? 1 : -1);+ tf(P[k], `translate(${hx.toFixed(1)},${hy.toFixed(1)}) rotate(${(a1 + j(4) * .4).toFixed(2)})`);+ tf(P[k + 'k'], `translate(0,${geo.up}) rotate(${a2.toFixed(2)})`);+ }+ tf(P.neckG, `rotate(${(o.neck + j(5) * .4).toFixed(2)},${geo.neck[0]},${geo.neck[1]})`);+ tf(P.headG, `rotate(${(o.nod + j(6) * .5).toFixed(2)},${geo.head[0]},${geo.head[1]})`);+ const jaw = o.jaw ?? (o.chew ? .25 + .25 * Math.sin(o.chew * Math.PI * 2) : JAW[o.mouth || 'X'] ?? 0);+ tf(P.jaw, `rotate(${(jaw * geo.jawOpen).toFixed(1)},${geo.jaw[0]},${geo.jaw[1]})`);+ tf(P.ear, `rotate(${(o.ear * 22 + j(7)).toFixed(1)},${geo.ear[0]},${geo.ear[1]})`);+ tf(P.tail, `rotate(${(o.tail + j(8) * 1.5).toFixed(1)},${geo.tail[0]},${geo.tail[1]})`);+ vis(P.eyeO, !o.shut); vis(P.eyeC, !!o.shut);+ if (P.lid) { vis(P.lid, !o.shut && o.lid > 0); tf(P.lid, `translate(0,${(-geo.lidH * (1 - o.lid)).toFixed(1)})`); }+ tf(P.pupil, `translate(${(o.look * geo.lookX).toFixed(1)},0)`);+ if (P.brow) tf(P.brow, `rotate(${(o.brow * 14).toFixed(1)},${geo.eye[0]},${geo.eye[1] - 12}) translate(0,${(-4 * Math.max(0, o.brow)).toFixed(1)})`);+ if (P.sack) vis(P.sack, !!o.sack);+ if (P.cloth) vis(P.cloth, !!o.cloth);+ if (P.grass) vis(P.grass, !!o.grass);+ if (P.tear) vis(P.tear, !!o.tear);+ },+ at(name) { const m = P[name] || P['at_' + name]; const M = g.parentNode.getCTM().inverse().multiply(m.getCTM()); return [M.e, M.f]; },+ };+ return pup;+}++/* ---------- Little Horse and Mother ----------+ Little Horse: a chestnut foal, long legs, a big head, a red saddle cloth (cloth), the half sack of wheat (sack).+ Mother: a bay mare, bigger (build her at s about 1.3), a white blaze. */+const HORSE_GEO = { hips: { nf: [44, -118], ff: [52, -118], nh: [-46, -118], fh: [-38, -118] }, up: 58, low: 64, L: 74, H: 18,+ body: [0, -128], neck: [46, -150], head: [86, -228], jaw: [112, -176], jawOpen: 16, ear: [84, -244], tail: [-70, -142],+ rest: { nf: 2, ff: 0, nh: -2, fh: 0 }, eye: [100, -222], lidH: 14, lookX: 4.5 };+function horseSVG(c) {+ const legs = (far) => far+ ? legSVG('fh', 58, 64, 30, 13, c.far, c.hoof) + legSVG('ff', 58, 64, 22, 13, c.far, c.hoof)+ : legSVG('nh', 58, 64, 32, 14, c.coat, c.hoof, c.sock) + legSVG('nf', 58, 64, 23, 14, c.coat, c.hoof, c.sockF);+ return `${legs(true)}+ <g data-p="trunk">+ <g data-p="tail">${pf(`<path d="M-70,-148 C-98,-152 -114,-124 -110,-84 C-108,-70 -98,-64 -92,-74 C-96,-100 -90,-124 -66,-136 Z" fill="${c.mane}"/><path d="M-96,-118 C-104,-104 -102,-88 -98,-78" stroke="${c.mane2}" stroke-width="4" fill="none"/>`)}</g>+ ${pf(`<path d="M-80,-128 C-82,-160 -52,-170 -12,-165 C30,-168 64,-162 76,-140 C84,-120 72,-96 40,-92 L-40,-92 C-72,-94 -80,-110 -80,-128 Z" fill="${c.coat}"/>+ <path d="M-70,-104 C-50,-92 30,-90 60,-104 C52,-94 40,-92 30,-92 L-40,-92 C-56,-93 -66,-98 -70,-104 Z" fill="${c.shade}"/>`)}+ <g data-p="cloth">${pf(`<path d="M-34,-166 C-10,-170 18,-170 34,-166 L38,-118 C14,-112 -14,-112 -38,-118 Z" fill="#c8322f"/><path d="M-34,-128 C-12,-122 14,-122 36,-128" stroke="#e8b73e" stroke-width="5" fill="none"/><circle cx="0" cy="-142" r="7" fill="#e8b73e"/>`)}</g>+ <g data-p="sack">${pf(`<path d="M-40,-160 C-46,-186 -30,-204 -4,-206 C24,-208 42,-192 40,-166 C26,-158 -24,-156 -40,-160 Z" fill="#d9b77c"/><path d="M-30,-174 C-10,-170 14,-170 32,-176" stroke="#b8935a" stroke-width="3" fill="none"/>+ <path d="M-8,-204 L-14,-222 M0,-206 L2,-226 M8,-204 L16,-220" stroke="#c9a04a" stroke-width="3"/><ellipse cx="-14" cy="-224" rx="3.5" ry="6" fill="#e2c062"/><ellipse cx="2" cy="-229" rx="3.5" ry="6" fill="#e2c062"/><ellipse cx="17" cy="-222" rx="3.5" ry="6" fill="#e2c062"/>+ <path d="M-6,-203 C-2,-208 6,-208 10,-203" stroke="#8a5a36" stroke-width="5" fill="none"/>`)}${mark('at_back', 0, -170)}</g>+ <g data-p="neckG">+ ${pf(`<path d="M24,-160 C36,-194 60,-228 84,-238 L106,-216 C94,-196 80,-168 74,-136 C58,-128 36,-132 24,-160 Z" fill="${c.coat}"/>`)}+ ${pf(`<path d="M22,-162 C30,-196 52,-232 80,-246 L86,-236 C70,-226 58,-212 50,-196 L44,-198 C40,-186 36,-176 32,-166 Z" fill="${c.mane}"/><path d="M30,-170 l-10,4 M38,-188 l-11,2 M48,-206 l-10,0 M60,-222 l-8,-3" stroke="${c.mane}" stroke-width="7" stroke-linecap="round"/>`)}+ <g data-p="headG">+ ${pf(`<path d="M70,-240 C82,-254 106,-250 116,-234 C128,-216 142,-202 146,-190 C150,-176 140,-168 128,-170 L104,-174 C86,-178 72,-196 68,-214 C66,-226 66,-234 70,-240 Z" fill="${c.coat}"/>+ <ellipse cx="132" cy="-182" rx="17" ry="13" fill="${c.muzzle}"/>${c.blaze ? `<path d="M94,-246 C104,-230 116,-210 126,-192 L132,-196 C122,-212 110,-234 100,-248 Z" fill="#f4ecdc"/>` : ''}+ <ellipse cx="142" cy="-187" rx="3.6" ry="2.6" fill="#3a2418"/>${c.cheek ? `<circle cx="112" cy="-198" r="8" fill="#e77f6a" opacity=".45"/>` : ''}`)}+ <g data-p="jaw">${pf(`<path d="M108,-178 C120,-172 136,-170 144,-174 C143,-163 128,-158 112,-166 Z" fill="${c.muzzle2}"/>`)}${mark('at_mouth', 140, -170)}</g>+ <g data-p="ear">${pf(`<path d="M76,-240 L78,-274 L94,-244 Z" fill="${c.coat}"/><path d="M80,-244 L81,-266 L90,-246 Z" fill="${c.ear}"/>`)}</g>+ ${pf(`<path d="M80,-246 C86,-256 98,-256 104,-248 C98,-246 94,-240 92,-232 C88,-240 84,-244 80,-246 Z" fill="${c.mane}"/>`)}+ <g data-p="eyeO"><ellipse cx="100" cy="-222" rx="${c.eyeR}" ry="${c.eyeR + 1}" fill="#fbf6ea"/><g data-p="pupil"><circle cx="102" cy="-221" r="${c.eyeR * .62}" fill="#2a1a10"/><circle cx="104" cy="-224" r="1.8" fill="#fff"/></g>+ ${c.lash ? `<path d="M${100 + c.eyeR - 2},-${222 + c.eyeR - 1} l5,-5 M${100 + c.eyeR - 6},-${222 + c.eyeR + 1} l3,-6" stroke="#2a1a10" stroke-width="2"/>` : ''}+ <g data-p="lid"><rect x="${100 - c.eyeR - 1}" y="-${222 + c.eyeR + 2}" width="${2 * c.eyeR + 2}" height="${c.eyeR + 3}" fill="${c.coat}"/><path d="M${100 - c.eyeR},-${219} h${2 * c.eyeR}" stroke="#2a1a10" stroke-width="2"/></g></g>+ <g data-p="eyeC"><path d="M${100 - c.eyeR},-221 Q100,-${214 - 1} ${100 + c.eyeR},-221" stroke="#2a1a10" stroke-width="2.6" fill="none"/></g>+ <path data-p="brow" d="M${92},-${236} Q100,-${240} ${110},-${236}" stroke="${c.mane}" stroke-width="3.5" fill="none" stroke-linecap="round"/>+ <g data-p="tear">${pf(`<path d="M104,-212 C100,-204 100,-200 104,-198 C108,-200 108,-204 104,-212 Z" fill="#9fd0ea"/>`)}</g>+ ${mark('at_eye', 100, -222)}${mark('at_head', 88, -260)}+ ${pinAt(86, -228)}+ </g>${pinAt(46, -150)}+ </g>+ </g>+ ${legs(false)}`;+}+const LITTLE = { coat: '#c8753d', shade: '#b0612f', far: '#a2592b', mane: '#6b3a1f', mane2: '#55301a', muzzle: '#eab68c', muzzle2: '#d99c72',+ hoof: '#4a2e1e', ear: '#e9a07e', sock: '#f2e6cf', sockF: null, eyeR: 9, cheek: true, lash: false, blaze: false };+const MAMA = { coat: '#8a5233', shade: '#784529', far: '#6c3e25', mane: '#3a2418', mane2: '#2a1a10', muzzle: '#c99a76', muzzle2: '#b5845f',+ hoof: '#2e1e14', ear: '#c98a6a', sock: '#f2e6cf', sockF: '#f2e6cf', eyeR: 7.5, cheek: false, lash: true, blaze: true };+function horsePuppet(parent, o = {}) { return beast(parent, horseSVG(LITTLE), HORSE_GEO, { cloth: true, ...o }); }+function motherPuppet(parent, o = {}) { return beast(parent, horseSVG(MAMA), HORSE_GEO, { cloth: false, gait: 'walk', ...o }); }++/* ---------- Uncle Ox: an old water buffalo, slate grey, great swept horns, sleepy lids ----------+ chew (a number that grows with time) works the jaw; grass: a tuft in his mouth. */+// Long legs on purpose: at the river's deepest the water must sit on his shins (half his lower leg), where it sits on+// Little Horse's knees. The trunk is drawn as before and lifted 28 units onto the longer legs.+const OX_GEO = { hips: { nf: [84, -140], ff: [94, -140], nh: [-88, -140], fh: [-78, -140] }, up: 66, low: 76, L: 80, H: 16,+ body: [0, -168], neck: [100, -156], head: [148, -166], jaw: [170, -104], jawOpen: 14, ear: [140, -168], tail: [-124, -164],+ rest: { nf: 2, ff: 0, nh: -2, fh: 0 }, eye: [162, -158], lidH: 10, lookX: 3 }; // pivots inside the lifted trunk keep its own coordinates+function oxSVG() {+ const C = '#776b63', S = '#655a53', F = '#5a5049', H = '#ddd0b2', N = '#a08f84';+ return `${legSVG('fh', 66, 76, 46, 28, F, '#2d2926')}${legSVG('ff', 66, 76, 40, 28, F, '#2d2926')}+ <g data-p="trunk"><g transform="translate(0 -28)">+ <g data-p="tail">${pf(`<path d="M-124,-166 C-140,-150 -146,-120 -142,-92" stroke="${S}" stroke-width="6" fill="none"/><path d="M-148,-96 C-150,-84 -142,-72 -136,-74 C-134,-84 -136,-92 -140,-98 Z" fill="#2d2926"/>`)}</g>+ ${pf(`<path d="M-130,-140 C-132,-186 -82,-198 -10,-194 C52,-198 106,-192 120,-160 C130,-130 116,-96 82,-90 L-82,-90 C-120,-92 -130,-112 -130,-140 Z" fill="${C}"/>+ <path d="M-120,-104 C-90,-90 60,-88 104,-104 C96,-94 88,-90 80,-90 L-82,-90 C-100,-91 -114,-96 -120,-104 Z" fill="${S}"/>+ <path d="M40,-192 C70,-196 100,-188 112,-170 C96,-178 70,-184 40,-186 Z" fill="#7c7672"/>`)}+ <g data-p="neckG">+ ${pf(`<path d="M86,-186 C118,-192 146,-182 158,-164 L152,-122 C132,-114 108,-118 90,-128 Z" fill="${C}"/>`)}+ <g data-p="headG">+ ${pf(`<path d="M154,-180 C130,-196 98,-204 72,-200 C48,-196 36,-210 40,-242 C54,-224 62,-216 78,-218 C106,-220 134,-212 156,-196 Z" fill="#a99c80"/>`)}+ ${pf(`<path d="M136,-186 C162,-192 184,-176 194,-150 C204,-128 206,-112 198,-104 C188,-96 172,-100 162,-110 C148,-130 136,-152 132,-170 Z" fill="${C}"/>+ <ellipse cx="190" cy="-110" rx="19" ry="14" fill="${N}"/><ellipse cx="199" cy="-114" rx="4" ry="2.8" fill="#2d2926"/>`)}+ <circle cx="201" cy="-103" r="6" fill="none" stroke="#c9a24c" stroke-width="2.6"/>+ <g data-p="jaw">${pf(`<path d="M164,-108 C176,-102 190,-98 198,-100 C196,-90 180,-86 168,-94 Z" fill="${S}"/>`)}+ <g data-p="grass">${pf(`<path d="M190,-98 C196,-92 200,-80 197,-64 M194,-98 C203,-94 211,-84 213,-70 M186,-97 C188,-88 186,-78 181,-68 M192,-98 C200,-90 204,-82 205,-74" stroke="#7da34a" stroke-width="5" fill="none" stroke-linecap="round"/><path d="M197,-64 l-2,7 M213,-70 l1,7 M181,-68 l-3,6" stroke="#6c9440" stroke-width="4" stroke-linecap="round"/>`)}</g>${mark('at_mouth', 194, -98)}</g>+ <g data-p="ear">${pf(`<path d="M140,-170 C124,-160 110,-160 104,-166 C114,-176 128,-178 140,-176 Z" fill="${S}"/><path d="M134,-170 C124,-166 116,-166 112,-168 C120,-172 128,-173 134,-173 Z" fill="#a08e86"/>`)}</g>+ ${pf(`<path d="M146,-174 C122,-186 90,-194 64,-190 C40,-186 28,-200 32,-232 C46,-214 54,-206 70,-208 C98,-210 126,-202 146,-190 Z" fill="${H}"/><path d="M64,-190 C62,-198 64,-204 70,-208 M96,-194 C94,-200 96,-206 100,-209" stroke="#c4b796" stroke-width="3" fill="none"/>`)}+ <g data-p="eyeO"><ellipse cx="162" cy="-158" rx="6" ry="6.5" fill="#f4ecdc"/><g data-p="pupil"><circle cx="163" cy="-157" r="4" fill="#1e1a18"/><circle cx="164.5" cy="-159" r="1.3" fill="#fff"/></g>+ <g data-p="lid"><rect x="155" y="-166" width="14" height="9" fill="${C}"/><path d="M155,-157 h14" stroke="#1e1a18" stroke-width="2"/></g></g>+ <g data-p="eyeC"><path d="M156,-157 Q162,-152 168,-157" stroke="#1e1a18" stroke-width="2.4" fill="none"/></g>+ <path data-p="brow" d="M154,-170 Q162,-174 170,-170" stroke="#3e3a37" stroke-width="3.5" fill="none" stroke-linecap="round"/>+ ${mark('at_eye', 162, -158)}${mark('at_head', 150, -200)}${pinAt(148, -166)}+ </g>${pinAt(100, -156)}+ </g>+ </g></g>+ ${legSVG('nh', 66, 76, 50, 30, C, '#2d2926')}${legSVG('nf', 66, 76, 44, 30, C, '#2d2926')}`;+}+function oxPuppet(parent, o = {}) { return beast(parent, oxSVG(), OX_GEO, { cloth: false, lid: .4, ...o }); }++/* ---------- Squirrel: rust red, a great plume of a tail, sits up on his haunches ----------+ Feet at (0, 0), facing right, about 130 tall with the tail. tail / tail2 bend the plume, paw raises the near front+ paw (degrees, - forward/up), pawF the far one, lean tips the upper body, hop lifts him (px, the scene's arc), stretch+ (0..1) lengthens him for a leap, tear shows a tear. */+const REST_SQ = { x: 0, y: 0, s: 1, turn: 1, lean: 0, headR: 0, tail: 0, tail2: 0, paw: 0, pawF: 0, mouth: 'X', shut: false, look: 0,+ brow: 0, ear: 0, tear: false, hop: 0, stretch: 0 };+function squirrelPuppet(parent, o = {}) {+ const C = '#c4622c', D = '#a24f22', B = '#f0d9b0', T = '#d9824a';+ const g = mk('g', {}, parent);+ g.innerHTML = `+ <g data-p="tailA">${pf(`<path d="M-14,-18 C-46,-14 -62,-40 -56,-72 C-52,-92 -40,-100 -30,-96 C-44,-80 -44,-54 -26,-40 Z" fill="${C}"/><path d="M-46,-48 C-52,-62 -50,-80 -40,-92" stroke="${T}" stroke-width="5" fill="none"/>`)}+ <g data-p="tailB">${pf(`<path d="M-36,-94 C-26,-122 0,-130 14,-116 C24,-106 20,-92 10,-92 C2,-108 -16,-108 -26,-88 Z" fill="${C}"/><path d="M-28,-108 C-16,-120 0,-122 10,-112" stroke="${T}" stroke-width="5" fill="none"/>`)}</g></g>+ <g data-p="pawFG">${pf(`<path d="M10,-64 C20,-58 28,-50 30,-42 C26,-38 22,-40 20,-46 C16,-52 10,-56 6,-58 Z" fill="${D}"/>`)}</g>+ ${pf(`<ellipse cx="-4" cy="-18" rx="22" ry="18" fill="${C}"/><path d="M-4,-2 C8,-2 22,0 28,-2 C28,4 8,4 -6,4 Z" fill="${D}"/>`)}+ <g data-p="upper">+ ${pf(`<path d="M-20,-30 C-26,-56 -14,-80 4,-82 C20,-82 24,-60 20,-36 C16,-22 -14,-18 -20,-30 Z" fill="${C}"/><path d="M6,-74 C16,-64 18,-44 12,-30 C6,-26 0,-30 2,-40 C4,-52 4,-64 6,-74 Z" fill="${B}"/>`)}+ <g data-p="headG">+ ${pf(`<circle cx="10" cy="-92" r="17" fill="${C}"/><path d="M14,-104 C28,-102 38,-94 40,-88 C40,-82 34,-80 26,-80 L12,-80 Z" fill="${C}"/><path d="M22,-86 C30,-84 36,-84 39,-87 C38,-80 30,-78 22,-80 Z" fill="${B}"/><circle cx="40" cy="-89" r="3" fill="#2a1a10"/>`)}+ <g data-p="ear">${pf(`<path d="M0,-104 L2,-124 L6,-128 L8,-122 L12,-106 Z" fill="${C}"/><path d="M3,-108 L5,-120 L9,-108 Z" fill="#e9a07e"/>`)}</g>+ <g data-p="jaw">${pf(`<path d="M22,-81 C28,-79 34,-79 37,-81 C36,-75 28,-73 22,-77 Z" fill="${D}"/>`)}${mark('at_mouth', 36, -80)}</g>+ <g data-p="eyeO"><circle cx="22" cy="-96" r="5" fill="#1e140c"/><circle cx="23.5" cy="-97.5" r="1.6" fill="#fff"/></g>+ <g data-p="eyeC"><path d="M17,-95 Q22,-91 27,-95" stroke="#1e140c" stroke-width="2.2" fill="none"/></g>+ <path data-p="brow" d="M16,-105 L28,-103" stroke="${D}" stroke-width="3" stroke-linecap="round"/>+ <g data-p="tear">${pf(`<path d="M24,-90 C21,-84 21,-81 24,-79 C27,-81 27,-84 24,-90 Z" fill="#9fd0ea"/>`)}</g>+ ${mark('at_eye', 22, -96)}${mark('at_top', 6, -128)}${pinAt(4, -78)}+ </g>+ <g data-p="pawG">${pf(`<path d="M8,-63 C20,-58 30,-48 33,-38 C29,-31 22,-33 21,-40 C17,-48 9,-51 4,-56 Z" fill="${D}"/><ellipse cx="30" cy="-35" rx="6" ry="5" fill="#6e3414"/>`)}${mark('at_paw', 31, -35)}${pinAt(7, -60)}</g>+ </g>+ ${pf(`<path d="M-2,-6 C10,-8 22,-6 26,-2 C24,2 6,2 -4,0 Z" fill="${D}"/>`)}`;+ bakeAll(g);+ const P = pieces(g), R = { ...REST_SQ, ...o };+ return { g, P,+ pose(o, f) {+ o = { ...R, ...o }; const j = k => jit(f, k);+ tf(g, `translate(${(o.x + j(1) * .5).toFixed(1)},${(o.y - o.hop + j(2) * .4).toFixed(1)}) scale(${(o.s * o.turn).toFixed(4)},${(o.s * (1 + .18 * o.stretch)).toFixed(4)})`);+ tf(P.upper, `rotate(${(o.lean + j(3) * .5).toFixed(2)},-2,-24)`);+ tf(P.headG, `rotate(${(o.headR + j(4) * .7).toFixed(2)},4,-78)`);+ tf(P.tailA, `rotate(${(o.tail + j(5) * 1.2).toFixed(2)},-14,-20)`); tf(P.tailB, `rotate(${(o.tail2 + j(6) * 1.5).toFixed(2)},-32,-92)`);+ tf(P.pawG, `rotate(${(o.paw + j(7)).toFixed(1)},7,-60)`); tf(P.pawFG, `rotate(${(o.pawF + j(9)).toFixed(1)},8,-62)`);+ tf(P.jaw, `rotate(${((JAW[o.mouth || 'X'] ?? 0) * 18).toFixed(1)},22,-80)`);+ tf(P.ear, `rotate(${(o.ear * 15).toFixed(1)},6,-106)`);+ tf(P.brow, `rotate(${(o.brow * 16).toFixed(1)},22,-104)`);+ vis(P.eyeO, !o.shut); vis(P.eyeC, !!o.shut); vis(P.tear, !!o.tear);+ },+ at(name) { const m = P['at_' + name]; const M = g.parentNode.getCTM().inverse().multiply(m.getCTM()); return [M.e, M.f]; },+ };+}++/* ---------- the little rabbit: white, long ears, sits ----------+ ears (degrees, + back), nose twitch on twos while `sniff`, hop lifts it, tuck (0..1) folds it down to ride. */+const REST_RB = { x: 0, y: 0, s: 1, turn: 1, ears: 0, ear2: 0, headR: 0, shut: false, look: 0, hop: 0, sniff: false, lean: 0 };+function rabbitPuppet(parent, o = {}) {+ const W = '#efe9df', S = '#d9d1c4', K = '#e9a7a2';+ const g = mk('g', {}, parent);+ g.innerHTML = `+ ${pf(`<circle cx="-28" cy="-26" r="10" fill="#fbf8f2"/>`)}+ <g data-p="earF">${pf(`<path d="M10,-66 C2,-92 4,-118 12,-124 C20,-118 20,-92 16,-66 Z" fill="${S}"/>`)}</g>+ <g data-p="body">+ ${pf(`<path d="M-30,-20 C-34,-46 -12,-62 10,-58 C30,-54 34,-30 26,-12 C18,0 -24,2 -30,-20 Z" fill="${W}"/><path d="M14,-4 C22,-4 32,-2 34,2 C26,4 14,4 8,2 Z" fill="${S}"/>`)}+ <g data-p="headG">+ ${pf(`<path d="M4,-64 C6,-82 24,-90 38,-80 C48,-72 48,-58 38,-52 C26,-46 8,-48 4,-64 Z" fill="${W}"/><circle cx="46" cy="-62" r="3" fill="${K}"/><circle cx="34" cy="-56" r="5" fill="#f2b8b0" opacity=".5"/>`)}+ <g data-p="ear">${pf(`<path d="M14,-76 C6,-102 10,-126 18,-130 C26,-124 26,-98 22,-76 Z" fill="${W}"/><path d="M16,-82 C12,-100 14,-118 18,-122 C22,-116 22,-98 20,-82 Z" fill="${K}"/>`)}</g>+ <g data-p="eyeO"><circle cx="34" cy="-70" r="4" fill="#2a1a20"/><circle cx="35.2" cy="-71.2" r="1.3" fill="#fff"/></g>+ <g data-p="eyeC"><path d="M30,-69 Q34,-66 38,-69" stroke="#2a1a20" stroke-width="2" fill="none"/></g>+ <g data-p="nose">${pf(`<path d="M44,-60 l3,4 l-5,1 Z" fill="#c97a78"/>`)}</g>+ ${mark('at_eye', 34, -70)}${mark('at_top', 18, -130)}${pinAt(8, -58)}+ </g>+ ${pf(`<path d="M8,-30 C14,-24 18,-14 16,-6 C12,-4 8,-8 8,-14 Z" fill="${S}"/>`)}+ </g>`;+ bakeAll(g);+ const P = pieces(g), R = { ...REST_RB, ...o };+ return { g, P,+ pose(o, f) {+ o = { ...R, ...o }; const j = k => jit(f, k);+ tf(g, `translate(${(o.x + j(1) * .5).toFixed(1)},${(o.y - o.hop + j(2) * .4).toFixed(1)}) scale(${(o.s * o.turn).toFixed(4)},${o.s.toFixed(4)})`);+ tf(P.body, `rotate(${(o.lean + j(3) * .4).toFixed(2)},0,-10)`);+ tf(P.headG, `rotate(${(o.headR + j(4) * .6).toFixed(2)},8,-58)`);+ tf(P.ear, `rotate(${(o.ears + j(5)).toFixed(1)},18,-76)`); tf(P.earF, `rotate(${(o.ears + o.ear2 - 6 + j(6)).toFixed(1)},14,-66)`);+ tf(P.nose, `translate(0,${o.sniff && onTwos(f / FPS) > 0 ? -1.5 : 0})`);+ vis(P.eyeO, !o.shut); vis(P.eyeC, !!o.shut);+ tf(P.eyeO, `translate(${(o.look * 1.5).toFixed(1)},0)`);+ },+ at(name) { const m = P['at_' + name]; const M = g.parentNode.getCTM().inverse().multiply(m.getCTM()); return [M.e, M.f]; },+ };+}++// The half sack of wheat on its own, for Mother to carry in her teeth: drawn around its tie (0, 0).+const SACK = pf(`<path d="M-40,10 C-46,-16 -30,-34 -4,-36 C24,-38 42,-22 40,4 C40,30 24,40 -2,40 C-28,40 -38,30 -40,10 Z" fill="#d9b77c"/><path d="M-30,-4 C-10,0 14,0 32,-6" stroke="#b8935a" stroke-width="3" fill="none"/>+ <path d="M-8,-34 L-14,-52 M0,-36 L2,-56 M8,-34 L16,-50" stroke="#c9a04a" stroke-width="3"/><ellipse cx="-14" cy="-54" rx="3.5" ry="6" fill="#e2c062"/><ellipse cx="2" cy="-59" rx="3.5" ry="6" fill="#e2c062"/><ellipse cx="17" cy="-52" rx="3.5" ry="6" fill="#e2c062"/>+ <path d="M-6,-33 C-2,-38 6,-38 10,-33" stroke="#8a5a36" stroke-width="5" fill="none"/>`);diff --git a/site/little-horse/lib/contents.css b/site/little-horse/lib/contents.cssnew file mode 100644index 0000000..d8f7f70--- /dev/null+++ b/site/little-horse/lib/contents.css@@ -0,0 +1,137 @@+/* The book's cover and contents (index.html): the chalkboard look, the cover, the guide, the chapter grid and the+ page-to-page motion. A book's own <style> after this file sets its theme: the colour and font tokens below, and the+ few rules a theme redraws (e.g. body::before for the paper). */+:root {+ --page: #0f1613; --board: #1d2b27; --panel: #22322d; --edge: #3a5047;+ --chalk: #ece8dc; --dim: #9aaba3; --faint: #5d7068; --task: #f0b45a; --quiz: #86c9e8; --good: #8fd6b0;+ --ui: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;+ --book: "Iowan Old Style", Palatino, Georgia, serif;+ --ease: cubic-bezier(.2, .8, .2, 1);+ --top-bg: rgba(22, 33, 29, .86); --top-line: #2a3b35; /* the sticky contents header */+ --lift: rgba(0, 0, 0, .3); /* a card's shadow on hover */+ color-scheme: dark;+}+* { box-sizing: border-box; }+html { scroll-padding-top: 90px; }+body { margin: 0; min-height: 100svh; background: var(--board); color: var(--chalk); font: 18px/1.5 var(--ui); }+/* Chalkboard: the same grain and vignette as the lesson stage. */+body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;+ background: radial-gradient(ellipse at 50% 42%, transparent 55%, rgba(0, 0, 0, .38)),+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .92 0 0 0 0 .95 0 0 0 0 .9 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E"); }+a { color: inherit; }+a:focus-visible { outline: 3px solid var(--task); outline-offset: 3px; }+.kicker { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--quiz); }++/* ---------- cover ---------- */+#cover { position: relative; min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center;+ padding: 48px 16px 64px; text-align: center; overflow: hidden; }+.open #cover, body:not(.open) #contents { display: none; }+/* #references is its own view: the full list, reached from one link at the end of the contents. */+body:not(.refsview) #refpage, .refsview #cover, .refsview #contents { display: none; }+#cover > * { animation: rise .8s var(--ease) backwards; }+#cover .mascot { animation: none; margin-bottom: 26px; view-transition-name: guide; }+#cover .kicker { animation-delay: .9s; }+#cover h1 { animation-delay: 1s; }+#cover .lede { animation-delay: 1.12s; }+#cover .acts { animation-delay: 1.24s; }+#cover .meta { animation-delay: 1.36s; }+h1 { margin: 14px 0 18px; font: 500 clamp(44px, 8.4vw, 92px)/1.02 var(--book); letter-spacing: -.01em; view-transition-name: book; }+h1 i { color: var(--task); font-style: italic; }+.lede { max-width: 34em; margin: 0 0 34px; color: var(--dim); font-size: clamp(17px, 2.2vw, 20px); text-wrap: balance; }+.acts { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }+.btn { display: inline-flex; align-items: center; gap: 12px; padding: 14px 30px; border-radius: 999px; font-weight: 600; font-size: 19px; text-decoration: none;+ transition: transform .25s var(--ease), background-color .25s, border-color .25s; }+.btn[hidden] { display: none; }+.btn:hover { transform: translateY(-2px); }+.btn.go { background: var(--chalk); color: var(--board); }+.btn.quiet { border: 1.5px solid var(--edge); color: var(--chalk); }+.btn.quiet:hover { border-color: var(--dim); }+.btn svg { width: 15px; height: 15px; fill: currentColor; }+.meta { margin: 30px 0 0; color: var(--faint); font-size: 15px; letter-spacing: .04em; }+/* Faint chalk notes around the edges of the board. */+.chalk { position: absolute; inset: 0; z-index: -1; pointer-events: none; animation: none !important; }+.chalk span { position: absolute; font: italic 400 clamp(22px, 3vw, 38px) var(--book); color: var(--chalk); opacity: 0; white-space: nowrap;+ animation: chalk 1.6s ease-out forwards, drift 14s ease-in-out infinite alternate; animation-delay: calc(var(--d) * 1s), calc(var(--d) * 1s); }+@keyframes chalk { to { opacity: .075; } }+@keyframes drift { to { translate: 0 -10px; } }+@keyframes rise { from { opacity: 0; transform: translateY(16px); } }++/* ---------- the guide: an infinity sign whose loops are its eyes ---------- */+.mascot { display: block; overflow: visible; }+.mascot .mbody { transform-box: view-box; transform-origin: 60px 46px; animation: bob 3.4s ease-in-out infinite; }+.mascot .pupil { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }+.mascot .joy { display: none; }+#cover:has(.go:hover, .go:focus-visible) .pupil { display: none; }+#cover:has(.go:hover, .go:focus-visible) .joy { display: inline; }+.draw .loop { stroke-dasharray: 1 1; animation: draw 1.3s cubic-bezier(.6, 0, .3, 1) .15s backwards; }+.draw .face { animation: pop .45s var(--ease) 1.25s backwards; }+@keyframes draw { from { stroke-dashoffset: 1; } }+@keyframes pop { from { opacity: 0; transform: scale(.6); } }+.draw .face { transform-box: view-box; transform-origin: 60px 44px; }+@keyframes bob { 50% { transform: translateY(-3px) rotate(-2deg); } }+@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }++/* ---------- contents ---------- */+.top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 14px; padding: 12px max(16px, calc(50% - 590px));+ background: var(--top-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--top-line); }+.home { display: flex; align-items: center; gap: 12px; text-decoration: none; border-radius: 10px; }+.home .mascot { view-transition-name: guide; }+.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }+.home strong i { color: var(--task); }+.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }+.prog b { color: var(--good); font-weight: 600; }+main#contents { padding-bottom: 80px; }+.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }+.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);+ text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }+.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }+.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }+.ch span { font-size: 18px; line-height: 1.3; }+.ch small { color: var(--dim); font-size: 14px; }+.ch.done small::before { content: var(--done, "✓ Finished · "); color: var(--good); font-weight: 600; }+.ch.last small::after { content: var(--last, " · Last opened"); color: var(--quiz); }+.ch.here:focus-visible { outline-color: var(--c); }+.ch.here { animation: here 1.8s ease-out .3s; }+@keyframes here { 0% { box-shadow: 0 0 0 0 var(--c); } 25% { box-shadow: 0 0 0 5px var(--c); } 100% { box-shadow: 0 0 0 14px transparent; } }+/* ---------- references: every source the book cites, linked to its DOI or catalogue record ---------- */+.refs-more { max-width: 1212px; margin: 44px auto 0; padding: 0 16px; }+.refs-more[hidden] { display: none; }+.refs-more a { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 16px 20px; border-radius: 16px; background: var(--panel);+ border: 1.5px solid var(--edge); text-decoration: none; transition: border-color .3s; }+.refs-more a:hover { border-color: var(--dim); }+.refs-more b { font: 500 22px/1.2 var(--book); }+.refs-more span { color: var(--dim); font-size: 15px; }+.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }+#refpage { padding-bottom: 80px; }+.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }+.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }+.top .rp-book i { color: var(--task); }+.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }+.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }+.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }+.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }+.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }+.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }+.refs a:hover { color: var(--quiz); }+.stagger .top { animation: rise .6s var(--ease) backwards; }+.stagger .unit h2, .stagger .ch { animation: rise .6s var(--ease) backwards; animation-delay: calc(min(var(--i), 14) * 32ms + 80ms); }++/* ---------- 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; }+@media (max-width: 560px) {+ .home strong { font-size: 18px; }+ #contents .top { flex-wrap: wrap; gap: 8px 12px; }+ .ch { min-height: 0; }+ .chalk span:not(:nth-child(3), :nth-child(4), :nth-child(7)) { display: none; }+}+@media (prefers-reduced-motion: reduce) {+ *, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }+ .chalk span { opacity: .075; }+}diff --git a/site/little-horse/lib/contents.js b/site/little-horse/lib/contents.jsnew file mode 100644index 0000000..0bacf99--- /dev/null+++ b/site/little-horse/lib/contents.js@@ -0,0 +1,226 @@+/* The book's cover and contents (index.html): interface text, the chapter list with reading progress, the guide,+ and the cover ↔ contents ↔ lesson motion. Load it in <head>; after the markup, the page calls+ Contents.book({ units, start, hues }) with its chapter list. With refs.js (REFS, built by the skill's+ scripts/refs.py) loaded first, the page also gets its References view (#references). */+'use strict';+// Observe aborted incoming transitions before the first rendering opportunity.+addEventListener('pagereveal', e => e.viewTransition?.ready.catch(() => {}));++const Contents = (() => {+ // Interface text in the page's <html lang>, as in the lessons; missing keys fall back to English.+ // A value is a string or plural forms { one, few, many, other } chosen by vars.n.+ const TRANSLATIONS = {+ en: {+ open: 'Open the book', toCover: 'Back to the cover', resume: 'Continue · Chapter {n}', unit: 'Unit {n}', minutes: '{n} min',+ meta: '{chapters}{samples} · {units} · with sound', metaChapters: { one: '{n} chapter', other: '{n} chapters' },+ metaUnits: { one: '{n} unit', other: '{n} units' }, metaSamples: { one: ' + {n} sample', other: ' + {n} samples' }, samples: 'Sample chapters, another look',+ chapterCount: { one: '{n} chapter', other: '{n} chapters' }, finished: '{done} of {n} finished',+ doneMark: '✓ Finished · ', lastMark: ' · Last opened',+ references: 'References', viewAll: 'View all →', backToContents: '← Contents',+ refsLead: 'Every work cited in the lessons. Each link opens the work’s DOI or library record in a new tab; works with no reliable online record are listed without a link.',+ refsCount: { one: '{n} work cited in the lessons', other: '{n} works cited in the lessons' },+ refsAllLinked: ', each linked to its source', refsSomeLinked: ', {n} linked to their sources',+ },+ ru: {+ open: 'Открыть книгу', toCover: 'К обложке', resume: 'Продолжить · Глава {n}', unit: 'Раздел {n}', minutes: '{n} мин',+ meta: '{chapters}{samples} · {units} · со звуком',+ metaChapters: { one: '{n} глава', few: '{n} главы', many: '{n} глав', other: '{n} главы' },+ metaUnits: { one: '{n} раздел', few: '{n} раздела', many: '{n} разделов', other: '{n} раздела' },+ metaSamples: { one: ' + {n} пробная', few: ' + {n} пробные', many: ' + {n} пробных', other: ' + {n} пробной' },+ samples: 'Пробные главы в другом стиле',+ chapterCount: { one: '{n} глава', few: '{n} главы', many: '{n} глав', other: '{n} главы' }, finished: 'Пройдено {done} из {n}',+ doneMark: '✓ Пройдено · ', lastMark: ' · Открыта последней',+ references: 'Список литературы', viewAll: 'Весь список →', backToContents: '← Оглавление',+ refsLead: 'Все работы, которые цитируются в уроках. Ссылка открывает DOI или библиотечную запись в новой вкладке; работы без надёжной записи в сети даны без ссылки.',+ refsCount: { one: '{n} работа цитируется в уроках', few: '{n} работы цитируются в уроках', many: '{n} работ цитируются в уроках', other: '{n} работы цитируются в уроках' },+ refsAllLinked: ', у каждой есть ссылка на источник', refsSomeLinked: ', ссылок на источник: {n}',+ },+ zh: {+ open: '打开这本书', toCover: '返回封面', resume: '继续 · 第 {n} 章', unit: '第 {n} 单元', minutes: '{n} 分钟',+ meta: '{chapters}{samples} · {units} · 有配音', metaChapters: '{n} 章', metaUnits: '{n} 个单元',+ metaSamples: ' + {n} 个示例章', samples: '示例章,另一种风格',+ chapterCount: '{n} 章', finished: '已完成 {done} / {n}',+ doneMark: '✓ 已完成 · ', lastMark: ' · 上次打开',+ references: '参考文献', viewAll: '查看全部 →', backToContents: '← 目录',+ refsLead: '课程中引用的全部作品。每个链接会在新标签页中打开该作品的 DOI 或图书馆记录;没有可靠在线记录的作品不附链接。',+ refsCount: '课程中引用了 {n} 部作品', refsAllLinked: ',均链接到来源', refsSomeLinked: ',其中 {n} 部链接到来源',+ },+ ja: {+ open: '本を開く', toCover: '表紙に戻る', resume: '続きから · 第{n}章', unit: '単元 {n}', minutes: '{n}分',+ meta: '{chapters}{samples} · {units} · 音声つき', metaChapters: '{n}章', metaUnits: '{n}単元',+ metaSamples: ' + サンプル{n}章', samples: 'サンプル章(別のスタイル)',+ chapterCount: '{n}章', finished: '{n}章中 {done}章 完了',+ doneMark: '✓ 完了 · ', lastMark: ' · 最後に開いた章',+ references: '参考文献', viewAll: 'すべて見る →', backToContents: '← 目次',+ refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',+ refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',+ },+ };+ // the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step+ const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];+ function translate(key, vars = {}) {+ const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';+ let text = TRANSLATIONS[language][key] ?? key;+ if (typeof text === 'object') {+ let rules;+ try { rules = new Intl.PluralRules(language); } catch { rules = new Intl.PluralRules('en'); }+ text = text[rules.select(vars.n)] ?? text.other;+ }+ return text.replace(/\{(\w+)\}/g, (placeholder, name) => name in vars ? vars[name] : placeholder);+ }+ const $ = id => document.getElementById(id);+ const id = n => 'ch' + String(n).padStart(2, '0');+ const esc = s => s.replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');+ const HUES = ['#f4a48c', '#86c9e8', '#f3c95c', '#e8a0c8', '#8fd6b0', '#bba8ee', '#f0b45a'];++ // Fixed interface text: data-t replaces an element's first text, data-t-label its aria-label.+ function translatePage() {+ for (const element of document.querySelectorAll('[data-t]')) element.firstChild.nodeValue = translate(element.dataset.t);+ for (const element of document.querySelectorAll('[data-t-label]')) element.setAttribute('aria-label', translate(element.dataset.tLabel));+ document.documentElement.style.setProperty('--done', JSON.stringify(translate('doneMark')));+ document.documentElement.style.setProperty('--last', JSON.stringify(translate('lastMark')));+ }++ // Reading progress { done: [chapter numbers], last }, written by the lessons. The engine and this page derive the+ // same key from the book's folder; a book that predates that passes its own key.+ function progress(key) {+ let P = {};+ try {+ const saved = JSON.parse(localStorage.getItem(key) || '{}');+ if (saved && typeof saved === 'object' && !Array.isArray(saved)) P = saved;+ } catch {}+ return { last: P.last, done: new Set(Array.isArray(P.done) ? P.done.filter(n => Number.isInteger(n) && n > 0) : []) };+ }++ // The chapter cards, unit by unit, with progress, the header count, the cover's meta line and its resume button.+ // A unit's optional third entry { unit, chapter, sample, href } numbers it from elsewhere in the book; a sample chapter,+ // made to show another look, is not counted with the book's chapters, and a unit of samples has no unit number.+ // With href, the sample lives in another book folder (its own progress): its card links there and leaves this book's+ // numbering and progress alone. A chapter's own third entry { href, chapter } does the same for that chapter alone;+ // without href, its chapter is only the number shown on the card.+ // start.label is the number shown for start.chapter (folders keep the book's numbers; lessons set CHAPTER.label).+ function contents(units, start, hues, P) {+ let n = start.chapter - 1, total = 0, i = 0, away = 0; // i staggers the entrance, in reading order+ const samples = new Set(), shown = k => k - start.chapter + (start.label ?? start.chapter);+ $('units').innerHTML = units.map(([name, chs, o = {}], u) => {+ if (o.chapter && !o.href) n = o.chapter - 1;+ return `<section class="unit" style="--c:${hues[u % hues.length]};--i:${i++}">${Units.header(u, o.sample ? translate('samples') : translate('unit', { n: o.unit ?? u + start.unit }), name)}<div class="grid">` ++ chs.map(([t, min, c = {}], k) => {+ const href = c.href ?? o.href;+ if (href) { away++; return `<a class="ch" href="${href}" style="--i:${i++}"><b>${c.chapter ?? (o.chapter ?? 1) + k}</b><span>${esc(t)}</span><small>${translate('minutes', { n: min })}</small></a>`; }+ n++; if (o.sample) samples.add(n); else total++;+ const cls = 'ch' + (P.done.has(n) ? ' done' : '') + (P.last === n ? ' last' : '');+ return `<a class="${cls}" id="${id(n)}" href="${id(n)}/" style="--i:${i++}"><b>${c.chapter ?? shown(n)}</b><span>${esc(t)}</span><small>${translate('minutes', { n: min })}</small></a>`;+ }).join('') + '</div></section>';+ }).join('');+ // A unit's sketch draws itself the first time the unit scrolls into view.+ Units.watch();+ const finished = [...P.done].filter(k => k >= start.chapter && k <= n && !samples.has(k)).length;+ $('prog').innerHTML = finished ? translate('finished', { done: `<b>${finished}</b>`, n: total }) : translate('chapterCount', { n: total });+ $('meta').textContent = translate('meta', {+ chapters: translate('metaChapters', { n: total }),+ samples: samples.size + away ? translate('metaSamples', { n: samples.size + away }) : '',+ units: translate('metaUnits', { n: units.filter(x => !x[2]?.sample).length }) });+ const last = Number.isInteger(P.last) && $(id(P.last));+ if (last) {+ const r = $('resume');+ r.hidden = false;+ r.href = last.getAttribute('href');+ r.textContent = translate('resume', { n: last.querySelector('b').textContent });+ }+ }++ // The References view, from refs.js: full entries, each linked to its DOI or catalogue record. It appears as one+ // link at the end of the contents only when the book cites something.+ function references() {+ const all = Object.values(typeof REFS === 'object' && REFS ? REFS : {});+ if (!$('refList') || !all.length) return;+ $('refList').innerHTML = all.sort((a, b) => a.ref.localeCompare(b.ref)).map(r => `<li>${esc(r.ref)}${r.url+ ? ` <a href="${esc(r.url)}" target="_blank" rel="noopener">${esc(r.url.replace(/^https?:\/\//, ''))}</a>` : ''}</li>`).join('');+ const linked = all.filter(r => r.url).length;+ $('refsCount').textContent = translate('refsCount', { n: all.length }) ++ (linked === all.length ? translate('refsAllLinked') : translate('refsSomeLinked', { n: linked }));+ $('rpBook').innerHTML = document.querySelector('#contents .home strong')?.innerHTML || '';+ $('refsMore').hidden = false;+ }++ // The guide, drawn the same way as in the lessons, in the page's chalk (ink) colour.+ function lemniscate(cx, cy, a, k) {+ let d = '';+ for (let i = 0; i <= 96; i++) {+ const t = i / 96 * 2 * Math.PI, sn = Math.sin(t), q = 1 + sn * sn;+ d += (i ? 'L' : 'M') + (cx + a * Math.cos(t) / q).toFixed(1) + ' ' + (cy + k * a * sn * Math.cos(t) / q).toFixed(1);+ }+ return d + 'Z';+ }+ function guides(ink) {+ for (const svg of document.querySelectorAll('svg.mascot')) {+ svg.setAttribute('viewBox', '0 0 120 84');+ svg.setAttribute('aria-hidden', 'true');+ const ln = `fill="none" stroke="${ink}" stroke-linecap="round" stroke-linejoin="round"`;+ svg.innerHTML = `<g class="mbody"><path class="loop" pathLength="1" d="${lemniscate(60, 40, 52, 1.5)}" ${ln} stroke-width="6"/><g class="face">` ++ [33, 87].map(x => `<circle class="pupil" cx="${x}" cy="40" r="6.5" fill="${ink}"/><path class="joy" d="M${x - 7} 43Q${x} 32 ${x + 7} 43" ${ln} stroke-width="4"/>`).join('') ++ `<path d="M55 62Q60 67 65 62" ${ln} stroke-width="3.5"/></g></g>`;+ }+ }++ // The cover, the contents and the references share this page: no hash or #book shows the cover, #references the+ // reference list, #contents or #chNN the contents.+ // Lessons link back with #chNN, so the reader lands on the chapter they just left.+ function views() {+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;+ function show(animate) {+ const refs = location.hash === '#references';+ const open = location.hash.length > 1 && location.hash !== '#book' && !refs;+ const apply = () => {+ document.body.classList.toggle('open', open);+ document.body.classList.toggle('refsview', refs);+ document.body.classList.toggle('stagger', animate && open);+ const here = open ? $(location.hash.slice(1)) : null;+ document.querySelectorAll('.here').forEach(e => e.classList.remove('here'));+ if (here?.classList.contains('ch')) { here.scrollIntoView({ block: 'center' }); here.classList.add('here'); }+ else scrollTo(0, 0);+ if (animate) {+ const heading = document.querySelector(refs ? '#refsTitle' : open ? '#contents .home' : '#cover h1');+ heading?.setAttribute('tabindex', '-1');+ heading?.focus({ preventScroll: true });+ }+ };+ 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(() => {});+ transition.finished.catch(() => {});+ } else apply();+ }+ addEventListener('hashchange', () => show(true));+ show(false);++ // Between pages, the chosen card grows into the lesson frame and the frame shrinks back into its card.+ let named = null;+ const name = el => {+ if (named) named.style.viewTransitionName = '';+ named = el;+ if (el) el.style.viewTransitionName = 'lesson';+ };+ document.addEventListener('click', e => { const a = e.target.closest('a[href^="ch"]'); if (a) name(a); });+ addEventListener('pagereveal', e => {+ const target = (location.hash.length > 1 && $(location.hash.slice(1))?.closest('.ch')) || (named?.offsetParent && named);+ name(e.viewTransition && target ? target : null);+ e.viewTransition?.finished.then(() => name(null), () => name(null));+ });+ }++ // units: [[unit title, [[chapter title, minutes], ...], { unit, chapter, sample, href }?], ...]. Chapters are numbered in+ // order from start (a book whose scope starts mid-way keeps the original numbers in its folders, and may show them+ // from start.label). hues: one colour per unit, cycling.+ function book({ units, start = { unit: 1, chapter: 1 }, hues = HUES, progressKey, ink } = {}) {+ translatePage();+ contents(units, start, hues, progress(progressKey ?? 'animebook:progress:' + new URL('.', location.href).pathname));+ references();+ guides(ink || getComputedStyle(document.documentElement).getPropertyValue('--chalk').trim() || '#ece8dc');+ views();+ }++ return { book, translate };+})();diff --git a/site/little-horse/lib/engine.css b/site/little-horse/lib/engine.cssnew file mode 100644index 0000000..bf42cc9--- /dev/null+++ b/site/little-horse/lib/engine.css@@ -0,0 +1,297 @@+@import url(volume.css);+@import url(book.css); /* this book's own settings and overrides (not shared), before the rules below */+/* The palette. lib/book.css may redefine any of it in its own ':root' (this one has no specificity), e.g. a light board+ with dark ink: the stage, COL in engine.js, the cards and the player bar all follow. Colours are #rrggbb. The last+ lines are shades between those colours, written out so the dark board stays exact: a palette of its own sets them too+ (the light set in book.css). */+:where(:root) {+ --page: #0f1613; --board: #1d2b27; --panel: #22322d; --edge: #3a5047;+ --chalk: #ece8dc; --dim: #9aaba3; --faint: #5d7068;+ --task: #f0b45a; --quiz: #86c9e8; --good: #8fd6b0; --bad: #f08c7a;+ --ui: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;+ --vignette: rgba(0, 0, 0, .35); /* the stage's darkened edges; a light board wants a faint, warm one */+ color-scheme: dark;+ --rule: #2e433b; /* lines between answer rows */+ --track: #2f4640; --track-ask: #2d4a57; /* the player bar's steps, and its question steps */+ --bar-edge: #2a3b35; --hover: #2b3f36; /* the bar's top line, the volume control under the pointer */+ --veil: #0a100e; /* behind the help panel and the captions */+}+* { box-sizing: border-box; }+html, body { height: 100%; margin: 0; overflow: hidden; background: var(--page); }+body { color: var(--chalk); font: 26px/1.4 var(--ui); }+button { font: inherit; color: inherit; cursor: pointer; }+button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--task); outline-offset: 3px; }+button[hidden] { display: none; }++/* One fixed 1600×960 frame (900 stage + 60 controls), scaled to fit the window. Fixed, not absolute: a frame wider+ than a phone would otherwise widen the phone's layout viewport, and fit() would scale to that wider width. */+#frame { position: fixed; left: 50%; top: 50%; width: var(--sw, 1600px); height: calc(var(--sh, 900px) + 60px); transform: translate(-50%, -50%) scale(var(--k, .5));+ border-radius: 20px; overflow: hidden; background: var(--board); box-shadow: 0 0 0 1px var(--edge), 0 30px 80px rgba(0, 0, 0, .45); }+#stage { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: block;+ background: radial-gradient(75% 75% at 50% 45%, rgba(0,0,0,0) 60%, var(--vignette)), var(--grain, none), var(--board); }+#ui { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); pointer-events: none; }+#ui > * { pointer-events: auto; }++.cover { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }+.cover[hidden] { display: none; }+.cover > div { display: flex; flex-direction: column; align-items: center; }+.cover-k { margin: 0 0 10px; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }+.cover-t { margin: 0 0 44px; max-width: min(1200px, calc(var(--sw, 1600px) - 100px)); text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }+.cover > div > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }+.cover-t { animation-delay: .08s; }+.cover .go { animation-delay: .18s; }+.cover small { animation-delay: .26s; }+@keyframes rise { from { opacity: 0; transform: translateY(14px); } }+.cover .go { display: inline-flex; align-items: center; gap: 16px; padding: 20px 40px; border-radius: 999px; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 32px; }+.cover small { display: block; margin-top: 22px; font-size: 22px; text-align: center; color: var(--dim); }+.paused-mark { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: none; place-items: center; pointer-events: none; }+.paused .paused-mark { display: grid; }+.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }++/* Question cards inside the picture. */+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }+.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }+.band .mascot { grid-area: pic; }+.band .head { grid-area: head; align-self: end; }+.band .fb { grid-area: fb; align-self: start; }+.band .body { grid-area: body; }+.band .acts { grid-area: acts; }+.side .mascot { float: right; margin: -2px -4px 6px 10px; }+.kicker { margin: 0 0 4px; font-size: 20px; font-weight: 600; color: var(--quiz); }+.prompt { margin: 0; font-size: 28px; line-height: 1.35; }+.side .prompt { font-size: 24px; }+.body:empty { display: none; }+.side .body { margin-top: 14px; }+.opts { display: flex; gap: 12px; flex-wrap: wrap; }+.opt { padding: 8px 24px; border-radius: 999px; border: 2px solid var(--edge); background: transparent; color: var(--chalk); font-size: 24px; min-height: 58px; display: inline-flex; align-items: center; }+.opt:hover:not(:disabled) { border-color: var(--dim); }+.opt[aria-pressed="true"] { background: var(--c, var(--chalk)); border-color: var(--c, var(--chalk)); color: var(--on-fill, #1b2320); font-weight: 600; }+.opt.good { border-color: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 35%, transparent); }+.opt.bad { border-color: var(--bad); color: var(--bad); }+.opt:disabled { cursor: default; }+.fb { margin-top: 8px; font-size: 22px; line-height: 1.4; color: var(--chalk); }+.fb:empty { display: none; }+.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }+.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }+.fb ul { margin: 6px 0 0; padding-left: 22px; }+.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }+.acts { display: flex; gap: 12px; align-items: center; }+.side .acts { margin-top: 16px; }+.side .acts { flex-wrap: wrap; gap: 10px; }+.side .btn { padding: 8px 16px; font-size: 20px; }+.card.side { padding: 18px 22px; }+.btn { padding: 10px 28px; border-radius: 999px; border: 0; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 22px; white-space: nowrap; }+.btn.quiet { background: transparent; color: var(--dim); border: 1.5px solid var(--edge); }+.btn.go { background: var(--quiz); color: var(--on-fill, #10242e); } /* --on-fill: text on a coloured fill */+.btn:disabled { background: var(--edge); color: var(--dim); cursor: default; }++.grid .row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 34px; gap: 16px; align-items: center; padding: 5px 0 5px 12px; border-bottom: 1px solid var(--rule); }+.grid .num { display: flex; justify-content: flex-end; align-items: center; font-size: 26px; }+.grid.text .row { grid-template-columns: minmax(0, 1fr) auto 34px; }+.grid.text .num { justify-content: flex-start; }+.grid .opts { gap: 8px; }+.grid .opt { padding: 3px 16px; min-height: 42px; font-size: 20px; }+.grid .mark { font-weight: 700; text-align: center; }+.grid .mark.good { color: var(--good); }+.grid .mark.bad { color: var(--bad); }+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }+.grid.text .why { padding-left: 0; }+.grid .why:empty { display: none; }++.hit { cursor: pointer; }+.hit .ring { fill: transparent; stroke: var(--chalk); stroke-width: 2.5; stroke-opacity: 0; }+.hit:hover .ring, .hit:focus .ring { stroke-opacity: .7; }+.hit.bad .ring { stroke: var(--bad); stroke-opacity: 1; }+.hit.good .ring { stroke: var(--good); stroke-opacity: 1; stroke-width: 4; }+/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.+ A book can set --word-font for its early-reader letters. */+.tapw .ring { stroke-width: 5; }+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }+@keyframes word-in { from { transform: scale(.6); opacity: 0; } }+.card.words .acts { margin: 0; gap: 18px; }+.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }+.card.words.lit .count { color: var(--good); }+.card.words.lit .btn.go { animation: word-in .4s cubic-bezier(.3, 1.5, .6, 1); }+.tok { cursor: grab; touch-action: none; } /* a finger drags the chip instead of scrolling the page */++/* Controls strip, part of the frame. */+#bar { position: absolute; left: 0; top: var(--sh, 900px); width: var(--sw, 1600px); height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }+.icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); display: grid; place-items: center; flex: none; padding: 0; }+.icon svg { width: 18px; height: 18px; fill: var(--chalk); }+.icon .i-pause { display: none; }+.is-playing .icon .i-play { display: none; }+.is-playing .icon .i-pause { display: block; }+.segs { flex: 1; display: flex; gap: 4px; height: 30px; align-items: center; min-width: 0; margin: 0 8px; }+.seg { position: relative; display: block; min-width: 0; height: 8px; border-radius: 4px; background: var(--track); border: 0; padding: 0; overflow: hidden; }+.seg:hover { height: 12px; }+.seg i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--chalk); }+.seg.ask { background: var(--track-ask); }+.seg.ask i { background: var(--quiz); }+.step { width: 300px; flex: none; color: var(--dim); font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }+/* Keep the control strip usable without scaling down its touch targets. */+@media (max-width: 700px) {+ #frame { top: calc(50% - 50px); overflow: visible; }+ #bar { width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;+ transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }+ #bar .icon { width: 36px; height: 40px; }+ .step { display: none; }+ #bHelp { display: none; } /* keyboard shortcuts; room for the speed button on a phone */+ #bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }+ .segs { order: 1; }+ .segs { min-width: 80px; margin: 0; }+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }+}+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */+@media (pointer: coarse) {+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }+ :root.full #bar .icon { width: 40px; height: 40px; }+ :root.full .step, :root.full #bHelp { display: none; }+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }+}+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }++.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }+.sound-note[hidden] { display: none; }+.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }+.blanks .brow:last-child { border-bottom: 0; }+.blanks .bline { line-height: 64px; white-space: nowrap; }+.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }+.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }+.blanks .mark.bad { color: var(--bad); }+.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }+.blanks .why:empty { display: none; }+.box { height: 52px; margin: 0 6px; padding: 0 6px; border: 0; border-bottom: 3px solid var(--quiz); border-radius: 8px 8px 0 0; background: color-mix(in srgb, var(--chalk) 7%, transparent); color: var(--chalk); font: 32px var(--math-font, "STIX Two Text", "Cambria Math", "Iowan Old Style", Palatino, Georgia, serif); text-align: center; vertical-align: -6px; }+.box:focus { outline: none; background: color-mix(in srgb, var(--quiz) 16%, transparent); }+.box.good { border-color: var(--good); }+.box.bad { border-color: var(--bad); }+.box:disabled { opacity: 1; }+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }+.opt kbd { margin: 0 .6em 0 0; }+.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }+.keys kbd { margin: 0 .15em; }+.grid .row.cur { background: color-mix(in srgb, var(--chalk) 5%, transparent); box-shadow: inset 4px 0 var(--quiz); }+.help { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }+.help[hidden] { display: none; }+.help-box { width: min(1120px, calc(var(--sw, 1600px) - 80px)); padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }+.help h2 { margin: 0 0 22px; font-size: 32px; font-weight: 600; }+.help h3 { margin: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--quiz); }+.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }+.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }+.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }+.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }+.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }+.help dd { margin: 0; color: var(--dim); }+.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }+.icon.txt { font-size: 20px; font-weight: 700; color: var(--dim); }+/* Optional captions of the narration, one sentence at a time. Off by default: teaching text lives in the picture. */+.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: min(1180px, calc(var(--sw, 1600px) - 80px)); padding: 10px 24px; border-radius: 14px; background: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }+.caption[hidden] { display: none; }+.icon.cc { font-size: 15px; font-weight: 700; color: var(--dim); }+.icon.cc[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--board); }+.card.side { overflow: auto; }+svg.m { display: inline-block; overflow: visible; }+.card b { font-weight: 700; } /* not 'bolder' (900 under a 600 prompt) */+.card { animation: card-in .45s cubic-bezier(.2, .9, .3, 1.15); }+.fb:not(:empty) { animation: fb-in .3s ease-out; }+.opt.bad, .grid .mark.bad { animation: shake .4s; }+.grid .mark.good { animation: pop .35s ease-out; }+@keyframes card-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }+@keyframes fb-in { from { opacity: 0; transform: translateY(8px); } }+@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.3); } }+@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }+/* Full-screen chapter practice. */+.card.screen { height: 900px; padding: 50px 70px; border: 0; border-radius: 0; background: transparent; box-shadow: none; animation: screen-in .5s ease-out; max-height: none; overflow: visible; }+.screen .kicker { font-size: 22px; }+.screen .prompt { font-size: 40px; font-weight: 600; }+.screen .body { margin-top: 30px; }+.card.screen { display: flex; flex-direction: column; }+.screen .head { order: 1; } .screen .body { order: 2; }+.screen .fb { order: 3; max-width: min(1080px, calc(var(--sw, 1600px) - 140px)); margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers */+/* Practice screens: the bottom 130 px hold the buttons. Long answers scroll inside the body, so the feedback under+ them stays in view after a wrong answer adds a 'why' line to each row. */+.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }+.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }+.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }+.screen .acts { position: absolute; right: 70px; bottom: 48px; }+.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }+/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */+.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }+.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }+.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }+.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }+.screen .grid .why { padding-left: 216px; font-size: 20px; }+.screen .grid.text .why { padding-left: 0; }+#ui > .screen.sort { pointer-events: none; }+.screen.sort > * { pointer-events: auto; }+.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }+.screen.sort .prompt { font-size: 28px; }+.screen.sort .fb { position: absolute; margin: 0; left: auto; right: 34px; bottom: 116px; width: 330px; max-height: 240px; overflow: auto; font-size: 20px; }+.screen.sort .acts { right: 34px; }+.fin .finwrap { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; padding-bottom: 60px; }+.fin .mascot { margin-bottom: 28px; }+.fin .fb, .fin .acts { position: static; }+.fin .fb { order: 0; margin: 0; } /* result lines, not answer feedback: keep them above the buttons */+.fin .acts { margin-top: 30px; }+@keyframes screen-in { from { opacity: 0; } }++/* The guide: an infinity sign whose loops are its eyes. */+.mascot { display: block; flex: none; overflow: visible; }+.mascot .mbody { transform-box: view-box; transform-origin: 60px 46px; animation: bob 3.4s ease-in-out infinite; }+.mascot .eyes { transition: transform .3s; }+.mascot .pupil { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }+.mascot .joy, .mascot .flat { display: none; }+.mascot.happy .pupil { display: none; }+.mascot.happy .joy { display: inline; }+.mascot.happy .mbody { animation: hop .55s ease-out 2, bob 3.4s ease-in-out 1.1s infinite; }+.mascot.oops .eyes { transform: translate(-3px, 4px); }+.mascot.oops .smile { display: none; }+.mascot.oops .flat { display: inline; }+.mascot.oops .mbody { animation: wobble .5s ease-in-out, bob 3.4s ease-in-out .5s infinite; }+@keyframes bob { 50% { transform: translateY(-3px) rotate(-2deg); } }+@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }+@keyframes hop { 40% { transform: translateY(-12px) rotate(4deg); } }+@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(6deg); } }+@media (prefers-reduced-motion: reduce) { .card, .fb, .opt, .grid .mark, .mascot * { animation: none !important; } }++a.icon { text-decoration: none; }+/* Citations (cite() and plain-text labels found in refs.js) and the finish card's source list open the source in a new tab. */+a.cite { cursor: pointer; }+a.cite text, a.cite tspan { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 5px; }+a.cite:hover text, a.cite:hover tspan { fill: var(--quiz); }+a.cite:focus { outline: none; }+a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }+a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }+#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }+#ui a.cite:hover { color: var(--quiz); }+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }+.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }+.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }+.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }+.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }+.fin .srcs a:hover { color: var(--quiz); }+.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }+a.btn { text-decoration: none; display: inline-block; }+/* Page-to-page motion: the contents card grows into this frame, and shrinks back on the way out. */+@view-transition { navigation: auto; }+#frame { view-transition-name: lesson; }+::view-transition-group(lesson) { animation-duration: .5s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }+::view-transition-old(lesson), ::view-transition-new(lesson) { height: 100%; object-fit: cover; }+::view-transition-old(lesson) { animation-duration: .18s; }+@media (prefers-reduced-motion: reduce) { .cover > div > * { animation: none; } ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }+/* The finish screen speaks the same type as the chapter cover and the contents page. */+.fin .kicker { font-size: 20px; letter-spacing: .14em; text-transform: uppercase; }+.fin .prompt { margin: 6px 0 14px; font: 500 56px/1.15 "Iowan Old Style", Palatino, Georgia, serif; }+.icon.speed { width: auto; min-width: 44px; padding: 0 10px; border-radius: 22px; font-size: 16px; }+/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */+:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */+:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }diff --git a/site/little-horse/lib/engine.js b/site/little-horse/lib/engine.jsnew file mode 100644index 0000000..f36ec13--- /dev/null+++ b/site/little-horse/lib/engine.js@@ -0,0 +1,1923 @@+// Papermorph lesson engine: stage, drawing, timeline, questions, player.+// A chapter page loads this file, defines CHAPTER and BEATS, then calls boot().+'use strict';+// A fast follow-up navigation can abort the incoming page transition.+addEventListener('pagereveal', e => e.viewTransition?.ready.catch(() => {}));++// The engine's state and helpers live in one closure. Only the names declared at the end of this file are global (the+// API that chapters, math.js, book libraries and the scripts use), so a chapter may name its own helpers anything else+// (clock, fit, frame, last, ui, …).+let seeking = false; // true while seek() replays the beats before its target+let captions = false; // the reader's captions setting (C)+const ENGINE = (() => {++/* ---------- interface language ---------- */+// The page's <html lang> picks the interface text; CHAPTER.language picks the audio folder. Set both alike.+// A value is a string or plural forms { one, few, many, other } chosen by vars.n. Missing keys fall back to English.+const TRANSLATIONS = {+ en: {+ decimalSign: '.', stageLabel: 'Lesson animation', stageLabelTitled: 'Lesson animation: {title}',+ shortcuts: 'Keyboard shortcuts', lesson: 'Lesson', questions: 'Questions',+ helpPlay: 'Play or pause', helpStep: 'Previous or next step', helpStepInQuestion: 'Change step during a question', helpRestart: 'Start over',+ helpCaptions: 'Captions on or off', helpSpeed: 'Slower or faster', helpFullScreen: 'Full screen', helpList: 'Show this list',+ helpChoose: 'Choose an answer or a ring', helpTrueFalse: 'True or false', helpRows: 'Move between rows',+ helpNumberLine: 'Move along the number line, or pick a number to sort', helpEnter: 'Check, then continue',+ helpShowAnswer: 'Show the answer', helpLeaveBox: 'Leave an answer box', helpClose: 'Press {key} to close.',+ paused: 'Paused. Press space or click to continue.',+ soundFailed: 'Sound could not play. The lesson continues with the on-screen text.',+ startLesson: 'Start lesson', startFilm: 'Play', aboutMinutesFilm: 'About {n} minutes, with sound.', coverKeys: 'Press {space} to start, {help} for shortcuts.', spaceKey: 'Space',+ chapterNumber: 'Chapter {n}', aboutMinutes: 'About {n} minutes, with sound and quick checks.',+ allChapters: 'All chapters', playLabel: 'Play or pause (space)', backLabel: 'Previous step (left arrow)', restartLabel: 'Restart lesson',+ checksInLesson: 'Quick checks and practice are in the interactive lesson.',+ volumeLabel: 'Adjust volume', volumeTitle: 'Volume (0 = muted)', volumeSlider: 'Volume',+ helpLabel: 'Keyboard shortcuts (?)', speedLabel: 'Playback speed (< and >)', captionsLabel: 'Captions (C)', fullScreenLabel: 'Full screen', goToStep: 'Go to step {n}: {title}',+ quickCheck: 'Quick check', countOf: 'question {k} of {n}', check: 'Check', showAnswer: 'Show answer', nextQuestion: 'Next question', continue: 'Continue',+ correct: 'Correct. ', notQuite: 'Not quite. ', answerPrefix: 'Answer: ', keysPrefix: 'Keys: ',+ hintMove: ' move, ', hintChoose: ' choose', hintChooseOrClickGrid: ' choose, or click the grid', hintMoveAlongLine: ' move along the line, ',+ hintChooseOrClick: ' choose, or click', hintRow: ' row, ', hintTypeFraction: 'type numbers like 3/4 or −2 1/4, ', hintTypeNumber: 'type the number, ',+ hintTypeDecimal: 'type the number, ', hintNextBox: ' next box, ', hintCheck: ' check, ', hintLeaveBox: ' leave the box',+ hintPickNumber: ' pick a number, ', hintPickRing: ' choose its ring',+ rowsRight: '{r} of {n} right. Fix the rows marked ✗ and check again.',+ choicesShown: 'the correct choices are now selected.', numbersShown: 'the correct numbers are filled in.',+ notPlacedYet: '{x} is not placed yet.',+ realRingIsEmpty: '{x}: every real number is rational or irrational, so that space has no numbers of its own.',+ ringsRight: '{r} of {n} in the right ring.', ringsShown: 'every number is now in its smallest ring.',+ chipPlaced: '{x}, placed in {ring}', chipNotPlaced: '{x}, not placed', pointLabel: 'The point {v}', answerBox: 'Answer',+ stepsLeftOfZero: '{n} steps left of 0',+ natural: 'Natural', whole: 'Whole', integers: 'Integers', rational: 'Rational', irrational: 'Irrational', real: 'Real', integerColumn: 'Integer',+ trueLabel: 'True', falseLabel: 'False',+ chapterComplete: 'Chapter {n} complete', quickChecks: 'Quick checks', chapterPractice: 'Chapter practice', sources: 'Sources in this chapter', opensSource: '{label}, opens the source in a new tab',+ firstTryScore: '{name}: {r} of {t} right on the first try.', notAttempted: '{name}: not attempted.',+ watchAgain: 'Watch again', nextChapter: 'Next chapter',+ wordsHeard: '{k} / {n}', allWordsHeard: 'You found them all!',+ },+ ru: {+ decimalSign: ',', stageLabel: 'Анимация урока', stageLabelTitled: 'Анимация урока: {title}',+ shortcuts: 'Горячие клавиши', lesson: 'Урок', questions: 'Вопросы',+ helpPlay: 'Пуск или пауза', helpStep: 'Предыдущий или следующий шаг', helpStepInQuestion: 'Сменить шаг во время вопроса', helpRestart: 'Начать сначала',+ helpCaptions: 'Субтитры вкл. или выкл.', helpSpeed: 'Медленнее или быстрее', helpFullScreen: 'Полноэкранный режим', helpList: 'Показать этот список',+ helpChoose: 'Выбрать ответ или круг', helpTrueFalse: 'Верно или неверно', helpRows: 'Перейти между строками',+ helpNumberLine: 'Двигаться по числовой прямой или выбрать число для сортировки', helpEnter: 'Проверить, затем продолжить',+ helpShowAnswer: 'Показать ответ', helpLeaveBox: 'Выйти из поля ответа', helpClose: 'Нажмите {key}, чтобы закрыть.',+ paused: 'Пауза. Нажмите пробел или щёлкните, чтобы продолжить.',+ soundFailed: 'Звук не воспроизводится. Урок продолжится с текстом на экране.',+ startLesson: 'Начать урок', startFilm: 'Смотреть', aboutMinutesFilm: { one: 'Около {n} минуты, со звуком.', few: 'Около {n} минут, со звуком.', many: 'Около {n} минут, со звуком.', other: 'Около {n} минуты, со звуком.' }, coverKeys: '{space} — начать, {help} — горячие клавиши.', spaceKey: 'Пробел',+ chapterNumber: 'Глава {n}',+ aboutMinutes: { one: 'Около {n} минуты, со звуком и проверками.', few: 'Около {n} минут, со звуком и проверками.',+ many: 'Около {n} минут, со звуком и проверками.', other: 'Около {n} минуты, со звуком и проверками.' },+ allChapters: 'Все главы', playLabel: 'Пуск или пауза (пробел)', backLabel: 'Предыдущий шаг (стрелка влево)', restartLabel: 'Начать урок заново',+ checksInLesson: 'Проверочные вопросы и практика — в интерактивном уроке.',+ volumeLabel: 'Настроить громкость', volumeTitle: 'Громкость (0 — без звука)', volumeSlider: 'Громкость',+ helpLabel: 'Горячие клавиши (?)', speedLabel: 'Скорость воспроизведения (< и >)', captionsLabel: 'Субтитры (C)', fullScreenLabel: 'Полный экран', goToStep: 'Перейти к шагу {n}: {title}',+ quickCheck: 'Проверь себя', countOf: 'вопрос {k} из {n}', check: 'Проверить', showAnswer: 'Показать ответ', nextQuestion: 'Следующий вопрос', continue: 'Продолжить',+ correct: 'Верно. ', notQuite: 'Не совсем. ', answerPrefix: 'Ответ: ', keysPrefix: 'Клавиши: ',+ hintMove: ' двигаться, ', hintChoose: ' выбрать', hintChooseOrClickGrid: ' выбрать или щёлкнуть по сетке', hintMoveAlongLine: ' двигаться по прямой, ',+ hintChooseOrClick: ' выбрать или щёлкнуть', hintRow: ' строка, ', hintTypeFraction: 'вводите числа вида 3/4 или −2 1/4, ', hintTypeNumber: 'введите число, ',+ hintTypeDecimal: 'вводите числа вида 0,75, ', hintNextBox: ' следующее поле, ', hintCheck: ' проверить, ', hintLeaveBox: ' выйти из поля',+ hintPickNumber: ' выбрать число, ', hintPickRing: ' выбрать его круг',+ rowsRight: 'Верно {r} из {n}. Исправьте строки с ✗ и проверьте снова.',+ choicesShown: 'правильные варианты отмечены.', numbersShown: 'правильные числа вписаны.',+ notPlacedYet: '{x}: ещё не размещено.',+ realRingIsEmpty: '{x}: каждое действительное число рационально или иррационально, поэтому своих чисел у этой области нет.',+ ringsRight: 'В нужном круге: {r} из {n}.', ringsShown: 'каждое число теперь в своём наименьшем круге.',+ chipPlaced: '{x}, в круге «{ring}»', chipNotPlaced: '{x}, не размещено', pointLabel: 'Точка {v}', answerBox: 'Ответ',+ stepsLeftOfZero: { one: '{n} шаг влево от 0', few: '{n} шага влево от 0', many: '{n} шагов влево от 0', other: '{n} шага влево от 0' },+ natural: 'Натуральные', whole: 'Целые неотрицательные', integers: 'Целые', rational: 'Рациональные', irrational: 'Иррациональные', real: 'Действительные', integerColumn: 'Целые',+ trueLabel: 'Верно', falseLabel: 'Неверно',+ chapterComplete: 'Глава {n} пройдена', quickChecks: 'Проверь себя', chapterPractice: 'Практика по главе', sources: 'Источники этой главы', opensSource: '{label}, источник откроется в новой вкладке',+ firstTryScore: '{name}: {r} из {t} верно с первой попытки.', notAttempted: '{name}: не выполнялось.',+ watchAgain: 'Смотреть снова', nextChapter: 'Следующая глава',+ wordsHeard: '{k} / {n}', allWordsHeard: 'Все найдены!',+ },+ zh: {+ decimalSign: '.', stageLabel: '课程动画', stageLabelTitled: '课程动画:{title}',+ shortcuts: '键盘快捷键', lesson: '课程', questions: '题目',+ helpPlay: '播放或暂停', helpStep: '上一步或下一步', helpStepInQuestion: '答题时切换步骤', helpRestart: '从头开始',+ helpCaptions: '打开或关闭字幕', helpSpeed: '减速或加速', helpFullScreen: '全屏', helpList: '显示此列表',+ helpChoose: '选择答案或圆环', helpTrueFalse: '对或错', helpRows: '在各行之间移动',+ helpNumberLine: '在数轴上移动,或选一个数来分类', helpEnter: '检查,然后继续',+ helpShowAnswer: '显示答案', helpLeaveBox: '离开答题框', helpClose: '按 {key} 关闭。',+ paused: '已暂停。按空格键或点击继续。',+ soundFailed: '声音无法播放。课程将借助屏幕上的文字继续。',+ startLesson: '开始上课', startFilm: '播放', aboutMinutesFilm: '约 {n} 分钟,有配音。', coverKeys: '按 {space} 开始,按 {help} 查看快捷键。', spaceKey: '空格',+ chapterNumber: '第 {n} 章', aboutMinutes: '约 {n} 分钟,含配音和随堂小测。',+ allChapters: '全部章节', playLabel: '播放或暂停(空格)', backLabel: '上一步(左方向键)', restartLabel: '重新开始本课',+ checksInLesson: '小测验和练习在互动课程里。',+ volumeLabel: '调节音量', volumeTitle: '音量(0 为静音)', volumeSlider: '音量',+ helpLabel: '键盘快捷键(?)', speedLabel: '播放速度(< 和 >)', captionsLabel: '字幕(C)', fullScreenLabel: '全屏', goToStep: '跳到第 {n} 步:{title}',+ quickCheck: '小测', countOf: '第 {k}/{n} 题', check: '检查', showAnswer: '显示答案', nextQuestion: '下一题', continue: '继续',+ correct: '正确。', notQuite: '还不对。', answerPrefix: '答案:', keysPrefix: '按键:',+ hintMove: ' 移动,', hintChoose: ' 选择', hintChooseOrClickGrid: ' 选择,或点击网格', hintMoveAlongLine: ' 沿数轴移动,',+ hintChooseOrClick: ' 选择,或点击', hintRow: ' 换行,', hintTypeFraction: '可输入 3/4 或 −2 1/4 这样的数,', hintTypeNumber: '输入数字,',+ hintTypeDecimal: '输入数字,', hintNextBox: ' 下一个框,', hintCheck: ' 检查,', hintLeaveBox: ' 离开答题框',+ hintPickNumber: ' 选一个数,', hintPickRing: ' 选它所在的圆环',+ rowsRight: '{n} 行中对了 {r} 行。改正标 ✗ 的行,再检查一次。',+ choicesShown: '正确选项已经选上。', numbersShown: '正确的数已经填上。',+ notPlacedYet: '{x} 还没有放好。',+ realRingIsEmpty: '{x}:每个实数不是有理数就是无理数,所以这一块没有只属于它的数。',+ ringsRight: '{n} 个中有 {r} 个放在了正确的圆环里。', ringsShown: '每个数现在都在它所属的最小圆环里。',+ chipPlaced: '{x},放在「{ring}」', chipNotPlaced: '{x},未放置', pointLabel: '点 {v}', answerBox: '答案',+ stepsLeftOfZero: '0 左边 {n} 步',+ natural: '正整数', whole: '非负整数', integers: '整数', rational: '有理数', irrational: '无理数', real: '实数', integerColumn: '整数',+ trueLabel: '对', falseLabel: '错',+ chapterComplete: '第 {n} 章完成', quickChecks: '小测', chapterPractice: '本章练习', sources: '本章引用的文献', opensSource: '{label},在新标签页中打开来源',+ firstTryScore: '{name}:第一次就答对 {r} / {t}。', notAttempted: '{name}:未作答。',+ watchAgain: '再看一遍', nextChapter: '下一章',+ wordsHeard: '{k} / {n}', allWordsHeard: '全都找到啦!',+ },+ ja: {+ decimalSign: '.', stageLabel: '授業アニメーション', stageLabelTitled: '授業アニメーション:{title}',+ shortcuts: 'キーボードショートカット', lesson: '授業', questions: '問題',+ helpPlay: '再生/一時停止', helpStep: '前または次のステップ', helpStepInQuestion: '問題の途中でステップを移動', helpRestart: '最初から',+ helpCaptions: '字幕のオン/オフ', helpSpeed: '遅く/速く', helpFullScreen: '全画面', helpList: 'この一覧を表示',+ helpChoose: '答えまたは輪を選ぶ', helpTrueFalse: '正しい/誤り', helpRows: '行を移動',+ helpNumberLine: '数直線上を移動、または分類する数を選ぶ', helpEnter: '答え合わせ、そして次へ',+ helpShowAnswer: '答えを表示', helpLeaveBox: '解答欄から出る', helpClose: '{key} で閉じる。',+ paused: '一時停止中。スペースキーかクリックで再開します。',+ soundFailed: '音声を再生できません。画面の文字で授業を続けます。',+ startLesson: '授業を始める', startFilm: '再生', aboutMinutesFilm: '約{n}分、音声つき。', coverKeys: '{space} で開始、{help} でショートカット一覧。', spaceKey: 'スペース',+ chapterNumber: '第{n}章', aboutMinutes: '約{n}分、音声と確認問題つき。',+ allChapters: 'すべての章', playLabel: '再生/一時停止(スペース)', backLabel: '前のステップ(左矢印)', restartLabel: '授業を最初から',+ checksInLesson: '確認問題と練習はインタラクティブな授業の中にあります。',+ volumeLabel: '音量を調整', volumeTitle: '音量(0 でミュート)', volumeSlider: '音量',+ helpLabel: 'キーボードショートカット(?)', speedLabel: '再生速度(< と >)', captionsLabel: '字幕(C)', fullScreenLabel: '全画面', goToStep: 'ステップ {n}:{title} へ移動',+ quickCheck: '確認問題', countOf: '問 {k}/{n}', check: '答え合わせ', showAnswer: '答えを見る', nextQuestion: '次の問題', continue: '続ける',+ correct: '正解。', notQuite: 'おしい。', answerPrefix: '答え:', keysPrefix: 'キー:',+ hintMove: ' 移動、', hintChoose: ' 選ぶ', hintChooseOrClickGrid: ' 選ぶ、またはマス目をクリック', hintMoveAlongLine: ' 数直線上を移動、',+ hintChooseOrClick: ' 選ぶ、またはクリック', hintRow: ' 行、', hintTypeFraction: '3/4 や −2 1/4 のように入力、', hintTypeNumber: '数を入力、',+ hintTypeDecimal: '数を入力、', hintNextBox: ' 次の欄、', hintCheck: ' 答え合わせ、', hintLeaveBox: ' 欄から出る',+ hintPickNumber: ' 数を選ぶ、', hintPickRing: ' その輪を選ぶ',+ rowsRight: '{n} 行中 {r} 行正解。✗ の行を直して、もう一度答え合わせ。',+ choicesShown: '正しい選択肢を選びました。', numbersShown: '正しい数を入れました。',+ notPlacedYet: '{x} はまだ置かれていません。',+ realRingIsEmpty: '{x}:実数はどれも有理数か無理数なので、この部分だけに入る数はありません。',+ ringsRight: '{n} 個中 {r} 個が正しい輪に入っています。', ringsShown: 'どの数も、入るいちばん小さい輪に移しました。',+ chipPlaced: '{x}、「{ring}」に配置', chipNotPlaced: '{x}、未配置', pointLabel: '点 {v}', answerBox: '答え',+ stepsLeftOfZero: '0 から左へ {n}',+ natural: '自然数', whole: '0 以上の整数', integers: '整数', rational: '有理数', irrational: '無理数', real: '実数', integerColumn: '整数',+ trueLabel: '正しい', falseLabel: '誤り',+ chapterComplete: '第{n}章 完了', quickChecks: '確認問題', chapterPractice: '章末練習', sources: 'この章の出典', opensSource: '{label}(出典を新しいタブで開く)',+ firstTryScore: '{name}:1 回目で {t} 問中 {r} 問正解。', notAttempted: '{name}:未挑戦。',+ watchAgain: 'もう一度見る', nextChapter: '次の章へ',+ wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',+ },+};+// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.+const PORTRAIT = document.documentElement.dataset.stage === 'portrait';+const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;+document.documentElement.style.setProperty('--sw', SW + 'px');+document.documentElement.style.setProperty('--sh', SH + 'px');+const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];+const pluralRules = {};+// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.+// contents.js has its own copy for the contents page: keep the two in step.+function translate(key, vars = {}) {+ const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';+ let text = TRANSLATIONS[language][key] ?? key;+ if (typeof text === 'object') {+ try { pluralRules[language] ??= new Intl.PluralRules(language); } catch { pluralRules[language] = new Intl.PluralRules('en'); }+ text = text[pluralRules[language].select(vars.n)] ?? text.other;+ }+ return text.replace(/\{(\w+)\}/g, (placeholder, name) => name in vars ? vars[name] : placeholder);+}+const DECIMAL_SIGN = translate('decimalSign'); // shown by num() and accepted by answer boxes+const isLatinLetter = key => /^[a-z]$/i.test(key);+// A letter shortcut on any keyboard layout: the typed letter, or the same physical key when the layout types a non-Latin letter.+const isShortcut = (event, letter) => event.key.toLowerCase() === letter.toLowerCase()+ || (isLatinLetter(letter) && !isLatinLetter(event.key) && event.code === 'Key' + letter.toUpperCase());+// A punctuation shortcut (code 'Comma', 'Period') on a layout that types a non-Latin letter on that key.+const isShortcutCode = (event, code) => /^\p{L}$/u.test(event.key) && !isLatinLetter(event.key) && event.code === code;++document.body.insertAdjacentHTML('afterbegin', `<div id="frame">+ <svg id="stage" viewBox="0 0 ${SW} ${SH}" role="img" aria-label="${translate('stageLabel')}">+ <g id="scene"></g>+ </svg>+ <div id="ui"></div>+ <div class="paused-mark"><div>${translate('paused')}</div></div>+ <div class="caption" id="caption" hidden></div>+ <div class="help" id="help" hidden role="dialog" aria-label="${translate('shortcuts')}">+ <div class="help-box">+ <h2>${translate('shortcuts')}</h2>+ <div class="help-cols">+ <div><h3>${translate('lesson')}</h3><dl>+ <dt><kbd>${translate('spaceKey')}</kbd></dt><dd>${translate('helpPlay')}</dd>+ <dt><kbd>←</kbd><kbd>→</kbd></dt><dd>${translate('helpStep')}</dd>+ <dt><kbd>Shift</kbd><kbd>←</kbd><kbd>→</kbd></dt><dd>${translate('helpStepInQuestion')}</dd>+ <dt><kbd>Home</kbd></dt><dd>${translate('helpRestart')}</dd>+ <dt><kbd>C</kbd></dt><dd>${translate('helpCaptions')}</dd>+ <dt><kbd><</kbd><kbd>></kbd></dt><dd>${translate('helpSpeed')}</dd>+ <dt><kbd>F</kbd></dt><dd>${translate('helpFullScreen')}</dd>+ <dt><kbd>?</kbd></dt><dd>${translate('helpList')}</dd>+ </dl></div>+ <div><h3>${translate('questions')}</h3><dl>+ <dt><kbd>1</kbd>–<kbd>6</kbd></dt><dd>${translate('helpChoose')}</dd>+ <dt><kbd>T</kbd><kbd>F</kbd></dt><dd>${translate('helpTrueFalse')}</dd>+ <dt><kbd>↑</kbd><kbd>↓</kbd></dt><dd>${translate('helpRows')}</dd>+ <dt><kbd>←</kbd><kbd>→</kbd></dt><dd>${translate('helpNumberLine')}</dd>+ <dt><kbd>Enter</kbd></dt><dd>${translate('helpEnter')}</dd>+ <dt><kbd>S</kbd></dt><dd>${translate('helpShowAnswer')}</dd>+ <dt><kbd>Esc</kbd></dt><dd>${translate('helpLeaveBox')}</dd>+ </dl></div>+ </div>+ <p class="help-close">${translate('helpClose', { key: '<kbd>Esc</kbd>' })}</p>+ </div>+ </div>+ <p class="sound-note" id="soundNote" hidden>${translate('soundFailed')}</p>+ <button class="cover" id="cover"><div>+ <p class="cover-k" id="coverK"></p>+ <h1 class="cover-t" id="coverT"></h1>+ <span class="go"><svg width="24" height="24" viewBox="0 0 18 18"><path d="M3 1.5v15l13-7.5z" fill="currentColor"/></svg><span id="coverGo">${translate('startLesson')}</span></span>+ <small><span id="coverMeta"></span> ${translate('coverKeys', { space: `<kbd>${translate('spaceKey')}</kbd>`, help: '<kbd>?</kbd>' })}</small>+ </div></button>+ <div id="bar">+ <a class="icon" id="bHome" href="../" aria-label="${translate('allChapters')}" title="${translate('allChapters')}">+ <svg viewBox="0 0 18 18"><path d="M2 2h6v6H2zM10 2h6v6h-6zM2 10h6v6H2zM10 10h6v6h-6z"/></svg>+ </a>+ <button class="icon" id="bPlay" aria-label="${translate('playLabel')}">+ <svg class="i-play" viewBox="0 0 18 18"><path d="M4 2v14l12-7z"/></svg>+ <svg class="i-pause" viewBox="0 0 18 18"><path d="M3.5 2h4v14h-4zM10.5 2h4v14h-4z"/></svg>+ </button>+ <button class="icon" id="bBack" aria-label="${translate('backLabel')}">+ <svg viewBox="0 0 18 18"><path d="M3 2h2.5v14H3zM16 2v14L6.5 9z"/></svg>+ </button>+ <button class="icon" id="bRestart" aria-label="${translate('restartLabel')}">+ <svg viewBox="0 0 18 18"><path d="M9 2.5a6.5 6.5 0 1 1-6.3 8.1l2-.5A4.5 4.5 0 1 0 9 4.5V7L4.5 3.5 9 0z"/></svg>+ </button>+ <div class="segs" id="segs"></div>+ <div class="step" id="stepName"></div>+ <button class="icon txt" id="bHelp" aria-label="${translate('helpLabel')}" title="${translate('helpLabel')}">?</button>+ <button class="icon txt speed" id="bSpeed" aria-label="${translate('speedLabel')}" title="${translate('speedLabel')}">1×</button>+ <button class="icon cc" id="bCC" aria-pressed="false" aria-label="${translate('captionsLabel')}" title="${translate('captionsLabel')}">CC</button>+ <button class="icon" id="bFull" aria-label="${translate('fullScreenLabel')}">+ <svg viewBox="0 0 18 18"><path d="M1 1h6v2H3v4H1zM11 1h6v6h-2V3h-4zM1 11h2v4h4v2H1zM15 11h2v6h-6v-2h4z"/></svg>+ </button>+ </div>+</div>`);++// Board colour, grain and vignette are a static CSS background of #stage (engine.css). The grain is a small noise+// texture made once here: an SVG turbulence filter behind animated content is recomputed on every frame in Firefox.+{+ const c = document.createElement('canvas'); c.width = c.height = 256;+ const x = c.getContext('2d'), d = x.createImageData(256, 256);+ for (let i = 0, s = 7; i < d.data.length; i += 4) { s = s * 16807 % 2147483647; d.data.set([235, 242, 230, 4 + s % 12], i); }+ x.putImageData(d, 0, 0);+ document.getElementById('stage').style.setProperty('--grain', `url(${c.toDataURL()})`);+}++/* ---------- drawing helpers ---------- */+const NS = 'http://www.w3.org/2000/svg';+const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';+// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,+// --progress-key for the localStorage key the cover and chapters share.+const BOOK = getComputedStyle(document.documentElement);+const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only+// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):+// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.+const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',+ chalk: '#ece8dc', dim: '#9aaba3', faint: '#5d7068', task: '#f0b45a', good: '#8fd6b0', bad: '#f08c7a', board: '#1d2b27' };+{ // a canvas reads any CSS colour back as #rrggbb, the form colour tweens mix; a missing or bad one keeps the default+ const c = document.createElement('canvas').getContext('2d');+ for (const k of ['chalk', 'dim', 'faint', 'task', 'good', 'bad', 'board']) { c.fillStyle = COL[k]; c.fillStyle = bookSetting('--' + k) || COL[k]; COL[k] = c.fillStyle; }+}+const MATH = bookSetting('--math-font') || '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';+const NAME = { nat: translate('natural'), whole: translate('whole'), int: translate('integers'), rat: translate('rational'), irr: translate('irrational'), real: translate('real') };+// Card positions inside the picture. BAND and the screens follow the stage; RIGHT and TOPR are placed for the wide+// stage's number line and map and have no upright layout yet.+const BAND = { x: 96 * SW / 1600, y: SH - 214, w: SW - 192 * SW / 1600, cls: 'band' }; // bottom band (moves up when taller than the space left)+const RIGHT = { x: 1258, y: 546, w: 330, cls: 'side', maxH: 346 }; // right of the number map+const TOPR = { x: 960, y: 70, w: 624, cls: 'side', maxH: 470 }; // top right, above the number line+const SCREEN = { x: 0, y: 0, w: SW, cls: 'screen' };+const SORT_SCREEN = { x: 0, y: 0, w: SW, cls: 'screen sort' };+const $m = (...parts) => ({ m: parts });++function mk(tag, attrs = {}, parent) {+ const e = document.createElementNS(NS, tag);+ for (const k in attrs) e.setAttribute(k, attrs[k]);+ if (parent) parent.appendChild(e);+ return e;+}+// Every animated element keeps a small state object; render() writes it to the DOM.+// Keys: x y s r o (transform/opacity), d (0..1 stroke drawn), a_<attr> numeric attr, c_<attr> hex colour.+function st(e) { return e._st || (e._st = { x: 0, y: 0, s: 1, r: 0, o: 1 }); }+function put(e, o) { Object.assign(st(e), o); render(e); return e; }+// Unchanged transform/opacity are not rewritten: per-frame updates of still elements cost repaints (notably in Firefox).+function render(e) {+ const s = e._st, tf = s.x || s.y || s.s !== 1 || s.r ? `translate(${s.x},${s.y}) rotate(${s.r}) scale(${s.s})` : null;+ // _tf starts unset: an element never moved keeps a transform attribute it was made with+ if (tf !== (e._tf ?? null)) { if (tf) e.setAttribute('transform', tf); else e.removeAttribute('transform'); e._tf = tf; }+ if (s.o !== e._o) { e.setAttribute('opacity', s.o); e._o = s.o; }+ if (s.d !== undefined) {+ e.setAttribute('stroke-dashoffset', 1 - s.d);+ e.style.visibility = s.d < .002 ? 'hidden' : '';+ }+ for (const k in s) {+ if (k.startsWith('a_')) e.setAttribute(k.slice(2), s[k]);+ else if (k.startsWith('c_')) e.setAttribute(k.slice(2), s[k]);+ }+}+function G(parent, o = {}) { return put(mk('g', {}, parent), o); }+function path(parent, d, attrs = {}, o = {}) {+ const p = mk('path', { d, fill: 'none', 'stroke-linecap': 'round', 'stroke-linejoin': 'round', ...attrs }, parent);+ if (o.d !== undefined) { p.setAttribute('pathLength', 1); p.setAttribute('stroke-dasharray', '1 1'); }+ return put(p, o);+}+function T(parent, str, { x = 0, y = 0, size = 30, fill = COL.chalk, font = UI, weight = 500, anchor = 'start', o = 1 } = {}) {+ const t = mk('text', { 'font-size': size, fill, 'font-family': font, 'font-weight': weight, 'text-anchor': anchor }, parent);+ t.textContent = str;+ t.style.whiteSpace = 'pre';+ return put(t, { x, y, o });+}+// A citation drawn in the picture that opens its source (REFS from ../refs.js, built by scripts/refs.py) in a new tab.+// cite(p, key, opts) takes T's options; str overrides the label (default REFS[key].cite). Returns the <a>; animate it like T.+const CITED = new Set();+function cite(parent, key, { str, ...opts } = {}) {+ const r = (typeof REFS === 'object' && REFS) ? REFS[key] : null;+ if (!r) throw new Error(`cite: no reference "${key}" in refs.js`);+ CITED.add(key);+ if (!r.url) return T(parent, str || r.cite, opts);+ linkStage();+ const a = mk('a', { class: 'cite', href: r.url, target: '_blank', rel: 'noopener', 'aria-label': translate('opensSource', { label: r.cite }) }, parent);+ const { o = 1, x = 0, y = 0, ...rest } = opts;+ T(a, str || r.cite, { ...rest, fill: rest.fill || COL.chalk });+ return put(a, { x, y, o });+}+// Any text in the picture or a card that equals a reference's cite label or one of its match strings (case-insensitive)+// becomes a link to the source, so chapters write citations as plain text. Watched by citeObs (set up after the player).+let CITE_RE = null, CITE_KEY = null;+function citeIndex() {+ if (CITE_RE !== null) return CITE_RE;+ CITE_KEY = new Map();+ for (const [k, r] of Object.entries(typeof REFS === 'object' && REFS ? REFS : {}))+ for (const s of [r.cite, ...(r.match || [])]) if (s) CITE_KEY.set(s.toLowerCase(), k);+ const alts = [...CITE_KEY.keys()].sort((a, b) => b.length - a.length).map(s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));+ return (CITE_RE = alts.length ? new RegExp(alts.join('|'), 'gi') : false);+}+function autoCite(root) {+ const re = citeIndex();+ if (!re) return;+ const nodes = [];+ if (root.nodeType === 3) nodes.push(root);+ else if (root.nodeType === 1) for (let w = document.createTreeWalker(root, NodeFilter.SHOW_TEXT), n; (n = w.nextNode());) nodes.push(n);+ for (const n of nodes) {+ const host = n.parentElement;+ if (!host || host.closest('a, button, input, script, style, kbd')) continue; // no links inside controls+ const ms = [...n.data.matchAll(re)];+ if (!ms.length) continue;+ const svg = host.namespaceURI === NS, frag = document.createDocumentFragment();+ let i = 0, made = 0;+ for (const m of ms) {+ const k = CITE_KEY.get(m[0].toLowerCase()), r = REFS[k];+ CITED.add(k);+ if (!r.url) continue; // a work with no reliable online record stays plain text but is still listed+ frag.append(n.data.slice(i, m.index));+ const a = svg ? mk('a', { href: r.url }) : document.createElement('a');+ if (!svg) a.href = r.url;+ a.setAttribute('class', 'cite');+ a.setAttribute('target', '_blank');+ a.setAttribute('rel', 'noopener');+ a.setAttribute('aria-label', translate('opensSource', { label: m[0] }));+ if (svg) mk('tspan', {}, a).textContent = m[0]; else a.textContent = m[0];+ frag.append(a);+ i = m.index + m[0].length;+ made++;+ }+ if (!made) continue; // replacing the node unchanged would re-trigger the observer+ if (svg) linkStage();+ frag.append(n.data.slice(i));+ n.replaceWith(frag);+ }+}+// The stage is announced as one image; once it holds a link it becomes a group, so the link stays reachable.+function linkStage() { document.getElementById('stage').setAttribute('role', 'group'); }+// Links that have faded out (or sit in a faded group) must not take clicks or Tab focus.+function syncLinks() {+ for (const a of scene.querySelectorAll('a.cite')) {+ let o = 1;+ for (let e = a; e && e !== scene; e = e.parentNode) o *= +(e.getAttribute('opacity') ?? 1);+ const on = o > .5;+ if (on === a._on) continue;+ a._on = on;+ a.style.pointerEvents = on ? '' : 'none';+ if (on) { a.removeAttribute('tabindex'); a.removeAttribute('aria-hidden'); }+ else { a.setAttribute('tabindex', '-1'); a.setAttribute('aria-hidden', 'true'); }+ }+}+const ctx2d = document.createElement('canvas').getContext('2d');+function textW(str, size, italic = false) { ctx2d.font = `${italic ? 'italic ' : ''}${size}px ${MATH}`; return ctx2d.measureText(str).width; }+const VAR = /(?<![A-Za-z°])(?:(?!(?:of|in|is|to|or|at|on|by|as|an|if|it|be|no|so|up|we|my)(?![A-Za-z]))[a-z]{1,2}|(?!(?:If|In|It|Is|On|At|No|So|Or|An|As|To|By|Up)(?![A-Za-z]))[a-z]?[A-Z]{1,3}[a-z]?)(?![A-Za-z])/g; // capitals: A, PV, nRT // short lowercase runs are variables (a, x, ab), except short English words+const F = (n, d) => ({ f: [String(n), String(d)] }); // fraction+const R = (x, i) => ({ r: x && x.f ? x : String(x), i: i && String(i) }); // root of a number or of F(n, d); i = index, e.g. 3 for a cube root+const E = x => ({ sup: String(x) }); // exponent, raised after the part before it+const TX = tex => ({ tex: String(tex) }); // LaTeX, drawn by MathJax; the book loads lib/mathjax.js right after this file+const $tex = tex => $m(TX(tex)); // LaTeX inline in HTML text+// MathJax takes this object as its configuration when lib/mathjax.js loads after the engine.+window.MathJax ??= {+ startup: { typeset: false }, // no page scan; formulas are converted on demand+ svg: { fontCache: 'none', mtextInheritFont: true }, // self-contained paths; \text{} in the book's math font+ tex: { packages: { '[-]': ['noerrors', 'noundefined'] }, // a typo stops the page, like a misspelt mark+ formatError: (_, error) => { throw error; } },+ options: { enableMenu: false },+};+const TEX_CACHE = new Map(); // TeX source -> { graphic, viewBox }; seek() redraws every earlier beat+// A copy of the formula's MathJax drawing: units of 1/1000 em, baseline at y = 0; viewBox is [x, y, width, height].+function texGraphic(tex) {+ let drawn = TEX_CACHE.get(tex);+ if (!drawn) {+ if (!window.MathJax?.tex2svg) throw new Error(`TX('${tex}') needs lib/mathjax.js: load ../lib/mathjax.js right after engine.js`);+ if (!document.getElementById('MJX-SVG-styles')) document.head.append(MathJax.svgStylesheet()); // draws table rules and frames+ let svg;+ try { svg = MathJax.tex2svg(tex, { display: false, family: MATH }).querySelector('svg'); } // family: \text{} is measured in the font it is drawn in+ catch (error) { throw new Error(`TX('${tex}'): ${error.message}`); }+ const graphic = mk('g');+ graphic.append(...svg.childNodes);+ drawn = { graphic, viewBox: svg.getAttribute('viewBox').split(' ').map(Number) };+ TEX_CACHE.set(tex, drawn);+ }+ return { graphic: drawn.graphic.cloneNode(true), viewBox: drawn.viewBox };+}+// The part of a TeX formula marked \class{name}{...}, ready for tw/fx on c_color and o.+// MathJax places the part with its own transform, so the tweens act on a group inside it.+function texPart(el, name) {+ const part = el.querySelector(`g.${CSS.escape(name)}`);+ if (!part) throw new Error(`texPart: no \\class{${name}}{…} in this formula`);+ if (!part._tweenGroup) {+ const group = mk('g');+ group.append(...part.childNodes);+ part.append(group);+ const color = part.closest('[color]')?.getAttribute('color'); // the formula's fill+ put(group, /^#[\da-f]{6}$/i.test(color) ? { c_color: color } : {});+ part._tweenGroup = group;+ }+ return part._tweenGroup;+}+const OV = x => ({ ov: String(x) }); // digits under a repeat bar: ['0.', OV('3')] is 0.333…+// Math expression from parts: 'text' | F(n,d) | R(x) | E(exp) | OV(digits) | TX(tex). Baseline at y; anchor start/middle/end.+// _ascent and _descent are the TeX parts' height above and below the baseline (0 without TX).+function M(parent, parts, { x = 0, y = 0, size = 36, fill = COL.chalk, anchor = 'middle', o = 1, s = 1 } = {}) {+ const g = G(parent, { x, y, o, s });+ const inner = mk('g', {}, g);+ const lw = size * .05;+ const text = (str, tx, ty, sz) => {+ const t = mk('text', { x: tx, y: ty, 'font-size': sz, 'font-family': MATH, fill }, inner);+ t.style.whiteSpace = 'pre';+ let w = 0, last = 0;+ const run = (piece, italic) => {+ if (!piece) return;+ mk('tspan', italic ? { 'font-style': 'italic' } : {}, t).textContent = piece;+ w += textW(piece, sz, italic);+ };+ for (const m of str.matchAll(VAR)) { run(str.slice(last, m.index), false); run(m[0], true); last = m.index + m[0].length; }+ run(str.slice(last), false);+ return w;+ };+ const rule = (x1, x2, yy) => mk('path', { d: `M${x1} ${yy}H${x2}`, stroke: fill, 'stroke-width': lw, 'stroke-linecap': 'round' }, inner);+ let cx = 0, ascent = 0, descent = 0;+ for (const p of parts) {+ if (typeof p === 'string') cx += text(p, cx, 0, size);+ else if (p.tex !== undefined) {+ const { graphic, viewBox: [, top, w, h] } = texGraphic(p.tex), k = size / 1000; // 1000 units = 1 em = size+ graphic.setAttribute('transform', `translate(${cx},0) scale(${k})`);+ graphic.setAttribute('color', fill); // MathJax paints with currentColor+ inner.append(graphic);+ ascent = Math.max(ascent, -top * k);+ descent = Math.max(descent, (top + h) * k);+ cx += w * k;+ } else if (p.f) {+ const fs = size * .72, [n, d] = p.f, wn = textW(n, fs), wd = textW(d, fs);+ const w = Math.max(wn, wd) + size * .2, bar = -size * .3;+ text(n, cx + (w - wn) / 2, bar - size * .12, fs);+ text(d, cx + (w - wd) / 2, bar + size * .62, fs);+ rule(cx + size * .04, cx + w - size * .04, bar);+ cx += w + size * .04;+ } else if (p.r) {+ const fr = typeof p.r === 'object', mid = fr ? -size * .12 : -size * .3, bot = fr ? size * .45 : size * .06, top = fr ? -size * 1.12 : -size * .82;+ let x0 = cx + size * .04;+ if (p.i) { const iw = textW(p.i, size * .42); text(p.i, x0, mid - size * .14, size * .42); x0 += Math.max(0, iw - size * .12); } // index in the radical's crook+ let w;+ if (fr) { // a fraction under the radical, laid out like F()+ const fs = size * .72, [n, d] = p.r.f, wn = textW(n, fs), wd = textW(d, fs), bx = x0 + size * .56, bar = -size * .3;+ w = Math.max(wn, wd) + size * .2;+ text(n, bx + (w - wn) / 2, bar - size * .12, fs);+ text(d, bx + (w - wd) / 2, bar + size * .62, fs);+ mk('path', { d: `M${bx + size * .04} ${bar}H${bx + w - size * .04}`, stroke: fill, 'stroke-width': lw, 'stroke-linecap': 'round' }, inner);+ } else { w = textW(p.r, size); text(p.r, x0 + size * .56, 0, size); }+ mk('path', { d: `M${x0} ${mid}L${x0 + size * .1} ${mid - size * .06}L${x0 + size * .27} ${bot}L${x0 + size * .45} ${top}H${x0 + size * .56 + w + size * .06}`,+ fill: 'none', stroke: fill, 'stroke-width': lw, 'stroke-linejoin': 'round', 'stroke-linecap': 'round' }, inner);+ cx = x0 + size * .56 + w + size * .1;+ } else if (p.sup !== undefined) {+ cx += text(p.sup, cx + size * .03, -size * .45, size * .62) + size * .06;+ } else if (p.ov !== undefined) {+ const w = text(p.ov, cx, 0, size);+ rule(cx + size * .04, cx + w - size * .02, -size * .8);+ cx += w;+ }+ }+ const dx = anchor === 'middle' ? -cx / 2 : anchor === 'end' ? -cx : 0;+ inner.setAttribute('transform', `translate(${dx},0)`);+ g._w = cx;+ g._ascent = ascent;+ g._descent = descent;+ return g;+}+// Pill-shaped number token, centred on (x, y).+function chip(parent, parts, color, { x = 0, y = 0, o = 1, s = 1, size = 34 } = {}) {+ const g = G(parent, { x, y, o, s });+ const rect = mk('rect', {}, g);+ const m = M(g, parts, { size, y: size * .3 });+ const w = Math.max(m._w + 36, 64);+ let h = size * (parts.some(p => p.f) ? 1.75 : 1.45);+ if (m._ascent) { // a TeX formula: centre it and grow the pill to fit+ const above = Math.max(size * 1.05, m._ascent), below = Math.max(size * .45, m._descent);+ put(m, { y: (above - below) / 2 });+ h = Math.max(h, m._ascent + m._descent + size * .4);+ }+ for (const [k, v] of Object.entries({ x: -w / 2, y: -h / 2, width: w, height: h, rx: h / 2, fill: COL.board, stroke: color, 'stroke-width': 2.5 })) rect.setAttribute(k, v);+ g._rect = rect;+ return g;+}+// A row of math tokens laid out left to right. Items: string | parts array | { t, fill }.+// Each token is centred on its own x, so it can move alone (swaps, sliding parentheses). Spacing comes from the strings.+function tokens(parent, items, { x = 0, y = 0, size = 44, fill = COL.chalk, anchor = 'start', o = 1 } = {}) {+ const els = items.map(it => {+ const spec = it && it.t !== undefined ? it : { t: it };+ return M(parent, [].concat(spec.t), { size, fill: spec.fill || fill, o });+ });+ return layRow(els, { x, y, size, anchor }, e => put(e, { x: e._px, y }));+}+// Place a row's tokens side by side. Each token keeps its planned centre in _px, so later steps+// can be planned before earlier tweens have run.+function layRow(els, { x, y, size, anchor }, move) {+ const total = els.reduce((a, e) => a + e._w, 0);+ let cx = anchor === 'middle' ? x - total / 2 : anchor === 'end' ? x - total : x;+ for (const e of els) { e._px = cx + e._w / 2; move(e); cx += e._w; }+ return Object.assign(els, { w: total, x, y, size, anchor });+}+// One simplification step: box tokens i..j, shrink them into a single result token, then close the gap.+// Returns the new row. live = true runs on the question clock (inside ask) instead of the lesson clock.+function collapse(row, i, j, parts, t0, { color = COL.task, fill = COL.chalk, live = false } = {}) {+ const run = live ? fx : tw, p = row[0].parentNode, { size, y } = row;+ const left = row[i]._px - row[i]._w / 2, right = row[j]._px + row[j]._w / 2;+ let above = size * .95, height = size * 1.3;+ const tall = row.slice(i, j + 1).filter(e => e._ascent); // TeX tokens may reach higher and lower than text+ if (tall.length) {+ above = Math.max(above, ...tall.map(e => e._ascent + 8));+ height = above + Math.max(size * .35, ...tall.map(e => e._descent + 8));+ }+ const box = put(mk('rect', { rx: 10, fill: 'none', stroke: color, 'stroke-width': 3 }, p),+ { o: 0, a_x: left - 8, a_y: y - above, a_width: right - left + 16, a_height: height });+ run(box, { o: 1 }, t0, .3);+ run(box, { o: 0 }, t0 + 1.2, .3);+ const res = M(p, parts, { size, fill, o: 0, x: (left + right) / 2, y });+ for (let k = i; k <= j; k++) run(row[k], { o: 0, s: .6 }, t0 + .8, .35);+ run(res, { o: 1 }, t0 + .95, .35);+ const next = [...row.slice(0, i), res, ...row.slice(j + 1)];+ return layRow(next, row, e => run(e, { x: e._px }, t0 + 1.3, .5));+}+// The maths helpers (number lines, tiles, fractions, planes, the number map, sorter) are in math.js.+// Inline math for HTML text.+function mathEl(parts, size = 22) {+ const svg = mk('svg', { class: 'm', 'font-weight': 400 }); // widths are measured at normal weight, so a bold prompt must not thicken the math+ const m = M(svg, parts, { size, anchor: 'start', fill: 'currentColor' });+ let top = size * 1.05, bottom = size * .45, h = size * 1.5;+ if (m._ascent) { // a TeX formula may reach higher and lower than text+ top = Math.max(top, m._ascent + size * .1);+ bottom = Math.max(bottom, m._descent + size * .1);+ h = top + bottom;+ }+ svg.setAttribute('viewBox', `0 ${-top} ${m._w + 2} ${h}`);+ svg.setAttribute('width', m._w + 2);+ svg.setAttribute('height', h);+ svg.style.verticalAlign = `${-bottom}px`; // line up the math baseline with the text baseline+ return svg;+}+++/* ---------- timeline ---------- */+let TW = [];+const io = p => p < .5 ? 4 * p * p * p : 1 - (-2 * p + 2) ** 3 / 2;+const out = p => 1 - (1 - p) ** 3;+const back = p => 1 + 2.2 * (p - 1) ** 3 + 1.2 * (p - 1) ** 2;+const lin = p => p;+function tw(e, to, t0, dur = .6, ease = io) { TW.push({ e, to, t0, dur, ease }); }+function prog(pf, t0, dur, ease = io) { TW.push({ pf, t0, dur, ease }); }+const show = (e, t0, dur = .5, ease) => tw(e, { o: 1 }, t0, dur, ease);+const hide = (e, t0, dur = .5, ease) => tw(e, { o: 0 }, t0, dur, ease);+const draw = (e, t0, dur = .9, ease) => tw(e, { d: 1 }, t0, dur, ease);+const pop = (e, t0) => tw(e, { s: 1, o: 1 }, t0, .45, back);+function pulse(e, t0, k = 1.7) { tw(e, { s: k }, t0, .22, out); tw(e, { s: 1 }, t0 + .22, .4); }+function stream(t, str, t0, dur) { prog(q => { t.textContent = str.slice(0, Math.round(q * str.length)); }, t0, dur, lin); }+function mix(a, b, q) {+ const h = c => [1, 3, 5].map(i => parseInt(c.slice(i, i + 2), 16));+ const A = h(a), B = h(b);+ return '#' + A.map((v, i) => Math.round(v + (B[i] - v) * q).toString(16).padStart(2, '0')).join('');+}+// A colour or attribute tween with no starting value in the state starts from the element's attribute.+const fromAttr = (e, k) => k.startsWith('c_') ? e.getAttribute(k.slice(2)) : k.startsWith('a_') ? parseFloat(e.getAttribute(k.slice(2))) : undefined;+function evalTo(t, list = TW) {+ for (const w of list) {+ if (w.done || t < w.t0) continue;+ if (!w.go) { w.go = 1; if (w.e) { const s = st(w.e); w.from = {}; for (const k in w.to) w.from[k] = s[k] ?? fromAttr(w.e, k); } }+ const p = w.dur ? Math.min(1, (t - w.t0) / w.dur) : 1, q = w.ease(p);+ if (w.e) {+ const s = st(w.e);+ for (const k in w.to) s[k] = k.startsWith('c_') ? mix(w.from[k], w.to[k], q) : w.from[k] + (w.to[k] - w.from[k]) * q;+ render(w.e);+ } else w.pf(q);+ if (p >= 1) w.done = 1;+ }+}++/* ---------- world clock and camera ---------- */+const soft = p => (1 - Math.cos(Math.PI * p)) / 2; // gentle in-out, for camera moves+// Continuous motion: f(t) runs on every frame of the beat with t in seconds from its start (0..D).+// Keep f a pure function of t, so pause, seek and ?beat=N&t=S show the same frame. A beat holds its picture for HOLD s+// after its narration and last tween; with { tail: true } f keeps running through that hold (t up to the beat's end)+// instead of freezing at D, for motion that never stops, as in a film. A camera runs through the hold too when anything+// in its beat does (its tail is 'follow'), so a follow shot keeps up with a tailed subject. f also gets the run's end+// (for a tail, the beat's real end), so a move can land on it, as a whip at the end of a beat does. Under music that+// end is where the beat really leaves, up to HOLD early (P.back, see frameStep), so the move is still seen landing.+// A tail's own D does not lengthen the beat: it runs to the end whatever it is (so D + HOLD adds no second hold).+const clockRun = (f, D, { tail = false } = {}) => { const w = { t0: 0, dur: D, ease: lin, tail }; f(0, D); w.pf = q => f(q * w.dur, w.tail ? w.dur - P.back : w.dur); TW.push(w); };+// A camera looks at a world group through the stage (or a box, for split screen and picture-in-picture).+// The view {x, y, z, r} is the world point at the centre, the zoom (screen px per world px) and the roll in degrees.+// Moves are keyed on the beat clock: to(view, t0, dur, ease) blends each given key from its value at t0; a key may be a+// function of t (follow). Unspecified keys keep following the earlier moves. dur 0 is a hard cut.+let camN = 0;+function camera(p, D, { box, x = SW / 2, y = SH / 2, z, r = 0, bg = COL.board } = {}) {+ const [bx, by, bw, bh] = box || [0, 0, SW, SH];+ const el = G(p, { x: bx + bw / 2, y: by + bh / 2 });+ let hold = el;+ if (box) {+ const id = 'cam' + (++camN);+ mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18 }, mk('clipPath', { id }, mk('defs', {}, el)));+ hold = G(el); hold.setAttribute('clip-path', `url(#${id})`);+ mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, fill: bg }, hold);+ }+ const view = mk('g', {}, hold), world = G(view);+ if (box) mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18, fill: 'none', stroke: COL.faint, 'stroke-width': 2 }, el);+ const v0 = { x, y, z: z ?? (box ? Math.min(bw / SW, bh / SH) : 1), r };+ const ops = [], shakes = [], layers = [];+ const val = (v, t) => typeof v === 'function' ? v(t) : v;+ // The view at time t after the first n moves; each move remembers the view it starts from.+ function at(t, n = ops.length) {+ const s = { ...v0 };+ for (let i = 0; i < n && ops[i].t0 <= t; i++) {+ const o = ops[i], a = o.from || (o.from = at(o.t0, i));+ const q = o.dur ? o.ease(Math.min(1, (t - o.t0) / o.dur)) : 1, b = {};+ for (const k in o.v) b[k] = val(o.v[k], t);+ if ('z' in b) s.z = a.z * (b.z / a.z) ** q; // even zoom speed+ // While zooming, x/y move so that one world point stays put on screen (when start and end allow it).+ const u = 'z' in b && Math.abs(b.z - a.z) > 1e-6 * a.z ? (1 / s.z - 1 / a.z) / (1 / b.z - 1 / a.z) : q;+ for (const k of ['x', 'y']) if (k in b) s[k] = a[k] + (b[k] - a[k]) * u;+ if ('r' in b) s.r = a.r + (b.r - a.r) * q;+ }+ return s;+ }+ function apply(t) {+ const s = at(t);+ let sx = 0, sy = 0;+ for (const k of shakes) if (t > k.t0 && t < k.t0 + k.dur) {+ const e = k.amp * Math.min(1, (t - k.t0) / .3, (k.t0 + k.dur - t) / .3), w = 2 * Math.PI * k.hz * t;+ sx += e * (Math.sin(w) + .5 * Math.sin(2.3 * w + 1)) / 1.5; sy += e * (Math.sin(1.7 * w + 2) + .5 * Math.sin(3.1 * w)) / 1.5;+ }+ const tf = `translate(${sx} ${sy}) rotate(${-s.r}) scale(${s.z}) translate(${-s.x} ${-s.y})`;+ if (tf !== view._tf) view.setAttribute('transform', view._tf = tf);+ const dx = s.x - v0.x, dy = s.y - v0.y;+ for (const L of layers) put(L.g, { x: L.wrap ? dx - ((L.k * dx) % L.wrap + L.wrap) % L.wrap : (1 - L.k) * dx, y: (1 - L.k) * dy });+ }+ const cam = { el, world, at,+ to(v, t0, dur = 1, ease = soft) { ops.push({ v, t0, dur, ease }); ops.sort((a, b) => a.t0 - b.t0); ops.forEach(o => delete o.from); return cam; },+ cut: (v, t0) => cam.to(v, t0, 0),+ shake(amp, t0, dur, hz = 7) { shakes.push({ amp, t0, dur, hz }); return cam; },+ // Parallax layer: k < 1 is far (moves slower than the camera), k > 1 near. With wrap = W the layer's content+ // repeats every W world px: draw one period plus the widest view, and the layer never runs out.+ layer(k = 1, wrap) { const g = G(world); layers.push({ g, k, wrap }); return g; },+ // Screen position of a world point at time t (k = 1 layers, no shake): for labels that track an object.+ screen(wx, wy, t) {+ const s = at(t), a = -s.r * Math.PI / 180, ux = (wx - s.x) * s.z, uy = (wy - s.y) * s.z;+ return [bx + bw / 2 + ux * Math.cos(a) - uy * Math.sin(a), by + bh / 2 + ux * Math.sin(a) + uy * Math.cos(a)];+ },+ // Put a screen-space label (text, anchor middle, outside the camera) over world point (wx, wy) at time t, kept+ // inside the frame or box by margin m; it fades out once the point itself leaves. Fade it in with a wrapper group.+ track(el, wx, wy, t, m = 24) {+ const [sx, sy] = cam.screen(wx, wy, t), str = el.textContent;+ if (el._tw?.[0] !== str) el._tw = [str, el.getComputedTextLength() / 2];+ const h = el._tw[1], away = Math.max(bx - sx, sx - bx - bw, 0);+ put(el, { x: Math.min(bx + bw - m - h, Math.max(bx + m + h, sx)), y: sy, o: Math.max(0, 1 - away / 80) });+ },+ };+ clockRun(apply, D, { tail: 'follow' });+ return cam;+}++/* ---------- scene ---------- */+const scene = document.getElementById('scene');+const S = {};+const AXIS = { o: SW / 2, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change it+const X = v => AXIS.o + AXIS.u * v, Y0 = 610;+const num = v => (v < 0 ? '−' : '') + String(Math.abs(v)).replace('.', DECIMAL_SIGN);+function reset() {+ scene.replaceChildren();+ for (const k in S) delete S[k];+ Object.assign(S, { dots: {}, tick: {}, rows: [], chips: [], samples: [], list: G(scene), line: G(scene), venn: G(scene) });+}+function tick(v) {+ const g = G(S.line, { o: 0 });+ path(g, `M${X(v)} ${Y0 - 11}V${Y0 + 11}`, { stroke: COL.dim, 'stroke-width': 2.5 });+ T(g, num(v), { x: X(v), y: Y0 + 50, size: 30, fill: COL.dim, font: MATH, anchor: 'middle' });+ return (S.tick[v] = g);+}+function dot(key, v, r = 9, name = v) {+ const g = G(S.line, { x: X(v), y: Y0, s: 0, o: 0 });+ mk('circle', { r, fill: COL[key], stroke: COL.board, 'stroke-width': 2 }, g);+ return (S.dots[name] = g);+}+const arrow = (x, dir) => `M${x - 15 * dir} ${Y0 - 10}L${x} ${Y0}L${x - 15 * dir} ${Y0 + 10}`;+function panel(t0) {+ if (t0 < .5) S.cleared = true; // the old panel fades, or this is the first panel after the title+ const old = S.panel;+ if (old && t0 < .5) retire(old);+ else if (old) { // a panel change later in the beat stays on the beat clock+ hide(old, t0, .4);+ prog(q => { if (q === 1) old.style.display = 'none'; }, t0 + .4, 0, lin);+ }+ return (S.panel = G(scene));+}+// Take a beat's old picture away on wall time: a 150 ms fade, then out of rendering. On the beat clock the fade would+// wait for the new clip's audio to start (a few hundred ms in Firefox) with the old, frozen scene still showing.+// While seeking, the pictures passed on the way were never seen: they go at once.+// It then leaves the page: a long film otherwise keeps every earlier beat's picture (a documentary's maps: megabytes).+function retire(e) {+ if (seeking) { e.remove(); return; }+ e.style.transition = 'opacity .15s linear';+ e.style.opacity = '0';+ setTimeout(() => e.remove(), 160);+}+function header(p, str, t0, x = 1000, y = 170) {+ const h = T(p, str, { x, y, size: 30, fill: COL.dim, weight: 600, o: 0 });+ show(h, t0);+ return h;+}++/* ---------- question effects: run on wall time, independent of the lesson clock ---------- */+let FX = [], clock = 0;+function fx(e, to, delay = 0, dur = .5, ease = io) { FX.push({ e, to, t0: clock + delay, dur, ease }); }+function fxp(pf, delay, dur, ease = io) { FX.push({ pf, t0: clock + delay, dur, ease }); }+function finishFx() { FX.sort((a, b) => a.t0 - b.t0); evalTo(Infinity, FX); FX = []; }+const pulseFx = (e, k = 1.8) => { if (!e) return; fx(e, { s: k }, 0, .22, out); fx(e, { s: 1 }, .22, .45); };+const shakeFx = e => { if (!e) return; const x0 = st(e).x; fxp(q => put(e, { x: x0 + Math.sin(q * Math.PI * 6) * (1 - q) * 12 }), 0, .55, lin); };+function floatText(str, x, y, colr) {+ const t = T(S.q || qlayer(), str, { x, y: y + 14, size: 24, fill: colr, anchor: 'middle', weight: 600, o: 0 });+ fx(t, { o: 1, y }, 0, .5, out);+}++/* ---------- shared answer columns ---------- */+const TF = [['t', translate('trueLabel'), null, 'T'], ['f', translate('falseLabel'), null, 'F']];+function finishCard() {+ const c = card(SCREEN, 'fin');+ const sum = pre => Object.entries(SCORE).filter(([k]) => k.startsWith(pre)).reduce((a, [, v]) => [a[0] + v.right, a[1] + v.total], [0, 0]);+ const line = (name, [r, t]) => h('p', 'fb', t ? translate('firstTryScore', { name, r, t }) : translate('notAttempted', { name }));+ progress(p => { p.done = [...new Set([...(p.done || []), CHAPTER.number])]; });+ const home = h('a', 'btn quiet', translate('allChapters'));+ home.href = $('bHome').href;+ const again = h('button', 'btn' + (CHAPTER.next ? ' quiet' : ' go'), [translate('watchAgain'), kbd(CHAPTER.next ? 'R' : 'Enter')]);+ again.onclick = restart;+ const next = CHAPTER.next && h('button', 'btn go', [translate('nextChapter'), kbd('Enter')]);+ if (next) next.onclick = () => { location.href = CHAPTER.next; };+ P.keys = e => e.key === 'Enter' ? ((next ? next.onclick() : restart()), true)+ : isShortcut(e, 'r') ? (restart(), true) : false;+ const guide = mascotEl(240);+ c.append(h('div', 'finwrap', [guide, h('p', 'kicker', translate('chapterComplete', { n: CHAPTER.label ?? CHAPTER.number })), h('p', 'prompt', CHAPTER.title),+ line(translate('quickChecks'), sum('c-')), line(translate('chapterPractice'), sum('p-')), h('div', 'acts', next ? [home, again, next] : [home, again]), sources()].filter(Boolean)));+ setTimeout(() => mood(guide, 'happy'), 400);+}++/* ---------- in-picture cards ---------- */+const $ = id => document.getElementById(id);+// The volume control (volume.js, volume.css) lives in its own files next to this one, the same in every book.+document.head.append(Object.assign(document.createElement('script'), { src: new URL('volume.js', document.currentScript.src) }));+const kbd = s => h('kbd', '', s);+// The chapter's sources: every key passed to cite() plus CHAPTER.refs, as full references that link to the source.+function sources() {+ for (const m of citeObs.takeRecords()) for (const n of m.addedNodes) autoCite(n); // link text added just now (a seek to the end)+ const keys = [...new Set([...(CHAPTER.refs || []), ...CITED])].filter(k => typeof REFS === 'object' && REFS?.[k]);+ if (!keys.length) return null;+ const items = keys.map(k => REFS[k]).sort((a, b) => a.ref.localeCompare(b.ref)).map(r => {+ if (!r.url) return h('li', '', r.ref);+ const a = h('a', '', r.url.replace(/^https?:\/\//, ''));+ Object.assign(a, { href: r.url, target: '_blank', rel: 'noopener' });+ return h('li', '', [r.ref + ' ', a]);+ });+ return h('section', 'srcs', [h('h2', '', translate('sources')), h('ol', '', items)]);+}+const uiW = (str, size) => { ctx2d.font = `600 ${size}px ${UI}`; return ctx2d.measureText(str).width; };+const SCORE = {}; // question id -> first-attempt {right, total}++function h(tag, cls, kids = []) {+ const e = document.createElement(tag);+ if (cls) e.className = cls;+ for (const k of [].concat(kids)) e.append(k);+ return e;+}+// Rich text: strings, DOM nodes, or $m(...) inline math.+function rich(parts, size = 28) {+ const s = document.createElement('span');+ for (const p of [].concat(parts)) s.append(typeof p === 'string' || p instanceof Node ? p : mathEl(p.m, size));+ return s;+}+// A card at pos; a band card keeps its bottom on the stage: when its content grows (a long question, feedback),+// it moves up rather than running under the player bar.+function card(pos, cls) {+ const c = h('div', `card ${pos.cls} ${cls}`);+ Object.assign(c.style, { left: pos.x + 'px', top: pos.y + 'px', width: pos.w + 'px' });+ if (pos.maxH) c.style.maxHeight = pos.maxH + 'px';+ $('ui').append(c);+ if (pos.cls === 'band') {+ const fit = () => { c.style.top = Math.max(16, Math.min(pos.y, SH - 16 - c.offsetHeight)) + 'px'; };+ const ro = new ResizeObserver(fit);+ ro.observe(c); fit();+ P.cleanup.push(() => ro.disconnect());+ }+ return c;+}+// The guide: an infinity sign whose two loops are its eyes. Drawn in SVG so it can blink, hop and wobble.+function lemniscate(cx, cy, a, k) {+ let d = '';+ for (let i = 0; i <= 96; i++) {+ const t = i / 96 * 2 * Math.PI, sn = Math.sin(t), q = 1 + sn * sn;+ d += (i ? 'L' : 'M') + (cx + a * Math.cos(t) / q).toFixed(1) + ' ' + (cy + k * a * sn * Math.cos(t) / q).toFixed(1);+ }+ return d + 'Z';+}+function mascotEl(size = 100) {+ const svg = mk('svg', { class: 'mascot', viewBox: '0 0 120 84', width: size, height: size * .7, 'aria-hidden': 'true' });+ const body = mk('g', { class: 'mbody' }, svg);+ const line = { fill: 'none', stroke: COL.chalk, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' };+ mk('path', { d: lemniscate(60, 40, 52, 1.5), ...line, 'stroke-width': 6 }, body);+ const eyes = mk('g', { class: 'eyes' }, body);+ for (const x of [33, 87]) {+ mk('circle', { class: 'pupil', cx: x, cy: 40, r: 6.5, fill: COL.chalk }, eyes);+ mk('path', { class: 'joy', d: `M${x - 7} 43Q${x} 32 ${x + 7} 43`, ...line, 'stroke-width': 4 }, body);+ }+ mk('path', { class: 'smile', d: 'M55 62Q60 67 65 62', ...line, 'stroke-width': 3.5 }, body);+ mk('path', { class: 'flat', d: 'M55 64H65', ...line, 'stroke-width': 3.5 }, body);+ return svg;+}+function mood(el, m) {+ el.classList.remove('happy', 'oops');+ void el.getBoundingClientRect(); // restart the CSS animation+ if (m) el.classList.add(m);+}+// A sequence of questions in one card. Each question: { id, prompt, build(body, api) -> { check?, reveal, lock? } }.+function quiz(pos, qs, done, label = translate('quickCheck')) {+ const c = card(pos, 'quiz');+ let k = 0;+ const show = () => {+ const q = qs[k];+ let first = true, resolved = false;+ const fb = h('div', 'fb'), body = h('div', 'body'), acts = h('div', 'acts');+ fb.setAttribute('role', 'status'); // screen readers announce right or wrong+ const bCheck = h('button', 'btn', [translate('check'), kbd('Enter')]), bShow = h('button', 'btn quiet', [translate('showAnswer'), kbd('S')]);+ const bNext = h('button', 'btn go', [k < qs.length - 1 ? translate('nextQuestion') : translate('continue'), kbd('Enter')]);+ bShow.hidden = bNext.hidden = true;+ const guide = pos.cls === 'band' || pos.cls === 'side' ? mascotEl(pos.cls === 'band' ? 108 : 70) : null;+ const say = (cls, parts) => { fb.className = 'fb ' + cls; fb.replaceChildren(rich(parts, 24)); fb.style.animation = 'none'; void fb.offsetWidth; fb.style.animation = ''; };+ const resolve = () => {+ resolved = true;+ bCheck.hidden = bShow.hidden = true;+ ctl.lock?.();+ bNext.hidden = false;+ bNext.focus({ preventScroll: true });+ };+ const api = {+ grade(ok, msg, score) {+ if (resolved) return;+ if (first) { if (!Object.hasOwn(SCORE, q.id)) SCORE[q.id] = score || { right: +ok, total: 1 }; first = false; }+ say(ok ? 'ok' : 'no', [ok ? translate('correct') : translate('notQuite'), ...[].concat(msg || [])]);+ if (guide) {+ mood(guide, ok ? 'happy' : 'oops');+ if (!ok) setTimeout(() => { if (guide.classList.contains('oops')) mood(guide, null); }, 1600);+ }+ if (ok) resolve(); else bShow.hidden = false;+ },+ };+ const ctl = q.build(body, api);+ if (ctl.check) { bCheck.onclick = () => ctl.check(); acts.append(bCheck); }+ acts.append(bShow, bNext);+ bShow.onclick = () => { say('', [translate('answerPrefix'), ...[].concat(ctl.reveal())]); resolve(); };+ bNext.onclick = () => { if (k < qs.length - 1) { k++; show(); } else done(); };+ P.keys = e => {+ if (e.key === 'Enter' && resolved) { bNext.click(); return true; }+ if (!resolved && ctl.key?.(e)) return true;+ if (e.key === 'Enter' && !resolved && ctl.check) { bCheck.click(); return true; }+ if (isShortcut(e, 's') && !bShow.hidden) { bShow.click(); return true; }+ return false;+ };+ const kick = label + (qs.length > 1 ? ' · ' + translate('countOf', { k: k + 1, n: qs.length }) : '');+ const head = h('div', 'head', [h('p', 'kicker', kick), h('p', 'prompt', [rich(q.prompt, pos.cls.startsWith('screen') ? 38 : 28)])]); // match the prompt's type size+ if (ctl.hint) head.append(h('p', 'keys', [translate('keysPrefix'), ...ctl.hint]));+ c.replaceChildren(...(guide ? [guide] : []), head, fb, body, acts);+ };+ show();+}+function qlayer() {+ S.q?.remove();+ S.q = G(scene);+ S.q.classList.add('qlayer');+ return S.q;+}+const keyAct = (el, fn) => el.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); fn(); } });++/* ---------- question builders ---------- */+// Single answer from buttons; each wrong option has its own explanation.+const choice = (opts, right, yes, no, onRight) => (body, api) => {+ const row = h('div', 'opts');+ const bs = opts.map((o, i) => {+ const b = h('button', 'opt', [kbd(String(i + 1)), rich(o, 32)]);+ b.onclick = () => {+ if (i === right) { b.classList.add('good'); onRight?.(); api.grade(true, yes); }+ else { b.classList.add('bad'); b.disabled = true; api.grade(false, no[i]); }+ };+ row.append(b);+ return b;+ });+ body.append(row);+ return {+ reveal() { bs[right].classList.add('good'); onRight?.(); return yes; },+ lock() { bs.forEach(b => { b.disabled = true; }); },+ key(e) { const b = bs[+e.key - 1]; if (!b || b.disabled) return false; b.click(); return true; },+ };+};+// A choice question from the chapter's item bank: ITEMS from ./items.js, built by scripts/items.py from the+// mcq-item-writer JSON. mcq('ID', onRight?) returns a quiz entry, so quiz(TOPR, [mcq('MB-03-01')], done) asks it.+function mcq(id, onRight) {+ const it = (typeof ITEMS === 'object' && ITEMS) ? ITEMS[id] : null;+ if (!it) throw new Error(`mcq: no item "${id}" in items.js`);+ return { id, prompt: it.prompt, build: choice(it.opts, it.right, it.why, it.no, onRight) };+}+// Stage targets the reader taps: each g turns into a focusable button named by its label that acts on a click, Enter or+// Space. Returns key(e) for P.keys: ← / → move the focus between them (from the one focused, if any).+function tappable(items) { // [{ g, label, act }]+ for (const { g, label, act } of items) {+ g.classList.add('hit');+ g.setAttribute('tabindex', 0);+ g.setAttribute('role', 'button');+ g.setAttribute('aria-label', label);+ g.addEventListener('click', act);+ keyAct(g, act);+ }+ let cur = -1;+ return e => {+ const d = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0;+ if (!d || !items.length) return false;+ const on = items.findIndex(it => it.g === document.activeElement);+ if (on >= 0) cur = on;+ cur = cur < 0 ? (d > 0 ? 0 : items.length - 1) : (cur + d + items.length) % items.length;+ items[cur].g.focus();+ return true;+ };+}+// The shared body of the stage tap questions: each target ring answers on click or Enter (tappable), wrong() shakes+// and returns the explanation. targets: [{ g, label, ok, wrong }].+const stageTap = (api, targets, show, yes, onRight, hint) => {+ let locked = false;+ const move = tappable(targets.map(({ g, label, ok, wrong }) => ({ g, label, act: () => {+ if (locked) return;+ if (ok) { g.classList.add('good'); onRight?.(); api.grade(true, yes); }+ else { g.classList.add('bad'); api.grade(false, wrong()); }+ } })));+ return {+ reveal() { targets[show].g.classList.add('good'); onRight?.(); return yes; },+ lock() { locked = true; },+ hint,+ key: e => !locked && move(e),+ };+};+// Tap a point on the stage number line.+const tap = (values, right, yes, no, onRight) => (body, api) => {+ const L = qlayer();+ const targets = values.map(v => {+ const g = G(L, { x: X(v), y: Y0 });+ mk('circle', { r: 30, class: 'ring' }, g);+ return { g, label: translate('pointLabel', { v: num(v) }), ok: v === right, wrong: () => { shakeFx(S.dots[v]); return no(v); } };+ });+ return stageTap(api, targets, values.lastIndexOf(right), yes, onRight,+ [kbd('←'), kbd('→'), translate('hintMoveAlongLine'), kbd('Enter'), translate('hintChoose')]);+};+// Tap one token of a stage token row, e.g. the operation to do first. idx: tappable token indexes.+const tapEls = (row, idx, right, yes, no, onRight) => (body, api) => {+ const L = qlayer();+ const targets = idx.map(i => {+ const e = row[i], w = e._w + 18, g = G(L, { x: e._px, y: row.y });+ mk('rect', { class: 'ring', x: -w / 2, y: -row.size * .95, width: w, height: row.size * 1.3, rx: 12 }, g);+ return { g, label: e.textContent.trim(), ok: i === right, wrong: () => { shakeFx(e); return no(i); } };+ });+ return stageTap(api, targets, idx.indexOf(right), yes, onRight,+ [kbd('←'), kbd('→'), translate('hintMove'), kbd('Enter'), translate('hintChoose')]);+};+// Click one of several stage objects (table cells, bars, small graphs). items: [{ el, box: [x, y, w, h], label }].+const pickEls = (items, right, yes, no, onRight) => (body, api) => {+ const L = qlayer();+ const targets = items.map((it, i) => {+ const [x, y, w, hh] = it.box, g = G(L);+ mk('rect', { class: 'ring', x, y, width: w, height: hh, rx: 12 }, g);+ return { g, label: it.label, ok: i === right, wrong: () => { shakeFx(it.el); return no(i); } };+ });+ return stageTap(api, targets, right, yes, onRight,+ [kbd('←'), kbd('→'), translate('hintMove'), kbd('Enter'), translate('hintChooseOrClick')]);+};+/* ---------- point and read ---------- */+// A picture book's point-and-read moment, for young children learning words: a film's ask beat (CHAPTER.film),+// ask: done => tapWords(THINGS, done) THINGS = [{ g, word: 'basket', clip: 'w-basket', side: 'below' }]+// which the scene fills as it builds the picture; g is what the reader taps (a puppet, a prop, or a transparent shape+// over part of a baked set), clip names audio/<lang>/<clip>.mp3, 'w-' + the word by default, and side puts the word+// 'above', 'below', 'left' or 'right' of its thing (kept on the stage); without it the word goes above, or wherever fits. Once the narration is+// over (P.waiting) every thing turns tappable: a tap hops it, shows its word in large letters beside it and says it, on+// wall time at the player volume with the music ducked under it; tapping again says it again. A counter and Continue+// (Enter) wait in the corner; Continue lights up once every thing has been heard. Seeking or replaying clears it all.+// While the page waits, the scene's continuous motion (stopClock, clockRun with tail: true) runs on past the beat's+// end on wall time, so puppets posed as a function of time keep breathing and blinking.+// The video (export.py) cannot tap: P.tapDemo.at(s) shows the words one by one, DEMO_STEP s apart, while it holds.+const TAP_MIN = 120, DEMO_STEP = 2; // TAP_MIN: the smallest hit box in stage px, a child's finger on a phone+const SIDES = { above: 0, below: 1, right: 2, left: 3 }; // where a word goes, in the order tried+const wordClip = word => 'w-' + word.toLowerCase().trim().replace(/[^\p{L}\p{N}]+/gu, '-').replace(/^-+|-+$/g, '');+function tapWords(things, done) {+ const gen = P.gen, stage = $('stage'), lang = CHAPTER.language || 'en';+ if (!CHAPTER.film) console.warn('tapWords: CHAPTER.film is not true, so the chapter plays as a lesson: no music or effects');+ const list = things.filter(t => {+ const why = !t.word ? 'has no word' : !(t.g instanceof SVGGraphicsElement && stage.contains(t.g)) ? 'is not an element on the stage' : '';+ if (why) console.warn(`tapWords: ${t.word ? `"${t.word}"` : 'a thing'} ${why}: left out`);+ return !why;+ }).map(t => {+ const clip = t.clip || wordClip(t.word), a = new Audio(`audio/${lang}/${clip}.mp3`);+ a.preload = 'auto';+ a.onerror = () => console.warn(`tapWords: "${t.word}" has no clip at audio/${lang}/${clip}.mp3`);+ if (t.side && !Object.hasOwn(SIDES, t.side)) console.warn(`tapWords: "${t.word}" has side "${t.side}": use above, below, left or right; its word goes where it fits`);+ return { g: t.g, word: t.word, clip, a, side: Object.hasOwn(SIDES, t.side ?? '') ? t.side : null, heard: false };+ });+ const L = mk('g', { class: 'tapw' }, stage); // the hit boxes, over the whole picture+ let on = false, alive = true, finished = false, word = null, shown = -1, bar, count, go;+ // a thing's box in stage px (its picture may move: puppets idle), and its hit box, at least TAP_MIN square+ const box = t => {+ const s = stage.getBoundingClientRect(), r = t.g.getBoundingClientRect(), kx = SW / s.width, ky = SH / s.height;+ return { x: (r.left - s.left) * kx, y: (r.top - s.top) * ky, w: r.width * kx, h: r.height * ky };+ };+ const place = () => {+ for (const t of list) {+ const b = box(t), w = Math.max(TAP_MIN, b.w), hh = Math.max(TAP_MIN, b.h);+ for (const [k, v] of Object.entries({ x: b.x + (b.w - w) / 2, y: b.y + (b.h - hh) / 2, width: w, height: hh })) t.ring.setAttribute(k, v.toFixed(1));+ }+ };+ const finish = () => { if (finished || P.gen !== gen) return; finished = true; done(); };+ const idle = s => { for (const w of TW) if (w.tail === true && w.dur) w.pf(1 + s / w.dur); }; // s seconds past the end+ let since = 0;+ const tapIt = (k, quiet) => {+ const t = list[k];+ shown = k;+ t.heard = true;+ const n = list.filter(x => x.heard).length, all = n === list.length;+ count.textContent = all ? translate('allWordsHeard') : translate('wordsHeard', { k: n, n: list.length });+ if (all && !go.classList.contains('go')) { go.className = 'btn go'; bar.classList.add('lit'); }+ // the word beside the thing: on its side, or above it, else below, right or left, wherever it fits on the stage+ // (slid along that side to stay on it)+ word?.remove();+ word = h('div', 'card word', t.word);+ word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word+ $('ui').append(word);+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];+ const [x, y] = t.side ? spots[SIDES[t.side]] : spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];+ Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });+ if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest+ for (const x of list) if (x !== t) x.a.pause();+ t.a.currentTime = 0;+ t.a.volume = +($('volume')?.value ?? 1);+ t.a.play().catch(() => {});+ SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)+ t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });+ t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });+ };+ const enable = () => {+ on = true;+ since = performance.now();+ linkStage(); // the stage is no longer one picture to a screen reader: the things are its buttons+ const at = new Map(list.map(t => [t, box(t)]));+ for (const [t, b] of at) if (b.x + b.w <= 0 || b.x >= SW || b.y + b.h <= 0 || b.y >= SH || !b.w || !b.h) console.warn(`tapWords: "${t.word}" is not in the picture`);+ // smaller boxes on top, so a thing standing in front of a bigger one can still be tapped+ for (const t of [...list].sort((a, c) => at.get(c).w * at.get(c).h - at.get(a).w * at.get(a).h)) { t.hit = G(L); t.ring = mk('rect', { class: 'ring', rx: 22 }, t.hit); }+ place();+ // the arrows go through the things from left to right+ const order = [...list].sort((a, c) => at.get(a).x + at.get(a).w / 2 - at.get(c).x - at.get(c).w / 2);+ const move = tappable(order.map(t => ({ g: t.hit, label: t.word, act: () => { if (alive) tapIt(list.indexOf(t)); } })));+ P.keys = e => e.key === 'Enter' ? (finish(), true) : move(e);+ bar = card({ x: 0, y: SH - 130, w: 0, cls: 'side' }, 'words');+ Object.assign(bar.style, { left: 'auto', right: '40px', width: 'auto' });+ count = h('span', 'count', translate('wordsHeard', { k: 0, n: list.length }));+ count.setAttribute('role', 'status');+ go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);+ go.onclick = finish;+ bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);+ };+ const cleanup = () => {+ alive = false;+ L.remove();+ for (const t of list) { t.a.onerror = null; t.a.pause(); t.a.removeAttribute('src'); t.a.load(); if (SND.word === t.a) SND.word = null; }+ if (P.tapDemo?.gen === gen) delete P.tapDemo;+ };+ P.cleanup.push(cleanup);+ P.tapDemo = { gen, clips: list.map(t => t.clip), step: DEMO_STEP, at(s) { if (!on) enable(); idle(s); const k = Math.min(list.length - 1, Math.floor(s / DEMO_STEP)); if (k >= 0 && k !== shown) { list.slice(0, k).forEach(t => { t.heard = true; }); tapIt(k, true); } } };+ const tick = () => {+ if (!alive) return;+ if (P.gen !== gen) { cleanup(); return; } // a seek away, or the beat replayed+ if (P.waiting && !on) enable();+ if (on && P.waiting) idle((performance.now() - since) / 1000);+ if (on) place();+ requestAnimationFrame(tick);+ };+ requestAnimationFrame(tick);+}+// Rows of toggles. items: { parts, ans: [keys], why }. parts are math parts (strings, F, R) unless text: true,+// where they are rich text (strings and $m(...)). cols: [[key, label, colour?, shortcut?]]. multi: several per row.+const grid = (items, cols, { multi = true, text = false } = {}) => (body, api) => {+ const wrap = h('div', 'grid' + (text ? ' text' : ''));+ const hot = cols.map((c, j) => c[3] || String(j + 1));+ let cur = 0, locked = false;+ const rows = items.map((it, ri) => {+ const opts = h('div', 'opts'), mark = h('div', 'mark'), why = h('div', 'why');+ const bs = cols.map(([key, lab, colr], j) => {+ const b = h('button', 'opt', [kbd(hot[j]), lab]);+ if (colr) b.style.setProperty('--c', colr);+ b.setAttribute('aria-pressed', 'false');+ b.onclick = () => {+ const on = b.getAttribute('aria-pressed') !== 'true';+ if (!multi) bs.forEach(x => x.setAttribute('aria-pressed', 'false'));+ b.setAttribute('aria-pressed', String(on));+ };+ opts.append(b);+ return b;+ });+ const el = h('div', 'row', [h('div', 'num', [text ? rich(it.parts, 26) : mathEl(it.parts, 32)]), opts, mark, why]);+ el.addEventListener('click', () => { cur = ri; showCur(); });+ wrap.append(el);+ const picked = () => cols.filter((c, i) => bs[i].getAttribute('aria-pressed') === 'true').map(c => c[0]);+ return { it, bs, mark, why, picked, el, played: false };+ });+ const single = rows.length === 1;+ const showCur = () => rows.forEach((r, i) => {+ const on = !single && !locked && i === cur;+ r.el.classList.toggle('cur', on);+ if (on && r.el.isConnected) r.el.scrollIntoView({ block: 'nearest' }); // a long practice list scrolls+ });+ showCur();+ body.append(wrap);+ const judge = r => {+ const p = r.picked(), ok = p.length === r.it.ans.length && r.it.ans.every(k => p.includes(k));+ r.mark.className = 'mark ' + (ok ? 'good' : 'bad');+ r.mark.textContent = ok ? '✓' : '✗';+ r.why.replaceChildren(ok || single ? '' : rich(r.it.why, 20));+ if (ok && !r.played) { r.played = true; r.it.fx?.(); }+ return ok;+ };+ return {+ check() {+ const right = rows.filter(judge).length;+ const all = right === rows.length;+ api.grade(all, single ? rows[0].it.why : all ? [] : [translate('rowsRight', { r: right, n: rows.length })], { right, total: rows.length });+ },+ reveal() {+ for (const r of rows) {+ r.bs.forEach((b, i) => b.setAttribute('aria-pressed', String(r.it.ans.includes(cols[i][0]))));+ judge(r);+ if (!single) r.why.replaceChildren(rich(r.it.why, 20));+ }+ return single ? rows[0].it.why : translate('choicesShown');+ },+ lock() { locked = true; showCur(); rows.forEach(r => r.bs.forEach(b => { b.disabled = true; })); },+ hint: [...(single ? [] : [kbd('↑'), kbd('↓'), translate('hintRow')]), ...(/\d/.test(hot[0]) ? [kbd(hot[0]), '–', kbd(hot[hot.length - 1])] : hot.map(kbd)), translate('hintChoose')],+ key(e) {+ if (locked) return false;+ if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && !single) {+ cur = (cur + (e.key === 'ArrowDown' ? 1 : -1) + rows.length) % rows.length;+ showCur();+ return true;+ }+ const j = hot.findIndex(x => isShortcut(e, x));+ if (j < 0) return false;+ rows[cur].bs[j].click();+ if (!multi && cur < rows.length - 1) { cur++; showCur(); }+ return true;+ },+ };+};+// Exact value of a typed answer: integer, decimal, fraction a/b or mixed number "w a/b"; returns [num, den] or null.+// Accepts −, – or - as the sign, a currency sign before or after ($5, -$5, 5 €), thousands grouped by spaces (any kind)+// or, where the decimal sign is a point, by commas, and a decimal comma when DECIMAL_SIGN is ','. Never evaluates the text as code.+function rat(str) {+ let t = String(str).trim().replace(/^[−–]/, '-').replace(/\s+/g, ' ').replace(/^(-?) ?\p{Sc} ?|(?<=\d) ?\p{Sc}$/gu, '$1');+ const group = DECIMAL_SIGN === ',' ? ' ' : '[, ]'; // one kind of separator throughout: 1,000 000 is not a number+ t = t.replace(new RegExp(`^(-?\\d{1,3})(${group})(\\d{3}(?:\\2\\d{3})*)(?=$|[.,])`), (_, head, sep, rest) => head + rest.split(sep).join(''));+ if (DECIMAL_SIGN === ',') t = t.replace(/^(-?\d+),(\d+)$/, '$1.$2'); // 0,75 where the decimal sign is a comma+ let m = t.match(/^(-?)(\d+)(?:\.(\d+))?$/);+ if (m) { const d = 10 ** (m[3] || '').length, n = (m[1] ? -1 : 1) * (Number(m[2]) * d + Number(m[3] || 0)); return Number.isSafeInteger(n) && Number.isSafeInteger(d) ? [n, d] : null; }+ m = t.match(/^(-?)(?:(\d+) )?(\d+) ?\/ ?(\d+)$/);+ if (m && Number(m[4]) > 0) { const d = Number(m[4]), n = (m[1] ? -1 : 1) * (Number(m[2] || 0) * d + Number(m[3])); return Number.isSafeInteger(n) && Number.isSafeInteger(d) ? [n, d] : null; }+ return null;+}+const gcd = (a, b) => { a = Math.abs(a); b = Math.abs(b); while (b) [a, b] = [b, a % b]; return a; };+const lowest = ([n, d]) => gcd(n, d) === 1;+// Fill-in boxes inside math. rows: [{ parts: [math parts and { box: '21' }], why, hint?, fx? }].+// test(values), when given, judges the whole row from the typed numbers (e.g. a factor pair in either order); the boxes' answers are still what Show answer fills in.+// Answers are exact numbers: "−5", "-5", "0.5", "3/4" and "2 1/4" all work, and equal values match ("6/8" = "3/4")+// unless the box has lowest: true. hint is shown after a wrong try, why after a right one.+const blanks = rowsIn => (body, api) => {+ const all = [];+ const rows = rowsIn.map(it => {+ const line = h('div', 'bline'), mark = h('span', 'mark'), why = h('div', 'why');+ let run = [];+ const flush = () => { if (run.length) line.append(mathEl(run, 34)); run = []; };+ const boxes = [];+ for (const p of it.parts) {+ if (p && p.box !== undefined) {+ flush();+ const b = h('input', 'box');+ Object.assign(b, { type: 'text', inputMode: 'decimal', autocomplete: 'off', spellcheck: false });+ b.setAttribute('aria-label', translate('answerBox'));+ b.dataset.ans = p.box;+ if (p.lowest) b.dataset.lowest = '1';+ b.style.width = `${Math.max(2, String(p.box).length) + 2}ch`;+ line.append(b);+ boxes.push(b);+ all.push(b);+ } else run.push(p);+ }+ flush();+ line.append(mark);+ body.append(h('div', 'brow', [line, why]));+ return { it, boxes, mark, why, played: false };+ });+ body.classList.add('blanks');+ const single = rows.length === 1;+ const judge = r => {+ let ok = true;+ if (r.it.test) { // the row is judged as a whole, e.g. two factors in either order+ const vals = r.boxes.map(b => rat(b.value));+ ok = vals.every(Boolean) && !!r.it.test(vals.map(([n, d]) => n / d));+ r.boxes.forEach(b => { b.classList.toggle('good', ok); b.classList.toggle('bad', !ok); });+ } else for (const b of r.boxes) {+ const want = rat(b.dataset.ans), got = rat(b.value);+ const good = !!got && !!want && BigInt(got[0]) * BigInt(want[1]) === BigInt(want[0]) * BigInt(got[1]) && (!b.dataset.lowest || lowest(got));+ b.classList.toggle('good', good);+ b.classList.toggle('bad', !good);+ ok = ok && good;+ }+ r.mark.className = 'mark ' + (ok ? 'good' : 'bad');+ r.mark.textContent = ok ? '✓' : '✗';+ r.why.replaceChildren(ok || single ? '' : rich(r.it.hint ?? r.it.why, 20));+ if (ok && !r.played) { r.played = true; r.it.fx?.(); }+ return ok;+ };+ // not on the frame ?beat=N opens before the lesson has started: there Space starts it rather than typing a space+ requestAnimationFrame(() => { if (P.started) all[0]?.focus({ preventScroll: true }); });+ return {+ check() {+ const right = rows.filter(judge).length, done = right === rows.length;+ const msg = single ? (done ? rows[0].it.why : rows[0].it.hint ?? rows[0].it.why)+ : done ? [] : [translate('rowsRight', { r: right, n: rows.length })];+ api.grade(done, msg, { right, total: rows.length });+ },+ reveal() {+ for (const r of rows) {+ r.boxes.forEach(b => { b.value = b.dataset.ans.replace('-', '−'); }); // shown exactly as authored+ judge(r);+ if (!single) r.why.replaceChildren(rich(r.it.why, 20));+ }+ return single ? rows[0].it.why : translate('numbersShown');+ },+ lock() { all.forEach(b => { b.disabled = true; }); },+ hint: [translate(all.some(b => b.dataset.ans.includes('/')) ? 'hintTypeFraction' : all.some(b => /[.,]/.test(b.dataset.ans)) ? 'hintTypeDecimal' : 'hintTypeNumber'),+ kbd('Tab'), translate('hintNextBox'), kbd('Enter'), translate('hintCheck'), kbd('Esc'), translate('hintLeaveBox')],+ };+};++/* ---------- sound effects and music ----------+ sfx(beat, at, name, vol, bed): play audio/sfx/<name>.mp3 when the clock of beat `beat` passes `at` in normal playback+ (a seek past it fires nothing), at half volume (vol 2 is full). A long ambience is listed in SFX_BED with its length+ (SFX_BED.birds = 10): a seek into it joins it part-way. A beat function runs again at every seek; an effect is listed once.+ An effect still loading when it is due plays late, joined part-way, for up to a second (or its bed).+ music(file, beats, gain, fade): a looping track under the listed beats (all of them by default). Its place is the+ length of its earlier beats plus the clock. It ducks to 30 % under the whole beat, or 70 % in the music-only lead-in+ (`pre`) of the beats in window.MUSIC_UP_IN_PRE (true: every beat). It crossfades over `fade` s (0: a cut), and+ window.MUSIC_OFF = { beat: t => true } fades it out for a moment.+ export.py reads SFX, BGM and these settings, and mixes the film by the same rules.+ Films only (a chapter without questions): effects and music go through one Web Audio graph, so ducks, fades and the+ volume slider reach them on phones too (iOS ignores an element's .volume). A pause holds them; a seek stops the effects.+ When a clip loading or buffering holds the film's clock, the music runs on and then eases back (5 % slower or faster),+ or jumps back once if it is more than a second out. */+const SND = { sfx: [], bed: {}, bgm: [], len: [], on: [], wait: [], buf: {}, ctx: null, out: null, last: { i: -1, t: 0 }, duck: .3 };+const everyBeat = () => { try { return BEATS.map(b => b.id); } catch { return undefined; } }; // undefined until BEATS is defined+// window properties, not declarations: a book with its own older sfx() or BGM declares them over these+Object.assign(window, { SFX: SND.sfx, SFX_BED: SND.bed, BGM: SND.bgm,+ sfx(beat, at, name, vol = 1, bed = SND.bed[name] || 0) {+ const e = SND.sfx.find(x => x.beat === beat && x.at === at && x.name === name);+ if (e) Object.assign(e, { vol, bed }); else SND.sfx.push({ beat, at, name, vol, bed });+ sfxLoad(name);+ },+ // without beats, every beat: boot() fills them in when music() comes before BEATS+ music(file, beats = everyBeat(), gain = 1, fade = .8) {+ const m = { n: file, beats, gain, fade, v: 0, a: Object.assign(new Audio(file), { preload: 'auto', loop: true, volume: 0 }) };+ SND.bgm.push(m);+ if (SND.ctx) bgmWire(m);+ },+});+// An effect is fetched and decoded at once, before the first click builds the sound graph: decoding needs no running+// context (an AudioBuffer plays in any), so an effect due in the first second after Play, or after an early seek, is+// ready instead of dropped on a slow line.+let DECODER = null;+function sfxLoad(name) {+ const s = SND.buf[name] ??= { data: fetch(`audio/sfx/${name}.mp3`).then(r => r.ok ? r.arrayBuffer() : null).catch(() => null) };+ const ctx = SND.ctx || (window.OfflineAudioContext && (DECODER ??= new OfflineAudioContext(2, 1, 44100)));+ if (ctx && !s.decoded) s.decoded = s.data.then(d => d && ctx.decodeAudioData(d)).then(b => { s.b = b; }, () => {});+}+function sfxPlay(e, late) {+ const ctx = SND.ctx, src = ctx.createBufferSource(), g = ctx.createGain();+ src.buffer = SND.buf[e.name].b; src._sfx = e.name; g.gain.value = src._vol = .5 * e.vol;+ src.playbackRate.value = P.rate;+ src.connect(g).connect(SND.out);+ src.start(0, late && !e.bed ? 0 : Math.max(0, P.t - e.at)); // a late one-shot starts from its attack+ SND.on.push(src);+ src.onended = () => { const k = SND.on.indexOf(src); if (k >= 0) SND.on.splice(k, 1); };+}+function bgmWire(m) {+ m.g = SND.ctx.createGain();+ SND.ctx.createMediaElementSource(m.a).connect(m.g).connect(SND.out);+ m.a.volume = 1;+}+// A browser starts sound only after a click or a key: the first one builds the graph (films only) and readies the music.+function soundUnlock() {+ if (typeof BEATS === 'undefined') return; // the chapter's script has not run yet+ if (!SND.ctx && window.AudioContext && (!BEATS.some(b => b.ask) || CHAPTER.film)) { // a film with a question (CHAPTER.film) keeps its sound+ if (navigator.audioSession) navigator.audioSession.type = 'playback'; // iOS: the silent switch must not mute the film+ SND.ctx = new AudioContext();+ SND.out = SND.ctx.createGain();+ SND.out.connect(SND.ctx.destination);+ for (const n in SND.buf) sfxLoad(n);+ for (const m of SND.bgm) bgmWire(m);+ }+ if (SND.ctx && SND.ctx.state !== 'running' && SND.ctx.state !== 'closed') SND.ctx.resume().catch(() => {}); // also iOS 'interrupted'+ for (const m of SND.bgm) if (!m.blessed) { // iOS lets an element play later only if it once played inside a click+ m.blessed = true; m.a.muted = true;+ m.a.play().then(() => { if (!m.cur) m.a.pause(); m.a.muted = false; }, () => { m.a.muted = false; m.blessed = false; });+ }+}+// a touch activates the page on touchend or click, not on pointerdown+for (const type of ['pointerdown', 'touchend', 'click', 'keydown']) addEventListener(type, soundUnlock, true);+// Safari (and every iOS browser) stops a media element for .3-.6 s at each playbackRate change, so easing the music+// back would only push it further out: there it keeps the film's rate and seeks instead.+const RATE_STALLS = /AppleWebKit/.test(navigator.userAgent) && !/Chrome\/|Android/.test(navigator.userAgent);+function soundTick(dt) {+ const id = BEATS[P.i]?.id, pre = BEATS[P.i]?.pre || 0, on = P.started && P.playing && !P.waiting && !P.done, L = SND.last;+ // a film waiting for the reader (CHAPTER.film, a question beat after its narration): the music plays on, louder+ const wait = P.started && P.playing && P.waiting && !P.done && !!CHAPTER.film;+ const held = P.started && !P.playing && !P.done, ctx = SND.ctx;+ if (ctx?.state === 'running' && held) ctx.suspend();+ else if (ctx && ctx.state !== 'running' && ctx.state !== 'closed' && !held) ctx.resume().catch(() => {});+ // the clock ran on (or stood still, paused) in the same beat; anything else is a seek, a replay or the next beat+ const same = L.i === P.i && P.t >= L.t && P.t - Math.max(0, L.t) < Math.max(.5, dt * P.rate + .25);+ if (!same) { while (SND.on.length) SND.on.pop().stop(); SND.wait = []; }+ // a beat that has just begun fires its effects from 0 on; a seek fires nothing it skipped, but joins a bed+ const from = same ? L.t : P.t < .25 ? -1 : P.t, seeked = !same || L.pend;+ if (on && ctx) {+ for (const e of SND.sfx) {+ if (e.beat !== id || !(e.at > from && e.at <= P.t || seeked && e.bed && e.at < P.t && P.t < e.at + e.bed)) continue;+ if (SND.buf[e.name]?.b) sfxPlay(e); else SND.wait.push(e);+ }+ SND.wait = SND.wait.filter(e => P.t - e.at < (e.bed || 1) && !(SND.buf[e.name]?.b && (sfxPlay(e, true), true)));+ for (const s of SND.on) if (s.playbackRate.value !== P.rate) s.playbackRate.value = P.rate;+ }+ SND.last = { i: P.i, t: on ? P.t : from, pend: !on && (!same || !!L.pend) };+ const vol = +($('volume')?.value ?? 1), up = window.MUSIC_UP_IN_PRE;+ if (SND.out) SND.out.gain.value = vol;+ if (!SND.bgm.length || BEATS.some(b => b.ask) && !CHAPTER.film) return; // a lesson with questions plays no music+ // the film's clock moved this frame (a clip loading or buffering holds it), or jumped (a seek, a replay)+ const runs = on && same && P.t > L.t, jump = !same && !(L.i === P.i - 1 && P.t < .5);+ // a word the reader tapped (tapWords) ducks the music at once, as the narration does+ const saying = !!SND.word && !SND.word.paused && !SND.word.ended;+ if (!held) SND.duck += Math.max(-dt * (saying ? 4 : 1), Math.min(dt, (wait && !saying || P.t < pre && (up === true || up?.includes?.(id)) ? .7 : .3) - SND.duck));+ for (const m of SND.bgm) {+ const k = m.beats.indexOf(id), current = (on || wait) && k >= 0 && !window.MUSIC_OFF?.[id]?.(P.t);+ if (jump) m.off = 0; // a seek or a replay puts every track back where the film's own timing says+ if (wait && current) m.off = (m.off || 0) + dt * P.rate; // the time it ran on while the reader decided+ m.cur = current;+ if (!held) m.v = m.fade > 0 ? Math.max(0, Math.min(1, m.v + (current ? 1 : -1) * dt / m.fade)) : +current;+ const g = m.v * m.gain * SND.duck;+ if (m.g) m.g.gain.value = g; else m.a.volume = Math.min(1, g * vol);+ if (current) {+ // where the film is: the beats before this one in the track as they really ran (P.end), plus now+ const dur = m.a.duration || Infinity;+ const want = (m.beats.slice(0, k).reduce((s, b) => s + (SND.len[BEATS.findIndex(x => x.id === b)] || 0), 0) + P.t + (m.off || 0)) % dur;+ let d = m.a.currentTime - want;+ if (d > dur / 2) d -= dur; else if (d < -dur / 2) d += dur;+ // a start, a jump, or more than a second out once the clock runs again: seek. Less: ease back while the clock runs,+ // from .25 s out until .05 s+ const ok = runs && !m.a.seeking;+ // (once more after a jump: the element plays on while it seeks)+ // Where a rate change stalls, starting and seeking stall too: once a second the music's lag is learnt (m.lead),+ // seeks aim that far ahead, and a quarter second out is then worth a seek.+ let far = m.settle ? .25 : 1;+ m.sought ??= clock;+ if (RATE_STALLS && ok && clock - m.sought > 1) {+ m.sought = clock; m.lead = Math.max(0, Math.min(.6, (m.lead || 0) - d)); far = .25;+ }+ if (m.a.paused || jump && Math.abs(d) > .05 || ok && Math.abs(d) > far) {+ m.a.currentTime = (want + (RATE_STALLS && m.lead || 0)) % dur; d = 0; m.settle = !ok; m.sought = clock;+ } else if (ok) m.settle = false;+ if (Math.abs(d) > .25) m.fix = true; else if (Math.abs(d) < .05) m.fix = false;+ // a frame where the clock stood still keeps the rate it had+ const rate = !m.fix || RATE_STALLS ? P.rate : ok ? P.rate * (1 - Math.sign(d) * .05) : m.a.playbackRate;+ if (Math.abs(m.a.playbackRate - rate) > .001) m.a.playbackRate = rate;+ if (m.a.paused) m.a.play().catch(() => {});+ } else {+ if (m.a.playbackRate !== P.rate) m.a.playbackRate = P.rate;+ if (m.v === 0 && !m.a.paused) m.a.pause();+ }+ }+ if (!on && !wait && !P.done) for (const m of SND.bgm) m.a.pause();+}++/* ---------- player ---------- */+const P = { i: 0, t: 0, end: 1, back: 0, playing: false, waiting: false, done: false, started: false, audio: null, afail: false, stall: 0, cleanup: [], rate: 1, nextClip: null };+function runBeat(i) {+ TW = [];+ const b = BEATS[i], tm = TIMINGS[b.id], pre = b.pre || 0; // pre: seconds of picture before the narration starts+ const m = (k, off = 0) => {+ if (!(k in tm.marks)) throw new Error(`${b.id}: missing mark ${k}`);+ return pre + tm.marks[k] + off;+ };+ S.cleared = false;+ b.run(m, pre + tm.dur);+ if (S.cleared && b.lead !== false && CHAPTER.lead !== false && !pre) leadIn(); // CHAPTER.lead false: no beat gets one (a film)+ TW.sort((a, c) => a.t0 - c.t0);+ // runs that last to the end anyway (tails, follow cameras) do not set it: only the narration and the other tweens do,+ // and minDur, the least the whole beat lasts (two mirrored beats run the same seconds)+ const end = Math.max(Math.max(pre + tm.dur, ...TW.filter(w => !w.tail).map(w => w.t0 + w.dur)) + HOLD, b.minDur || 0);+ const tail = TW.some(w => w.tail === true);+ for (const w of TW) if (w.tail === true || tail && w.tail === 'follow') w.dur = end - w.t0;+ return SND.len[i] = end; // the music places itself by how long each beat really runs+}+const HOLD = .6;+// A beat that clears the picture must not leave it empty while the narration has started.+// If nothing appears before LEAD_MAX, the opening group (every tween that starts within LEAD_GROUP s of the+// first reveal) moves earlier so it begins at LEAD_AT, just after the old panel has faded. Later steps keep their word timing.+const LEAD_AT = .4, LEAD_MAX = .8, LEAD_GROUP = 1.2;+function leadIn() {+ const reveals = TW.filter(w => {+ if (!w.e) return false;+ const s = st(w.e), to = w.to;+ return (to.o > 0 && s.o === 0) || (to.s > 0 && s.s === 0) || (to.d > 0 && (s.d ?? 1) === 0);+ });+ if (!reveals.length) return;+ const first = Math.min(...reveals.map(w => w.t0));+ if (first <= LEAD_MAX) return;+ for (const w of TW) if (w.t0 >= first && w.t0 < first + LEAD_GROUP) w.t0 -= first - LEAD_AT;+}+function stopAudio() {+ const a = P.audio;+ if (!a) return;+ a.onerror = null; a.pause(); a.removeAttribute('src'); a.load();+ P.audio = null;+}+function clearCards() {+ $('ui').replaceChildren();+ P.cleanup.forEach(f => f());+ P.cleanup = [];+ finishFx();+ P.keys = null;+ S.q?.remove();+ delete S.q;+}+// Rebuild the scene from scratch and fast-forward every earlier beat, so any step starts from its exact picture.+function seek(i, play = P.playing) {+ stopAudio(); clearCards(); reset();+ seeking = true;+ try {+ for (let k = 0; k < i; k++) { runBeat(k); evalTo(Infinity); }+ start(i, play);+ } finally { seeking = false; }+}+// Jump to a point inside beat i (frac of its narration); question beats always start at their beginning.+function seekInto(i, frac) {+ seek(i, true);+ const pre = BEATS[i].pre || 0, t = BEATS[i].ask && !CHAPTER.film ? 0 : frac * (pre + TIMINGS[BEATS[i].id].dur); // a film's question beats seek like any other+ if (t < .3) return;+ P.t = t;+ evalTo(t);+ if (P.audio) P.audio.currentTime = Math.max(0, t - pre);+}+function start(i, play) {+ stopAudio(); clearCards();+ // P.gen counts starts: a done() kept from an earlier start of this same beat (a step replayed) no longer counts+ const gen = P.gen = (P.gen || 0) + 1;+ Object.assign(P, { i, t: 0, waiting: false, done: false, afail: false, stall: 0, lost: 0, back: 0 });+ P.end = runBeat(i);+ evalTo(0);+ const a = P.audio = beatClip(i, true);+ if (a) { // a beat with no narration ({ dur }) has no clip: wall time drives its clock+ a.volume = +($('volume')?.value ?? 1);+ a.playbackRate = P.rate;+ // An aborted or superseded load (fast stepping, a reload) is not a failure: only a real error for the current clip+ // shows the note, and the note goes away as soon as a clip plays.+ a.onerror = () => { if (P.audio === a && a.error && a.error.code !== MediaError.MEDIA_ERR_ABORTED) soundFailed(); };+ a.onplaying = () => {+ if (P.audio !== a) return;+ $('soundNote').hidden = true;+ if (P.afail) { P.afail = false; a.currentTime = Math.max(0, P.t - (BEATS[P.i].pre || 0)); } // sound came back late: rejoin the picture where it is+ };+ }+ const b = BEATS[i];+ if (b.ask) b.ask(() => {+ if (P.gen !== gen || P.done) return;+ evalTo(Infinity);+ if (i + 1 < BEATS.length) start(i + 1, true);+ else { P.done = true; setPlaying(false); filmDone(); }+ });+ setPlaying(play);+ if (i + 1 < BEATS.length) beatClip(i + 1);+}+// The next beat's clip starts loading while this one plays, so a slow connection does not stall between beats.+function beatClip(i, take) {+ if (TIMINGS[BEATS[i].id]?.silent) return null;+ // the clip's length rides on the URL: regenerated narration gets a new address, so a browser cache cannot pair new+ // timings with an old clip+ const src = `audio/${CHAPTER.language || 'en'}/${BEATS[i].id}.mp3?v=${TIMINGS[BEATS[i].id]?.dur ?? ''}`;+ let a = P.nextClip?._src === src ? P.nextClip : null;+ if (!a) {+ if (P.nextClip && P.nextClip !== P.audio) { P.nextClip.removeAttribute('src'); P.nextClip.load(); } // abandon a stale preload+ a = Object.assign(new Audio(src), { preload: 'auto', _src: src });+ }+ P.nextClip = take ? null : a;+ return a;+}+// Playback speed: the audio clock drives the picture, so changing the clip's rate keeps them together.+const SPEEDS = [.75, 1, 1.25, 1.5];+function setSpeed(r) {+ P.rate = r;+ $('bSpeed').textContent = r + '×';+ if (P.audio) P.audio.playbackRate = r;+ try { localStorage.setItem('speed', String(r)); } catch {}+}+const stepSpeed = d => setSpeed(SPEEDS[Math.max(0, Math.min(SPEEDS.length - 1, SPEEDS.indexOf(P.rate) + d))]);+function soundFailed() { P.afail = true; $('soundNote').hidden = false; }+function setPlaying(v) {+ P.playing = v;+ const a = P.audio;+ if (!a) return;+ const lead = v && P.t < (BEATS[P.i]?.pre || 0);+ if (v && !P.waiting && !a.ended && !P.afail && !lead) a.play().catch(e => { if (P.audio === a && e.name === 'NotAllowedError') soundFailed(); });+ else if (lead && !a._unlocked) { // the clip starts later, outside this click: play it silently now so the browser allows that+ a._unlocked = true; a.muted = true;+ a.play().then(() => { if (P.t < (BEATS[P.i].pre || 0)) { a.pause(); a.currentTime = 0; } a.muted = false; }, () => { a.muted = false; });+ } else a.pause();+}+function beatDone() {+ // Steps finish; continuous motion (tails) stays where the clock is: a beat under music ends up to HOLD early, and+ // jumping its tails to their end would move them a few px on the last frame+ evalTo(Infinity, TW.filter(w => !w.tail));+ const b = BEATS[P.i];+ if (b.ask) P.waiting = true;+ else if (P.i < BEATS.length - 1) start(P.i + 1, true);+ else { P.done = true; setPlaying(false); filmDone(); }+}+// A chapter that ends on its last frame, with no closing card of questions (a picture book), is finished there: it+// counts as done, and CHAPTER.next is offered over that frame. Seeking or replaying clears the button with the cards.+function filmDone() {+ progress(p => { p.done = [...new Set([...(p.done || []), CHAPTER.number])]; });+ document.activeElement?.blur(); // a last question's Continue keeps focus, and Enter would press it again+ // as on the finish card: Enter opens the next chapter (or replays), R and Space replay+ const go = () => { if (CHAPTER.next) location.href = CHAPTER.next; else restart(); };+ P.keys = e => e.key === 'Enter' ? (go(), true) : isShortcut(e, 'r') ? (restart(), true) : false;+ if (!CHAPTER.next) return;+ const next = h('button', 'btn go', [translate('nextChapter'), kbd('Enter')]);+ next.onclick = go;+ const c = card({ x: 0, y: SH - 130, w: 0, cls: 'side' }, 'next');+ Object.assign(c.style, { left: 'auto', right: '40px', width: 'auto' });+ c.append(h('div', 'acts', [next]));+}+let last = performance.now();+function frame(now) {+ frameStep(now, .1);+ requestAnimationFrame(frame);+}+function frameStep(now, most) {+ const raw = Math.max(0, now - last) / 1000, dt = Math.min(most, raw);+ last = now;+ clock += dt;+ if (FX.length) { evalTo(clock, FX); FX = FX.filter(w => !w.done); }+ if (P.playing && !P.waiting && !P.done) {+ const a = P.audio, t0 = P.t;+ // While the clip plays, its clock drives the picture; before it starts or after it ends, wall time does.+ const pre = BEATS[P.i].pre || 0;+ if (a && P.t < pre) { // the picture's lead before the narration, on wall time; then the clip starts+ P.t += dt * P.rate;+ if (P.t >= pre && !P.afail) { a.muted = false; a.currentTime = P.t - pre; a.play().catch(e => { if (P.audio === a && e.name === 'NotAllowedError') soundFailed(); }); }+ } else if (a && !P.afail && !a.ended) {+ if (a.currentTime > 0) { P.t = Math.max(P.t, pre + a.currentTime); P.stall = 0; }+ else if ((P.stall += dt) > (a.readyState < 2 ? 8 : 15)) soundFailed(); // nothing to play after 8 s, or stuck for 15+ } else P.t += dt * P.rate;+ // P.lost: how long the clock stood still while the film played (a clip getting going, buffering). Music runs on+ // through it, so a beat under music gives that time back from its closing hold: each beat then lasts as long in+ // real time as on the music's timeline, and the music stays with the picture instead of drifting ahead beat by beat.+ P.lost += raw * P.rate - (P.t - t0); // real time: a long frame moves the music by all of it+ const back = P.back = SND.bgm.some(m => m.beats.includes(BEATS[P.i].id)) ? Math.max(0, Math.min(HOLD, P.lost)) : 0;+ evalTo(P.t);+ if (P.t >= P.end - back) beatDone();+ }+ soundTick(dt);+ syncLinks();+ ui();+}+let segs = [];+function buildSegs() {+ segs = BEATS.map((b, i) => {+ const s = h('button', 'seg' + (b.ask ? ' ask' : ''), [h('i')]);+ s.style.flex = TIMINGS[b.id].dur + (b.ask ? 12 : 0);+ s.title = b.title;+ s.setAttribute('aria-label', translate('goToStep', { n: i + 1, title: b.title }));+ // A click lands at that point of the step; keyboard activation (no pointer position) starts the step.+ s.onclick = e => {+ const r = s.getBoundingClientRect();+ hideCover(); seekInto(i, e.detail ? (e.clientX - r.left) / r.width : 0);+ };+ $('segs').append(s);+ return s.firstChild;+ });+}+// ui() runs on every frame, paused or not: it writes only what changed, so an idle lesson does no layout work.+let stepText = '';+const setWidth = (f, w) => { if (f._w !== w) { f._w = w; f.style.width = w + '%'; } };+function ui() {+ segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));+ const fr = $('frame');+ fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls+ fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);+ const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;+ if (step !== stepText) { stepText = step; $('stepName').textContent = step; }+ const b = BEATS[P.i];+ let text = '';+ // a question's caption shows while its narration plays, clear of the cards; a full-screen card already shows the+ // question, so it has none+ const asking = !!b.ask;+ if (P.started && !P.done && !(asking && (P.waiting || $('ui').querySelector('.card.screen')))) {+ // a cue is [start, line], [start, line, end] or [start, line, end, 1]: with an end, the caption clears once its+ // words are over; a 1 marks a line in another language, whose subtitle shows even with captions off (as does every+ // cue of a beat whose timings say forced: true, from tts.py or eleven.py)+ // the last line without an end clears a second after the narration, so it does not sit on a closing title+ const cues = TIMINGS[b.id].cues;+ for (const [k, [t, line, end = k === cues.length - 1 ? TIMINGS[b.id].dur + 1 : null, forced]] of cues.entries()) {+ if (t + (b.pre || 0) > P.t + .05) break;+ text = (captions || forced || TIMINGS[b.id].forced) && !(end != null && P.t > end + (b.pre || 0)) ? line : '';+ }+ }+ if (text !== capText) { capText = text; $('caption').textContent = text; $('caption').hidden = !text; }+ if (text) placeCaption(asking);+}+// Above a bottom band, or centred left of a card in the bottom right; elsewhere the caption keeps its place.+let capAt = '';+function placeCaption(asking) {+ const c = asking ? $('ui').querySelector('.card.band, .card.side') : null;+ let at = '';+ if (c?.classList.contains('band')) at = `${SH + 60 - c.offsetTop + 12}||`;+ else if (c && c.offsetLeft > 800 && c.offsetTop + c.offsetHeight > 700) at = `|${c.offsetLeft / 2}|${c.offsetLeft - 60}`;+ if (at === capAt) return;+ capAt = at;+ const [bottom, left, width] = at.split('|'), s = $('caption').style;+ Object.assign(s, { bottom: bottom && bottom + 'px', left: left && left + 'px', maxWidth: width && width + 'px' });+}+let capText = '';+try { captions = localStorage.getItem('captions') === '1'; } catch {}+function setCaptions(on, save = true) {+ captions = on;+ $('bCC').setAttribute('aria-pressed', String(on));+ if (save) try { localStorage.setItem('captions', on ? '1' : '0'); } catch {}+}+setCaptions(captions, false); // only the reader's own choice is stored, so a book can still pick the first-time default+function hideCover() {+ P.started = true; $('cover').hidden = true;+ // a question that ?beat=N opened before the start (its box waited unfocused, so Space started) now takes the typing+ if (BEATS[P.i].ask) $('ui').querySelector('input.box:not(:disabled)')?.focus({ preventScroll: true });+}+function togglePlay() {+ if (!P.started) { turnPhone(); hideCover(); return setPlaying(true); }+ if (P.done) return restart(); // the end of a film (or of a chapter whose last step is a question): play again+ if (P.waiting) return;+ setPlaying(!P.playing);+}+const back1 = () => seek(P.t > 2.5 || P.i === 0 ? P.i : P.i - 1);+const restart = () => { for (const k in SCORE) delete SCORE[k]; hideCover(); seek(0, true); };+$('cover').onclick = togglePlay;+$('stage').addEventListener('click', e => {+ if (e.target.closest('a.cite')) { if (P.playing && !P.waiting) setPlaying(false); return; } // opening a source pauses the lesson+ const b = BEATS[P.i];+ if (!b.ask && !P.done && !e.target.closest('.qlayer')) togglePlay(); // a tap on a finished film's last frame does nothing+});+const citeObs = new MutationObserver(ms => { for (const m of ms) for (const n of m.addedNodes) autoCite(n); });+citeObs.observe(scene, { childList: true, subtree: true });+citeObs.observe($('ui'), { childList: true, subtree: true });+$('bPlay').onclick = togglePlay;+$('bBack').onclick = () => { hideCover(); back1(); };+$('bRestart').onclick = restart;+$('bCC').onclick = () => setCaptions(!captions);+$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);+try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}+$('bFull').onclick = () => toggleFull();+// Full screen also turns the screen to the stage's orientation where the browser allows it (Android browsers lock+// orientation only in full screen; iOS has no lock, so there the reader turns the phone). On a phone held across the+// stage's orientation, starting the lesson goes full screen the same way, since the stage would otherwise be a strip.+function goFull() {+ return document.documentElement.requestFullscreen?.({ navigationUI: 'hide' })+ .then(() => screen.orientation?.lock?.(PORTRAIT ? 'portrait' : 'landscape')).catch(() => {});+}+function turnPhone() {+ const phone = matchMedia('(pointer: coarse)').matches && Math.min(screen.width, screen.height) <= 600;+ if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();+}+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.+document.addEventListener('fullscreenchange', () => {+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);+ fit(); wake();+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}+});+let wakeT = 0;+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);+let helpResume = false;+function toggleHelp() {+ const open = $('help').hidden;+ $('help').hidden = !open;+ if (open) { helpResume = P.playing; if (P.playing) setPlaying(false); }+ else if (helpResume) setPlaying(true);+}+// Review notes, only with ?review in the URL: N pauses and asks for a note on this moment, Shift+N copies every+// note of the chapter (one line each, with the ?beat=N&t=S that reopens it) and offers to clear them.+const REVIEW = new URLSearchParams(location.search).has('review');+const REVIEW_KEY = 'papermorph:review:' + location.pathname;+const reviewNotes = () => { try { return JSON.parse(localStorage.getItem(REVIEW_KEY) || '[]'); } catch { return []; } };+function reviewNote() {+ if (P.playing) setPlaying(false);+ const at = `?beat=${P.i}&t=${P.t.toFixed(1)}`, note = prompt(`Note at ${BEATS[P.i].id} ${at}`);+ if (!note) return;+ try { localStorage.setItem(REVIEW_KEY, JSON.stringify([...reviewNotes(), `ch${String(CHAPTER.number).padStart(2, '0')} ${at} (${BEATS[P.i].id}): ${note}`])); } catch {}+}+function reviewCopy() {+ const notes = reviewNotes(), text = notes.join('\n');+ console.log(text);+ navigator.clipboard?.writeText(text).catch(() => {});+ if (confirm(`${notes.length} notes copied (also in the console). Clear them?`)) try { localStorage.removeItem(REVIEW_KEY); } catch {}+}+// Every action has a key. A question's own keys (P.keys) come first; Shift reaches the player during a question.+document.addEventListener('keydown', e => {+ if (e.altKey || e.metaKey || e.ctrlKey) return;+ const k = e.key;+ if (!$('help').hidden) { if (k === 'Escape' || k === '?') { e.preventDefault(); toggleHelp(); } return; }+ if (e.target.matches?.('input')) { // Keep native input keys; only answer boxes use Enter to check.+ if (k === 'Enter' && e.target.type !== 'range' && P.keys) { e.preventDefault(); P.keys(e); }+ else if (k === 'Escape') e.target.blur();+ return;+ }+ if (k === '?') { e.preventDefault(); toggleHelp(); return; }+ if (REVIEW && isShortcut(e, 'n')) { e.preventDefault(); e.shiftKey ? reviewCopy() : reviewNote(); return; }+ if ((k === 'Enter' || k === ' ') && e.target.closest?.('button, [tabindex], a')) return; // a Tab-focused control acts itself+ if (!P.started) { if (k === ' ' || k === 'Enter') { e.preventDefault(); togglePlay(); } return; }+ if (P.keys && !e.shiftKey && P.keys(e)) { e.preventDefault(); return; }+ const free = e.shiftKey || !P.keys || P.done; // after the end no question holds the arrows+ let used = true;+ if (k === ' ') togglePlay();+ else if (k === 'ArrowLeft' && free) back1();+ else if (k === 'ArrowRight' && free) { if (P.i < BEATS.length - 1) seek(P.i + 1); }+ else if (k === 'Home') restart();+ else if (isShortcut(e, 'c')) setCaptions(!captions);+ else if (k === '<' || k === ',' || isShortcutCode(e, 'Comma')) stepSpeed(-1);+ else if (k === '>' || k === '.' || isShortcutCode(e, 'Period')) stepSpeed(1);+ else if (isShortcut(e, 'f')) toggleFull();+ else used = false;+ if (used) e.preventDefault();+});+// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".+$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });+$('bHelp').onclick = toggleHelp;+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));+addEventListener('resize', fit);+fit();++// Start the lesson once the chapter page has defined CHAPTER and BEATS.+// ?beat=N&t=S opens a paused frame, for reviewing a single moment.+function boot() {+ // a beat with no narration: { dur } in its fourth slot stands in for its clip and its TIMINGS entry+ window.TIMINGS ??= {};+ for (const b of BEATS) if (!TIMINGS[b.id] && b.dur != null) TIMINGS[b.id] = { dur: b.dur, marks: {}, cues: [], silent: true };+ for (const m of SND.bgm) { // music() above BEATS plays under every beat+ m.beats ??= BEATS.map(b => b.id);+ const lost = m.beats.filter(id => !BEATS.some(b => b.id === id));+ if (lost.length) console.warn(`music('${m.n}'): no beat ${lost.join(', ')} in BEATS`);+ }+ $('coverK').textContent = translate('chapterNumber', { n: CHAPTER.label ?? CHAPTER.number });+ $('coverT').textContent = CHAPTER.title;+ $('bHome').href = `../#ch${String(CHAPTER.number).padStart(2, '0')}`;+ progress(p => { p.last = CHAPTER.number; });+ document.getElementById('stage').setAttribute('aria-label', translate('stageLabelTitled', { title: CHAPTER.title }));+ const film = !!CHAPTER.film || !BEATS.some(b => b.ask); // a picture book or a film: no "lesson" or "quick checks" on its cover+ if (film) $('coverGo').textContent = translate('startFilm');+ if (film && (!BEATS.some(b => b.ask) || CHAPTER.questionKeys === false)) { // nothing to answer with keys (or its own controls): the help lists no question keys and needs no column titles+ const shift = [...$('help').querySelectorAll('dt')].find(e => e.textContent.startsWith('Shift'));+ for (const e of [$('help').querySelector('.help-cols > :last-child'), $('help').querySelector('h3'), shift, shift.nextElementSibling]) e.hidden = true;+ }+ $('coverMeta').textContent = translate(film ? 'aboutMinutesFilm' : 'aboutMinutes', { n: num(CHAPTER.minutes) });+ buildSegs();+ const qs = new URLSearchParams(location.search);+ if (qs.has('lengths')) { // each beat's voice against its length on screen: a tween or a run past the voice lengthens it+ reset(); seeking = true;+ try { for (let k = 0; k < BEATS.length; k++) { runBeat(k); evalTo(Infinity); } } finally { seeking = false; }+ console.log(`?lengths: beat, voice (pre + clip), on screen (hold included), and the time past voice + ${HOLD} s hold\n` + BEATS.map((b, i) => {+ const v = (b.pre || 0) + TIMINGS[b.id].dur, over = SND.len[i] - HOLD - v;+ return `${b.id.padEnd(16)} ${v.toFixed(2).padStart(6)} ${SND.len[i].toFixed(2).padStart(6)}${over > .005 ? ` +${over.toFixed(2)}` : ''}`;+ }).join('\n'));+ }+ if (qs.has('beat')) {+ $('cover').hidden = true;+ seek(Math.max(0, Math.min(BEATS.length - 1, qs.get('beat') | 0)), false);+ P.t = +(qs.get('t') || 0);+ evalTo(P.t);+ if (P.audio) P.audio.currentTime = Math.max(0, P.t - (BEATS[P.i].pre || 0));+ } else seek(0, false);+ requestAnimationFrame(frame);+ // A hidden tab gets no animation frames: a timer keeps the film going, so a beat that ends there still starts the next+ // one (a tab playing sound keeps its timers). Its ticks come late, so they may move the clock further at once.+ setInterval(() => { if (document.hidden) frameStep(performance.now(), 1.5); }, 250);+}+return { TRANSLATIONS, PORTRAIT, SW, SH, LANGUAGE, translate, DECIMAL_SIGN, isShortcut, NS, UI, BOOK, bookSetting,+ COL, MATH, NAME, BAND, RIGHT, TOPR, SCREEN, SORT_SCREEN, $m, mk, st, put, render, G, path, T, cite, ctx2d, textW, F,+ R, E, TX, $tex, texGraphic, texPart, OV, M, chip, tokens, layRow, collapse, mathEl, io, out, back, lin, tw, prog,+ show, hide, draw, pop, pulse, stream, mix, evalTo, soft, clockRun, camera, scene, S, AXIS, X, Y0, num, reset, tick,+ dot, arrow, panel, retire, header, fx, fxp, finishFx, pulseFx, shakeFx, floatText, TF, $, kbd, sources, uiW, SCORE,+ h, rich, card, mascotEl, quiz, qlayer, keyAct, choice, mcq, tap, tapEls, pickEls, tapWords, grid, rat, gcd, lowest, blanks,+ SND, P, HOLD, clearCards, seek, seekInto, start, setSpeed, setPlaying, setCaptions, hideCover, restart, boot,+ finishCard };+})();++// The API, one global each: lint.py reads these declarations, and a chapter that declares one of them again stops+// with an error, as before.+const TRANSLATIONS = ENGINE.TRANSLATIONS, PORTRAIT = ENGINE.PORTRAIT, SW = ENGINE.SW, SH = ENGINE.SH,+ LANGUAGE = ENGINE.LANGUAGE, translate = ENGINE.translate, DECIMAL_SIGN = ENGINE.DECIMAL_SIGN,+ isShortcut = ENGINE.isShortcut, NS = ENGINE.NS, UI = ENGINE.UI, BOOK = ENGINE.BOOK,+ bookSetting = ENGINE.bookSetting, COL = ENGINE.COL, MATH = ENGINE.MATH, NAME = ENGINE.NAME, BAND = ENGINE.BAND,+ RIGHT = ENGINE.RIGHT, TOPR = ENGINE.TOPR, SCREEN = ENGINE.SCREEN, SORT_SCREEN = ENGINE.SORT_SCREEN, $m = ENGINE.$m,+ mk = ENGINE.mk, st = ENGINE.st, put = ENGINE.put, render = ENGINE.render, G = ENGINE.G, path = ENGINE.path,+ T = ENGINE.T, cite = ENGINE.cite, ctx2d = ENGINE.ctx2d, textW = ENGINE.textW, F = ENGINE.F, R = ENGINE.R,+ E = ENGINE.E, TX = ENGINE.TX, $tex = ENGINE.$tex, texGraphic = ENGINE.texGraphic, texPart = ENGINE.texPart,+ OV = ENGINE.OV, M = ENGINE.M, chip = ENGINE.chip, tokens = ENGINE.tokens, layRow = ENGINE.layRow,+ collapse = ENGINE.collapse, mathEl = ENGINE.mathEl, io = ENGINE.io, out = ENGINE.out, back = ENGINE.back,+ lin = ENGINE.lin, tw = ENGINE.tw, prog = ENGINE.prog, show = ENGINE.show, hide = ENGINE.hide, draw = ENGINE.draw,+ pop = ENGINE.pop, pulse = ENGINE.pulse, stream = ENGINE.stream, mix = ENGINE.mix, evalTo = ENGINE.evalTo,+ soft = ENGINE.soft, clockRun = ENGINE.clockRun, camera = ENGINE.camera, scene = ENGINE.scene, S = ENGINE.S,+ AXIS = ENGINE.AXIS, X = ENGINE.X, Y0 = ENGINE.Y0, num = ENGINE.num, reset = ENGINE.reset, tick = ENGINE.tick,+ dot = ENGINE.dot, arrow = ENGINE.arrow, panel = ENGINE.panel, retire = ENGINE.retire, header = ENGINE.header,+ fx = ENGINE.fx, fxp = ENGINE.fxp, finishFx = ENGINE.finishFx, pulseFx = ENGINE.pulseFx, shakeFx = ENGINE.shakeFx,+ floatText = ENGINE.floatText, TF = ENGINE.TF, $ = ENGINE.$, kbd = ENGINE.kbd, sources = ENGINE.sources,+ uiW = ENGINE.uiW, SCORE = ENGINE.SCORE, h = ENGINE.h, rich = ENGINE.rich, card = ENGINE.card,+ mascotEl = ENGINE.mascotEl, quiz = ENGINE.quiz, qlayer = ENGINE.qlayer, keyAct = ENGINE.keyAct,+ choice = ENGINE.choice, mcq = ENGINE.mcq, tap = ENGINE.tap, tapEls = ENGINE.tapEls, pickEls = ENGINE.pickEls,+ tapWords = ENGINE.tapWords, grid = ENGINE.grid, rat = ENGINE.rat, gcd = ENGINE.gcd, lowest = ENGINE.lowest, blanks = ENGINE.blanks,+ SND = ENGINE.SND, P = ENGINE.P, HOLD = ENGINE.HOLD, clearCards = ENGINE.clearCards, seek = ENGINE.seek,+ seekInto = ENGINE.seekInto, start = ENGINE.start, setSpeed = ENGINE.setSpeed, setPlaying = ENGINE.setPlaying,+ setCaptions = ENGINE.setCaptions, hideCover = ENGINE.hideCover, restart = ENGINE.restart, boot = ENGINE.boot;+// Hooks: scorm-bridge.js wraps these two, and the engine calls progress() through this global.+let finishCard = ENGINE.finishCard;+// Per-book progress shared with the cover/contents at the parent URL folder.+const BOOK_PROGRESS_KEY = bookSetting('--progress-key') || 'animebook:progress:' + new URL('../', location.href).pathname;+function progress(f) {+ try {+ const saved = JSON.parse(localStorage.getItem(BOOK_PROGRESS_KEY) || '{}');+ const p = saved && typeof saved === 'object' && !Array.isArray(saved) ? saved : {};+ p.done = Array.isArray(p.done) ? p.done.filter(n => Number.isInteger(n) && n > 0) : [];+ f(p); localStorage.setItem(BOOK_PROGRESS_KEY, JSON.stringify(p));+ } catch {}+}diff --git a/site/little-horse/lib/find.js b/site/little-horse/lib/find.jsnew file mode 100644index 0000000..c2687f2--- /dev/null+++ b/site/little-horse/lib/find.js@@ -0,0 +1,179 @@+/* find.js — "listen and find", the book's point-and-read stops (2026-10-31; to move into the engine beside tapWords).+ findWords(things, asks, done, opts): a character asks for one thing at a time ("Can you find the bird? Touch it!").+ Every thing in the picture answers a tap: a wrong one hops and says its own name, then the short question comes+ again ("Where's the bird?"). Nothing is ever called wrong; each miss helps more: at the second the thing asked for+ shakes at once, from the third paper stars circle it and it keeps shaking. A tap on nothing leaves a paper ripple+ (two of them count as a miss). A tap that lands inside the asked thing's box counts as finding it, even where a+ smaller thing's box lies on top. Nobody finds it for `giveUpAfter` s: the character says "Look! There it is!", the+ thing hops and counts as found, so a child who never taps is never stuck. After the last one, the praise line, and+ the film goes on by itself. A new tap cuts off whatever was being said, so lines never pile up.+ things: [{ g, word, side?, clip?, talk? }] as for tapWords (talk: the clip is the character's voice, e.g. 'q-me'+ for the character itself); asks: [{ word, clip, again? }] in order (again defaults to 'r-' + word);+ opts.end: the praise clip; opts.there: the give-up clip.+ While the character speaks, FIND.saying names its clip: a scene poses its mouth with findMouth(), and can turn its+ eyes to FIND.target (the thing asked for) or findSaw() (the thing just found, until the next question). The lines+ are captioned, from their timings, when captions are on. */+'use strict';+// The engine keeps a scene living while tapWords waits; it does not for another ask. So find.js remembers each+// scene's frame function (stopClock, paper.js) and draws it on past the beat's end while the page waits.+const FIND_CLOCKS = [];+{ const run = stopClock; stopClock = (D, draw) => { while (FIND_CLOCKS.length && FIND_CLOCKS[0].gen !== P.gen) FIND_CLOCKS.shift(); FIND_CLOCKS.push({ gen: P.gen, D, draw, f: -1 }); run(D, draw); }; }+const FIND = { saying: null, t0: 0, target: null, found: null, foundAt: -1e9 }, FIND_SEEN = .9; // until the next question starts+const findMouth = () => FIND.saying ? mouthAt(FIND.saying, performance.now() / 1000 - FIND.t0) : 'X';+const findSaw = () => performance.now() / 1000 - FIND.foundAt < FIND_SEEN ? FIND.found : null;+const FIND_SIDES = { above: 0, below: 1, right: 2, left: 3 };++function findWords(things, asks, done, { end = 'q-done', there = 'q-there', hintAfter = 5, giveUpAfter = 20, minBox = 120 } = {}) {+ const gen = P.gen, stage = $('stage'), lang = CHAPTER.language || 'en';+ const clip = name => { const a = new Audio(`audio/${lang}/${name}.mp3`); a.preload = 'auto'; a.clipName = name; return a; };+ const list = things.filter(t => t.word && t.g instanceof SVGGraphicsElement && stage.contains(t.g))+ .map(t => ({ ...t, a: clip(t.clip || 'w-' + t.word.toLowerCase().replace(/ /g, '-')) }));+ const qs = asks.map(q => ({ ...q, a: clip(q.clip), again: clip(q.again || 'r-' + q.word) }));+ const praise = clip(end), help = clip(there), chime = new Audio('audio/sfx/chime.mp3');+ const L = mk('g', { class: 'findw' }, stage);+ let on = false, alive = true, k = 0, word = null, lastAct = 0, askedAt = 0, wiggling = null, playing = null;+ let misses = 0, blanks = 0, turn = 0, stars = null;+ const now = () => performance.now();+ const box = t => {+ const s = stage.getBoundingClientRect(), r = t.g.getBoundingClientRect(), kx = SW / s.width, ky = SH / s.height;+ return { x: (r.left - s.left) * kx, y: (r.top - s.top) * ky, w: r.width * kx, h: r.height * ky };+ };+ const hitBox = t => { const b = box(t), w = Math.max(minBox, b.w), hh = Math.max(minBox, b.h); return { x: b.x + (b.w - w) / 2, y: b.y + (b.h - hh) / 2, w, h: hh }; };+ const place = () => { for (const t of list) { const b = hitBox(t); for (const [key, v] of Object.entries({ x: b.x, y: b.y, width: b.w, height: b.h })) t.hit.setAttribute(key, v.toFixed(1)); } };+ const stagePoint = e => { const s = stage.getBoundingClientRect(); return [(e.clientX - s.left) * SW / s.width, (e.clientY - s.top) * SH / s.height]; };+ const want = () => list.find(t => t.word === qs[k]?.word);++ // one sound at a time, ducking the music like a tapped word; the character's own lines move its mouth and are+ // captioned; resolves when the sound ends+ const caption = a => {+ if (typeof captions === 'undefined' || !captions) return;+ const line = (TIMINGS[a.clipName]?.cues || []).map(c => c[1]).join(' ');+ $('caption').textContent = line; $('caption').hidden = !line;+ };+ const say = (a, talk = false) => new Promise(ok => {+ if (!alive) return ok();+ playing?.pause(); playing = a;+ a.currentTime = 0; a.volume = +($('volume')?.value ?? 1);+ FIND.saying = talk ? a.clipName : null; FIND.t0 = now() / 1000;+ if (talk) caption(a);+ a.onended = () => { if (SND.word === a) SND.word = null; if (FIND.saying === a.clipName) FIND.saying = null; if (talk) { $('caption').hidden = true; } ok(); };+ SND.word = a;+ a.play().catch(ok);+ });+ let wordTimer = 0;+ const hideWord = (after = 1500) => { clearTimeout(wordTimer); const w = word; wordTimer = setTimeout(() => w?.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 300 }).finished.then(() => w.remove()), after); };+ // the word beside its thing, on its `side` or wherever it fits, as tapWords places it+ const showWord = t => {+ word?.remove(); clearTimeout(wordTimer);+ word = h('div', 'card word', t.word); word.setAttribute('aria-hidden', 'true');+ $('ui').append(word);+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];+ const [x, y] = t.side in FIND_SIDES ? spots[FIND_SIDES[t.side]] : spots.find(([x, y], i) => i < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];+ Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });+ };+ const hop = t => t.g.animate([{ translate: '0 0' }, { translate: '0 -22px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });+ // the hint: a big side-to-side shake (translate, so a scene can copy it onto a picture it moves itself, the mill's wheel)+ const wiggle = t => {+ if (wiggling) return;+ wiggling = t.g.animate([{ translate: '0 0' }, { translate: '-20px -6px' }, { translate: '20px 0' }, { translate: '-16px -4px' }, { translate: '12px 0' }, { translate: '0 0' }], { duration: 750 });+ wiggling.onfinish = () => { wiggling = null; lastAct = now() - (hintAfter - (misses >= 3 ? 0 : 2.5)) * 1000; };+ };+ // paper stars close round the thing asked for, from the third miss until it is found+ const starsOn = t => {+ if (stars) return;+ stars = mk('g', { 'pointer-events': 'none' }, L.parentNode);+ stars.innerHTML = Array.from({ length: 6 }, () => `<path d="M0,-28 L8,-8 L28,-8 L12,6 L18,26 L0,14 L-18,26 L-12,6 L-28,-8 L-8,-8 Z" fill="#f4c542" stroke="#b8862a" stroke-width="3"/>`).join('');+ stars.t = t;+ };+ const starsOff = () => { stars?.remove(); stars = null; };++ const ask = async () => {+ lastAct = askedAt = now();+ window.FIND_STATE = { k, of: qs.length }; // for tests+ FIND.target = want()?.g || null;+ if (k >= qs.length) {+ on = false; word?.remove(); FIND.target = null;+ await say(praise, true);+ setTimeout(() => { if (alive && P.gen === gen) { window.FIND_STATE.done = true; done(); } }, 900);+ return;+ }+ await say(qs[k].a, true);+ lastAct = askedAt = now();+ };+ const found = async (t, given) => {+ on = false; starsOff(); turn++;+ hop(t); showWord(t);+ if (given) await say(help, true);+ await say(t.a); hideWord(600);+ FIND.found = t.g; FIND.foundAt = now() / 1000;+ chime.currentTime = 0; chime.volume = .5 * +($('volume')?.value ?? 1); chime.play().catch(() => {});+ await new Promise(r => setTimeout(r, 700));+ if (!alive) return;+ k++; misses = blanks = 0; on = true; ask();+ };+ const miss = async (t, my) => {+ misses++;+ const w = want();+ if (misses >= 2 && w) wiggle(w);+ if (misses >= 3 && w) starsOn(w);+ if (t) { await say(t.a, !!t.talk); if (my !== turn) return; hideWord(); }+ await new Promise(r => setTimeout(r, 250));+ if (my === turn && alive && on) say(qs[k].again, true);+ };+ // every tap: inside the asked thing's box it is found, whatever lies on top; else the thing tapped, or nothing+ const press = (e, t) => {+ e.preventDefault();+ if (!on || !alive) return;+ lastAct = now();+ const [x, y] = stagePoint(e), w = want(), b = w && hitBox(w);+ if (b && x >= b.x && x <= b.x + b.w && y >= b.y && y <= b.y + b.h) return found(w);+ if (t) { const my = ++turn; hop(t); showWord(t); return miss(t, my); }+ const r = mk('circle', { cx: x, cy: y, r: 10, fill: 'none', stroke: '#fbf6ea', 'stroke-width': 4, 'pointer-events': 'none' }, L.parentNode);+ r.animate([{ r: 10, opacity: .9 }, { r: 46, opacity: 0 }], { duration: 500, easing: 'ease-out' }).finished.then(() => r.remove());+ if (++blanks % 2 === 0) miss(null, ++turn);+ };+ const enable = () => {+ on = true;+ const bg = mk('rect', { x: 0, y: 0, width: SW, height: SH, fill: 'transparent', style: 'pointer-events:all' }, L);+ bg.addEventListener('pointerdown', e => press(e, null));+ for (const t of list) {+ t.hit = mk('rect', { fill: 'transparent', style: 'cursor:pointer;pointer-events:all;outline:none', 'aria-label': t.word, role: 'button' }, L);+ t.hit.addEventListener('pointerdown', e => press(e, t));+ }+ // smaller things on top, so a bird in front of a tree can be reached+ [...list].sort((a, b) => box(b).w * box(b).h - box(a).w * box(a).h).forEach(t => L.append(t.hit));+ place();+ P.keys = e => e.key === 'Enter' ? (done(), true) : false;+ ask();+ };+ const cleanup = () => {+ alive = false; L.remove(); word?.remove(); starsOff();+ for (const a of [...list.map(t => t.a), ...qs.map(q => q.a), ...qs.map(q => q.again), praise, help]) a.pause();+ if (SND.word) SND.word = null;+ Object.assign(FIND, { saying: null, target: null, found: null });+ };+ P.cleanup.push(cleanup);+ let waitFrom = 0;+ const tick = () => {+ if (!alive) return;+ if (P.gen !== gen) { cleanup(); return; }+ // the scene lives on while the page waits: its frame function at D + the seconds waited, on its own 12 fps steps+ if (P.waiting) {+ waitFrom ||= now();+ for (const c of FIND_CLOCKS) if (c.gen === gen) {+ const q = c.D + (now() - waitFrom) / 1000, f = Math.floor(q * FPS + 1e-6);+ if (f !== c.f) { c.f = f; c.draw(f / FPS, f); }+ }+ }+ if (P.waiting && !on && k === 0 && !list[0].hit) enable();+ if (list[0]?.hit) place();+ if (stars) { const b = box(stars.t), cx = b.x + b.w / 2, cy = b.y + b.h / 2, R = Math.max(b.w, b.h) * .38 + 24, a0 = now() / 900;+ [...stars.children].forEach((st, i) => { const a = a0 + i * Math.PI / 3; st.setAttribute('transform', `translate(${(cx + R * Math.cos(a)).toFixed(1)},${(cy + R * .8 * Math.sin(a)).toFixed(1)}) rotate(${(a * 60).toFixed(0)})`); }); }+ const w = want();+ if (on && w && now() - askedAt > giveUpAfter * 1000) found(w, true);+ else if (on && w && now() - lastAct > hintAfter * 1000) wiggle(w);+ requestAnimationFrame(tick);+ };+ requestAnimationFrame(tick);+}diff --git a/site/little-horse/lib/math.js b/site/little-horse/lib/math.jsnew file mode 100644index 0000000..19a26f5--- /dev/null+++ b/site/little-horse/lib/math.js@@ -0,0 +1,698 @@+// Papermorph maths helpers: number lines, tiles, fractions, planes, dice, the number map, sorter.+// A maths chapter loads this right after engine.js; it uses the engine's globals as it loads.+'use strict';+// Vertical number line at x; Yf maps a value to its y. Labels sit on the left.+function vAxis(p, { x, Yf, lo, hi, step = 1, t0 = .1, unit = '' }) {+ draw(path(p, `M${x} ${Yf(lo - .5)}V${Yf(hi + .5)}`, { stroke: COL.chalk, 'stroke-width': 3 }, { d: 0 }), t0, .8);+ for (let v = lo; v <= hi; v += step) {+ const g = G(p, { o: 0 });+ path(g, `M${x - 9} ${Yf(v)}H${x + 9}`, { stroke: COL.dim, 'stroke-width': 2.5 });+ T(g, num(v) + unit, { x: x - 46, y: Yf(v) + 9, size: 24, fill: v === 0 ? COL.chalk : COL.dim, font: MATH, anchor: 'end' });+ show(g, t0 + .2 + Math.abs(v - lo) * .02);+ }+}+// Thermometer from lo (bottom) to hi (top). set(v, t0, run) moves the column; run = tw (lesson) or fx (answer).+function thermometer(p, { x = 800, bottom = 600, top = 200, lo = -10, hi = 15, step = 5, value = 0, color = COL.nat } = {}) {+ const Yt = v => bottom - (v - lo) / (hi - lo) * (bottom - top), bulb = bottom + 32, g = G(p);+ mk('rect', { x: x - 18, y: top - 24, width: 36, height: bulb - top + 24, rx: 18, fill: COL.board, stroke: COL.dim, 'stroke-width': 2.5 }, g);+ mk('circle', { cx: x, cy: bulb, r: 26, fill: color }, g);+ const merc = put(mk('rect', { x: x - 9, width: 18, rx: 9, fill: color }, g), { a_y: Yt(value), a_height: bulb - Yt(value) });+ for (let v = lo; v <= hi; v += step) {+ path(g, `M${x - 30} ${Yt(v)}H${x - 18}`, { stroke: COL.dim, 'stroke-width': 2 });+ T(g, `${num(v)}°`, { x: x - 40, y: Yt(v) + 9, size: 24, fill: v === 0 ? COL.chalk : COL.dim, font: MATH, anchor: 'end' });+ }+ return { g, merc, Yt, set: (v, t0, run = tw, dur = 1.2) => run(merc, { a_y: Yt(v), a_height: bulb - Yt(v) }, t0, dur) };+}+/* ---------- fractions: rows with strikable parts, bars and brackets ---------- */+// A row of fractions and symbols whose numerators and denominators can be struck out one by one.+// items: { f: [n, d], fill } | 'symbol text'. The fraction bars sit on y.+function fracRow(p, items, { x = 800, y = 300, size = 60, anchor = 'middle', o = 0 } = {}) {+ const fs = size * .8, g = G(p, { o });+ const els = items.map(it => {+ if (typeof it === 'string') {+ const w = textW(it, size);+ return { w, draw(cx) { this.cx = cx; T(g, it, { x: cx, y: y + size * .33, size, font: MATH, fill: COL.chalk, anchor: 'middle' }); } };+ }+ const [n, d] = it.f.map(String), w = Math.max(textW(n, fs), textW(d, fs)) + size * .35, fill = it.fill || COL.chalk;+ return { w, n, d, draw(cx) {+ this.cx = cx;+ path(g, `M${cx - w / 2 + 4} ${y}H${cx + w / 2 - 4}`, { stroke: fill, 'stroke-width': size * .055 });+ this.num = T(g, n, { x: cx, y: y - size * .18, size: fs, font: MATH, fill, anchor: 'middle' });+ this.den = T(g, d, { x: cx, y: y + size * .78, size: fs, font: MATH, fill, anchor: 'middle' });+ } };+ });+ const total = els.reduce((a, e) => a + e.w, 0);+ let cx = anchor === 'middle' ? x - total / 2 : x;+ for (const e of els) { e.draw(cx + e.w / 2); cx += e.w; }+ return Object.assign(els, { g, y, size, x0: anchor === 'middle' ? x - total / 2 : x, w: total });+}+// Strike the numerator ('num') or denominator ('den') of fraction k and write its reduced value beside it.+function reduce(row, k, part, value, color, t0, run = tw) {+ const e = row[k], { y, size } = row, top = part === 'num';+ const cy = top ? y - size * .42 : y + size * .52, g = row.g;+ const slash = path(g, `M${e.cx - size * .28} ${cy + size * .3}L${e.cx + size * .28} ${cy - size * .3}`, { stroke: color, 'stroke-width': 3.5 }, { d: 0 });+ const nv = T(g, String(value), { x: e.cx + size * .02, y: top ? y - size * .92 : y + size * 1.36, size: size * .5, font: MATH, fill: color, anchor: 'middle', o: 0 });+ run(slash, { d: 1 }, t0, .4); run(nv, { o: 1 }, t0 + .3, .4);+ run(e[part], { o: .45 }, t0 + .3, .4);+}+function rect(p, x, y, w, h, fill, o = 0, stroke = 'none') {+ return put(mk('rect', { x, y, width: w, height: h, fill, stroke, 'stroke-width': 2.5 }, p), { o });+}+function bracketH(p, x1, x2, y, label, color, t0) {+ draw(path(p, `M${x1} ${y - 10}V${y}H${x2}V${y - 10}`, { stroke: color, 'stroke-width': 3 }, { d: 0 }), t0, .5);+ show(T(p, label, { x: (x1 + x2) / 2, y: y + 32, size: 26, fill: color, font: MATH, anchor: 'middle', o: 0 }), t0 + .3);+}++/* ---------- decimal point that hops between digits (ch10, ch20) ---------- */+// Digits in evenly spaced slots with a decimal point that can hop between them.+// places = digits after the point (0 = point at the far right, hidden).+function pointRow(p, digits, x, y, places, { size = 72, fill = COL.chalk, sign = '' } = {}) {+ const g = G(p, { o: 0 }), w = size * .7, n = digits.length, x0 = x - n * w / 2;+ if (sign) T(g, sign, { x: x0 - w * .6, y, size, fill, font: MATH, anchor: 'middle' });+ const ds = [...digits].map((c, i) => T(g, c, { x: x0 + i * w + w / 2, y, size, fill, font: MATH, anchor: 'middle' }));+ const px = k => x0 + (n - k) * w;+ const dot = mk('circle', { r: size * .065, fill: COL.task }, g);+ put(dot, { x: px(places), y: y - size * .02, o: places ? 1 : 0 });+ const trail = path(g, '', { stroke: COL.task, 'stroke-width': 2.5, 'stroke-dasharray': '5 6' });+ return { g, ds, dot, px, w,+ hop(from, to, t0, run = tw, dur = .55) {+ const steps = Math.abs(to - from);+ run(dot, { o: 1 }, t0, .2);+ let d = '';+ for (let k = 0; k < steps; k++) {+ const a = px(from + Math.sign(to - from) * k), b = px(from + Math.sign(to - from) * (k + 1));+ d += `M${a} ${y - 10}Q${(a + b) / 2} ${y - size * .9} ${b} ${y - 10}`;+ }+ trail.setAttribute('d', d);+ put(trail, { o: 0 }); run(trail, { o: .9 }, t0 + steps * dur, .3);+ (run === tw ? prog : fxp)(q => {+ const s = q * steps, k = Math.min(steps - 1, Math.floor(s)), f = s - k;+ const a = px(from + Math.sign(to - from) * k), b = px(from + Math.sign(to - from) * (k + 1));+ put(dot, { x: a + (b - a) * f, y: y - size * .02 - Math.sin(Math.PI * f) * size * .7 });+ }, t0, steps * dur, lin);+ } };+}++/* ---------- balance scale for equations (ch24, ch25) ---------- */+// A balance scale. Its pans hang from the beam ends; tilt(deg, t0) rocks it (positive: left side down).+function balance(p, { x = 800, y = 330, L = 300 } = {}) {+ const g = G(p, { o: 0 });+ path(g, `M${x} ${y}L${x - 50} ${y + 330}H${x + 50}Z`, { stroke: COL.dim, 'stroke-width': 3, fill: mix(COL.board, COL.dim, .15) });+ const beam = G(g, { x, y });+ path(beam, `M${-L} 0H${L}`, { stroke: COL.chalk, 'stroke-width': 6 });+ mk('circle', { r: 10, fill: COL.chalk }, beam);+ const pan = side => {+ const pg = G(g, { x: x + side * L, y });+ path(pg, 'M0 0L-90 110M0 0L90 110', { stroke: COL.dim, 'stroke-width': 2 });+ path(pg, 'M-110 110Q0 150 110 110Z', { stroke: side < 0 ? COL.whole : COL.nat, 'stroke-width': 3, fill: mix(COL.board, side < 0 ? COL.whole : COL.nat, .2) });+ return pg;+ };+ const Lp = pan(-1), Rp = pan(1);+ let angle = 0;+ const place = a => {+ const r = a * Math.PI / 180, dx = L * Math.cos(r), dy = L * Math.sin(r);+ put(beam, { r: -a }); put(Lp, { x: x - dx, y: y + dy }); put(Rp, { x: x + dx, y: y - dy });+ };+ return {+ g, L: Lp, R: Rp,+ // Content sits on a pan: text or math at (0, 90) in pan coordinates.+ load(side, parts, color, t0, size = 44) { const e = M(side < 0 ? Lp : Rp, parts, { y: 96, size, fill: color, o: 0 }); show(e, t0); return e; },+ tilt(a, t0, run = prog) { const from = angle; angle = a; run(q => place(from + (a - from) * back(q)), t0, .9); },+ };+}+/* ---------- algebra tiles (ch23, ch25) ---------- */+const XL = 120, UN = 30; // length of x, size of 1+const TS = { x2: [XL, XL, COL.real], x: [UN, XL, COL.whole], y: [UN, 90, COL.nat], one: [UN, UN, COL.int] };+function atile(p, kind, x, y, neg = false, o = 0) {+ const [w, h, c] = TS[kind], g = G(p, { x, y, o, s: o ? 1 : .6 });+ mk('rect', { x: -w / 2, y: -h / 2, width: w, height: h, rx: 5, fill: neg ? COL.board : mix(COL.board, c, .55), stroke: neg ? COL.bad : c, 'stroke-width': neg ? 3.5 : 2.5, 'stroke-dasharray': neg ? '7 5' : '' }, g);+ g.kind = kind; g.neg = neg;+ return g;+}+const popIn = (els, t0, step = .08) => els.forEach((e, i) => tw(e, { o: 1, s: 1 }, t0 + i * step, .35, back));+// n tiles of a kind in a row starting at x.+const tileRow = (p, kind, n, x, y, neg = false, gap = 12) => Array.from({ length: n }, (_, i) => atile(p, kind, x + i * (TS[kind][0] + gap), y, neg));+// Pair each negative tile with a positive one: they move together and vanish.+function cancel(pos, negs, t0) {+ negs.forEach((n, i) => {+ const a = pos[i];+ tw(n, { x: st(a).x, y: st(a).y }, t0 + i * .3, .6);+ tw(n, { o: 0, s: .5 }, t0 + i * .3 + .7, .3); tw(a, { o: 0, s: .5 }, t0 + i * .3 + .7, .3);+ });+}+/* ---------- inequality graphs (ch26, ch27) ---------- */+// Solution ray on the number line: endpoint v, closed or open circle, dir +1 (right) or −1 (left).+function ray(p, v, closed, dir, t0, color = COL.task, run = tw) {+ const end = X(dir > 0 ? 5.7 : -5.7), g = G(p, { o: 1 });+ const line = path(g, `M${X(v)} ${Y0}H${end}`, { stroke: color, 'stroke-width': 7 }, { d: 0 });+ const head = path(g, `M${end - 18 * dir} ${Y0 - 13}L${end} ${Y0}L${end - 18 * dir} ${Y0 + 13}`, { stroke: color, 'stroke-width': 6 }, { o: 0 });+ const dot = G(g, { x: X(v), y: Y0, s: 0, o: 0 });+ mk('circle', { r: 13, fill: closed ? color : COL.board, stroke: color, 'stroke-width': 4 }, dot);+ run(dot, { s: 1, o: 1 }, t0, .4, back);+ run(line, { d: 1 }, t0 + .3, .8); run(head, { o: 1 }, t0 + 1, .2);+ return g;+}+// Segment between a and b on the number line, each end open or closed.+function segment(p, a, b, ca, cb, t0, color = COL.task, run = tw) {+ const g = G(p, { o: 1 });+ const line = path(g, `M${X(a)} ${Y0}H${X(b)}`, { stroke: color, 'stroke-width': 7 }, { d: 0 });+ const ends = [[a, ca], [b, cb]].map(([v, c]) => {+ const d = G(g, { x: X(v), y: Y0, s: 0, o: 0 });+ mk('circle', { r: 13, fill: c ? color : COL.board, stroke: color, 'stroke-width': 4 }, d);+ run(d, { s: 1, o: 1 }, t0, .4, back);+ return d;+ });+ run(line, { d: 1 }, t0 + .3, .8);+ g.parentNode.appendChild(g); ends.forEach(e => g.appendChild(e));+ return g;+}+/* ---------- equation steps (ch25 onward) ---------- */+// One line of an equation or inequality with its sign at xEq, so a column of steps lines up. note: grey hint on the right.+function eqLine(p, L, R, y, t0, { xEq = 760, fill = COL.chalk, size = 50, note, sym = '=', symFill, noteX = 1180 } = {}) {+ const g = G(p, { o: 0 });+ M(g, [].concat(L), { x: xEq - size * .6, y, size, fill, anchor: 'end' });+ M(g, [sym], { x: xEq, y, size, fill: symFill || fill });+ M(g, [].concat(R), { x: xEq + size * .6, y, size, fill, anchor: 'start' });+ if (note) T(g, note, { x: noteX, y: y - 8, size: 26, fill: COL.task, weight: 600 });+ show(g, t0);+ return g;+}+/* ---------- data on a number line: dot plots (unit 7) ---------- */+// Axis for data from lo to hi drawn between x0 and x1 at baseline y; every: label every n-th tick.+// shape 'x' draws line-plot crosses instead of dots.+// Returns D: D.V(value) -> x; D.dot(v, color, t0) stacks a dot above v; D.mark(v, color, t0, label) is a+// balance triangle under the axis that can slide with D.slide(mark, v, t0).+function dataLine(p, { lo, hi, x0 = 200, x1 = 1400, y = 600, step = 1, every = 1, t0 = .1, r = 13, size = 22, shape = 'dot' }) {+ const V = v => x0 + (v - lo) / (hi - lo) * (x1 - x0), g = G(p, { o: 0 });+ path(g, `M${x0 - 24} ${y}H${x1 + 24}`, { stroke: COL.dim, 'stroke-width': 3 });+ for (let v = lo, i = 0; v <= hi + 1e-9; v += step, i++) {+ path(g, `M${V(v)} ${y - 7}V${y + 7}`, { stroke: COL.dim, 'stroke-width': 2 });+ if (i % every === 0) T(g, num(+v.toFixed(6)), { x: V(v), y: y + 26 + size, size, fill: COL.dim, font: MATH, anchor: 'middle' });+ }+ show(g, t0);+ const D = {+ g, V, y, r, count: {},+ top: v => y - 6 - r - ((D.count[v] || 1) - 1) * (2 * r + 5),+ dot(v, color, t0, { run = tw, into = p, from } = {}) {+ D.count[v] = (D.count[v] || 0) + 1;+ let d;+ if (shape === 'x') { d = G(into); path(d, `M${-r * .75} ${-r * .75}L${r * .75} ${r * .75}M${r * .75} ${-r * .75}L${-r * .75} ${r * .75}`, { stroke: color, 'stroke-width': 5 }); }+ else d = mk('circle', { r, fill: color, stroke: COL.board, 'stroke-width': 2 }, into);+ put(d, { x: V(v), y: D.top(v), s: 0, o: 0 });+ if (from !== undefined) { put(d, { y: from, s: 1 }); run(d, { o: 1 }, t0, .2); run(d, { y: D.top(v) }, t0, .7, back); }+ else run(d, { s: 1, o: 1 }, t0, .45, back);+ return d;+ },+ dots: (vals, color, t0, gap = .15, opts) => vals.map((v, i) => D.dot(v, color, t0 + i * gap, opts)),+ mark(v, color, t0, label, { run = tw, into = p } = {}) {+ const m = G(into, { x: V(v), y, o: 0 });+ path(m, 'M0 4L-17 30H17Z', { fill: color, stroke: COL.board, 'stroke-width': 2 });+ if (label) T(m, label, { y: 64 + size, size: 24, fill: color, weight: 600, anchor: 'middle' });+ run(m, { o: 1 }, t0, .4);+ return m;+ },+ slide: (m, v, t0, run = tw, dur = 1.2) => run(m, { x: V(v) }, t0, dur),+ // Bracket above the data from a to b at height yb, with a label.+ span(a, b, yb, label, color, t0, { run = tw, into = p } = {}) {+ const g = G(into), l = path(g, `M${V(a)} ${yb + 12}V${yb}H${V(b)}V${yb + 12}`, { stroke: color, 'stroke-width': 3 }, { d: 0 });+ run(l, { d: 1 }, t0, .6);+ const t = M(g, [label], { x: (V(a) + V(b)) / 2, y: yb - 14, size: 28, fill: color, o: 0 });+ run(t, { o: 1 }, t0 + .4, .4);+ return g;+ },+ };+ return D;+}+/* ---------- chance: number cubes, coins, spinners (unit 7) ---------- */+// A number cube face showing n pips, centred on (x, y).+const PIPS = { 1: [[0, 0]], 2: [[-1, -1], [1, 1]], 3: [[-1, -1], [0, 0], [1, 1]], 4: [[-1, -1], [1, -1], [-1, 1], [1, 1]],+ 5: [[-1, -1], [1, -1], [0, 0], [-1, 1], [1, 1]], 6: [[-1, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [1, 1]] };+function die(p, n, x, y, s = 96, o = 0) {+ const g = G(p, { x, y, o, s: o ? 1 : .6 });+ g._box = mk('rect', { x: -s / 2, y: -s / 2, width: s, height: s, rx: s * .18, fill: mix(COL.board, COL.chalk, .1), stroke: COL.chalk, 'stroke-width': 3 }, g);+ PIPS[n].forEach(([a, b]) => mk('circle', { cx: a * s * .26, cy: b * s * .26, r: s * .085, fill: COL.chalk }, g));+ return g;+}+// Spinner with equal sections; pointer starts straight up. land(k) is the rotation that points at section k.+const SPIN = [COL.whole, COL.nat, COL.int, COL.whole, COL.irr, COL.nat, COL.whole, COL.int];+function spinner(p, cx, cy, r, t0, cols = SPIN) {+ const g = G(p, { x: cx, y: cy, o: 0 }), n = cols.length, secs = [];+ cols.forEach((c, i) => {+ const a1 = (-90 + i * 360 / n) * Math.PI / 180, a2 = (-90 + (i + 1) * 360 / n) * Math.PI / 180;+ secs.push(path(g, `M0 0L${r * Math.cos(a1)} ${r * Math.sin(a1)}A${r} ${r} 0 0 1 ${r * Math.cos(a2)} ${r * Math.sin(a2)}Z`,+ { fill: mix(COL.board, c, .7), stroke: COL.board, 'stroke-width': 3 }));+ });+ mk('circle', { r, fill: 'none', stroke: COL.chalk, 'stroke-width': 3 }, g);+ const ptr = G(g);+ path(ptr, `M0 ${r * .12}V${-r * .78}M-14 ${-r * .66}L0 ${-r * .8}L14 ${-r * .66}`, { stroke: COL.chalk, 'stroke-width': 7 });+ mk('circle', { r: 12, fill: COL.chalk }, g);+ show(g, t0);+ return { g, secs, ptr, land: k => (k + .5) * 360 / n };+}+// Outline some spinner sections: a bright border that fades in.+function outline(p, sp, ks, color, t0, run = tw) {+ return ks.map(k => { const e = sp.secs[k].cloneNode(); e.setAttribute('fill', 'none'); e.setAttribute('stroke', color); e.setAttribute('stroke-width', 7); sp.g.insertBefore(e, sp.ptr); put(e, { o: 0 }); run(e, { o: 1 }, t0, .4); return e; });+}+// A coin face.+function coin(p, side, x, y, t0, r = 34, run = tw) {+ const g = G(p, { x, y, s: .5, o: 0 });+ mk('circle', { r, fill: mix(COL.board, side === 'H' ? COL.int : COL.rat, .5), stroke: side === 'H' ? COL.int : COL.rat, 'stroke-width': 3 }, g);+ T(g, side, { y: r * .36, size: r, fill: COL.chalk, weight: 700, anchor: 'middle' });+ run(g, { s: 1, o: 1 }, t0, .45, back);+ return g;+}+/* ---------- scaled axes for data and real-world graphs (ch41 onward) ---------- */+// Axes with a scale on each; returns value -> pixel maps. ybreak draws a zigzag when y does not start at 0.+function axes(p, { x0, y0, w, h, xs: [xlo, xhi, xst], ys: [ylo, yhi, yst], xl, yl, t0, ybreak }) {+ const PX = v => x0 + (v - xlo) / (xhi - xlo) * w, PY = v => y0 - (v - ylo) / (yhi - ylo) * h, g = G(p, { o: 0 });+ let d = '';+ for (let v = xlo + xst; v <= xhi + 1e-9; v += xst) d += `M${PX(v)} ${y0}V${y0 - h}`;+ for (let v = ylo + yst; v <= yhi + 1e-9; v += yst) d += `M${x0} ${PY(v)}H${x0 + w}`;+ mk('path', { d, stroke: COL.chalk, 'stroke-opacity': .1, 'stroke-width': 1.5, fill: 'none' }, g);+ path(g, `M${x0} ${y0 - h - 20}V${y0}H${x0 + w + 20}`, { stroke: COL.chalk, 'stroke-width': 3 });+ if (ybreak) path(g, `M${x0 - 10} ${y0 - 22}L${x0 + 10} ${y0 - 30}M${x0 - 10} ${y0 - 34}L${x0 + 10} ${y0 - 42}`, { stroke: COL.chalk, 'stroke-width': 3 });+ for (let v = xlo; v <= xhi + 1e-9; v += xst) T(g, String(v), { x: PX(v), y: y0 + 30, size: 20, fill: COL.dim, font: MATH, anchor: 'middle' });+ for (let v = ylo; v <= yhi + 1e-9; v += yst) T(g, String(v), { x: x0 - 14, y: PY(v) + 7, size: 20, fill: COL.dim, font: MATH, anchor: 'end' });+ T(g, xl, { x: x0 + w / 2, y: y0 + 66, size: 24, fill: COL.dim, anchor: 'middle' });+ T(g, yl, { x: x0, y: y0 - h - 36, size: 24, fill: COL.dim, anchor: 'middle' });+ show(g, t0);+ return { PX, PY };+}+/* ---------- area grids for multiplying and factoring polynomials (ch51 onward) ---------- */+// Area grid from (x0, y0): column widths ws, row heights hs, factor terms along the top and the left side.+function areaGrid(p, x0, y0, ws, hs, colLab, rowLab, t0, { size = 40 } = {}) {+ const xs = [x0], ys = [y0];+ ws.forEach(w => xs.push(xs.at(-1) + w)); hs.forEach(h => ys.push(ys.at(-1) + h));+ let d = '';+ xs.forEach(x => { d += `M${x} ${y0}V${ys.at(-1)}`; }); ys.forEach(y => { d += `M${x0} ${y}H${xs.at(-1)}`; });+ draw(path(p, d, { stroke: COL.chalk, 'stroke-width': 3 }, { d: 0 }), t0, .9);+ colLab.forEach((l, j) => show(M(p, [].concat(l), { x: (xs[j] + xs[j + 1]) / 2, y: y0 - 22, size, fill: COL.whole, o: 0 }), t0 + .3 + j * .15));+ rowLab.forEach((l, i) => show(M(p, [].concat(l), { x: x0 - 24, y: (ys[i] + ys[i + 1]) / 2 + size * .35, size, fill: COL.nat, anchor: 'end', o: 0 }), t0 + .3 + i * .15));+ const box = (i, j, pad) => ({ x: xs[j] + pad, y: ys[i] + pad, width: xs[j + 1] - xs[j] - 2 * pad, height: ys[i + 1] - ys[i] - 2 * pad });+ return {+ xs, ys,+ cell(i, j, parts, t0, { fill = COL.chalk, tint, run = tw, into = p } = {}) {+ if (tint) { const r = put(mk('rect', { ...box(i, j, 3), fill: tint }, into), { o: 0 }); into.insertBefore(r, into.firstChild); run(r, { o: .3 }, t0, .4); }+ const e = M(into, [].concat(parts), { x: (xs[j] + xs[j + 1]) / 2, y: (ys[i] + ys[i + 1]) / 2 + size * .35, size, fill, o: 0, s: .6 });+ run(e, { o: 1, s: 1 }, t0, .4, back);+ return e;+ },+ ring(i, j, color, t0, run = tw, into = p) { const r = put(mk('rect', { ...box(i, j, 8), rx: 12, fill: 'none', stroke: color, 'stroke-width': 4.5 }, into), { o: 0 }); run(r, { o: 1 }, t0, .3); return r; },+ };+}+// A curved arrow from (x1, y1) to (x2, y2) bending up (h < 0) or down (h > 0).+function arc(p, x1, y1, x2, y2, h, color, t0, run = tw) {+ const mx = (x1 + x2) / 2, l = path(p, `M${x1} ${y1}Q${mx} ${y1 + h} ${x2} ${y2}`, { stroke: color, 'stroke-width': 3.5 }, { d: 0 });+ run(l, { d: 1 }, t0, .5);+ return l;+}++/* ---------- built-up fractions with math above and below the bar (ch60 onward) ---------- */+// Width of math parts at a size, without leaving anything on the stage.+function mathW(parts, size) { const e = M(scene, [].concat(parts), { size, o: 0 }), w = e._w; e.remove(); return w; }+// A built-up fraction whose top and bottom are math parts (they may hold radicals); bar on y. Returns { g, w, t, b, x0 }.+function frac(p, top, bot, x, y, t0, { size = 56, fill = COL.chalk, anchor = 'start', topFill, botFill } = {}) {+ const g = G(p, { o: 0 });+ const w = Math.max(mathW(top, size), mathW(bot, size)) + size * .3;+ const x0 = anchor === 'middle' ? x - w / 2 : x;+ const t = M(g, [].concat(top), { x: x0 + w / 2, y: y - size * .25, size, fill: topFill || fill });+ const b = M(g, [].concat(bot), { x: x0 + w / 2, y: y + size * 1.05, size, fill: botFill || fill });+ path(g, `M${x0} ${y}H${x0 + w}`, { stroke: fill, 'stroke-width': size * .05 });+ if (t0 !== undefined) show(g, t0);+ return { g, w, t, b, x0 };+}++/* ---------- coordinate plane (unit 6 onward) ---------- */+// Grid centred on the origin at (cx, cy); u pixels per unit; x from x0 to x1, y from y0 to y1.+// Returns { g, PX, PY, u, ... } with helpers to plot points, walk to a point, and draw lines.+// The grid stays in p; marks go into P.layer (set it to the current panel so marks clear with the step) or opts.into.+function plane(p, { cx = 800, cy = 450, u = 50, x0 = -6, x1 = 6, y0 = -6, y1 = 6, t0 = .1, labels = true, step = 1 } = {}) {+ const PX = x => cx + x * u, PY = y => cy - y * u, g = G(p, { o: 0 });+ let d = '';+ for (let x = x0; x <= x1; x++) if (x) d += `M${PX(x)} ${PY(y0)}V${PY(y1)}`;+ for (let y = y0; y <= y1; y++) if (y) d += `M${PX(x0)} ${PY(y)}H${PX(x1)}`;+ mk('path', { d, stroke: COL.chalk, 'stroke-opacity': .1, 'stroke-width': 1.5, fill: 'none' }, g);+ const ax = { stroke: COL.chalk, 'stroke-width': 3 };+ path(g, `M${PX(x0 - .5)} ${cy}H${PX(x1 + .5)}M${PX(x1 + .5) - 14} ${cy - 9}L${PX(x1 + .5)} ${cy}L${PX(x1 + .5) - 14} ${cy + 9}`, ax);+ path(g, `M${cx} ${PY(y0 - .5)}V${PY(y1 + .5)}M${cx - 9} ${PY(y1 + .5) + 14}L${cx} ${PY(y1 + .5)}L${cx + 9} ${PY(y1 + .5) + 14}`, ax);+ T(g, 'x', { x: PX(x1 + .5) + 10, y: cy + 30, size: 28, fill: COL.dim, font: MATH, anchor: 'middle' }).setAttribute('font-style', 'italic');+ T(g, 'y', { x: cx - 26, y: PY(y1 + .5) + 10, size: 28, fill: COL.dim, font: MATH, anchor: 'middle' }).setAttribute('font-style', 'italic');+ if (labels) {+ for (let x = x0; x <= x1; x += step) if (x) T(g, num(x), { x: PX(x), y: cy + 26, size: 18, fill: COL.dim, font: MATH, anchor: 'middle' });+ for (let y = y0; y <= y1; y += step) if (y) T(g, num(y), { x: cx - 12, y: PY(y) + 6, size: 18, fill: COL.dim, font: MATH, anchor: 'end' });+ }+ show(g, t0, .5);+ const P = {+ g, PX, PY, u, cx, cy, x0, x1, y0, y1, layer: null,+ dot(x, y, color, t0, { r = 10, label, run = tw, dx = 14, dy = -14, anchor = 'start', into = P.layer || p, open = false } = {}) {+ const d = G(into, { x: PX(x), y: PY(y), s: 0, o: 0 });+ mk('circle', open ? { r, fill: COL.board, stroke: color, 'stroke-width': 3.5 } : { r, fill: color, stroke: COL.board, 'stroke-width': 2 }, d);+ run(d, { s: 1, o: 1 }, t0, .4, back);+ if (label) { const l = M(into, [label], { x: PX(x) + dx, y: PY(y) + dy, size: 26, fill: color, anchor, o: 0 }); run(l, { o: 1 }, t0 + .2, .3); }+ return d;+ },+ // Walk from the origin: along x, then along y, drawing arrows; then a dot.+ walk(x, y, t0, { cx: colX = COL.whole, cy: colY = COL.nat, run = tw, color = COL.task, label, into = P.layer || p } = {}) {+ const a = path(into, `M${PX(0)} ${PY(0)}H${PX(x)}`, { stroke: colX, 'stroke-width': 5 }, { d: 0 });+ const b = path(into, `M${PX(x)} ${PY(0)}V${PY(y)}`, { stroke: colY, 'stroke-width': 5 }, { d: 0 });+ run(a, { d: 1 }, t0, .3 + Math.abs(x) * .12, lin);+ run(b, { d: 1 }, t0 + .4 + Math.abs(x) * .12, .3 + Math.abs(y) * .12, lin);+ return P.dot(x, y, color, t0 + .8 + (Math.abs(x) + Math.abs(y)) * .12, { run, label, into });+ },+ // Arrow from (xa, ya) to (xb, yb) with an optional label beside its middle.+ arrow(xa, ya, xb, yb, color, t0, { label, run = tw, into = P.layer || p } = {}) {+ const a = [PX(xa), PY(ya)], b = [PX(xb), PY(yb)], L = Math.hypot(b[0] - a[0], b[1] - a[1]), ux = (b[0] - a[0]) / L, uy = (b[1] - a[1]) / L;+ const l = path(into, `M${a[0]} ${a[1]}L${b[0]} ${b[1]}M${b[0] - 12 * ux - 8 * uy} ${b[1] - 12 * uy + 8 * ux}L${b[0]} ${b[1]}L${b[0] - 12 * ux + 8 * uy} ${b[1] - 12 * uy - 8 * ux}`, { stroke: color, 'stroke-width': 4 }, { d: 0 });+ run(l, { d: 1 }, t0, .5);+ if (label !== undefined) {+ const vert = Math.abs(uy) > Math.abs(ux);+ const t = M(into, [label], { x: (a[0] + b[0]) / 2 + (vert ? -24 : 0), y: (a[1] + b[1]) / 2 + (vert ? 9 : -12), size: 26, fill: color, anchor: vert ? 'end' : 'middle', o: 0 });+ run(t, { o: 1 }, t0 + .3, .3);+ }+ return l;+ },+ // One slope step from (x, y): rise first (irr green), then run (real violet).+ stair(x, y, rise, runX, t0, { run = tw, into = P.layer || p, labels = true } = {}) {+ P.arrow(x, y, x, y + rise, COL.irr, t0, { label: labels ? num(rise) : undefined, run, into });+ P.arrow(x, y + rise, x + runX, y + rise, COL.real, t0 + .6, { label: labels ? num(runX) : undefined, run, into });+ },+ // Shade the region where every a·x + b·y ≥ c in the list holds, clipped to the grid.+ region(list, color, t0, { run = tw, into = P.layer || p, o = .22 } = {}) {+ let pts = [[x0, y0], [x1, y0], [x1, y1], [x0, y1]];+ for (const [a, b, c] of list) {+ const f = ([x, y]) => a * x + b * y - c, next = [];+ pts.forEach((v, i) => {+ const w = pts[(i + 1) % pts.length], fv = f(v), fw = f(w);+ if (fv >= 0) next.push(v);+ if (fv * fw < 0) { const t = fv / (fv - fw); next.push([v[0] + t * (w[0] - v[0]), v[1] + t * (w[1] - v[1])]); }+ });+ pts = next;+ }+ const e = path(into, pts.length ? 'M' + pts.map(([x, y]) => `${PX(x)} ${PY(y)}`).join('L') + 'Z' : '', { fill: color, stroke: 'none' }, { o: 0 });+ into.insertBefore(e, into.firstChild);+ run(e, { o }, t0, .6);+ return e;+ },+ half: (a, b, c, color, t0, opts) => P.region([[a, b, c]], color, t0, opts),+ // Graph of y = f(x) for x from xa to xb, drawn on; the part outside the grid's y range is cut off.+ fn(f, xa, xb, color, t0, { run = tw, w = 4, into = P.layer || p, n = 160, dur = 1.2 } = {}) {+ let d = '', pen = false;+ for (let i = 0; i <= n; i++) {+ const x = xa + (xb - xa) * i / n, y = f(x), inside = y >= y0 - .5 && y <= y1 + .5;+ if (inside) { d += `${pen ? 'L' : 'M'}${PX(x).toFixed(1)} ${PY(y).toFixed(1)}`; pen = true; } else pen = false;+ }+ const l = path(into, d, { stroke: color, 'stroke-width': w }, { d: 0 });+ run(l, { d: 1 }, t0, dur);+ return l;+ },+ // Line through two points, extended to the edge of the grid.+ line(xa, ya, xb, yb, color, t0, { run = tw, w = 4, dash, into = P.layer || p } = {}) {+ const dx = xb - xa, dy = yb - ya, ts = [];+ const clip = (t, v, lo, hi) => { if (v >= lo - 1e-9 && v <= hi + 1e-9) ts.push(t); };+ if (dx) { for (const X of [x0, x1]) { const t = (X - xa) / dx; clip(t, ya + t * dy, y0, y1); } }+ if (dy) { for (const Y of [y0, y1]) { const t = (Y - ya) / dy; clip(t, xa + t * dx, x0, x1); } }+ const t1 = Math.min(...ts), t2 = Math.max(...ts);+ // A dashed line fades in: drawing it on would need the dash array for the reveal.+ const l = path(into, `M${PX(xa + t1 * dx)} ${PY(ya + t1 * dy)}L${PX(xa + t2 * dx)} ${PY(ya + t2 * dy)}`, { stroke: color, 'stroke-width': w, ...(dash ? { 'stroke-dasharray': dash } : {}) }, dash ? { o: 0 } : { d: 0 });+ run(l, dash ? { o: 1 } : { d: 1 }, t0, dash ? .6 : 1);+ return l;+ },+ };+ return P;+}+// Question: pick a grid point. ans = [x, y]; no(x, y) explains a wrong pick. Arrows move a cursor, Enter picks.+// test(x, y), when given, accepts any point it approves; ans is then the point Show answer uses.+const pickPoint = (P, ans, yes, no, onRight, test) => (body, api) => {+ const L = qlayer();+ let cur = [0, 0], locked = false;+ const cursor = G(L, { x: P.PX(0), y: P.PY(0) });+ mk('circle', { r: 16, fill: 'none', stroke: COL.task, 'stroke-width': 3 }, cursor);+ let tag = null;+ const moveTo = (x, y) => {+ cur = [Math.max(P.x0, Math.min(P.x1, x)), Math.max(P.y0, Math.min(P.y1, y))];+ put(cursor, { x: P.PX(cur[0]), y: P.PY(cur[1]) });+ tag?.remove();+ tag = M(L, [`(${num(cur[0])}, ${num(cur[1])})`], { x: P.PX(cur[0]) + 22, y: P.PY(cur[1]) - 18, size: 24, fill: COL.task, anchor: 'start' });+ };+ moveTo(0, 0);+ const pick = () => {+ if (locked) return;+ const [x, y] = cur;+ if (test ? test(x, y) : x === ans[0] && y === ans[1]) { P.dot(x, y, COL.good, 0, { run: fx, into: L }); onRight?.(); api.grade(true, typeof yes === 'function' ? yes(x, y) : yes); }+ else { const d = P.dot(x, y, COL.bad, 0, { run: fx, r: 8, into: L }); fx(d, { o: 0 }, 1.2, .4); shakeFx(cursor); api.grade(false, no(x, y)); }+ };+ const hit = mk('rect', { x: P.PX(P.x0 - .5), y: P.PY(P.y1 + .5), width: (P.x1 - P.x0 + 1) * P.u, height: (P.y1 - P.y0 + 1) * P.u, fill: 'transparent' }, L);+ L.insertBefore(hit, L.firstChild);+ hit.style.cursor = 'crosshair';+ hit.addEventListener('click', e => {+ if (locked) return;+ const s = $('stage'), pt = s.createSVGPoint(); pt.x = e.clientX; pt.y = e.clientY;+ const q = pt.matrixTransform(s.getScreenCTM().inverse());+ moveTo(Math.round((q.x - P.cx) / P.u), Math.round((P.cy - q.y) / P.u));+ pick();+ });+ return {+ reveal() { moveTo(...ans); P.dot(ans[0], ans[1], COL.good, 0, { run: fx, into: L }); onRight?.(); return typeof yes === 'function' ? yes(...ans) : yes; },+ lock() { locked = true; },+ hint: [kbd('←'), kbd('↑'), kbd('↓'), kbd('→'), translate('hintMove'), kbd('Enter'), translate('hintChooseOrClickGrid')],+ key(e) {+ if (locked) return false;+ const d = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] }[e.key];+ if (d) { moveTo(cur[0] + d[0], cur[1] + d[1]); return true; }+ if (e.key === 'Enter') { pick(); return true; }+ return false;+ },+ };+};+/* ---------- signed numbers: number-line moves and plus/minus tiles ---------- */+const POS = COL.whole, NEG = COL.nat; // positive: blue, negative: coral+// Integer number line from lo to hi with arrows at both ends, drawn into S.line.+function numberLine(t0 = .1, lo = -8, hi = 8) {+ const L = S.line;+ draw(path(L, `M${X(lo - .7)} ${Y0}H${X(hi + .7)}`, { stroke: COL.chalk, 'stroke-width': 3 }, { d: 0 }), t0, .8);+ for (const [x, d] of [[X(hi + .7), 1], [X(lo - .7), -1]]) {+ show(path(L, `M${x - 15 * d} ${Y0 - 10}L${x} ${Y0}L${x - 15 * d} ${Y0 + 10}`, { stroke: COL.chalk, 'stroke-width': 3 }, { o: 0 }), t0 + .7, .3);+ }+ for (let v = lo; v <= hi; v++) show(tick(v), t0 + .2 + Math.abs(v) * .04, .4);+}+// A move along the number line from a to b, drawn as an arrow at height y. run = tw (lesson) or fx (answer).+function move(p, a, b, y, t0, run = tw) {+ const x1 = X(a), x2 = X(b), d = Math.sign(b - a), color = d > 0 ? POS : NEG;+ const dur = .35 + Math.abs(b - a) * .09;+ const line = path(p, `M${x1} ${y}H${x2}`, { stroke: color, 'stroke-width': 5 }, { d: 0 });+ const head = path(p, `M${x2 - 15 * d} ${y - 11}L${x2} ${y}L${x2 - 15 * d} ${y + 11}`, { stroke: color, 'stroke-width': 5 }, { o: 0 });+ const lab = T(p, (d > 0 ? '+' : '−') + Math.abs(b - a), { x: (x1 + x2) / 2, y: y - 16, size: 28, fill: color, font: MATH, anchor: 'middle', o: 0 });+ const drop = path(p, `M${x2} ${y + 12}V${Y0 - 14}`, { stroke: color, 'stroke-width': 2, 'stroke-dasharray': '5 6' }, { o: 0 });+ run(line, { d: 1 }, t0, dur, lin); run(head, { o: 1 }, t0 + dur - .1, .15);+ run(lab, { o: 1 }, t0 + .2, .3); run(drop, { o: .8 }, t0 + dur, .3);+}+function landDot(p, v, t0, color = COL.chalk, run = tw) {+ const g = G(p, { x: X(v), y: Y0, s: 0, o: 0 });+ mk('circle', { r: 12, fill: color, stroke: COL.board, 'stroke-width': 2 }, g);+ run(g, { s: 1, o: 1 }, t0, .45, back);+ return g;+}+function tile(p, sign, x, y, o = 0) {+ const c = sign > 0 ? POS : NEG, g = G(p, { x, y, o, s: o ? 1 : .6 });+ mk('rect', { x: -27, y: -27, width: 54, height: 54, rx: 10, fill: mix(COL.board, c, .45), stroke: c, 'stroke-width': 2.5 }, g);+ M(g, [sign > 0 ? '+' : '−'], { y: 13, size: 40 });+ return g;+}+const tiles = (p, n, sign, x0, y, gap = 70) => Array.from({ length: n }, (_, i) => tile(p, sign, x0 + i * gap, y));+const popAll = (els, t0, step = .08) => els.forEach((e, i) => tw(e, { o: 1, s: 1 }, t0 + i * step, .35, back));+// Circle each plus/minus pair, then let the pairs vanish: they make zero.+function cancelPairs(p, tops, bottoms, t0) {+ tops.forEach((a, i) => {+ const b = bottoms[i], x = st(a).x, y1 = st(a).y, y2 = st(b).y;+ const ring = put(mk('rect', { rx: 18, fill: 'none', stroke: COL.dim, 'stroke-width': 2.5, 'stroke-dasharray': '8 6' }, p),+ { o: 0, a_x: x - 38, a_y: y1 - 38, a_width: 76, a_height: y2 - y1 + 76 });+ tw(ring, { o: 1 }, t0 + i * .2, .3);+ for (const e of [a, b, ring]) tw(e, { o: 0, ...(e === ring ? {} : { s: .5 }) }, t0 + 1.4 + i * .1, .4);+ });+}+function brace(p, a, b, y, label, color, t0) {+ const x1 = X(a), x2 = X(b);+ draw(path(p, `M${x1} ${y - 10}V${y}H${x2}V${y - 10}`, { stroke: color, 'stroke-width': 3 }, { d: 0 }), t0, .6);+ show(T(p, label, { x: (x1 + x2) / 2, y: y + 34, size: 26, fill: color, anchor: 'middle', o: 0 }), t0 + .4);+}++/* ---------- number map geometry ---------- */+const RINGS = {+ real: { cx: 640, cy: 470, rx: 610, ry: 390, lx: 640, ly: 128 },+ rat: { cx: 500, cy: 480, rx: 400, ry: 320, lx: 500, ly: 202 },+ int: { cx: 500, cy: 510, rx: 300, ry: 250, lx: 500, ly: 302 },+ whole: { cx: 500, cy: 540, rx: 210, ry: 180, lx: 500, ly: 400 },+ nat: { cx: 500, cy: 570, rx: 125, ry: 110, lx: 500, ly: 500 },+ irr: { cx: 1060, cy: 480, rx: 140, ry: 170, lx: 1060, ly: 360 },+};+const CHAIN = { nat: ['nat', 'whole', 'int', 'rat', 'real'], whole: ['whole', 'int', 'rat', 'real'], int: ['int', 'rat', 'real'], rat: ['rat', 'real'], irr: ['irr', 'real'], real: ['real'] };+const ell = r => `M${r.cx} ${r.cy - r.ry}A${r.rx} ${r.ry} 0 1 1 ${r.cx} ${r.cy + r.ry}A${r.rx} ${r.ry} 0 1 1 ${r.cx} ${r.cy - r.ry}`;+const inRing = (k, x, y) => { const r = RINGS[k]; return ((x - r.cx) / r.rx) ** 2 + ((y - r.cy) / r.ry) ** 2 <= 1; };+function regionAt(x, y) {+ for (const k of ['nat', 'whole', 'int', 'rat', 'irr', 'real']) if (inRing(k, x, y)) return k;+ return null;+}+function buildVenn(parent, hidden) {+ const out = {};+ for (const k of ['real', 'rat', 'int', 'whole', 'nat', 'irr']) {+ const r = RINGS[k], g = G(parent);+ const fill = path(g, ell(r), { fill: mix(COL.board, COL[k], k === 'real' ? .1 : .16), stroke: 'none' }, { o: hidden ? 0 : 1 });+ const stroke = path(g, ell(r), { stroke: COL[k], 'stroke-width': 3 }, hidden ? { d: 0, 'a_stroke-width': 3 } : { 'a_stroke-width': 3 });+ const lab = T(g, NAME[k], { x: r.lx, y: r.ly, size: 26, fill: COL[k], weight: 600, anchor: 'middle', o: hidden ? 0 : 1 });+ out[k] = { g, fill, stroke, lab };+ }+ return out;+}+function glow(key, t0) {+ const s = S.ring[key].stroke;+ tw(s, { 'a_stroke-width': 9 }, t0, .22, out); tw(s, { 'a_stroke-width': 3 }, t0 + .25, .5);+}+function glowRun(key, t0) { CHAIN[key].forEach((k, i) => glow(k, t0 + i * .3)); }+const glowFx = (key, delay = 0) => CHAIN[key].forEach((k, i) => {+ const s = S.ring[k].stroke;+ fx(s, { 'a_stroke-width': 9 }, delay + i * .28, .22, out); fx(s, { 'a_stroke-width': 3 }, delay + i * .28 + .25, .5);+});+function popDotFx(key, v, label) {+ const L = S.q || qlayer();+ const g = G(L, { x: X(v), y: Y0, s: 0, o: 0 });+ mk('circle', { r: 7, fill: COL[key], stroke: COL.board, 'stroke-width': 2 }, g);+ fx(g, { s: 1, o: 1 }, 0, .45, back);+ if (label) fx(M(L, label, { x: X(v) + 10, y: Y0 + 56, size: 28, fill: COL[key], o: 0 }), { o: 1 }, .3, .4);+}+function hopsFx(n) {+ for (let k = 1; k <= -n; k++) {+ const a = X(1 - k), b = X(-k);+ fx(path(S.q, `M${a} ${Y0 - 12}Q${(a + b) / 2} ${Y0 - 84} ${b} ${Y0 - 12}`, { stroke: COL.int, 'stroke-width': 3 }, { d: 0 }), { d: 1 }, (k - 1) * .35, .35, lin);+ }+ floatText(translate('stepsLeftOfZero', { n: -n }), X(n / 2), Y0 - 100, COL.int);+}+const FAMILIES = ['nat', 'whole', 'int', 'rat', 'irr', 'real'];+const FAM_COLS = FAMILIES.map(k => [k, k === 'int' ? translate('integerColumn') : NAME[k], COL[k]]);+const RING_KEYS = ['nat', 'whole', 'int', 'rat', 'irr', 'real']; // number keys 1–6 in sorting questions+// Drag number chips into the stage number map. items: [parts, smallest ring, explanation].+const slot = (k, n) => {+ if (k === 'real') return [[940, 210], [1000, 760], [820, 800]][n % 3]; // inside Real, outside every other ring+ const r = RINGS[k];+ return [r.lx + [-72, 72, 0][n % 3], r.ly + 50 + 56 * Math.floor(n / 2)];+};+const plain = parts => parts.map(p => typeof p === 'string' ? p : p.ov !== undefined ? p.ov + ' repeating' : p.tex !== undefined ? p.tex : p.f ? p.f.join('/') : p.sup !== undefined ? '^' + p.sup : (p.i ? p.i : '') + '√' + (p.r.f ? p.r.f.join('/') : p.r)).join('');+const sorter = (items, trayXY) => (body, api) => {+ const L = qlayer();+ const bg = mk('rect', { width: 1600, height: 900, fill: 'transparent' }, L);+ const svg = $('stage');+ const pt = e => { const p = svg.createSVGPoint(); p.x = e.clientX; p.y = e.clientY; return p.matrixTransform(svg.getScreenCTM().inverse()); };+ let sel = null, drag = null, locked = false;+ const label = c => c.setAttribute('aria-label', c.region ? translate('chipPlaced', { x: c.say, ring: NAME[c.region] }) : translate('chipNotPlaced', { x: c.say }));+ const outline = (c, colr, w = 2.5) => { c._rect.setAttribute('stroke', colr); c._rect.setAttribute('stroke-width', w); };+ const choose = c => {+ if (sel) outline(sel, COL.chalk);+ sel = c;+ if (sel) { outline(sel, COL.task, 4); L.append(sel); }+ };+ const select = c => choose(sel === c ? null : c);+ // Number badges next to the ring names, for keys 1–6.+ RING_KEYS.forEach((k, i) => {+ const r = RINGS[k], g = G(L, { x: r.lx - uiW(NAME[k], 26) / 2 - 24, y: r.ly - 9 });+ g.style.pointerEvents = 'none';+ mk('circle', { r: 14, fill: COL.board, stroke: COL[k], 'stroke-width': 1.5 }, g);+ T(g, String(i + 1), { y: 6.5, size: 18, fill: COL[k], anchor: 'middle', weight: 600 });+ });+ const place = (c, x, y) => {+ c.region = regionAt(x, y);+ if (!c.region) [x, y] = c.home;+ put(c, { x, y });+ outline(c, COL.chalk);+ c.querySelector('.mark')?.remove();+ if (sel === c) sel = null;+ label(c);+ };+ const chips = items.map(([parts, answer, why], i) => {+ const [x, y] = trayXY(i);+ const c = chip(L, parts, COL.chalk, { x, y, size: 32 });+ Object.assign(c, { answer, why, home: [x, y], region: null, say: plain(parts) });+ c.classList.add('tok');+ c.setAttribute('tabindex', 0);+ c.setAttribute('role', 'button');+ label(c);+ c.addEventListener('pointerdown', e => {+ if (locked) return;+ e.preventDefault();+ const p = pt(e);+ drag = { dx: p.x - st(c).x, dy: p.y - st(c).y, sx: p.x, sy: p.y, moved: false };+ L.append(c); // re-parent before capturing: moving a node drops its capture+ c.setPointerCapture(e.pointerId);+ });+ c.addEventListener('pointermove', e => {+ if (!drag) return;+ const p = pt(e);+ if (Math.hypot(p.x - drag.sx, p.y - drag.sy) > 6) drag.moved = true;+ if (drag.moved) put(c, { x: p.x - drag.dx, y: p.y - drag.dy });+ });+ c.addEventListener('pointerup', () => {+ if (!drag) return;+ const moved = drag.moved;+ drag = null;+ if (moved) place(c, st(c).x, st(c).y); else select(c);+ });+ // A cancelled drag (a system gesture, a lost capture) drops the chip where it is instead of leaving it stuck to no pointer.+ c.addEventListener('lostpointercapture', () => {+ if (!drag) return;+ const moved = drag.moved;+ drag = null;+ if (moved) place(c, st(c).x, st(c).y);+ });+ keyAct(c, () => { if (!locked) select(c); });+ return c;+ });+ bg.addEventListener('pointerup', e => { if (sel && !locked) { const p = pt(e); place(sel, p.x, p.y); } });+ return {+ check() {+ let right = 0;+ const notes = h('ul');+ for (const c of chips) {+ c.querySelector('.mark')?.remove();+ if (!c.region) { notes.append(h('li', '', translate('notPlacedYet', { x: c.say }))); continue; }+ const ok = c.region === c.answer;+ right += ok;+ outline(c, ok ? COL.good : COL.bad, 4);+ if (ok) { pulseFx(c, 1.25); glowFx(c.answer, right * .15); } else shakeFx(c);+ const w = +c._rect.getAttribute('width');+ T(c, ok ? '✓' : '✗', { x: w / 2 + 4, y: -16, size: 26, fill: ok ? COL.good : COL.bad, weight: 700 }).classList.add('mark');+ if (!ok) notes.append(h('li', '', c.region === 'real'+ ? translate('realRingIsEmpty', { x: c.say })+ : c.why));+ }+ const all = right === chips.length;+ api.grade(all, all ? [] : [translate('ringsRight', { r: right, n: chips.length }), notes], { right, total: chips.length });+ },+ reveal() {+ const count = {};+ chips.forEach((c, i) => {+ const n = count[c.answer] = (count[c.answer] ?? -1) + 1;+ const [x, y] = slot(c.answer, n);+ c.region = c.answer;+ c.querySelector('.mark')?.remove();+ outline(c, COL.good, 4);+ fx(c, { x, y }, i * .12, .8);+ });+ return translate('ringsShown');+ },+ lock() { locked = true; choose(null); },+ hint: [kbd('←'), kbd('→'), translate('hintPickNumber'), kbd('1'), '–', kbd('6'), translate('hintPickRing')],+ key(e) {+ if (locked) return false;+ const d = e.key === 'ArrowRight' || e.key === 'ArrowDown' ? 1 : e.key === 'ArrowLeft' || e.key === 'ArrowUp' ? -1 : 0;+ if (d) {+ const i = sel ? chips.indexOf(sel) : d > 0 ? -1 : 0;+ choose(chips[(i + d + chips.length) % chips.length]);+ return true;+ }+ const ring = RING_KEYS[+e.key - 1];+ if (!ring || !sel) return false;+ const c = sel;+ place(c, ...slot(ring, chips.filter(x => x.region === ring && x !== c).length));+ choose(chips.find(x => !x.region) || null);+ return true;+ },+ };+};diff --git a/site/little-horse/lib/paper.js b/site/little-horse/lib/paper.jsnew file mode 100644index 0000000..83d11af--- /dev/null+++ b/site/little-horse/lib/paper.js@@ -0,0 +1,233 @@+/* paper.js — a paper-cutout stop-motion kit on top of the engine.+ Sets are baked bitmaps (img/sets/, from SKILL/scripts/bake_sets.py or painted.py); puppets are live SVG pieces with the+ same paper filter. Everything moves on a 12 fps clock (on twos), each frame with its own small hand jitter, so+ pause, seek and ?beat=N&t=S show exactly the frame a viewer would see. */+'use strict';+const FPS = 12;++// Filters, mouths and patterns live in their own hidden SVG: the engine clears the scene at every beat.+const PAPER_DEFS = `<defs>+ <filter id="paper" x="-15%" y="-15%" width="130%" height="135%" color-interpolation-filters="sRGB">+ <feTurbulence type="fractalNoise" baseFrequency="0.035" numOctaves="2" seed="3" result="warp"/>+ <feDisplacementMap in="SourceGraphic" in2="warp" scale="3.5" xChannelSelector="R" yChannelSelector="G" result="cut"/>+ <feTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="3" seed="7" result="fib"/>+ <feColorMatrix in="fib" type="matrix" values="0 0 0 0 .25 0 0 0 0 .17 0 0 0 0 .08 .5 0 0 0 -.14" result="tint"/>+ <feComposite in="tint" in2="cut" operator="in" result="grain"/>+ <feMerge result="tex"><feMergeNode in="cut"/><feMergeNode in="grain"/></feMerge>+ <feDropShadow in="tex" dx="2.5" dy="3.5" stdDeviation="2.2" flood-color="#2a1608" flood-opacity=".38"/>+ </filter>+ <pattern id="check" width="10" height="10" patternUnits="userSpaceOnUse">+ <rect width="10" height="10" fill="#f6efe0"/><rect width="5" height="5" fill="#c8322f"/><rect x="5" y="5" width="5" height="5" fill="#c8322f"/>+ </pattern>+ <g id="mX"><path d="M-8,-1 Q0,6 8,-1" fill="none" stroke="#5a2a1e" stroke-width="2.6" stroke-linecap="round"/></g>+ <g id="mA"><path d="M-7,1 L7,1" fill="none" stroke="#5a2a1e" stroke-width="2.6" stroke-linecap="round"/></g>+ <g id="mB"><ellipse rx="6.5" ry="2.6" fill="#6b1f1f"/></g>+ <g id="mC"><ellipse rx="7" ry="4.6" fill="#6b1f1f"/><ellipse cy="2.6" rx="4" ry="1.8" fill="#e07a78"/></g>+ <g id="mD"><path d="M-9,-3 Q0,-5 9,-3 Q8,9 0,10 Q-8,9 -9,-3Z" fill="#6b1f1f"/><ellipse cy="6.5" rx="5" ry="2.6" fill="#e07a78"/></g>+ <g id="mE"><ellipse rx="5" ry="6" fill="#6b1f1f"/></g>+ <g id="mF"><circle r="3.6" fill="#6b1f1f"/></g>+ <g id="mG"><ellipse rx="6.5" ry="2.6" fill="#6b1f1f"/><path d="M-5,-1.5 h10" stroke="#f6efe0" stroke-width="2"/></g>+ <g id="mH"><ellipse rx="6" ry="3.8" fill="#6b1f1f"/><ellipse cy="-1" rx="2.6" ry="1.6" fill="#e07a78"/></g>+ <radialGradient id="vignette" cx="50%" cy="45%" r="75%"><stop offset="60%" stop-color="#1e0f05" stop-opacity="0"/><stop offset="100%" stop-color="#1e0f05" stop-opacity=".45"/></radialGradient>+</defs>`;+document.body.insertAdjacentHTML('afterbegin', `<svg width="0" height="0" style="position:absolute" aria-hidden="true">${PAPER_DEFS}</svg>`);+// The exposure flicker is an HTML layer over the stage: changing it every frame inside the SVG would repaint the whole picture.+const FLICKER = document.getElementById('stage').insertAdjacentElement('afterend', Object.assign(document.createElement('div'),+ { style: 'position:absolute;left:0;top:0;width:1600px;height:900px;background:#000;opacity:0;pointer-events:none;will-change:opacity' }));++// Seeded noise in [-1, 1]: the same frame always gets the same jitter.+function jit(f, k) { let h = Math.imul(f * 374761393 + k * 668265263, 1274126177); h ^= h >>> 13; h = Math.imul(h, 1103515245); return ((h ^ (h >>> 16)) >>> 0) / 2147483648 - 1; }+const ease = x => x <= 0 ? 0 : x >= 1 ? 1 : x * x * (3 - 2 * x);+const span = (t, a, b) => ease((t - a) / (b - a));++// draw(q, f) runs once per 12 fps frame with q the frame's time; a pure function of time, like every beat clock.+// It runs to the beat's end, through the engine's hold after D (HOLD s), so a scene poses sensibly for q up to D + HOLD.+function stopClock(D, draw) { let last = null; clockRun(t => { const f = Math.floor(t * FPS + 1e-6); if (f === last) return; last = f; draw(f / FPS, f); }, D, { tail: true }); }++/* ---------- camera over a baked set ----------+ A view {x, y, z} is the world point at the frame's centre and the zoom. Moves: to(view, t0, dur) eases each given+ key from where the camera is at t0 (zooms keep one world point still, as the engine's camera does); cut(view, t0).+ Layers slide by their parallax factor k against the base view. soft(t0, on) swaps the far layers (k < 1) for their+ blurred copies: shallow focus on close shots (on = 'all' blurs the puppets' plane too, for a set seen behind a close-up). Puppets go in cam.stage, on the k = 1 plane in front of `after`. */+function paperCam(p, setName, v0 = {}, { after = null, stages = [] } = {}) {+ const root = mk('g', {}, p), view = mk('g', {}, root), world = mk('g', {}, view), layers = [], ops = [], softs = [], shakes = [];+ let stage = null; const stageAt = {};+ for (const L of SETS[setName]) {+ const g = mk('g', {}, world), [x, y, width, height] = L.box, img = { x, y, width, height, preserveAspectRatio: 'none' };+ const sharp = mk('image', { href: `../img/sets/${setName}/${L.name}.webp`, ...img }, g);+ const blur = L.soft ? mk('image', { href: `../img/sets/${setName}/${L.name}-soft.webp`, ...img, visibility: 'hidden' }, g) : null;+ layers.push({ g, k: L.k, sharp, blur, name: L.name });+ if (stages.includes(L.name)) layers.push({ g: stageAt[L.name] = mk('g', {}, world), k: L.k });+ if (L.name === after || (!after && L.k === 1 && !stage)) layers.push({ g: stage = mk('g', {}, world), k: 1 });+ }+ mk('rect', { width: 1600, height: 900, fill: 'url(#vignette)', 'pointer-events': 'none' }, root); // a tap goes through to the picture+ // Parallax is measured from the set's own framing (base), wherever the beat's first view is.+ const base = { x: 800, y: 450, z: 1 }, start = { ...base, ...v0 };+ function at(t, n = ops.length) {+ const s = { ...start };+ for (let i = 0; i < n && ops[i].t0 <= t; i++) {+ const o = ops[i], a = o.from || (o.from = at(o.t0, i)), q = o.dur ? ease(Math.min(1, (t - o.t0) / o.dur)) : 1;+ const v = {}; for (const k in o.v) v[k] = typeof o.v[k] === 'function' ? o.v[k](t) : o.v[k]; // a key may follow+ if ('z' in v) s.z = a.z * (v.z / a.z) ** q;+ const u = 'z' in v && Math.abs(v.z - a.z) > 1e-6 ? (1 / s.z - 1 / a.z) / (1 / v.z - 1 / a.z) : q;+ for (const k of ['x', 'y']) if (k in v) s[k] = a[k] + (v[k] - a[k]) * u;+ }+ return s;+ }+ const cam = { root, world, stage, stageAt, at,+ to(v, t0, dur = 1) { ops.push({ v, t0, dur }); ops.sort((a, b) => a.t0 - b.t0); ops.forEach(o => delete o.from); return cam; },+ cut: (v, t0) => cam.to(v, t0, 0),+ show(name, on) { for (const L of layers) if (L.name === name) vis(L.g, on); return cam; }, // swap a set layer (weather)+ soft(t0, on) { softs.push([t0, on]); softs.sort((a, b) => a[0] - b[0]); return cam; },+ shake(t0, dur, amp = 10) { shakes.push([t0, dur, amp]); return cam; },+ apply(q, f) {+ const s = at(q);+ let sx = 0, sy = 0;+ for (const [t0, d, amp] of shakes) if (q >= t0 && q < t0 + d) { sx += jit(f, 91) * amp; sy += jit(f, 92) * amp; }+ view.setAttribute('transform', `translate(${800 + sx} ${450 + sy}) scale(${s.z}) translate(${-s.x} ${-s.y})`);+ const dx = s.x - base.x, dy = s.y - base.y;+ let soft = false; for (const [t0, on] of softs) if (q >= t0) soft = on;+ for (const L of layers) {+ L.g.setAttribute('transform', `translate(${((1 - L.k) * dx).toFixed(1)} ${((1 - L.k) * dy).toFixed(1)})`);+ if (L.blur) { const b = soft === 'all' || (soft && L.k < 1); vis(L.blur, b); vis(L.sharp, !b); } // never 'visible': it would show through a hidden camera+ }+ FLICKER.style.opacity = (.02 + .02 * jit(f, 30)).toFixed(3); // the exposure flicker of real frames+ },+ };+ return cam;+}++/* ---------- small live pieces ---------- */+// Chimney smoke: paper puffs that rise, drift and fade, one cycle every `every` seconds.+function smoke(parent, x, y, n = 4, every = 3.2) {+ const puffs = Array.from({ length: n }, () => { const g = mk('g', {}, parent); g.innerHTML = '<g filter="url(#paper)"><circle r="20" fill="#f4ecdc"/></g>'; return g; });+ bakeAll(parent);+ return q => puffs.forEach((g, i) => {+ const u = ((q / every + i / n) % 1 + 1) % 1;+ tf(g, `translate(${(x + 60 * u + 12 * Math.sin(u * 6)).toFixed(1)},${(y - 190 * u).toFixed(1)}) scale(${((14 + 30 * u) / 20).toFixed(3)})`);+ g.setAttribute('opacity', (Math.min(1, u * 5) * (1 - u) * .95).toFixed(2));+ });+}++// The mouth shape a clip's cues give `t` seconds into it ('X' rest before and after).+const mouthAt = (clip, t) => { let m = 'X'; if (t < 0) return m; for (const [at, k] of MOUTHS[clip] || []) { if (at > t) break; m = k; } return m; };++/* ---------- puppets ----------+ A puppet is paper pieces on brass pins, built at its hip (0, 0) facing right, feet near y 166. pose(o, f) sets the+ whole state for frame f; any key left out keeps its rest value. A profile puppet that turns round squashes its+ side figure, shows its whole front figure through the thin middle of the turn and comes out mirrored (puppets.md). */+const pinAt = (x, y) => `<circle cx="${x}" cy="${y}" r="3.4" fill="#caa24c" stroke="#7d5f22" stroke-width="1.2"/>`;+const tf = (el, s) => { if (el._t !== s) el.setAttribute('transform', el._t = s); };+const vis = (el, on) => { const v = on ? 'inherit' : 'hidden'; if (el._v !== v) el.setAttribute('visibility', el._v = v); };++function pieces(g) { const o = {}; g.querySelectorAll('[data-p]').forEach(e => o[e.dataset.p] = e); return o; }+function face(h, o) { // eyes and mouth of one head+ h.querySelectorAll('.eyeO').forEach(e => vis(e, !o.shut)); h.querySelectorAll('.eyeC').forEach(e => vis(e, !!o.shut));+ h.querySelectorAll('.mouth').forEach(e => { const m = '#m' + (o.mouth || 'X'); if (e._m !== m) e.setAttribute('href', e._m = m); });+}+// Blinks: closed for two frames at each listed time.+const blinking = (q, times) => times.some(b => q >= b && q < b + 2 / FPS);++/* ---------- baking puppet pieces ----------+ Running the paper filter live on every piece costs too much once a close-up enlarges them, so every filtered+ piece is drawn once to a bitmap (at RES px per unit) and replaced by that image. Parts that change (eyes, mouths,+ brows, pieces with data-p) stay live; a filtered live part is baked on its own. Identical pieces share one bitmap. */+const RES = 4, bakedReady = new Map(), bakedJobs = new Map(), PAPER_EXTRA = []; // extra defs (patterns) other files add+// Pieces baked ahead of time (SKILL/scripts/bake_puppets.py): img/puppets/<hash>.webp, listed in+// window.BAKED. A piece missing from it (just edited) is baked here in the browser; ?bake ignores the list.+const BAKED = new URLSearchParams(location.search).has('bake') ? {} : (window.BAKED || {});+const keyHash = k => { let h = 2166136261; for (let i = 0; i < k.length; i++) h = Math.imul(h ^ k.charCodeAt(i), 16777619); return (h >>> 0).toString(16).padStart(8, '0'); };+const isLive = e => e.hasAttribute('data-p') || ['eyeO', 'eyeC', 'mouth'].some(c => e.classList.contains(c));+function rasterize(svg, w, h) {+ return new Promise((ok, no) => {+ const img = new Image();+ img.onload = () => { const c = document.createElement('canvas'); c.width = w; c.height = h; c.getContext('2d').drawImage(img, 0, 0, w, h); URL.revokeObjectURL(img.src); c.toBlob(b => ok(URL.createObjectURL(b))); };+ img.onerror = no;+ img.src = URL.createObjectURL(new Blob([svg], { type: 'image/svg+xml' }));+ });+}+function bakeAll(root) {+ // Measure everything first, then change the DOM: a getBBox after each change would lay the page out again every time.+ const covered = el => { for (let c = el, a = el.parentNode; a && a !== root; c = a, a = a.parentNode) if (isLive(c)) return false; else if (a.hasAttribute?.('filter')) return true; return false; };+ const items = [];+ for (const el of root.querySelectorAll('[filter]')) {+ if (covered(el)) continue; // drawn into a filtered ancestor's bitmap+ const bb = el.getBBox(), x = Math.floor(bb.x - 10), y = Math.floor(bb.y - 10), w = Math.ceil(bb.width + 22), h = Math.ceil(bb.height + 24);+ const clone = el.cloneNode(true);+ ['transform', 'visibility', 'data-p', 'opacity'].forEach(a => clone.removeAttribute(a));+ [...clone.children].forEach((c, i) => { if (isLive(el.children[i])) c.remove(); });+ items.push({ el, x, y, w, h, html: clone.outerHTML });+ }+ const jobs = [];+ for (const { el, x, y, w, h, html } of items) {+ const key = `${x} ${y} ${w} ${h}|${html}`;+ const apply = url => {+ if (!el.hasAttribute('filter')) return;+ el.removeAttribute('filter');+ [...el.children].forEach(c => { if (!isLive(c)) c.remove(); });+ el.insertBefore(mk('image', { href: url, x, y, width: w, height: h }), el.firstChild);+ };+ const file = BAKED[keyHash(key)];+ if (file) { apply(`../img/puppets/${file}`); continue; }+ if (bakedReady.has(key)) { apply(bakedReady.get(key)); continue; }+ if (!bakedJobs.has(key)) bakedJobs.set(key, rasterize(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${w * RES}" height="${h * RES}" viewBox="${x} ${y} ${w} ${h}">${PAPER_DEFS}<defs>${PAPER_EXTRA.join('')}</defs>${html}</svg>`, w * RES, h * RES)+ .then(url => (bakedReady.set(key, url), url)));+ jobs.push(bakedJobs.get(key).then(apply));+ }+ return Promise.all(jobs);+}+// Build the book's pieces once at load, off screen, so their bitmaps are ready before the first beat needs them.+function paperWarm(build) {+ const svg = mk('svg', { width: 1, height: 1, style: 'position:absolute;left:-10px;top:-10px' });+ document.body.appendChild(svg);+ build(mk('g', {}, svg));+ return bakeAll(svg).then(() => svg.remove());+}++/* ---------- walking ----------+ A compass walk: the stance foot stays planted while the hip rides over it, so feet never slide. tau seconds into+ the walk, `period` s per two steps; returns leg angles and knee bends (degrees), how far the hip has travelled (d)+ and how far it has dropped from standing (drop), both in the puppet's own units. */+function walk(tau, { L = 166, A = 22, period = 1, knee = 38 } = {}) {+ tau = Math.max(0, tau);+ const a = A * Math.PI / 180, ph = 2 * Math.PI * tau / period, j = Math.floor((ph + Math.PI / 2) / Math.PI);+ const ts = (j % 2 ? 1 : -1) * a * Math.sin(ph), near = a * Math.sin(ph) * 180 / Math.PI;+ const swing = knee * Math.max(0, Math.cos(ph - j * Math.PI)), nearStance = j % 2 === 1;+ return { ph, d: j * 2 * L * Math.sin(a) - L * Math.sin(ts), drop: L * (1 - Math.cos(ts)),+ near, far: -near, kNear: nearStance ? 0 : swing, kFar: nearStance ? swing : 0 };+}++// A piece of the set that sits in front of puppets (a trunk, a bush, a blanket): drawn like a puppet piece, baked.+function prop(parent, svg, attrs = {}) { const g = mk('g', attrs, parent); g.innerHTML = svg; bakeAll(g); return g; }++// The iris closing on (cx, cy) between t0 and t0 + dur, as in old films; then black.+function iris(p, t0, dur, cx, cy) {+ const e = mk('path', { fill: '#120a05', 'fill-rule': 'evenodd' }, p);+ return q => {+ const u = (q - t0) / dur; vis(e, u > 0);+ if (u <= 0) return;+ const r = Math.max(0, 1900 * (1 - ease(Math.min(1, u))));+ e.setAttribute('d', `M-50,-50 H1650 V950 H-50 Z M${cx - r},${cy} a${r},${r} 0 1 0 ${2 * r},0 a${r},${r} 0 1 0 ${-2 * r},0 Z`);+ };+}+// A scene change: a tree trunk (or any dark foreground, redraw it) passing close in front of the camera, right to left: 'in' ends with the frame covered (a scene+// ends), 'out' starts covered and uncovers it (the next scene begins).+function trunkWipe(p, t0, dur, mode = 'in') {+ const g = mk('g', {}, p);+ g.innerHTML = `<g filter="url(#paper)"><path d="M0,-40 C40,200 -30,600 20,940 L2100,940 L2100,-40 Z" fill="#5a3b24"/>+ ${[160, 420, 700, 980, 1300, 1600].map((x, i) => `<path d="M${x},-40 C${x + 30},${200 + i * 40} ${x - 40},${560 - i * 30} ${x + 10},940" stroke="#46301d" stroke-width="${10 + (i % 3) * 5}" fill="none"/>`).join('')}</g>`;+ bakeAll(g);+ const [a, b] = mode === 'in' ? [1650, -200] : [-200, -2150];+ return q => { const u = Math.min(1, Math.max(0, (q - t0) / dur)); vis(g, mode === 'in' ? u > 0 : u < 1); tf(g, `translate(${(a + (b - a) * ease(u)).toFixed(0)},0)`); };+}+// The title card at the end: a paper label that drops in on its pin, as wide as its words. Give the words in the book's+// language; { x, y } is the card's centre (default the frame's centre), size the letters' height in px (a title too long+// for the frame gets smaller letters). Put it where it covers nothing the last shot needs (a score, a face).+function endCard(p, t0, words = 'The End', { x = 800, y = 450, size = 78 } = {}) {+ const c = document.createElement('canvas').getContext('2d'), wide = s => (c.font = `italic ${s}px Georgia, serif`, c.measureText(words).width + 2.2 * s);+ if (wide(size) > 1500) size = Math.floor(size * 1500 / wide(size));+ const w = Math.max(480, Math.ceil(wide(size))), h = Math.round(size * 3.08), L = Math.round(x - w / 2), T = Math.round(y - h / 2);+ const g = prop(p, `<g filter="url(#paper)"><rect x="${L}" y="${T}" width="${w}" height="${h}" rx="14" fill="#f3e9d2"/><rect x="${L + 20}" y="${T + 20}" width="${w - 40}" height="${h - 40}" rx="8" fill="none" stroke="#c8322f" stroke-width="5"/></g>+ <text x="${x}" y="${Math.round(y + size * .36)}" text-anchor="middle" font-family="Georgia, serif" font-size="${size}" font-style="italic" fill="#5a2a1e">${words}</text>${pinAt(x, T + 12)}`);+ return q => { const u = (q - t0) * FPS; vis(g, u >= 0); const d = [-60, -20, 8, -3, 0][Math.min(4, Math.max(0, Math.floor(u / 2)))]; tf(g, `translate(0,${d})`); };+}diff --git a/site/little-horse/lib/shared.js b/site/little-horse/lib/shared.jsnew file mode 100644index 0000000..907bf6c--- /dev/null+++ b/site/little-horse/lib/shared.js@@ -0,0 +1,60 @@+/* shared.js — what every scene of the book uses: timing helpers and painted props. Put the book's+ recurring places and props here too (a classroom or a street built the same way whenever it appears, so the staging+ matches across cuts): a function like `function room(p) { const cam = paperCam(p, 'room'); … return { cam, … }; }`. */+'use strict';+// Beat-clock time of `t` seconds into clip `clip` of a joined scene whose speech starts `pre` s in (join.py's `parts`).+const clipAt = (scene, pre, clip, t = 0) => pre + TIMINGS[scene].parts[clip] + t;+// Beat-clock time of the n-th caption cue (one per sentence) of a joined scene: for cutting on sentences.+const cueAt = (scene, pre, n) => pre + TIMINGS[scene].cues[n][0];+const onTwos = q => Math.floor(q * FPS / 2) % 2 ? 1 : -1;+const between = (q, a, b) => q >= a && q < b;+const tween = (q, t0, d, a, b) => a + (b - a) * span(q, t0, t0 + d);+// Who is speaking: the mouth for this frame from the listed clips of a joined scene, or 'X' (rest).+const lips = (q, scene, pre, ...clips) => { for (const c of clips) { const m = mouthAt(c, q - clipAt(scene, pre, c)); if (m !== 'X') return m; } return 'X'; };+// Chewing on twos: the mouth alternates between two shapes.+const chew = q => onTwos(q) > 0 ? 'chew' : 'A';++/* ---------- painted props (img/props/<name>.webp, from painted.py) ---------- */+// A picture at (x, y), w by h, to hold in a puppet's hand (holds: { key: svg }) or drop into prop().+const artSVG = (name, x, y, w, h) => `<image href="../img/props/${name}.webp" x="${x}" y="${y}" width="${w}" height="${h}"/>`;++/* ---------- this book's places ---------- */+// The river, side-on (books/little-horse/art/sets.js): the waterline and the bed under it, so a wader's hooves stand on+// the bed and the water layer covers whatever is below the line.+const WATER = 720;+const RIVER_BED = x => x < 600 ? 700 : x < 690 ? 700 + 20 * (x - 600) / 90 + 18 * ((x - 600) / 90) ** 2+ : x < 1230 ? 738 + 48 * Math.sin(Math.PI * Math.min(1, Math.max(0, (x - 690) / 540))) ** .8 : x < 1320 ? 738 - 32 * (x - 1230) / 90 : 706;+// A camera on one of the book's sets with the puppets' plane where it belongs: at the river the puppets stand in front+// of the tree (Squirrel sits on its branch) and behind the water and the near faces of the banks.+const setCam = (p, set, v0 = {}) => paperCam(p, set, v0, set === 'river' ? { after: 'tree' } : {});++// Moving a four-legged puppet along the ground: keys [[t, x], …] on the scene clock, eased between keys. Returns x, the+// distance walked in the puppet's own units (d, for pose: x = x0 + turn·s·d keeps the hooves planted) and stand, 1 at+// rest, blending to 0 within a quarter second of setting off and back to 1 after stopping.+function route(q, keys, s = 1) {+ let x = keys[0][1], d = 0, moving = false, since = 1e9;+ for (let i = 1; i < keys.length; i++) {+ const [t0, a] = keys[i - 1], [t1, b] = keys[i];+ if (q >= t1) { d += Math.abs(b - a) / s; x = b; if (a !== b) since = q - t1; continue; }+ if (q > t0 && a !== b) { const u = ease((q - t0) / (t1 - t0)); x = a + (b - a) * u; d += Math.abs(b - a) * u / s; moving = true; since = 0; }+ break;+ }+ const start = keys.find((k, i) => i && keys[i - 1][1] !== k[1] && q >= keys[i - 1][0] && q < k[0]);+ const into = start ? q - keys[keys.indexOf(start) - 1][0] : 1e9;+ const stand = moving ? Math.max(0, 1 - into / .25) : Math.min(1, since / .25);+ return { x, d, stand };+}++// The mill's water wheel, a paper wheel that turns on the scene clock: wheel(q) poses it.+function millWheel(parent, x = 1340, y = 650, r = 150) {+ const spokes = Array.from({ length: 8 }, (_, i) => { const a = i * Math.PI / 4; return `<path d="M0,0 L${(r * Math.cos(a)).toFixed(1)},${(r * Math.sin(a)).toFixed(1)}" stroke="#6e4a30" stroke-width="12"/>`; }).join('');+ const paddles = Array.from({ length: 16 }, (_, i) => { const a = i * Math.PI / 8; return `<rect x="-9" y="${-r - 26}" width="18" height="40" fill="#8a5a36" transform="rotate(${(a * 180 / Math.PI).toFixed(1)})"/>`; }).join('');+ const g = prop(parent, `<g filter="url(#paper)">${paddles}<circle r="${r}" fill="none" stroke="#7a5236" stroke-width="14"/><circle r="${r * .62}" fill="none" stroke="#7a5236" stroke-width="8"/>${spokes}<circle r="22" fill="#5a3b24"/></g>`);+ return q => tf(g, `translate(${x},${y}) rotate(${(q * 24 % 360).toFixed(1)})`);+}++// Beds (river, birds, wind, mill) are files of about 10 s with soft ends; a scene calls sfx() for one once, and it is+// laid again every BED_STEP s so it runs to the scene's end (effects past a beat's end never play, and export.py+// leaves them out too). The page waiting at a point-and-read stop plays no effects; the music carries the wait.+const BED_STEP = { river: 9.5, mill: 9.5, birds: 9.6, wind: 7.5 };+{ const once = window.sfx; window.sfx = (beat, t, name, vol) => { once(beat, t, name, vol); if (BED_STEP[name]) for (let k = 1; k * BED_STEP[name] < 60; k++) once(beat, +(t + k * BED_STEP[name]).toFixed(2), name, vol); }; }diff --git a/site/little-horse/lib/units.css b/site/little-horse/lib/units.cssnew file mode 100644index 0000000..e9c62cb--- /dev/null+++ b/site/little-horse/lib/units.css@@ -0,0 +1,79 @@+/* The unit headers of a book's contents page, the same in every book: a strip of chalkboard per unit, with the unit's+ label and title and a sketch of its ideas (UNIT_ART, from the book's own unit-art.js) drawn in the unit colour --c.+ Markup and the scroll observer are in units.js. Uses the contents page's --book, --ui, --chalk and --ease. */+.unit { position: relative; max-width: 1212px; margin: 0 auto; padding: 28px 16px 0; }+.unit h2 { position: relative; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; min-height: 168px; margin: 0 0 16px; padding-top: 130px; font: 500 28px/1.2 var(--book); }+.unit .grid { position: relative; }+.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;+ background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }+.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;+ color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }+.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }+.unit-art .a { color: var(--chalk); opacity: .55; }+.unit-art .faint { opacity: .22; }+.unit-art .d { stroke-dasharray: 1 1; stroke-dashoffset: 1; }+.unit-art .t { opacity: 0; }+.seen .unit-art .d { animation: art-draw 1.1s cubic-bezier(.5, 0, .3, 1) forwards; animation-delay: calc(var(--k) * 55ms + 120ms); }+.seen .unit-art .t { animation: art-fade .6s ease-out forwards; animation-delay: calc(var(--k) * 55ms + 300ms); }+.seen .unit-art .a.t { animation-name: art-fade-a; }+@keyframes art-draw { to { stroke-dashoffset: 0; } }+@keyframes art-fade { to { opacity: 1; } }+@keyframes art-fade-a { to { opacity: .55; } }+/* After the drawing, each sketch keeps one small motion that belongs to its topic. */+.unit-art g { transform-box: fill-box; }+.seen .unit-art .swap-a { animation: swap-a 6s var(--ease) 2.4s infinite; }+.seen .unit-art .swap-b { animation: swap-b 6s var(--ease) 2.4s infinite; }+@keyframes swap-a { 0%, 30%, 100% { transform: none; } 45%, 80% { transform: translate(80px, 0); } 37% { transform: translate(40px, -30px); } 88% { transform: translate(40px, 30px); } }+@keyframes swap-b { 0%, 30%, 100% { transform: none; } 45%, 80% { transform: translate(-80px, 0); } 37% { transform: translate(-40px, 30px); } 88% { transform: translate(-40px, -30px); } }+.seen .unit-art .step { animation: art-fade .6s ease-out forwards, step 4s ease-in-out infinite; animation-delay: calc(var(--k) * 55ms + 300ms), calc(var(--k) * 300ms + 2s); }+@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; }+.seen .unit-art .pie { animation: art-fade .4s ease-out 1.6s forwards, pie 5s var(--ease) 1.6s infinite; }+@keyframes pie { 0% { stroke-dasharray: 0 100; } 35%, 85% { stroke-dasharray: 25 100; } 100% { stroke-dasharray: 0 100; } }+.seen .unit-art .tilt { transform-box: view-box; transform-origin: 300px 72px; animation: tilt 4.8s ease-in-out 2s infinite; }+@keyframes tilt { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-4deg); } 60% { transform: rotate(2deg); } }+.seen .unit-art .spin { transform-box: view-box; transform-origin: 320px 95px; animation: spin 5s cubic-bezier(.2, .7, .2, 1) 2s infinite; }+@keyframes spin { from { transform: rotate(0); } 70%, to { transform: rotate(1530deg); } }+.seen .unit-art .feed-in { animation: feed-in 4s ease-in-out 2s infinite; }+.seen .unit-art .feed-out { opacity: 0; animation: feed-out 4s ease-in-out 2s infinite; }+@keyframes feed-in { 0% { transform: none; opacity: 1; } 40% { transform: translate(100px, 0); opacity: 0; } 41%, 100% { transform: none; opacity: 0; } 95% { opacity: 1; } }+@keyframes feed-out { 0%, 45% { transform: translate(-40px, 0); opacity: 0; } 70%, 90% { transform: none; opacity: 1; } 100% { opacity: 0; } }+.unit-art .cell { opacity: .25; }+.seen .unit-art .cell { animation: cell 5s ease-in-out infinite; animation-delay: calc(var(--j) * .5s + 2s); }+@keyframes cell { 0%, 100% { opacity: .25; } 15%, 60% { opacity: 1; } }+.unit-art .cut, .unit-art .shade { opacity: 0; }+.seen .unit-art .cut { animation: cut 4s ease-in-out 2s infinite; }+@keyframes cut { 0%, 100% { opacity: 0; } 30%, 70% { opacity: .5; } }+.seen .unit-art .shade { animation: shade 1s ease-out 1.6s forwards; }+@keyframes shade { to { opacity: .14; } }+.seen .unit-art .diag { animation: art-draw 1.1s cubic-bezier(.5, 0, .3, 1) forwards, redraw 4s ease-in-out 2.5s infinite; }+@keyframes redraw { 0%, 15% { stroke-dashoffset: 1; } 50%, 100% { stroke-dashoffset: 0; } }+.seen .unit-art .root { animation: art-fade .4s ease-out 1.8s forwards, root 2.4s ease-in-out 2.2s infinite; }+@keyframes root { 0%, 100% { r: 7px; } 50% { r: 11px; } }+.seen .unit-art .breathe { transform-box: view-box; transform-origin: 380px 140px; animation: breathe 4s ease-in-out 2s infinite alternate; }+@keyframes breathe { from { transform: scaleY(1); } to { transform: scaleY(.35); } }+/* The label and the title share a line when they fit; a long title wraps below the label instead of running off. */+.unit h2 .title { min-width: 0; text-wrap: balance; }+.unit h2 .label { font: 600 14px var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--c); white-space: nowrap; }+/* Keep the sketches cheap: each is its own layer, so its loop repaints only itself, and loops pause while their unit is+ off screen or under the sticky bar (units.js toggles .live), so the bar's blur is not redrawn every frame. */+.unit-art { will-change: transform; contain: layout style; }+.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }+@media (max-width: 560px) {+ .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }+ .unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }+}+@media (prefers-reduced-motion: reduce) {+ .unit-art * { animation: none !important; }+ .unit-art .d { stroke-dashoffset: 0; }+ .unit-art .t, .unit-art .cell { opacity: 1; }+ .unit-art .a.t { opacity: .55; }+ .unit-art .shade { opacity: .14; }+ .unit-art .pie { stroke-dasharray: 25 100; }+}diff --git a/site/little-horse/lib/units.js b/site/little-horse/lib/units.jsnew file mode 100644index 0000000..e9e8c27--- /dev/null+++ b/site/little-horse/lib/units.js@@ -0,0 +1,26 @@+// The unit headers of a book's contents page, the same in every book; styled by units.css. The sketches come from+// the book's own unit-art.js (window.UNIT_ART, one SVG body per unit, viewBox 0 0 600 180).+// Units.header(u, label, title) the sketch and heading for unit u, as HTML to put first in its <section class="unit">+// Units.watch() draw each sketch the first time its unit scrolls into view, and run its loop only+// while the unit is on screen+'use strict';+(() => {+ const esc = s => String(s).replace(/&/g, '&').replace(/</g, '<');+ const header = (u, label, title) =>+ `<svg class="unit-art" viewBox="0 0 600 180" aria-hidden="true">${window.UNIT_ART?.[u] || ''}</svg>` ++ `<h2><span class="label">${esc(label)}</span><span class="title">${esc(title)}</span></h2>`;++ function watch(root = document) {+ const units = root.querySelectorAll('.unit');+ if (!('IntersectionObserver' in window)) return units.forEach(u => u.classList.add('seen', 'live'));+ // The first sight draws the sketch; leaving the screen (or sliding under the sticky bar) pauses it.+ const first = new IntersectionObserver(es => es.forEach(e => {+ if (e.isIntersecting) { e.target.classList.add('seen'); first.unobserve(e.target); }+ }), { threshold: .25 });+ const live = new IntersectionObserver(es => es.forEach(e => e.target.classList.toggle('live', e.isIntersecting)),+ { rootMargin: '-64px 0px 0px 0px' });+ units.forEach(u => { first.observe(u); live.observe(u); });+ }++ window.Units = { header, watch };+})();diff --git a/site/little-horse/lib/volume.css b/site/little-horse/lib/volume.cssnew file mode 100644index 0000000..106dd36--- /dev/null+++ b/site/little-horse/lib/volume.css@@ -0,0 +1,24 @@+/* Volume control for the player bar (volume.js); imported by engine.css. */+.volume { display: flex; align-items: center; flex: none; width: 44px; height: 44px; overflow: hidden;+ border: 1px solid var(--edge); border-radius: 999px; background: var(--panel); color: var(--chalk); transition: width .18s ease; }+.volume .icon { width: 42px; height: 42px; border: 0; background: transparent; }+.volume:hover, .volume:focus-within { width: 166px; gap: 10px; padding-right: 12px; }+.volume:hover { background: var(--hover, #2b3f36); border-color: var(--faint); }+.volume:has(:focus-visible) { outline: 2px solid var(--task); outline-offset: 3px; }+.volume .icon:focus-visible { outline: none; }+.volume input { appearance: none; flex: none; width: 0; height: 42px; margin: 0; opacity: 0; background: transparent; cursor: pointer; }+.volume:hover input, .volume:focus-within input { width: 100px; opacity: 1; }+.volume input:focus-visible { outline: none; }+.volume input::-webkit-slider-runnable-track { height: 4px; border-radius: 999px;+ background: linear-gradient(to right, var(--chalk) var(--volume, 100%), var(--faint) var(--volume, 100%)); }+.volume input::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -4px; border: 0; border-radius: 50%; background: var(--chalk); }+.volume input::-moz-range-track { height: 4px; border-radius: 999px; background: var(--faint); }+.volume input::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--chalk); }+.volume input::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--chalk); }+@media (max-width: 700px) {+ .volume { width: 36px; height: 40px; }+ #bar .volume .icon { width: 34px; height: 38px; }+ .volume:hover, .volume:focus-within { width: 158px; }+ .volume input { height: 38px; }+}+@media (prefers-reduced-motion: reduce) { .volume { transition: none; } }diff --git a/site/little-horse/lib/volume.js b/site/little-horse/lib/volume.jsnew file mode 100644index 0000000..4ea3a55--- /dev/null+++ b/site/little-horse/lib/volume.js@@ -0,0 +1,23 @@+/* Volume control for the player bar: a speaker button that opens a slider. engine.js loads this file and reads+ #volume when it starts each beat's audio, so the control is the same in every book. */+'use strict';+{+ document.getElementById('bHelp').insertAdjacentHTML('beforebegin', `<div class="volume">+ <button class="icon" id="bVolume" aria-label="${translate('volumeLabel')}" aria-controls="volume" title="${translate('volumeTitle')}">+ <svg viewBox="0 0 24 24" aria-hidden="true">+ <path d="M3 9v6h4l5 4V5L7 9z" fill="currentColor"/>+ <path d="M16 8a6 6 0 0 1 0 8m3-11a10 10 0 0 1 0 14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>+ </svg>+ </button>+ <input id="volume" type="range" min="0" max="1" step="0.05" value="1" aria-label="${translate('volumeSlider')}">+ </div>`);+ const input = document.getElementById('volume');+ document.getElementById('bVolume').onclick = () => input.focus();+ const apply = () => {+ input.style.setProperty('--volume', +input.value * 100 + '%');+ if (P.audio) P.audio.volume = +input.value;+ };+ // the volume carries over to the next chapter; a muted slider does not, so a new visit always has sound+ try { const v = +localStorage.getItem('papermorph:volume'); if (v) { input.value = v; apply(); } } catch {}+ input.oninput = () => { apply(); try { localStorage.setItem('papermorph:volume', input.value); } catch {} };+}