@open-take/compositor 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdp-CzT5BKNY.js +3 -0
- package/dist/cdp-QXbQfXna.js +373 -0
- package/dist/cdp-QXbQfXna.js.map +1 -0
- package/dist/index.d.ts +4327 -195
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26282 -160
- package/dist/index.js.map +1 -1
- package/dist/server-841PMF2H.js +163 -0
- package/dist/server-841PMF2H.js.map +1 -0
- package/dist/server-C2aVv4-t.js +3 -0
- package/kit/audio.mjs +2366 -0
- package/kit/camera.js +587 -0
- package/kit/cursor.js +264 -0
- package/kit/cut.js +427 -0
- package/kit/draw.js +346 -0
- package/kit/look.js +589 -0
- package/kit/map.js +170 -0
- package/kit/media.js +3568 -0
- package/kit/motion.js +1115 -0
- package/kit/seams.js +1006 -0
- package/kit/stage.js +923 -0
- package/kit/time.js +812 -0
- package/kit/world.js +1072 -0
- package/package.json +7 -3
- package/src/ffmpeg.ts +63 -0
- package/src/film/beats.ts +1285 -0
- package/src/film/carry.ts +221 -0
- package/src/film/changes.ts +330 -0
- package/src/film/check.ts +996 -0
- package/src/film/clock.ts +2530 -0
- package/src/film/components-probe.ts +809 -0
- package/src/film/components.ts +1566 -0
- package/src/film/frames.ts +389 -0
- package/src/film/gallery.ts +3276 -0
- package/src/film/kit.ts +515 -0
- package/src/film/layout.ts +701 -0
- package/src/film/listen.ts +1979 -0
- package/src/film/look.ts +3829 -0
- package/src/film/materials.ts +976 -0
- package/src/film/moving.ts +248 -0
- package/src/film/part-files.ts +729 -0
- package/src/film/picture.ts +74 -0
- package/src/film/probe-text.ts +843 -0
- package/src/film/probe.ts +3456 -0
- package/src/film/provenance.ts +596 -0
- package/src/film/render.ts +2447 -0
- package/src/film/report.ts +1631 -0
- package/src/film/sheet.ts +156 -0
- package/src/film/study-declared.ts +123 -0
- package/src/film/study-picture.ts +791 -0
- package/src/film/study-sound.ts +416 -0
- package/src/film/study.ts +864 -0
- package/src/film/tuning.ts +155 -0
- package/src/film/viewer.ts +174 -0
- package/src/html/cdp.ts +575 -0
- package/src/html/server.ts +208 -0
- package/src/index.ts +202 -0
- package/src/launch-render.ts +3 -2
- package/src/math.ts +3 -3
- package/src/mjpeg-matroska.ts +228 -0
- package/src/render.ts +6 -4
- package/src/state-diff.ts +215 -0
- package/src/state-index.ts +99 -0
- package/src/types.ts +59 -1
- package/starter/PLAN.md +84 -0
- package/starter/START.md +460 -0
- package/starter/lib/anim.js +760 -0
- package/starter/lib/devices.js +1402 -0
- package/starter/lib/handoff.js +421 -0
- package/starter/lib/hud.js +1879 -0
- package/starter/lib/measure.mjs +154 -0
- package/starter/lib/moves.js +1095 -0
- package/starter/lib/palette.mjs +803 -0
- package/starter/lib/physics-seeds.mjs +198 -0
- package/starter/lib/physics.js +738 -0
- package/starter/lib/sampler.mjs +242 -0
- package/starter/lib/solid.js +727 -0
- package/starter/lib/space.js +1227 -0
- package/starter/lib/swarm.js +1398 -0
- package/starter/reference/motion.md +276 -0
- package/starter/reference/structure.md +466 -0
- package/starter/reference/travel/motion.md +433 -0
- package/starter/reference/travel/sound.md +241 -0
- package/starter/reference/travel/structure.md +518 -0
- package/starter/samples/NOTICE.txt +55 -0
- package/starter/samples/celli/celli_24_1.opus +0 -0
- package/starter/samples/celli/celli_24_3.opus +0 -0
- package/starter/samples/celli/celli_28_1.opus +0 -0
- package/starter/samples/celli/celli_28_3.opus +0 -0
- package/starter/samples/celli/celli_31_1.opus +0 -0
- package/starter/samples/celli/celli_31_3.opus +0 -0
- package/starter/samples/celli/celli_35_1.opus +0 -0
- package/starter/samples/celli/celli_35_3.opus +0 -0
- package/starter/samples/celli/celli_38_1.opus +0 -0
- package/starter/samples/celli/celli_38_3.opus +0 -0
- package/starter/samples/celli/celli_41_1.opus +0 -0
- package/starter/samples/celli/celli_41_3.opus +0 -0
- package/starter/samples/celli/celli_45_1.opus +0 -0
- package/starter/samples/celli/celli_45_3.opus +0 -0
- package/starter/samples/celli/celli_48_1.opus +0 -0
- package/starter/samples/celli/celli_48_3.opus +0 -0
- package/starter/samples/celli/celli_52_1.opus +0 -0
- package/starter/samples/celli/celli_52_3.opus +0 -0
- package/starter/samples/celli/celli_55_1.opus +0 -0
- package/starter/samples/celli/celli_55_3.opus +0 -0
- package/starter/samples/celli/celli_59_1.opus +0 -0
- package/starter/samples/celli/celli_59_3.opus +0 -0
- package/starter/samples/celli/celli_62_1.opus +0 -0
- package/starter/samples/celli/celli_62_3.opus +0 -0
- package/starter/samples/celli/celli_65_1.opus +0 -0
- package/starter/samples/celli/celli_65_3.opus +0 -0
- package/starter/samples/crash/crash_f_1.flac +0 -0
- package/starter/samples/crash/crash_fff_1.flac +0 -0
- package/starter/samples/ebass/ebass_0_x.flac +0 -0
- package/starter/samples/ebass/ebass_10_x.flac +0 -0
- package/starter/samples/ebass/ebass_11_x.flac +0 -0
- package/starter/samples/ebass/ebass_1_x.flac +0 -0
- package/starter/samples/ebass/ebass_2_x.flac +0 -0
- package/starter/samples/ebass/ebass_3_x.flac +0 -0
- package/starter/samples/ebass/ebass_4_x.flac +0 -0
- package/starter/samples/ebass/ebass_5_x.flac +0 -0
- package/starter/samples/ebass/ebass_6_x.flac +0 -0
- package/starter/samples/ebass/ebass_7_x.flac +0 -0
- package/starter/samples/ebass/ebass_8_x.flac +0 -0
- package/starter/samples/ebass/ebass_9_x.flac +0 -0
- package/starter/samples/ek_clap/ek_clap_1_1.flac +0 -0
- package/starter/samples/ek_hat/ek_hat_1_1.flac +0 -0
- package/starter/samples/ek_hat/ek_hat_1_2.flac +0 -0
- package/starter/samples/ek_kick/ek_kick_1_1.flac +0 -0
- package/starter/samples/ek_kick/ek_kick_1_2.flac +0 -0
- package/starter/samples/glock/glock_67_x.flac +0 -0
- package/starter/samples/glock/glock_72_x.flac +0 -0
- package/starter/samples/glock/glock_79_x.flac +0 -0
- package/starter/samples/glock/glock_84_x.flac +0 -0
- package/starter/samples/glock/glock_91_x.flac +0 -0
- package/starter/samples/glock/glock_96_x.flac +0 -0
- package/starter/samples/harp/harp_101_f.opus +0 -0
- package/starter/samples/harp/harp_28_f.opus +0 -0
- package/starter/samples/harp/harp_31_mp.opus +0 -0
- package/starter/samples/harp/harp_35_mf.opus +0 -0
- package/starter/samples/harp/harp_38_mf.opus +0 -0
- package/starter/samples/harp/harp_41_mf.opus +0 -0
- package/starter/samples/harp/harp_45_mf.opus +0 -0
- package/starter/samples/harp/harp_48_mf.opus +0 -0
- package/starter/samples/harp/harp_52_mf.opus +0 -0
- package/starter/samples/harp/harp_55_mf.opus +0 -0
- package/starter/samples/harp/harp_59_mf.opus +0 -0
- package/starter/samples/harp/harp_62_mf.opus +0 -0
- package/starter/samples/harp/harp_65_mf.opus +0 -0
- package/starter/samples/harp/harp_69_mf.opus +0 -0
- package/starter/samples/harp/harp_72_mf.opus +0 -0
- package/starter/samples/harp/harp_76_mf.opus +0 -0
- package/starter/samples/harp/harp_79_mf.opus +0 -0
- package/starter/samples/harp/harp_83_mf.opus +0 -0
- package/starter/samples/harp/harp_86_mf.opus +0 -0
- package/starter/samples/harp/harp_89_mf.opus +0 -0
- package/starter/samples/harp/harp_93_mf.opus +0 -0
- package/starter/samples/harp/harp_95_mf.opus +0 -0
- package/starter/samples/harp/harp_98_f.opus +0 -0
- package/starter/samples/manifest.json +2951 -0
- package/starter/samples/marimba/marimba_29_x.flac +0 -0
- package/starter/samples/marimba/marimba_36_x.flac +0 -0
- package/starter/samples/marimba/marimba_43_x.flac +0 -0
- package/starter/samples/marimba/marimba_47_x.flac +0 -0
- package/starter/samples/marimba/marimba_53_x.flac +0 -0
- package/starter/samples/marimba/marimba_60_x.flac +0 -0
- package/starter/samples/marimba/marimba_67_x.flac +0 -0
- package/starter/samples/marimba/marimba_71_x.flac +0 -0
- package/starter/samples/marimba/marimba_77_x.flac +0 -0
- package/starter/samples/marimba/marimba_84_x.flac +0 -0
- package/starter/samples/piano/piano_102_12.opus +0 -0
- package/starter/samples/piano/piano_102_16.opus +0 -0
- package/starter/samples/piano/piano_102_4.opus +0 -0
- package/starter/samples/piano/piano_102_8.opus +0 -0
- package/starter/samples/piano/piano_105_12.opus +0 -0
- package/starter/samples/piano/piano_105_16.opus +0 -0
- package/starter/samples/piano/piano_105_4.opus +0 -0
- package/starter/samples/piano/piano_105_8.opus +0 -0
- package/starter/samples/piano/piano_108_12.opus +0 -0
- package/starter/samples/piano/piano_108_16.opus +0 -0
- package/starter/samples/piano/piano_108_4.opus +0 -0
- package/starter/samples/piano/piano_108_8.opus +0 -0
- package/starter/samples/piano/piano_21_12.opus +0 -0
- package/starter/samples/piano/piano_21_16.opus +0 -0
- package/starter/samples/piano/piano_21_4.opus +0 -0
- package/starter/samples/piano/piano_21_8.opus +0 -0
- package/starter/samples/piano/piano_24_12.opus +0 -0
- package/starter/samples/piano/piano_24_16.opus +0 -0
- package/starter/samples/piano/piano_24_4.opus +0 -0
- package/starter/samples/piano/piano_24_8.opus +0 -0
- package/starter/samples/piano/piano_27_12.opus +0 -0
- package/starter/samples/piano/piano_27_16.opus +0 -0
- package/starter/samples/piano/piano_27_4.opus +0 -0
- package/starter/samples/piano/piano_27_8.opus +0 -0
- package/starter/samples/piano/piano_30_12.opus +0 -0
- package/starter/samples/piano/piano_30_16.opus +0 -0
- package/starter/samples/piano/piano_30_4.opus +0 -0
- package/starter/samples/piano/piano_30_8.opus +0 -0
- package/starter/samples/piano/piano_33_12.opus +0 -0
- package/starter/samples/piano/piano_33_16.opus +0 -0
- package/starter/samples/piano/piano_33_4.opus +0 -0
- package/starter/samples/piano/piano_33_8.opus +0 -0
- package/starter/samples/piano/piano_36_12.opus +0 -0
- package/starter/samples/piano/piano_36_16.opus +0 -0
- package/starter/samples/piano/piano_36_4.opus +0 -0
- package/starter/samples/piano/piano_36_8.opus +0 -0
- package/starter/samples/piano/piano_39_12.opus +0 -0
- package/starter/samples/piano/piano_39_16.opus +0 -0
- package/starter/samples/piano/piano_39_4.opus +0 -0
- package/starter/samples/piano/piano_39_8.opus +0 -0
- package/starter/samples/piano/piano_42_12.opus +0 -0
- package/starter/samples/piano/piano_42_16.opus +0 -0
- package/starter/samples/piano/piano_42_4.opus +0 -0
- package/starter/samples/piano/piano_42_8.opus +0 -0
- package/starter/samples/piano/piano_45_12.opus +0 -0
- package/starter/samples/piano/piano_45_16.opus +0 -0
- package/starter/samples/piano/piano_45_4.opus +0 -0
- package/starter/samples/piano/piano_45_8.opus +0 -0
- package/starter/samples/piano/piano_48_12.opus +0 -0
- package/starter/samples/piano/piano_48_16.opus +0 -0
- package/starter/samples/piano/piano_48_4.opus +0 -0
- package/starter/samples/piano/piano_48_8.opus +0 -0
- package/starter/samples/piano/piano_51_12.opus +0 -0
- package/starter/samples/piano/piano_51_16.opus +0 -0
- package/starter/samples/piano/piano_51_4.opus +0 -0
- package/starter/samples/piano/piano_51_8.opus +0 -0
- package/starter/samples/piano/piano_54_12.opus +0 -0
- package/starter/samples/piano/piano_54_16.opus +0 -0
- package/starter/samples/piano/piano_54_4.opus +0 -0
- package/starter/samples/piano/piano_54_8.opus +0 -0
- package/starter/samples/piano/piano_57_12.opus +0 -0
- package/starter/samples/piano/piano_57_16.opus +0 -0
- package/starter/samples/piano/piano_57_4.opus +0 -0
- package/starter/samples/piano/piano_57_8.opus +0 -0
- package/starter/samples/piano/piano_60_12.opus +0 -0
- package/starter/samples/piano/piano_60_16.opus +0 -0
- package/starter/samples/piano/piano_60_4.opus +0 -0
- package/starter/samples/piano/piano_60_8.opus +0 -0
- package/starter/samples/piano/piano_63_12.opus +0 -0
- package/starter/samples/piano/piano_63_16.opus +0 -0
- package/starter/samples/piano/piano_63_4.opus +0 -0
- package/starter/samples/piano/piano_63_8.opus +0 -0
- package/starter/samples/piano/piano_66_12.opus +0 -0
- package/starter/samples/piano/piano_66_16.opus +0 -0
- package/starter/samples/piano/piano_66_4.opus +0 -0
- package/starter/samples/piano/piano_66_8.opus +0 -0
- package/starter/samples/piano/piano_69_12.opus +0 -0
- package/starter/samples/piano/piano_69_16.opus +0 -0
- package/starter/samples/piano/piano_69_4.opus +0 -0
- package/starter/samples/piano/piano_69_8.opus +0 -0
- package/starter/samples/piano/piano_72_12.opus +0 -0
- package/starter/samples/piano/piano_72_16.opus +0 -0
- package/starter/samples/piano/piano_72_4.opus +0 -0
- package/starter/samples/piano/piano_72_8.opus +0 -0
- package/starter/samples/piano/piano_75_12.opus +0 -0
- package/starter/samples/piano/piano_75_16.opus +0 -0
- package/starter/samples/piano/piano_75_4.opus +0 -0
- package/starter/samples/piano/piano_75_8.opus +0 -0
- package/starter/samples/piano/piano_78_12.opus +0 -0
- package/starter/samples/piano/piano_78_16.opus +0 -0
- package/starter/samples/piano/piano_78_4.opus +0 -0
- package/starter/samples/piano/piano_78_8.opus +0 -0
- package/starter/samples/piano/piano_81_12.opus +0 -0
- package/starter/samples/piano/piano_81_16.opus +0 -0
- package/starter/samples/piano/piano_81_4.opus +0 -0
- package/starter/samples/piano/piano_81_8.opus +0 -0
- package/starter/samples/piano/piano_84_12.opus +0 -0
- package/starter/samples/piano/piano_84_16.opus +0 -0
- package/starter/samples/piano/piano_84_4.opus +0 -0
- package/starter/samples/piano/piano_84_8.opus +0 -0
- package/starter/samples/piano/piano_87_12.opus +0 -0
- package/starter/samples/piano/piano_87_16.opus +0 -0
- package/starter/samples/piano/piano_87_4.opus +0 -0
- package/starter/samples/piano/piano_87_8.opus +0 -0
- package/starter/samples/piano/piano_90_12.opus +0 -0
- package/starter/samples/piano/piano_90_16.opus +0 -0
- package/starter/samples/piano/piano_90_4.opus +0 -0
- package/starter/samples/piano/piano_90_8.opus +0 -0
- package/starter/samples/piano/piano_93_12.opus +0 -0
- package/starter/samples/piano/piano_93_16.opus +0 -0
- package/starter/samples/piano/piano_93_4.opus +0 -0
- package/starter/samples/piano/piano_93_8.opus +0 -0
- package/starter/samples/piano/piano_96_12.opus +0 -0
- package/starter/samples/piano/piano_96_16.opus +0 -0
- package/starter/samples/piano/piano_96_4.opus +0 -0
- package/starter/samples/piano/piano_96_8.opus +0 -0
- package/starter/samples/piano/piano_99_12.opus +0 -0
- package/starter/samples/piano/piano_99_16.opus +0 -0
- package/starter/samples/piano/piano_99_4.opus +0 -0
- package/starter/samples/piano/piano_99_8.opus +0 -0
- package/starter/samples/piano/piano_rel_102_x.opus +0 -0
- package/starter/samples/piano/piano_rel_105_x.opus +0 -0
- package/starter/samples/piano/piano_rel_108_x.opus +0 -0
- package/starter/samples/piano/piano_rel_21_x.opus +0 -0
- package/starter/samples/piano/piano_rel_24_x.opus +0 -0
- package/starter/samples/piano/piano_rel_27_x.opus +0 -0
- package/starter/samples/piano/piano_rel_30_x.opus +0 -0
- package/starter/samples/piano/piano_rel_33_x.opus +0 -0
- package/starter/samples/piano/piano_rel_36_x.opus +0 -0
- package/starter/samples/piano/piano_rel_39_x.opus +0 -0
- package/starter/samples/piano/piano_rel_42_x.opus +0 -0
- package/starter/samples/piano/piano_rel_45_x.opus +0 -0
- package/starter/samples/piano/piano_rel_48_x.opus +0 -0
- package/starter/samples/piano/piano_rel_51_x.opus +0 -0
- package/starter/samples/piano/piano_rel_54_x.opus +0 -0
- package/starter/samples/piano/piano_rel_57_x.opus +0 -0
- package/starter/samples/piano/piano_rel_60_x.opus +0 -0
- package/starter/samples/piano/piano_rel_63_x.opus +0 -0
- package/starter/samples/piano/piano_rel_66_x.opus +0 -0
- package/starter/samples/piano/piano_rel_69_x.opus +0 -0
- package/starter/samples/piano/piano_rel_72_x.opus +0 -0
- package/starter/samples/piano/piano_rel_75_x.opus +0 -0
- package/starter/samples/piano/piano_rel_78_x.opus +0 -0
- package/starter/samples/piano/piano_rel_81_x.opus +0 -0
- package/starter/samples/piano/piano_rel_84_x.opus +0 -0
- package/starter/samples/piano/piano_rel_87_x.opus +0 -0
- package/starter/samples/piano/piano_rel_90_x.opus +0 -0
- package/starter/samples/piano/piano_rel_93_x.opus +0 -0
- package/starter/samples/piano/piano_rel_96_x.opus +0 -0
- package/starter/samples/piano/piano_rel_99_x.opus +0 -0
- package/starter/samples/pizz/pizz_24_2.flac +0 -0
- package/starter/samples/pizz/pizz_28_2.flac +0 -0
- package/starter/samples/pizz/pizz_31_2.flac +0 -0
- package/starter/samples/pizz/pizz_35_2.flac +0 -0
- package/starter/samples/pizz/pizz_38_2.flac +0 -0
- package/starter/samples/pizz/pizz_41_2.flac +0 -0
- package/starter/samples/pizz/pizz_45_2.flac +0 -0
- package/starter/samples/pizz/pizz_48_2.flac +0 -0
- package/starter/samples/pizz/pizz_52_2.flac +0 -0
- package/starter/samples/pizz/pizz_57_2.flac +0 -0
- package/starter/samples/pizz/pizz_60_2.flac +0 -0
- package/starter/samples/pizz/pizz_64_2.flac +0 -0
- package/starter/samples/pizz/pizz_67_2.flac +0 -0
- package/starter/samples/pizz/pizz_71_2.flac +0 -0
- package/starter/samples/pizz/pizz_74_2.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_2_1.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_2_2.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_6_1.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_6_2.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_3_1.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_3_2.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_7_1.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_7_2.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_3_1.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_3_2.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_6_1.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_6_2.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_2_1.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_2_2.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_5_1.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_5_2.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_3_1.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_3_2.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_7_1.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_7_2.flac +0 -0
- package/starter/samples/shaker/shaker_1_1.flac +0 -0
- package/starter/samples/shaker/shaker_2_1.flac +0 -0
- package/starter/samples/snap/snap_r_1.flac +0 -0
- package/starter/samples/snap/snap_r_2.flac +0 -0
- package/starter/samples/snap/snap_r_3.flac +0 -0
- package/starter/samples/snap/snap_r_4.flac +0 -0
- package/starter/samples/snap/snap_r_5.flac +0 -0
- package/starter/samples/snap/snap_r_6.flac +0 -0
- package/starter/samples/tom/tom_3_1.flac +0 -0
- package/starter/samples/tom/tom_3_2.flac +0 -0
- package/starter/samples/tom/tom_4_1.flac +0 -0
- package/starter/samples/tom/tom_4_2.flac +0 -0
- package/starter/samples/vibes/vibes_41_1.opus +0 -0
- package/starter/samples/vibes/vibes_41_2.opus +0 -0
- package/starter/samples/vibes/vibes_45_1.opus +0 -0
- package/starter/samples/vibes/vibes_45_2.opus +0 -0
- package/starter/samples/vibes/vibes_48_1.opus +0 -0
- package/starter/samples/vibes/vibes_48_2.opus +0 -0
- package/starter/samples/vibes/vibes_52_1.opus +0 -0
- package/starter/samples/vibes/vibes_52_2.opus +0 -0
- package/starter/samples/vibes/vibes_55_1.opus +0 -0
- package/starter/samples/vibes/vibes_55_2.opus +0 -0
- package/starter/samples/vibes/vibes_59_1.opus +0 -0
- package/starter/samples/vibes/vibes_59_2.opus +0 -0
- package/starter/samples/vibes/vibes_62_1.opus +0 -0
- package/starter/samples/vibes/vibes_62_2.opus +0 -0
- package/starter/samples/vibes/vibes_65_1.opus +0 -0
- package/starter/samples/vibes/vibes_65_2.opus +0 -0
- package/starter/samples/vibes/vibes_69_1.opus +0 -0
- package/starter/samples/vibes/vibes_69_2.opus +0 -0
- package/starter/samples/vibes/vibes_72_1.opus +0 -0
- package/starter/samples/vibes/vibes_72_2.opus +0 -0
- package/starter/samples/vibes/vibes_76_1.opus +0 -0
- package/starter/samples/vibes/vibes_76_2.opus +0 -0
- package/starter/samples/violas/violas_36_1.opus +0 -0
- package/starter/samples/violas/violas_36_2.opus +0 -0
- package/starter/samples/violas/violas_38_1.opus +0 -0
- package/starter/samples/violas/violas_38_2.opus +0 -0
- package/starter/samples/violas/violas_40_1.opus +0 -0
- package/starter/samples/violas/violas_40_2.opus +0 -0
- package/starter/samples/violas/violas_43_1.opus +0 -0
- package/starter/samples/violas/violas_43_2.opus +0 -0
- package/starter/samples/violas/violas_47_1.opus +0 -0
- package/starter/samples/violas/violas_47_2.opus +0 -0
- package/starter/samples/violas/violas_50_1.opus +0 -0
- package/starter/samples/violas/violas_50_2.opus +0 -0
- package/starter/samples/violas/violas_53_1.opus +0 -0
- package/starter/samples/violas/violas_53_2.opus +0 -0
- package/starter/samples/violas/violas_57_1.opus +0 -0
- package/starter/samples/violas/violas_57_2.opus +0 -0
- package/starter/samples/violas/violas_60_1.opus +0 -0
- package/starter/samples/violas/violas_60_2.opus +0 -0
- package/starter/samples/violas/violas_64_1.opus +0 -0
- package/starter/samples/violas/violas_64_2.opus +0 -0
- package/starter/samples/violas/violas_67_1.opus +0 -0
- package/starter/samples/violas/violas_67_2.opus +0 -0
- package/starter/samples/violas/violas_71_1.opus +0 -0
- package/starter/samples/violas/violas_71_2.opus +0 -0
- package/starter/samples/violas/violas_74_1.opus +0 -0
- package/starter/samples/violas/violas_74_2.opus +0 -0
- package/starter/samples/violins/violins_43_1.opus +0 -0
- package/starter/samples/violins/violins_43_2.opus +0 -0
- package/starter/samples/violins/violins_45_1.opus +0 -0
- package/starter/samples/violins/violins_45_2.opus +0 -0
- package/starter/samples/violins/violins_47_1.opus +0 -0
- package/starter/samples/violins/violins_47_2.opus +0 -0
- package/starter/samples/violins/violins_50_1.opus +0 -0
- package/starter/samples/violins/violins_50_2.opus +0 -0
- package/starter/samples/violins/violins_54_1.opus +0 -0
- package/starter/samples/violins/violins_54_2.opus +0 -0
- package/starter/samples/violins/violins_57_1.opus +0 -0
- package/starter/samples/violins/violins_57_2.opus +0 -0
- package/starter/samples/violins/violins_60_1.opus +0 -0
- package/starter/samples/violins/violins_60_2.opus +0 -0
- package/starter/samples/violins/violins_64_1.opus +0 -0
- package/starter/samples/violins/violins_64_2.opus +0 -0
- package/starter/samples/violins/violins_67_1.opus +0 -0
- package/starter/samples/violins/violins_67_2.opus +0 -0
- package/starter/samples/violins/violins_71_1.opus +0 -0
- package/starter/samples/violins/violins_71_2.opus +0 -0
- package/starter/samples/violins/violins_74_1.opus +0 -0
- package/starter/samples/violins/violins_74_2.opus +0 -0
- package/starter/samples/woodblock/woodblock_f_1.flac +0 -0
- package/starter/samples/woodblock/woodblock_f_2.flac +0 -0
|
@@ -0,0 +1,3276 @@
|
|
|
1
|
+
// `open-take film gallery`: what each building block of the film kit does,
|
|
2
|
+
// drawn — so a film's author can see a block before choosing it, and see it
|
|
3
|
+
// on its own product rather than on a grey box.
|
|
4
|
+
//
|
|
5
|
+
// Every block of kit/motion.js, every camera option of kit/camera.js, the
|
|
6
|
+
// helpers of kit/cut.js, the marks and light of kit/draw.js, the places of
|
|
7
|
+
// kit/map.js, the moves of kit/stage.js and the seams of kit/seams.js (each
|
|
8
|
+
// when the kit has it) gets one PNG: the block at six
|
|
9
|
+
// instants, its value over time and its speed, with the default and three
|
|
10
|
+
// other settings side by side — defaults are one choice among many, and seeing
|
|
11
|
+
// them next to others keeps them from becoming every film's look. The blocks
|
|
12
|
+
// run as the film would run them: the kit's own functions (the film's copy
|
|
13
|
+
// when a film folder is given), their numbers put into CSS on a stage of the
|
|
14
|
+
// film's size, of which each cell shows a window.
|
|
15
|
+
//
|
|
16
|
+
// With --with, the stage is the product's own material: a picture, a saved
|
|
17
|
+
// screen (`make --states`, its live.png and the boxes of everything on it) or
|
|
18
|
+
// a take (its first saved screen, else a frame of its recording); one element
|
|
19
|
+
// of it (--subject, or one chosen and said) is what the blocks lift and move.
|
|
20
|
+
//
|
|
21
|
+
// The numbers under each setting — when it settles, how far it swings past its
|
|
22
|
+
// rest, its top speed — are measured on the function's output, sampled every
|
|
23
|
+
// millisecond; one that never happens in the window is "not detected". None
|
|
24
|
+
// of them is a target.
|
|
25
|
+
|
|
26
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
27
|
+
import { copyFile, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
28
|
+
import { tmpdir } from "node:os";
|
|
29
|
+
import { basename, dirname, extname, join, relative, resolve } from "node:path";
|
|
30
|
+
import { pathToFileURL } from "node:url";
|
|
31
|
+
import { resolveFfmpeg, resolveFfprobe, runTool } from "../ffmpeg";
|
|
32
|
+
import { launchHtmlBrowser } from "../html/cdp";
|
|
33
|
+
import { serveDirectory } from "../html/server";
|
|
34
|
+
import { readStateIndex, type StateElement, type StateIndex } from "../state-index";
|
|
35
|
+
import { filmKitDir, THREE_FILES, threeBuildDir } from "./kit";
|
|
36
|
+
import { filmPicture } from "./picture";
|
|
37
|
+
|
|
38
|
+
// --- what comes back ------------------------------------------------------------------
|
|
39
|
+
|
|
40
|
+
/** a region of the stage, CSS px */
|
|
41
|
+
export type GalleryBox = { x: number; y: number; width: number; height: number };
|
|
42
|
+
|
|
43
|
+
export type GalleryMaterial = {
|
|
44
|
+
/** what the stage shows: a neutral stand-in when no --with was given */
|
|
45
|
+
kind: "placeholder" | "image" | "state" | "video";
|
|
46
|
+
/** what --with named (null for the stand-in) */
|
|
47
|
+
source: string | null;
|
|
48
|
+
/** the picture used (a saved screen's live.png, the take's frame, the image) */
|
|
49
|
+
picture: string | null;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
/** what the blocks lift and move */
|
|
53
|
+
subject: GalleryBox & {
|
|
54
|
+
label: string;
|
|
55
|
+
/** how it was picked: given, chosen automatically (and from what), or a fallback */
|
|
56
|
+
how: string;
|
|
57
|
+
};
|
|
58
|
+
/** a second region, unlike the subject: where a match cut lands */
|
|
59
|
+
other: GalleryBox & { label: string };
|
|
60
|
+
/** what type/untype write: the subject's own text when it has some */
|
|
61
|
+
text: string;
|
|
62
|
+
notes: string[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** one setting's numbers, measured on the function's output (1 ms apart) */
|
|
66
|
+
export type GalleryStats = {
|
|
67
|
+
/** the value where the block starts and where it comes to rest */
|
|
68
|
+
from: number;
|
|
69
|
+
to: number;
|
|
70
|
+
/** s after the block starts until it stays within 1 % of its travel (or of
|
|
71
|
+
* its peak, for a move that comes back to where it was); null: not detected
|
|
72
|
+
* in the window measured */
|
|
73
|
+
settle: number | null;
|
|
74
|
+
/** how far it first goes past its rest, as a share of the travel; null for a
|
|
75
|
+
* move that comes back to where it was */
|
|
76
|
+
swing: number | null;
|
|
77
|
+
/** the largest distance from its rest, for a move that comes back (a kick, a
|
|
78
|
+
* shake, a press); null otherwise */
|
|
79
|
+
peak: number | null;
|
|
80
|
+
/** the top speed (value units a second) and when (s after the start) */
|
|
81
|
+
peakSpeed: number;
|
|
82
|
+
peakSpeedAt: number;
|
|
83
|
+
/** the window each speed is the change over (s): 2 ms, or a stepping value's */
|
|
84
|
+
speedOver: number;
|
|
85
|
+
/** when the value jumps (a cut: a quarter of its travel within 1 ms), s
|
|
86
|
+
* after the start; its "speed" there is the jump over 2 ms, not a speed */
|
|
87
|
+
jump: number | null;
|
|
88
|
+
/** how long was measured (s after the start) */
|
|
89
|
+
window: number;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type GalleryRow = {
|
|
93
|
+
label: string;
|
|
94
|
+
stats: GalleryStats | null;
|
|
95
|
+
/** what the PNG and index.md say under the setting */
|
|
96
|
+
text: string;
|
|
97
|
+
error?: string;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type GalleryEntry = {
|
|
101
|
+
name: string;
|
|
102
|
+
group: "motion" | "camera" | "cut" | "draw" | "map" | "stage" | "seams" | "world";
|
|
103
|
+
/** the call, as the film writes it */
|
|
104
|
+
signature: string;
|
|
105
|
+
/** where its defaults come from */
|
|
106
|
+
note: string;
|
|
107
|
+
/** what the plotted value is, and its unit */
|
|
108
|
+
value: string;
|
|
109
|
+
/** the PNG (absolute), or null when it could not be drawn */
|
|
110
|
+
png: string | null;
|
|
111
|
+
rows: GalleryRow[];
|
|
112
|
+
/** why it could not be drawn (a kit changed under it, a missing export) */
|
|
113
|
+
error?: string;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export type FilmGalleryOptions = {
|
|
117
|
+
chromePath: string;
|
|
118
|
+
/** the folder to write the PNGs, index.md and gallery.json into */
|
|
119
|
+
out: string;
|
|
120
|
+
/** a film folder (its kit/ is used) or a kit folder; default: the kit this package ships */
|
|
121
|
+
kit?: string;
|
|
122
|
+
/** names (rise, camera.shake), or groups (motion, camera, cut); default all */
|
|
123
|
+
blocks?: string[];
|
|
124
|
+
/** a picture, a saved screen (state folder or its state.html) or a take */
|
|
125
|
+
with?: string;
|
|
126
|
+
/** the element to move: a saved screen's element id (e12), its text, or x,y,w,h */
|
|
127
|
+
subject?: string;
|
|
128
|
+
/** a beats file (`open-take film beats`): kit/cut.js is drawn on the film's
|
|
129
|
+
* own music; default a stand-in pulse */
|
|
130
|
+
beats?: string;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export type FilmGalleryResult = {
|
|
134
|
+
out: string;
|
|
135
|
+
index: string;
|
|
136
|
+
json: string;
|
|
137
|
+
kit: string;
|
|
138
|
+
material: GalleryMaterial;
|
|
139
|
+
entries: GalleryEntry[];
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// --- the kit --------------------------------------------------------------------------
|
|
143
|
+
|
|
144
|
+
// biome-ignore lint/suspicious/noExplicitAny: the kit is the film's own JavaScript, untyped here
|
|
145
|
+
type Mod = Record<string, any>;
|
|
146
|
+
type Kit = {
|
|
147
|
+
dir: string;
|
|
148
|
+
motion: Mod;
|
|
149
|
+
camera: Mod;
|
|
150
|
+
cut: Mod | null;
|
|
151
|
+
draw: Mod | null;
|
|
152
|
+
map: Mod | null;
|
|
153
|
+
stage: Mod | null;
|
|
154
|
+
seams: Mod | null;
|
|
155
|
+
world: Mod | null;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/** the kit folder a --kit names: a film's kit/, or a kit folder itself */
|
|
159
|
+
export function galleryKitDir(given?: string): string {
|
|
160
|
+
if (!given) return filmKitDir();
|
|
161
|
+
const dir = resolve(given);
|
|
162
|
+
if (existsSync(join(dir, "kit", "motion.js"))) return join(dir, "kit");
|
|
163
|
+
if (existsSync(join(dir, "motion.js"))) return dir;
|
|
164
|
+
throw new Error(
|
|
165
|
+
`film gallery: no kit at ${given} (neither kit/motion.js nor motion.js is there)`,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async function loadKit(dir: string): Promise<Kit> {
|
|
170
|
+
// a fresh copy each time: the film's author may have just changed it
|
|
171
|
+
const load = async (name: string): Promise<Mod | null> => {
|
|
172
|
+
const file = join(dir, name);
|
|
173
|
+
if (!existsSync(file)) return null;
|
|
174
|
+
const m = (await import(`${pathToFileURL(file).href}?gallery=${Date.now()}`)) as Mod;
|
|
175
|
+
// a kit outside any package.json may come back as CommonJS (a loader that
|
|
176
|
+
// transpiles it): its exports are then on `default`
|
|
177
|
+
return m.default && typeof m.default === "object" ? { ...m.default, ...m } : m;
|
|
178
|
+
};
|
|
179
|
+
return {
|
|
180
|
+
dir,
|
|
181
|
+
motion: (await load("motion.js")) ?? {},
|
|
182
|
+
camera: (await load("camera.js")) ?? {},
|
|
183
|
+
cut: await load("cut.js"),
|
|
184
|
+
draw: await load("draw.js"),
|
|
185
|
+
map: await load("map.js"),
|
|
186
|
+
stage: await load("stage.js"),
|
|
187
|
+
seams: await load("seams.js"),
|
|
188
|
+
world: await load("world.js"),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// --- the material ---------------------------------------------------------------------
|
|
193
|
+
|
|
194
|
+
const IMAGE = new Set([".png", ".jpg", ".jpeg", ".webp", ".gif", ".svg", ".avif"]);
|
|
195
|
+
const VIDEO = new Set([".mp4", ".webm", ".mov", ".mkv"]);
|
|
196
|
+
const DEFAULT_TEXT = "typed on the film's time";
|
|
197
|
+
|
|
198
|
+
const area = (b: GalleryBox) => b.width * b.height;
|
|
199
|
+
|
|
200
|
+
/** the subject a --subject names in a saved screen, or why none */
|
|
201
|
+
export function pickSubject(
|
|
202
|
+
index: Pick<StateIndex, "viewport" | "elements">,
|
|
203
|
+
given?: string,
|
|
204
|
+
): { box: GalleryBox; label: string; how: string; text?: string } {
|
|
205
|
+
const vw = index.viewport.w;
|
|
206
|
+
const vh = index.viewport.h;
|
|
207
|
+
const boxOf = (e: StateElement): GalleryBox => ({
|
|
208
|
+
x: e.box[0],
|
|
209
|
+
y: e.box[1],
|
|
210
|
+
width: e.box[2],
|
|
211
|
+
height: e.box[3],
|
|
212
|
+
});
|
|
213
|
+
const onScreen = (b: GalleryBox) =>
|
|
214
|
+
b.width >= 4 &&
|
|
215
|
+
b.height >= 4 &&
|
|
216
|
+
b.x < vw &&
|
|
217
|
+
b.y < vh &&
|
|
218
|
+
b.x + b.width > 0 &&
|
|
219
|
+
b.y + b.height > 0;
|
|
220
|
+
const name = (e: StateElement) => (e.name ?? e.text ?? "").trim();
|
|
221
|
+
const describe = (e: StateElement) =>
|
|
222
|
+
`${e.id} <${e.tag}${e.role ? ` role=${e.role}` : ""}>${name(e) ? ` "${name(e).slice(0, 40)}"` : ""}`;
|
|
223
|
+
if (given) {
|
|
224
|
+
const rect = given.split(",").map(Number);
|
|
225
|
+
if (rect.length === 4 && rect.every(Number.isFinite)) {
|
|
226
|
+
const [x, y, width, height] = rect as [number, number, number, number];
|
|
227
|
+
if (!(width > 0 && height > 0))
|
|
228
|
+
throw new Error(`film gallery: --subject ${given}: a box needs a width and a height`);
|
|
229
|
+
return { box: { x, y, width, height }, label: `box ${given}`, how: "given (--subject)" };
|
|
230
|
+
}
|
|
231
|
+
const byId = index.elements.find((e) => e.id === given);
|
|
232
|
+
const exact = index.elements.filter((e) => name(e) === given && onScreen(boxOf(e)));
|
|
233
|
+
const part = index.elements.filter((e) => name(e).includes(given) && onScreen(boxOf(e)));
|
|
234
|
+
// the smallest element carrying the text is the one that is it, not its container
|
|
235
|
+
const smallest = (es: StateElement[]) =>
|
|
236
|
+
[...es].sort((a, b) => area(boxOf(a)) - area(boxOf(b)))[0];
|
|
237
|
+
const e = byId ?? smallest(exact) ?? smallest(part);
|
|
238
|
+
if (!e)
|
|
239
|
+
throw new Error(
|
|
240
|
+
index.elements.length
|
|
241
|
+
? `film gallery: --subject ${given}: no element of the saved screen has that id or text (or x,y,w,h)`
|
|
242
|
+
: `film gallery: --subject ${given}: a picture or the stand-in has no elements to name — give a box, x,y,w,h`,
|
|
243
|
+
);
|
|
244
|
+
return { box: boxOf(e), label: describe(e), how: "given (--subject)", text: name(e) };
|
|
245
|
+
}
|
|
246
|
+
// the first control of a size a viewer can see, in the page's order: what a
|
|
247
|
+
// film most often lifts. Said, so another can be asked for.
|
|
248
|
+
const share = (b: GalleryBox) => area(b) / (vw * vh);
|
|
249
|
+
const fits = (e: StateElement) => {
|
|
250
|
+
const b = boxOf(e);
|
|
251
|
+
return onScreen(b) && share(b) >= 0.001 && share(b) <= 0.08 && b.x >= 0 && b.y >= 0;
|
|
252
|
+
};
|
|
253
|
+
const rank = (e: StateElement) =>
|
|
254
|
+
e.role === "button" || e.tag === "button" ? 0 : e.role === "link" || e.tag === "a" ? 1 : 2;
|
|
255
|
+
const controls = index.elements
|
|
256
|
+
.filter((e) => e.interactive && fits(e) && name(e))
|
|
257
|
+
.sort((a, b) => rank(a) - rank(b));
|
|
258
|
+
const any = controls[0] ?? index.elements.find((e) => fits(e) && name(e));
|
|
259
|
+
if (any)
|
|
260
|
+
return {
|
|
261
|
+
box: boxOf(any),
|
|
262
|
+
label: describe(any),
|
|
263
|
+
how: `chosen automatically — the first ${any.interactive ? "control" : "element"} with a name and a visible size (--subject <id|text|x,y,w,h> picks another)`,
|
|
264
|
+
text: name(any),
|
|
265
|
+
};
|
|
266
|
+
return {
|
|
267
|
+
box: middle(vw, vh),
|
|
268
|
+
label: "the middle of the screen",
|
|
269
|
+
how: "no element to choose — the middle of the picture (--subject picks one)",
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const middle = (w: number, h: number): GalleryBox => ({
|
|
274
|
+
x: w / 3,
|
|
275
|
+
y: h / 3,
|
|
276
|
+
width: w / 3,
|
|
277
|
+
height: h / 3,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
/** a second element of a saved screen, unlike the subject in place and shape
|
|
281
|
+
* (where a match cut lands); else the subject mirrored through the centre */
|
|
282
|
+
export function pickOther(
|
|
283
|
+
index: Pick<StateIndex, "viewport" | "elements">,
|
|
284
|
+
subject: GalleryBox,
|
|
285
|
+
): GalleryBox & { label: string } {
|
|
286
|
+
const vw = index.viewport.w;
|
|
287
|
+
const vh = index.viewport.h;
|
|
288
|
+
const aspect = (b: GalleryBox) => b.width / b.height;
|
|
289
|
+
const apart = (a: GalleryBox, b: GalleryBox) =>
|
|
290
|
+
a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y;
|
|
291
|
+
// a control first, as the subject is chosen; then any element
|
|
292
|
+
const order = [
|
|
293
|
+
...index.elements.filter((e) => e.interactive),
|
|
294
|
+
...index.elements.filter((e) => !e.interactive),
|
|
295
|
+
];
|
|
296
|
+
for (const e of order) {
|
|
297
|
+
const b = { x: e.box[0], y: e.box[1], width: e.box[2], height: e.box[3] };
|
|
298
|
+
const share = area(b) / (vw * vh);
|
|
299
|
+
const name = (e.name ?? e.text ?? "").trim();
|
|
300
|
+
if (
|
|
301
|
+
name &&
|
|
302
|
+
share >= 0.002 &&
|
|
303
|
+
share <= 0.15 &&
|
|
304
|
+
b.x >= 0 &&
|
|
305
|
+
b.y >= 0 &&
|
|
306
|
+
b.x + b.width <= vw &&
|
|
307
|
+
b.y + b.height <= vh &&
|
|
308
|
+
apart(b, subject) &&
|
|
309
|
+
Math.abs(Math.log(aspect(b) / aspect(subject))) > 0.4
|
|
310
|
+
)
|
|
311
|
+
return { ...b, label: `${e.id} <${e.tag}> "${name.slice(0, 40)}"` };
|
|
312
|
+
}
|
|
313
|
+
return mirrored(vw, vh, subject);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** the subject mirrored through the picture's centre, twice as wide: another
|
|
317
|
+
* place and another shape */
|
|
318
|
+
const mirrored = (w: number, h: number, s: GalleryBox): GalleryBox & { label: string } => {
|
|
319
|
+
const width = Math.min(w / 2, s.width * 2);
|
|
320
|
+
return {
|
|
321
|
+
x: Math.max(0, w - s.x - s.width / 2 - width / 2),
|
|
322
|
+
y: Math.max(0, h - s.y - s.height),
|
|
323
|
+
width,
|
|
324
|
+
height: s.height,
|
|
325
|
+
label: "the subject's mirror image, twice as wide",
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
/** a neutral stand-in interface: greys only, so no look comes from the gallery */
|
|
330
|
+
function placeholderSvg(w: number, h: number, s: GalleryBox): string {
|
|
331
|
+
const cards: string[] = [];
|
|
332
|
+
for (let i = 0; i < 3; i++)
|
|
333
|
+
for (let j = 0; j < 2; j++) {
|
|
334
|
+
const x = 340 + i * 420;
|
|
335
|
+
const y = 150 + j * 330;
|
|
336
|
+
cards.push(
|
|
337
|
+
`<rect x="${x}" y="${y}" width="380" height="290" rx="18" fill="#f6f6f4"/>` +
|
|
338
|
+
`<rect x="${x + 28}" y="${y + 34}" width="200" height="22" rx="6" fill="#c9c9c5"/>` +
|
|
339
|
+
`<rect x="${x + 28}" y="${y + 78}" width="300" height="14" rx="5" fill="#dcdcd8"/>` +
|
|
340
|
+
`<rect x="${x + 28}" y="${y + 104}" width="260" height="14" rx="5" fill="#dcdcd8"/>`,
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}">
|
|
344
|
+
<rect width="${w}" height="${h}" fill="#e9e9e6"/>
|
|
345
|
+
<rect width="${w}" height="80" fill="#d5d5d1"/><rect x="40" y="26" width="160" height="28" rx="8" fill="#b4b4af"/>
|
|
346
|
+
<rect y="80" width="280" height="${h - 80}" fill="#dfdfdb"/>
|
|
347
|
+
${[0, 1, 2, 3, 4].map((i) => `<rect x="36" y="${130 + i * 64}" width="200" height="20" rx="6" fill="#c4c4bf"/>`).join("")}
|
|
348
|
+
${cards.join("\n")}
|
|
349
|
+
<rect x="${s.x}" y="${s.y}" width="${s.width}" height="${s.height}" rx="${Math.min(s.height / 2, 24)}" fill="#4a4a47"/>
|
|
350
|
+
<text x="${s.x + s.width / 2}" y="${s.y + s.height / 2 + 13}" font-family="ui-monospace, Menlo, monospace" font-size="36" fill="#f4f4f2" text-anchor="middle">subject</text>
|
|
351
|
+
</svg>`;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** the take folder a path names: a .take folder, or a take's MP4 with its .take beside it */
|
|
355
|
+
function takeDir(p: string): string | null {
|
|
356
|
+
if (statSync(p).isDirectory())
|
|
357
|
+
return existsSync(join(p, "states")) || existsSync(join(p, "capture.mp4")) ? p : null;
|
|
358
|
+
const beside = p.replace(/\.[^./\\]+$/, ".take");
|
|
359
|
+
return beside !== p && existsSync(beside) && statSync(beside).isDirectory() ? beside : null;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** a take's saved screens, in recording order, the faithful ones first */
|
|
363
|
+
function takeStates(take: string): { dir: string; index: StateIndex }[] {
|
|
364
|
+
const root = join(take, "states");
|
|
365
|
+
if (!existsSync(root)) return [];
|
|
366
|
+
return readdirSync(root)
|
|
367
|
+
.map((id) => join(root, id))
|
|
368
|
+
.filter((d) => existsSync(join(d, "index.json")))
|
|
369
|
+
.map((dir) => ({ dir, index: readStateIndex(dir) }))
|
|
370
|
+
.filter((s): s is { dir: string; index: StateIndex } => typeof s.index !== "string")
|
|
371
|
+
.sort(
|
|
372
|
+
(a, b) =>
|
|
373
|
+
Number(a.index.fidelity?.ok === false) - Number(b.index.fidelity?.ok === false) ||
|
|
374
|
+
a.index.tMs - b.index.tMs,
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
async function videoFrame(video: string, out: string): Promise<void> {
|
|
379
|
+
let at = 0;
|
|
380
|
+
try {
|
|
381
|
+
const d = Number(
|
|
382
|
+
(
|
|
383
|
+
await runTool(await resolveFfprobe(), [
|
|
384
|
+
"-v",
|
|
385
|
+
"error",
|
|
386
|
+
"-show_entries",
|
|
387
|
+
"format=duration",
|
|
388
|
+
"-of",
|
|
389
|
+
"default=nw=1:nk=1",
|
|
390
|
+
video,
|
|
391
|
+
])
|
|
392
|
+
).trim(),
|
|
393
|
+
);
|
|
394
|
+
if (Number.isFinite(d) && d > 0) at = d / 3;
|
|
395
|
+
} catch {
|
|
396
|
+
/* no duration: its first frame */
|
|
397
|
+
}
|
|
398
|
+
await runTool(await resolveFfmpeg(), [
|
|
399
|
+
"-v",
|
|
400
|
+
"error",
|
|
401
|
+
"-y",
|
|
402
|
+
"-ss",
|
|
403
|
+
at.toFixed(3),
|
|
404
|
+
"-i",
|
|
405
|
+
video,
|
|
406
|
+
"-frames:v",
|
|
407
|
+
"1",
|
|
408
|
+
out,
|
|
409
|
+
]);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** the stage the blocks run on, copied into `tmp` as material.<ext> */
|
|
413
|
+
async function resolveMaterial(
|
|
414
|
+
opts: Pick<FilmGalleryOptions, "with" | "subject" | "chromePath">,
|
|
415
|
+
tmp: string,
|
|
416
|
+
): Promise<GalleryMaterial & { file: string }> {
|
|
417
|
+
const notes: string[] = [];
|
|
418
|
+
if (!opts.with) {
|
|
419
|
+
const w = 1920;
|
|
420
|
+
const h = 1080;
|
|
421
|
+
const s = { x: 1180, y: 620, width: 380, height: 110 };
|
|
422
|
+
let subject = { ...s, label: "the stand-in's dark button", how: "the stand-in's own" };
|
|
423
|
+
if (opts.subject) {
|
|
424
|
+
const p = pickSubject({ viewport: { w, h, dpr: 1 }, elements: [] }, opts.subject);
|
|
425
|
+
subject = { ...p.box, label: p.label, how: p.how };
|
|
426
|
+
}
|
|
427
|
+
const file = join(tmp, "material.svg");
|
|
428
|
+
await writeFile(file, placeholderSvg(w, h, subject));
|
|
429
|
+
return {
|
|
430
|
+
kind: "placeholder",
|
|
431
|
+
source: null,
|
|
432
|
+
picture: null,
|
|
433
|
+
file,
|
|
434
|
+
width: w,
|
|
435
|
+
height: h,
|
|
436
|
+
subject,
|
|
437
|
+
other: { x: 760, y: 150, width: 380, height: 290, label: "the stand-in's second card" },
|
|
438
|
+
text: DEFAULT_TEXT,
|
|
439
|
+
notes: [
|
|
440
|
+
"no --with: a neutral stand-in interface; --with <picture|state|take> shows the product's own",
|
|
441
|
+
],
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
const given = resolve(opts.with);
|
|
445
|
+
if (!existsSync(given)) throw new Error(`film gallery: --with ${opts.with}: nothing there`);
|
|
446
|
+
let stateDir: string | null = null;
|
|
447
|
+
const take = takeDir(given);
|
|
448
|
+
if (statSync(given).isDirectory() && existsSync(join(given, "index.json"))) stateDir = given;
|
|
449
|
+
else if (extname(given).toLowerCase() === ".html") stateDir = dirname(given);
|
|
450
|
+
else if (take) {
|
|
451
|
+
const states = takeStates(take);
|
|
452
|
+
if (states[0]) {
|
|
453
|
+
stateDir = states[0].dir;
|
|
454
|
+
const others = states.slice(1).map((s) => s.index.id);
|
|
455
|
+
notes.push(
|
|
456
|
+
`the take's saved screen ${states[0].index.id} (the first${states[0].index.fidelity?.ok === false ? "" : " faithful one"} in recording order)` +
|
|
457
|
+
(others.length
|
|
458
|
+
? `; others: ${others.join(", ")} — --with ${relative(process.cwd(), join(take, "states")) || "."}/<id> shows one`
|
|
459
|
+
: ""),
|
|
460
|
+
);
|
|
461
|
+
} else if (existsSync(join(take, "capture.mp4"))) {
|
|
462
|
+
const file = join(tmp, "material.png");
|
|
463
|
+
await videoFrame(join(take, "capture.mp4"), file);
|
|
464
|
+
notes.push("the take has no saved screens: a frame a third of the way into its recording");
|
|
465
|
+
return withSubject("video", opts, file, notes, given);
|
|
466
|
+
} else
|
|
467
|
+
throw new Error(
|
|
468
|
+
`film gallery: --with ${opts.with}: a take with neither states nor capture.mp4`,
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
if (stateDir) {
|
|
472
|
+
const index = readStateIndex(stateDir);
|
|
473
|
+
if (typeof index === "string") throw new Error(`film gallery: --with ${opts.with}: ${index}`);
|
|
474
|
+
const file = join(tmp, "material.png");
|
|
475
|
+
if (existsSync(join(stateDir, "live.png"))) await copyFile(join(stateDir, "live.png"), file);
|
|
476
|
+
else {
|
|
477
|
+
notes.push("the saved screen has no live.png: drawn from its state.html");
|
|
478
|
+
await filmPicture({ state: stateDir, chromePath: opts.chromePath, scale: 1, out: file });
|
|
479
|
+
}
|
|
480
|
+
const p = pickSubject(index, opts.subject);
|
|
481
|
+
return {
|
|
482
|
+
kind: "state",
|
|
483
|
+
source: opts.with,
|
|
484
|
+
picture: existsSync(join(stateDir, "live.png")) ? join(stateDir, "live.png") : null,
|
|
485
|
+
file,
|
|
486
|
+
width: index.viewport.w,
|
|
487
|
+
height: index.viewport.h,
|
|
488
|
+
subject: { ...p.box, label: p.label, how: p.how },
|
|
489
|
+
other: pickOther(index, p.box),
|
|
490
|
+
text:
|
|
491
|
+
p.text && Array.from(p.text).length >= 3
|
|
492
|
+
? Array.from(p.text).slice(0, 40).join("")
|
|
493
|
+
: DEFAULT_TEXT,
|
|
494
|
+
notes,
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
const ext = extname(given).toLowerCase();
|
|
498
|
+
if (IMAGE.has(ext)) {
|
|
499
|
+
const file = join(tmp, `material${ext}`);
|
|
500
|
+
await copyFile(given, file);
|
|
501
|
+
return withSubject("image", opts, file, notes, given);
|
|
502
|
+
}
|
|
503
|
+
if (VIDEO.has(ext)) {
|
|
504
|
+
const file = join(tmp, "material.png");
|
|
505
|
+
await videoFrame(given, file);
|
|
506
|
+
notes.push("a frame a third of the way into the video");
|
|
507
|
+
return withSubject("video", opts, file, notes, given);
|
|
508
|
+
}
|
|
509
|
+
throw new Error(
|
|
510
|
+
`film gallery: --with ${opts.with}: not a picture, a video, a saved screen or a take`,
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/** a picture's material: its size is read where it is drawn (filled in later) */
|
|
515
|
+
function withSubject(
|
|
516
|
+
kind: "image" | "video",
|
|
517
|
+
opts: Pick<FilmGalleryOptions, "with" | "subject">,
|
|
518
|
+
file: string,
|
|
519
|
+
notes: string[],
|
|
520
|
+
source: string,
|
|
521
|
+
): GalleryMaterial & { file: string } {
|
|
522
|
+
return {
|
|
523
|
+
kind,
|
|
524
|
+
source: opts.with ?? null,
|
|
525
|
+
picture: kind === "image" ? source : null,
|
|
526
|
+
file,
|
|
527
|
+
width: 0,
|
|
528
|
+
height: 0,
|
|
529
|
+
// a picture has no elements: a box, or the middle (set once its size is known)
|
|
530
|
+
subject: { x: 0, y: 0, width: 0, height: 0, label: "", how: opts.subject ?? "" },
|
|
531
|
+
other: { x: 0, y: 0, width: 0, height: 0, label: "" },
|
|
532
|
+
text: DEFAULT_TEXT,
|
|
533
|
+
notes,
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// --- the blocks -----------------------------------------------------------------------
|
|
538
|
+
|
|
539
|
+
type Row = { label: string; o: Record<string, unknown> };
|
|
540
|
+
type Block = {
|
|
541
|
+
name: string;
|
|
542
|
+
group: GalleryEntry["group"];
|
|
543
|
+
signature: string;
|
|
544
|
+
note: string;
|
|
545
|
+
/** exports it needs, as "motion.rise" */
|
|
546
|
+
needs: string[];
|
|
547
|
+
/** the strip and the plots cover [t0, t1] (s); the block starts at `start` (default t0) */
|
|
548
|
+
t0: number;
|
|
549
|
+
t1: number;
|
|
550
|
+
start?: number;
|
|
551
|
+
/** the six instants drawn (default: evenly over [t0, t1]); per setting when a function */
|
|
552
|
+
frames?: number[] | ((row: Row) => number[]);
|
|
553
|
+
/** what each cell shows: a window around the subject, or the whole stage */
|
|
554
|
+
view: "subject" | "full";
|
|
555
|
+
/** what the window is around, when not the subject (or its line of text) */
|
|
556
|
+
focus?: GalleryBox;
|
|
557
|
+
rows: Row[];
|
|
558
|
+
/** the stage at t for one setting: HTML in stage px */
|
|
559
|
+
draw: (t: number, row: Row) => string;
|
|
560
|
+
value: (t: number, row: Row) => number;
|
|
561
|
+
valueLabel: string;
|
|
562
|
+
/** the speed is the change over this many s (default 1 ms): a value that
|
|
563
|
+
* steps (characters shown) has a rate only over a window */
|
|
564
|
+
speedOver?: number;
|
|
565
|
+
/** what to say under a setting instead of the motion numbers (a cut's) */
|
|
566
|
+
describe?: (row: Row) => string;
|
|
567
|
+
/** times to mark on the plots (a grid's beats) */
|
|
568
|
+
marks?: number[];
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
const CW = 224;
|
|
572
|
+
const CH = 126;
|
|
573
|
+
const GAP = 10;
|
|
574
|
+
const LABEL_W = 196;
|
|
575
|
+
const ROW_H = CH + 34;
|
|
576
|
+
const HEAD_H = 74;
|
|
577
|
+
const PLOT_H = 132;
|
|
578
|
+
const PLOT_GAP = 40;
|
|
579
|
+
const ROWS = 4;
|
|
580
|
+
const PAGE_W = LABEL_W + 6 * (CW + GAP) + GAP;
|
|
581
|
+
const PAGE_H = HEAD_H + ROWS * ROW_H + 2 * (PLOT_H + PLOT_GAP) + 16;
|
|
582
|
+
const COLOURS = ["#1f2937", "#c2410c", "#2563eb", "#15803d"];
|
|
583
|
+
|
|
584
|
+
const esc = (s: string) =>
|
|
585
|
+
s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
586
|
+
const n3 = (v: number) => (Number.isFinite(v) ? +v.toFixed(3) : 0);
|
|
587
|
+
|
|
588
|
+
/** the blocks the kit has, drawn on `mat` (whose picture is `img` beside the page) */
|
|
589
|
+
function blocks(kit: Kit, mat: GalleryMaterial, img: string, beats?: unknown): Block[] {
|
|
590
|
+
const M = kit.motion;
|
|
591
|
+
const C = kit.camera;
|
|
592
|
+
const S = mat.subject;
|
|
593
|
+
const W = mat.width;
|
|
594
|
+
const H = mat.height;
|
|
595
|
+
const full = { x: 0, y: 0, w: W, h: H, r: 0 };
|
|
596
|
+
const sc = { x: S.x + S.width / 2, y: S.y + S.height / 2 };
|
|
597
|
+
const pic = (style = "") => `<img class="m" src="${img}" style="${style}">`;
|
|
598
|
+
const home = (b: GalleryBox = S) =>
|
|
599
|
+
`<div class="home" style="left:${b.x}px;top:${b.y}px;width:${b.width}px;height:${b.height}px"></div>`;
|
|
600
|
+
/** the subject lifted out of the picture, as a layer of its own */
|
|
601
|
+
const lifted = (style: string, b: GalleryBox = S, origin = "50% 50%") =>
|
|
602
|
+
`<div class="l" style="left:${b.x}px;top:${b.y}px;width:${b.width}px;height:${b.height}px;transform-origin:${origin};${style}">${pic(`left:${-b.x}px;top:${-b.y}px`)}</div>`;
|
|
603
|
+
const dim = pic("opacity:0.32");
|
|
604
|
+
const T = (x = 0, y = 0, s = 1, sx = s, sy = s) =>
|
|
605
|
+
`transform:translate(${n3(x)}px,${n3(y)}px) scale(${n3(sx)},${n3(sy)})`;
|
|
606
|
+
const list: Block[] = [];
|
|
607
|
+
const add = (b: Block) => list.push(b);
|
|
608
|
+
/** an offset measured along the direction a rise travels: it goes past 0 when it swings */
|
|
609
|
+
const along = (
|
|
610
|
+
w: { x: number; y: number },
|
|
611
|
+
o: Record<string, unknown>,
|
|
612
|
+
dx0: number,
|
|
613
|
+
dy0: number,
|
|
614
|
+
) => {
|
|
615
|
+
const dx = (o.dx as number | undefined) ?? dx0;
|
|
616
|
+
const dy = (o.dy as number | undefined) ?? dy0;
|
|
617
|
+
const len = Math.hypot(dx, dy) || 1;
|
|
618
|
+
return (w.x * dx + w.y * dy) / len;
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
// springs and entrances: the lifted subject arrives at its own place
|
|
622
|
+
const slide = Math.max(S.width * 1.5, W * 0.12);
|
|
623
|
+
add({
|
|
624
|
+
name: "spring",
|
|
625
|
+
group: "motion",
|
|
626
|
+
signature: "spring(t, { from, to, start, freq, damping | overshoot | stiffness+friction })",
|
|
627
|
+
note: "1.6 Hz, damping ratio 0.7: within 2 % in ≈ 0.57 s, a ≈ 4.6 % swing (the take camera's push-in scaled down)",
|
|
628
|
+
needs: ["motion.spring"],
|
|
629
|
+
t0: 0,
|
|
630
|
+
t1: 1.1,
|
|
631
|
+
view: "subject",
|
|
632
|
+
rows: [
|
|
633
|
+
{ label: "default", o: {} },
|
|
634
|
+
{ label: "overshoot: 0.25", o: { overshoot: 0.25 } },
|
|
635
|
+
{ label: "damping: 1", o: { damping: 1 } },
|
|
636
|
+
{ label: "freq: 0.8, damping: 1.4", o: { freq: 0.8, damping: 1.4 } },
|
|
637
|
+
],
|
|
638
|
+
draw: (t, r) => dim + home() + lifted(T(-slide * (1 - M.spring(t, r.o)))),
|
|
639
|
+
value: (t, r) => M.spring(t, r.o),
|
|
640
|
+
valueLabel: "value (0 → 1)",
|
|
641
|
+
});
|
|
642
|
+
add({
|
|
643
|
+
name: "rise",
|
|
644
|
+
group: "motion",
|
|
645
|
+
signature: "rise(t, start, { dx, dy, lead, …spring }) → { x, y, opacity, p }",
|
|
646
|
+
note: "dy 24 px (about a line of 20 px text); solid once 60 % of the travel is covered; the spring's 1.6 Hz / 0.7",
|
|
647
|
+
needs: ["motion.rise"],
|
|
648
|
+
t0: 0,
|
|
649
|
+
t1: 0.8,
|
|
650
|
+
view: "subject",
|
|
651
|
+
rows: [
|
|
652
|
+
{ label: "default", o: {} },
|
|
653
|
+
{ label: "dy: 120, damping: 0.5", o: { dy: 120, damping: 0.5 } },
|
|
654
|
+
{ label: "dx: -240, dy: 0", o: { dx: -240, dy: 0 } },
|
|
655
|
+
{ label: "freq: 0.9, damping: 1", o: { freq: 0.9, damping: 1 } },
|
|
656
|
+
],
|
|
657
|
+
draw: (t, r) => {
|
|
658
|
+
const w = M.rise(t, 0, r.o);
|
|
659
|
+
return dim + home() + lifted(`${T(w.x, w.y)};opacity:${n3(w.opacity)}`);
|
|
660
|
+
},
|
|
661
|
+
value: (t, r) => along(M.rise(t, 0, r.o), r.o, 0, 24),
|
|
662
|
+
valueLabel: "offset along its travel (px)",
|
|
663
|
+
});
|
|
664
|
+
add({
|
|
665
|
+
name: "riseOut",
|
|
666
|
+
group: "motion",
|
|
667
|
+
signature: "riseOut(t, start, { dx, dy, dur, lead }) → { x, y, opacity, p }",
|
|
668
|
+
note: "0.32 s (about half an entrance's settle), accelerating away; dy −24",
|
|
669
|
+
needs: ["motion.riseOut"],
|
|
670
|
+
t0: 0,
|
|
671
|
+
t1: 0.7,
|
|
672
|
+
view: "subject",
|
|
673
|
+
rows: [
|
|
674
|
+
{ label: "default", o: {} },
|
|
675
|
+
{ label: "dy: -90", o: { dy: -90 } },
|
|
676
|
+
{ label: "dx: 300, dy: 0", o: { dx: 300, dy: 0 } },
|
|
677
|
+
{ label: "dur: 0.6", o: { dur: 0.6 } },
|
|
678
|
+
],
|
|
679
|
+
draw: (t, r) => {
|
|
680
|
+
const w = M.riseOut(t, 0, r.o);
|
|
681
|
+
return dim + home() + lifted(`${T(w.x, w.y)};opacity:${n3(w.opacity)}`);
|
|
682
|
+
},
|
|
683
|
+
value: (t, r) => along(M.riseOut(t, 0, r.o), r.o, 0, -24),
|
|
684
|
+
valueLabel: "offset along its travel (px)",
|
|
685
|
+
});
|
|
686
|
+
add({
|
|
687
|
+
name: "pop",
|
|
688
|
+
group: "motion",
|
|
689
|
+
signature: "pop(t, start, { scale, …spring }) → { scale, opacity, p }",
|
|
690
|
+
note: "from 0.6, 2.2 Hz, overshoot 0.12 (≈ 5 % past full size)",
|
|
691
|
+
needs: ["motion.pop"],
|
|
692
|
+
t0: 0,
|
|
693
|
+
t1: 0.7,
|
|
694
|
+
view: "subject",
|
|
695
|
+
rows: [
|
|
696
|
+
{ label: "default", o: {} },
|
|
697
|
+
{ label: "scale: 0", o: { scale: 0 } },
|
|
698
|
+
{ label: "scale: 0.9, overshoot: 0.35", o: { scale: 0.9, overshoot: 0.35 } },
|
|
699
|
+
{ label: "damping: 1", o: { damping: 1 } },
|
|
700
|
+
],
|
|
701
|
+
draw: (t, r) => {
|
|
702
|
+
const p = M.pop(t, 0, r.o);
|
|
703
|
+
return dim + home() + lifted(`${T(0, 0, p.scale)};opacity:${n3(p.opacity)}`);
|
|
704
|
+
},
|
|
705
|
+
value: (t, r) => M.pop(t, 0, r.o).scale,
|
|
706
|
+
valueLabel: "scale",
|
|
707
|
+
});
|
|
708
|
+
add({
|
|
709
|
+
name: "popOut",
|
|
710
|
+
group: "motion",
|
|
711
|
+
signature: "popOut(t, start, { scale, dur, swell }) → { scale, opacity, p }",
|
|
712
|
+
note: "swells 4 % first, then shrinks to 0.6 in ≈ 0.26 s",
|
|
713
|
+
needs: ["motion.popOut"],
|
|
714
|
+
t0: 0,
|
|
715
|
+
t1: 0.5,
|
|
716
|
+
view: "subject",
|
|
717
|
+
rows: [
|
|
718
|
+
{ label: "default", o: {} },
|
|
719
|
+
{ label: "swell: 0.15", o: { swell: 0.15 } },
|
|
720
|
+
{ label: "scale: 0", o: { scale: 0 } },
|
|
721
|
+
{ label: "dur: 0.5", o: { dur: 0.5 } },
|
|
722
|
+
],
|
|
723
|
+
draw: (t, r) => {
|
|
724
|
+
const p = M.popOut(t, 0, r.o);
|
|
725
|
+
return dim + home() + lifted(`${T(0, 0, p.scale)};opacity:${n3(p.opacity)}`);
|
|
726
|
+
},
|
|
727
|
+
value: (t, r) => M.popOut(t, 0, r.o).scale,
|
|
728
|
+
valueLabel: "scale",
|
|
729
|
+
});
|
|
730
|
+
add({
|
|
731
|
+
name: "drop",
|
|
732
|
+
group: "motion",
|
|
733
|
+
signature: "drop(t, start, { height, squash, …spring }) → { y, sx, sy, opacity }",
|
|
734
|
+
note: "falls 120 px, 1.8 Hz, damping 0.45 (one clear bounce); squash 0.18 (text stays legible to ≈ 0.2)",
|
|
735
|
+
needs: ["motion.drop"],
|
|
736
|
+
t0: 0,
|
|
737
|
+
t1: 1,
|
|
738
|
+
frames: [0.04, 0.14, 0.22, 0.3, 0.45, 0.9],
|
|
739
|
+
view: "subject",
|
|
740
|
+
rows: [
|
|
741
|
+
{ label: "default", o: {} },
|
|
742
|
+
{ label: "squash: 0.4", o: { squash: 0.4 } },
|
|
743
|
+
{ label: "damping: 0.8", o: { damping: 0.8 } },
|
|
744
|
+
{ label: "height: 400, squash: 0", o: { height: 400, squash: 0 } },
|
|
745
|
+
],
|
|
746
|
+
draw: (t, r) => {
|
|
747
|
+
const d = M.drop(t, 0, r.o);
|
|
748
|
+
return (
|
|
749
|
+
dim + home() + lifted(`${T(0, d.y, 1, d.sx, d.sy)};opacity:${n3(d.opacity)}`, S, "50% 100%")
|
|
750
|
+
);
|
|
751
|
+
},
|
|
752
|
+
value: (t, r) => M.drop(t, 0, r.o).y,
|
|
753
|
+
valueLabel: "y from its place (px)",
|
|
754
|
+
});
|
|
755
|
+
add({
|
|
756
|
+
name: "dropOut",
|
|
757
|
+
group: "motion",
|
|
758
|
+
signature: "dropOut(t, start, { depth, dur, squash }) → { y, sx, sy, opacity }",
|
|
759
|
+
note: "falls 160 px in 0.4 s under constant acceleration, stretching with its speed",
|
|
760
|
+
needs: ["motion.dropOut"],
|
|
761
|
+
t0: 0,
|
|
762
|
+
t1: 0.8,
|
|
763
|
+
view: "subject",
|
|
764
|
+
rows: [
|
|
765
|
+
{ label: "default", o: {} },
|
|
766
|
+
{ label: "depth: 400", o: { depth: 400 } },
|
|
767
|
+
{ label: "squash: 0", o: { squash: 0 } },
|
|
768
|
+
{ label: "dur: 0.8", o: { dur: 0.8 } },
|
|
769
|
+
],
|
|
770
|
+
draw: (t, r) => {
|
|
771
|
+
const d = M.dropOut(t, 0, r.o);
|
|
772
|
+
return (
|
|
773
|
+
dim + home() + lifted(`${T(0, d.y, 1, d.sx, d.sy)};opacity:${n3(d.opacity)}`, S, "50% 0%")
|
|
774
|
+
);
|
|
775
|
+
},
|
|
776
|
+
value: (t, r) => M.dropOut(t, 0, r.o).y,
|
|
777
|
+
valueLabel: "y from its place (px)",
|
|
778
|
+
});
|
|
779
|
+
add({
|
|
780
|
+
name: "maskRise",
|
|
781
|
+
group: "motion",
|
|
782
|
+
signature: "maskRise(t, start, { height, …spring }) → { y, clip, p }",
|
|
783
|
+
note: "rises out of its own box; damping 0.85 (a swing past the line would be cut), 1.5 Hz",
|
|
784
|
+
needs: ["motion.maskRise"],
|
|
785
|
+
t0: 0,
|
|
786
|
+
t1: 0.9,
|
|
787
|
+
view: "subject",
|
|
788
|
+
rows: [
|
|
789
|
+
{ label: "default", o: {} },
|
|
790
|
+
{ label: "damping: 0.5", o: { damping: 0.5 } },
|
|
791
|
+
{ label: "freq: 3", o: { freq: 3 } },
|
|
792
|
+
{ label: "freq: 0.8", o: { freq: 0.8 } },
|
|
793
|
+
],
|
|
794
|
+
draw: (t, r) => {
|
|
795
|
+
const m = M.maskRise(t, 0, { height: S.height, ...r.o });
|
|
796
|
+
return dim + home() + lifted(`transform:translateY(${n3(m.y)}px);clip-path:${m.clip}`);
|
|
797
|
+
},
|
|
798
|
+
value: (t, r) => M.maskRise(t, 0, { height: S.height, ...r.o }).y,
|
|
799
|
+
valueLabel: "y below its line (px)",
|
|
800
|
+
});
|
|
801
|
+
add({
|
|
802
|
+
name: "maskOut",
|
|
803
|
+
group: "motion",
|
|
804
|
+
signature: "maskOut(t, start, { height, dur, up }) → { y, clip, p }",
|
|
805
|
+
note: "sinks into its own box in 0.32 s, accelerating",
|
|
806
|
+
needs: ["motion.maskOut"],
|
|
807
|
+
t0: 0,
|
|
808
|
+
t1: 0.7,
|
|
809
|
+
view: "subject",
|
|
810
|
+
rows: [
|
|
811
|
+
{ label: "default", o: {} },
|
|
812
|
+
{ label: "up: true", o: { up: true } },
|
|
813
|
+
{ label: "dur: 0.6", o: { dur: 0.6 } },
|
|
814
|
+
{ label: "dur: 0.15", o: { dur: 0.15 } },
|
|
815
|
+
],
|
|
816
|
+
draw: (t, r) => {
|
|
817
|
+
const m = M.maskOut(t, 0, { height: S.height, ...r.o });
|
|
818
|
+
return dim + home() + lifted(`transform:translateY(${n3(m.y)}px);clip-path:${m.clip}`);
|
|
819
|
+
},
|
|
820
|
+
value: (t, r) => Math.abs(M.maskOut(t, 0, { height: S.height, ...r.o }).y),
|
|
821
|
+
valueLabel: "distance moved (px)",
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
// typing: the subject's own words, at the subject's own height
|
|
825
|
+
const fs = Math.max(18, Math.min(64, S.height * 0.5));
|
|
826
|
+
const textBox: GalleryBox = {
|
|
827
|
+
x: S.x,
|
|
828
|
+
y: S.y,
|
|
829
|
+
width: Math.max(S.width, fs * 0.62 * Array.from(mat.text).length + fs * 1.4),
|
|
830
|
+
height: Math.max(S.height, fs * 1.6),
|
|
831
|
+
};
|
|
832
|
+
const typed = (s: string) =>
|
|
833
|
+
dim +
|
|
834
|
+
`<div class="txt" style="left:${textBox.x}px;top:${textBox.y}px;width:${textBox.width}px;height:${textBox.height}px;font-size:${fs}px;line-height:${textBox.height}px;padding-left:${fs * 0.5}px">${esc(s)}<span class="caret"></span></div>`;
|
|
835
|
+
// long enough for the slowest setting shown (8 a second) to finish
|
|
836
|
+
const typeT1 = Math.max(0.6, (Array.from(mat.text).length / 8) * 1.1);
|
|
837
|
+
add({
|
|
838
|
+
name: "type",
|
|
839
|
+
group: "motion",
|
|
840
|
+
signature:
|
|
841
|
+
"type(t, start, text, { cps, human, seed }) → { text, count, done, lastAt } · typeTimes(text, start, opts)",
|
|
842
|
+
note: "16 characters a second (about twice a fast typist: a film shows the typing, not the typist)",
|
|
843
|
+
needs: ["motion.type"],
|
|
844
|
+
t0: 0,
|
|
845
|
+
t1: typeT1,
|
|
846
|
+
view: "subject",
|
|
847
|
+
rows: [
|
|
848
|
+
{ label: "default", o: {} },
|
|
849
|
+
{ label: "human: true", o: { human: true } },
|
|
850
|
+
{ label: "cps: 8", o: { cps: 8 } },
|
|
851
|
+
{ label: "cps: 40", o: { cps: 40 } },
|
|
852
|
+
],
|
|
853
|
+
draw: (t, r) => typed(M.type(t, 0, mat.text, r.o).text),
|
|
854
|
+
value: (t, r) => M.type(t, 0, mat.text, r.o).count,
|
|
855
|
+
valueLabel: "characters shown",
|
|
856
|
+
speedOver: 0.25,
|
|
857
|
+
});
|
|
858
|
+
add({
|
|
859
|
+
name: "untype",
|
|
860
|
+
group: "motion",
|
|
861
|
+
signature: "untype(t, start, text, { cps }) → { text, count, done }",
|
|
862
|
+
note: "30 characters a second: a held key's auto-repeat",
|
|
863
|
+
needs: ["motion.untype"],
|
|
864
|
+
t0: 0,
|
|
865
|
+
t1: Math.max(0.6, (Array.from(mat.text).length / 12) * 1.1),
|
|
866
|
+
view: "subject",
|
|
867
|
+
rows: [
|
|
868
|
+
{ label: "default", o: {} },
|
|
869
|
+
{ label: "cps: 12", o: { cps: 12 } },
|
|
870
|
+
{ label: "cps: 60", o: { cps: 60 } },
|
|
871
|
+
{ label: "cps: 120", o: { cps: 120 } },
|
|
872
|
+
],
|
|
873
|
+
draw: (t, r) => typed(M.untype(t, 0, mat.text, r.o).text),
|
|
874
|
+
value: (t, r) => M.untype(t, 0, mat.text, r.o).count,
|
|
875
|
+
valueLabel: "characters shown",
|
|
876
|
+
speedOver: 0.25,
|
|
877
|
+
});
|
|
878
|
+
|
|
879
|
+
// a line, a figure, landing
|
|
880
|
+
const figure = "$1,290";
|
|
881
|
+
add({
|
|
882
|
+
name: "scramble",
|
|
883
|
+
group: "motion",
|
|
884
|
+
signature:
|
|
885
|
+
"scramble(t, start, text, { each, lead, rate, glyphs, seed, from, keep }) → { text, locked, done }",
|
|
886
|
+
note: "the first character locks after 0.2 s, then one every 0.05 s, left to right; glyphs change 30 times a second, seeded",
|
|
887
|
+
needs: ["motion.scramble"],
|
|
888
|
+
t0: 0,
|
|
889
|
+
t1: Math.max(0.6, 0.2 + Array.from(mat.text).length * 0.05 * 1.15),
|
|
890
|
+
view: "subject",
|
|
891
|
+
rows: [
|
|
892
|
+
{ label: "default", o: {} },
|
|
893
|
+
{ label: 'from: "right"', o: { from: "right" } },
|
|
894
|
+
{ label: "each: 0.02, lead: 0.1", o: { each: 0.02, lead: 0.1 } },
|
|
895
|
+
{ label: "rate: 12", o: { rate: 12 } },
|
|
896
|
+
],
|
|
897
|
+
draw: (t, r) => typed(M.scramble(t, 0, mat.text, r.o).text),
|
|
898
|
+
value: (t, r) => M.scramble(t, 0, mat.text, r.o).locked,
|
|
899
|
+
valueLabel: "characters locked",
|
|
900
|
+
speedOver: 0.25,
|
|
901
|
+
});
|
|
902
|
+
const strip = (pos: number, h: number) =>
|
|
903
|
+
`<span style="display:inline-block;height:${h}px;overflow:hidden;vertical-align:top"><span style="display:block;transform:translateY(${n3(-(pos % 10) * h)}px)">${"01234567890"
|
|
904
|
+
.split("")
|
|
905
|
+
.map((d) => `<span style="display:block;height:${h}px">${d}</span>`)
|
|
906
|
+
.join("")}</span></span>`;
|
|
907
|
+
const rolled = (cols: { char: string; digit: boolean; pos: number }[]) =>
|
|
908
|
+
dim +
|
|
909
|
+
`<div class="txt" style="left:${textBox.x}px;top:${textBox.y}px;width:${textBox.width}px;height:${textBox.height}px;font-size:${fs}px;line-height:${textBox.height}px;padding-left:${fs * 0.5}px">${cols.map((c) => (c.digit ? strip(c.pos, textBox.height) : esc(c.char))).join("")}</div>`;
|
|
910
|
+
add({
|
|
911
|
+
name: "odometer",
|
|
912
|
+
group: "motion",
|
|
913
|
+
signature:
|
|
914
|
+
"odometer(t, start, to, { from, each, dur, laps, overshoot, order }) → { columns: [{ pos, speed }], text, done }",
|
|
915
|
+
note: `${figure}: columns land left to right 0.15 s apart, each rolling 0.6 s with one extra lap and ≈ 5 % past its digit`,
|
|
916
|
+
needs: ["motion.odometer"],
|
|
917
|
+
t0: 0,
|
|
918
|
+
t1: 1.3,
|
|
919
|
+
view: "subject",
|
|
920
|
+
rows: [
|
|
921
|
+
{ label: "default", o: {} },
|
|
922
|
+
{ label: 'from: "$990"', o: { from: "$990" } },
|
|
923
|
+
{ label: 'order: "right", laps: 0', o: { order: "right", laps: 0 } },
|
|
924
|
+
{ label: "each: 0, overshoot: 0", o: { each: 0, overshoot: 0 } },
|
|
925
|
+
],
|
|
926
|
+
draw: (t, r) => rolled(M.odometer(t, 0, figure, r.o).columns),
|
|
927
|
+
value: (t, r) =>
|
|
928
|
+
M.odometer(t, 0, figure, r.o).columns.filter((c: { digit: boolean }) => c.digit)[0]?.pos ?? 0,
|
|
929
|
+
valueLabel: "first digit column's roll (digits)",
|
|
930
|
+
});
|
|
931
|
+
const tile = (o: string, nw: string, top: number, bottom: number) => {
|
|
932
|
+
const half = (ch: string, part: "top" | "bottom", sy: number) =>
|
|
933
|
+
`<span style="position:absolute;left:0;right:0;${part}:0;height:50%;overflow:hidden;background:#1f1f1d;transform-origin:${part === "top" ? "50% 100%" : "50% 0"};transform:scaleY(${n3(sy)})"><span style="position:absolute;left:0;right:0;${part === "top" ? "top:0" : "bottom:0"};height:${textBox.height}px;line-height:${textBox.height}px;text-align:center;color:#fff">${esc(ch)}</span></span>`;
|
|
934
|
+
return `<span style="position:relative;display:inline-block;width:${fs * 0.72}px;height:${textBox.height}px;margin-right:${fs * 0.06}px">${half(nw, "top", 1)}${half(o, "bottom", 1)}${top > 0 ? half(o, "top", top) : ""}${bottom > 0 ? half(nw, "bottom", bottom) : ""}<span style="position:absolute;left:0;right:0;top:50%;height:2px;background:#000"></span></span>`;
|
|
935
|
+
};
|
|
936
|
+
add({
|
|
937
|
+
name: "flap",
|
|
938
|
+
group: "motion",
|
|
939
|
+
signature:
|
|
940
|
+
"flap(t, start, from, to, { each, dur }) → { tiles: [{ old, now, top, bottom, p }], done }",
|
|
941
|
+
note: "$990 → $1,290: the old top half folds down, then the new bottom half; 0.26 s a tile, 0.2 s apart",
|
|
942
|
+
needs: ["motion.flap"],
|
|
943
|
+
t0: 0,
|
|
944
|
+
t1: 1.8,
|
|
945
|
+
view: "subject",
|
|
946
|
+
rows: [
|
|
947
|
+
{ label: "default", o: {} },
|
|
948
|
+
{ label: "each: 0.08", o: { each: 0.08 } },
|
|
949
|
+
{ label: "each: 0, dur: 0.4", o: { each: 0, dur: 0.4 } },
|
|
950
|
+
{ label: "dur: 0.6", o: { dur: 0.6 } },
|
|
951
|
+
],
|
|
952
|
+
draw: (t, r) =>
|
|
953
|
+
dim +
|
|
954
|
+
`<div style="position:absolute;left:${textBox.x}px;top:${textBox.y}px;font:600 ${fs}px system-ui,sans-serif;white-space:nowrap">${M.flap(
|
|
955
|
+
t,
|
|
956
|
+
0,
|
|
957
|
+
"$990",
|
|
958
|
+
figure,
|
|
959
|
+
r.o,
|
|
960
|
+
)
|
|
961
|
+
.tiles.map((x: { old: string; now: string; top: number; bottom: number }) =>
|
|
962
|
+
tile(x.old, x.now, x.top, x.bottom),
|
|
963
|
+
)
|
|
964
|
+
.join("")}</div>`,
|
|
965
|
+
value: (t, r) =>
|
|
966
|
+
M.flap(t, 0, "$990", figure, r.o).tiles.filter((x: { p: number }) => x.p >= 1).length,
|
|
967
|
+
valueLabel: "tiles turned",
|
|
968
|
+
});
|
|
969
|
+
|
|
970
|
+
// handoffs: one picture becomes the next
|
|
971
|
+
const subjRect = { x: S.x, y: S.y, w: S.width, h: S.height, r: Math.min(S.height / 2, 12) };
|
|
972
|
+
const morphRows: Row[] = [
|
|
973
|
+
{ label: "default (sizes in log, lands on a spring)", o: {} },
|
|
974
|
+
{ label: "log: false", o: { log: false } },
|
|
975
|
+
{ label: "ease: smooth", o: { ease: M.smooth } },
|
|
976
|
+
{
|
|
977
|
+
label: "ease: settle(p, { overshoot: 0.08 })",
|
|
978
|
+
o: { ease: (p: number) => M.settle?.(p, { overshoot: 0.08 }) ?? p },
|
|
979
|
+
},
|
|
980
|
+
];
|
|
981
|
+
add({
|
|
982
|
+
name: "morphRect",
|
|
983
|
+
group: "motion",
|
|
984
|
+
signature:
|
|
985
|
+
"morphRect(t, start, end, fromBox, toBox, { ease, log }) → { x, y, w, h, r, p } · rectClip(rect, frame)",
|
|
986
|
+
note: "sizes change in log space (a 10× growth looks steady); a critically damped spring that lands on `end`",
|
|
987
|
+
needs: ["motion.morphRect", "motion.rectClip"],
|
|
988
|
+
t0: 0,
|
|
989
|
+
t1: 0.6,
|
|
990
|
+
view: "full",
|
|
991
|
+
rows: morphRows,
|
|
992
|
+
draw: (t, r) => {
|
|
993
|
+
const m = M.morphRect(t, 0, 0.5, subjRect, full, r.o);
|
|
994
|
+
return `${dim}${home()}${pic(`clip-path:${M.rectClip(m, { width: W, height: H })}`)}<div class="edge" style="left:${m.x}px;top:${m.y}px;width:${m.w}px;height:${m.h}px;border-radius:${m.r}px"></div>`;
|
|
995
|
+
},
|
|
996
|
+
value: (t, r) => M.morphRect(t, 0, 0.5, subjRect, full, r.o).w,
|
|
997
|
+
valueLabel: "width (px)",
|
|
998
|
+
});
|
|
999
|
+
add({
|
|
1000
|
+
name: "iris",
|
|
1001
|
+
group: "motion",
|
|
1002
|
+
signature: "iris(t, start, end, at, frame, { ease, from, to, close }) → { r, clip, p }",
|
|
1003
|
+
note: "the radius reaches the farthest corner at `end`; smootherstep on the radius",
|
|
1004
|
+
needs: ["motion.iris"],
|
|
1005
|
+
t0: 0,
|
|
1006
|
+
t1: 0.7,
|
|
1007
|
+
view: "full",
|
|
1008
|
+
rows: [
|
|
1009
|
+
{ label: "default (from the subject)", o: {} },
|
|
1010
|
+
{ label: "ease: easeOut", o: { ease: M.easeOut } },
|
|
1011
|
+
{ label: "close: true", o: { close: true } },
|
|
1012
|
+
{ label: "at the top-left corner", o: { at: { x: 0, y: 0 } } },
|
|
1013
|
+
],
|
|
1014
|
+
draw: (t, r) => {
|
|
1015
|
+
const { at = sc, ...o } = r.o as { at?: { x: number; y: number } };
|
|
1016
|
+
const i = M.iris(t, 0, 0.6, at, { width: W, height: H }, o);
|
|
1017
|
+
return `<div class="void"></div>${pic(`clip-path:${i.clip}`)}`;
|
|
1018
|
+
},
|
|
1019
|
+
value: (t, r) => {
|
|
1020
|
+
const { at = sc, ...o } = r.o as { at?: { x: number; y: number } };
|
|
1021
|
+
return M.iris(t, 0, 0.6, at, { width: W, height: H }, o).r;
|
|
1022
|
+
},
|
|
1023
|
+
valueLabel: "radius (px)",
|
|
1024
|
+
});
|
|
1025
|
+
add({
|
|
1026
|
+
name: "zoomThrough",
|
|
1027
|
+
group: "motion",
|
|
1028
|
+
signature:
|
|
1029
|
+
"zoomThrough(t, start, end, rect, view, { ease, fit, through }) → { scale, x, y, transform, p }",
|
|
1030
|
+
note: "one scale about a fixed point, in log space: every step of the flight looks the same size",
|
|
1031
|
+
needs: ["motion.zoomThrough"],
|
|
1032
|
+
t0: 0,
|
|
1033
|
+
t1: 0.9,
|
|
1034
|
+
view: "full",
|
|
1035
|
+
rows: [
|
|
1036
|
+
{ label: "default (cover)", o: {} },
|
|
1037
|
+
{ label: 'fit: "contain"', o: { fit: "contain" } },
|
|
1038
|
+
{ label: "through: 3", o: { through: 3 } },
|
|
1039
|
+
{ label: "ease: easeIn", o: { ease: M.easeIn } },
|
|
1040
|
+
],
|
|
1041
|
+
draw: (t, r) => {
|
|
1042
|
+
const z = M.zoomThrough(t, 0, 0.8, subjRect, { width: W, height: H }, r.o);
|
|
1043
|
+
return `<div class="layer" style="transform:${z.transform}">${pic()}${home()}</div>`;
|
|
1044
|
+
},
|
|
1045
|
+
value: (t, r) => M.zoomThrough(t, 0, 0.8, subjRect, { width: W, height: H }, r.o).scale,
|
|
1046
|
+
valueLabel: "scale",
|
|
1047
|
+
});
|
|
1048
|
+
// the picture in thirds, gathering onto the subject
|
|
1049
|
+
const tiles: GalleryBox[] = [];
|
|
1050
|
+
for (let j = 0; j < 3; j++)
|
|
1051
|
+
for (let i = 0; i < 3; i++)
|
|
1052
|
+
tiles.push({ x: (i * W) / 3, y: (j * H) / 3, width: W / 3, height: H / 3 });
|
|
1053
|
+
const tileCentres = tiles.map((b) => ({ x: b.x + b.width / 2, y: b.y + b.height / 2 }));
|
|
1054
|
+
add({
|
|
1055
|
+
name: "gather",
|
|
1056
|
+
group: "motion",
|
|
1057
|
+
signature:
|
|
1058
|
+
"gather(t, start, fromPoints, to, { dur, stagger, ease, scale, order }) → [{ x, y, scale, p }]",
|
|
1059
|
+
note: "each leaves 0.04 s after the one before (2–3 frames: a ripple, not a block or a queue), 0.5 s each",
|
|
1060
|
+
needs: ["motion.gather"],
|
|
1061
|
+
t0: 0,
|
|
1062
|
+
t1: 0.95,
|
|
1063
|
+
view: "full",
|
|
1064
|
+
rows: [
|
|
1065
|
+
{ label: "scale: 0.25", o: { scale: 0.25 } },
|
|
1066
|
+
{ label: 'order: "far", scale: 0.25', o: { order: "far", scale: 0.25 } },
|
|
1067
|
+
{ label: "stagger: 0.12, scale: 0.25", o: { stagger: 0.12, scale: 0.25 } },
|
|
1068
|
+
{ label: "stagger: 0, scale: 0.6", o: { stagger: 0, scale: 0.6 } },
|
|
1069
|
+
],
|
|
1070
|
+
draw: (t, r) =>
|
|
1071
|
+
`<div class="void"></div>` +
|
|
1072
|
+
M.gather(t, 0, tileCentres, sc, r.o)
|
|
1073
|
+
.map((g: { x: number; y: number; scale: number }, i: number) => {
|
|
1074
|
+
const c = tileCentres[i]!;
|
|
1075
|
+
return lifted(T(g.x - c.x, g.y - c.y, g.scale), tiles[i]);
|
|
1076
|
+
})
|
|
1077
|
+
.join(""),
|
|
1078
|
+
value: (t, r) => {
|
|
1079
|
+
const gs: { x: number; y: number }[] = M.gather(t, 0, tileCentres, sc, r.o);
|
|
1080
|
+
return gs.reduce((a, g) => a + Math.hypot(g.x - sc.x, g.y - sc.y), 0) / gs.length;
|
|
1081
|
+
},
|
|
1082
|
+
valueLabel: "pieces' mean distance to the subject (px)",
|
|
1083
|
+
});
|
|
1084
|
+
const hopFrom = { x: sc.x - Math.max(S.width * 2, W * 0.15), y: sc.y };
|
|
1085
|
+
add({
|
|
1086
|
+
name: "hop",
|
|
1087
|
+
group: "motion",
|
|
1088
|
+
signature: "hop(t, start, end, from, to, { height, ease }) → { x, y, p }",
|
|
1089
|
+
note: "a parabola 80 px above the straight line at its middle; smootherstep along the path",
|
|
1090
|
+
needs: ["motion.hop"],
|
|
1091
|
+
t0: 0,
|
|
1092
|
+
t1: 0.6,
|
|
1093
|
+
view: "subject",
|
|
1094
|
+
rows: [
|
|
1095
|
+
{ label: "default", o: {} },
|
|
1096
|
+
{ label: "height: 0", o: { height: 0 } },
|
|
1097
|
+
{ label: "height: 240", o: { height: 240 } },
|
|
1098
|
+
{ label: "ease: linear", o: { ease: (p: number) => Math.max(0, Math.min(1, p)) } },
|
|
1099
|
+
],
|
|
1100
|
+
draw: (t, r) => {
|
|
1101
|
+
const h = M.hop(t, 0, 0.6, hopFrom, sc, r.o);
|
|
1102
|
+
return dim + home() + lifted(T(h.x - sc.x, h.y - sc.y));
|
|
1103
|
+
},
|
|
1104
|
+
value: (t, r) => {
|
|
1105
|
+
const h = M.hop(t, 0, 0.6, hopFrom, sc, r.o);
|
|
1106
|
+
return sc.y - h.y;
|
|
1107
|
+
},
|
|
1108
|
+
valueLabel: "height above its line (px)",
|
|
1109
|
+
});
|
|
1110
|
+
|
|
1111
|
+
// contact
|
|
1112
|
+
add({
|
|
1113
|
+
name: "press",
|
|
1114
|
+
group: "motion",
|
|
1115
|
+
signature: "press(t, at, { depth, sink, hold, freq, damping, drop }) → { scale, y, down }",
|
|
1116
|
+
note: "6 % smaller (a film reads smaller than an interface's 2–5 %), down in 0.07 s, held 0.05 s, back on a 3 Hz spring",
|
|
1117
|
+
needs: ["motion.press"],
|
|
1118
|
+
t0: 0,
|
|
1119
|
+
t1: 0.6,
|
|
1120
|
+
frames: [0, 0.05, 0.1, 0.17, 0.26, 0.5],
|
|
1121
|
+
view: "subject",
|
|
1122
|
+
rows: [
|
|
1123
|
+
{ label: "default", o: {} },
|
|
1124
|
+
{ label: "depth: 0.02", o: { depth: 0.02 } },
|
|
1125
|
+
{ label: "depth: 0.15, drop: 6", o: { depth: 0.15, drop: 6 } },
|
|
1126
|
+
{ label: "damping: 1", o: { damping: 1 } },
|
|
1127
|
+
],
|
|
1128
|
+
draw: (t, r) => {
|
|
1129
|
+
const p = M.press(t, 0, r.o);
|
|
1130
|
+
return pic() + lifted(`${T(0, p.y, p.scale)};box-shadow:0 0 0 2px rgba(0,0,0,0.25)`);
|
|
1131
|
+
},
|
|
1132
|
+
value: (t, r) => M.press(t, 0, r.o).scale,
|
|
1133
|
+
valueLabel: "scale",
|
|
1134
|
+
});
|
|
1135
|
+
add({
|
|
1136
|
+
name: "impact",
|
|
1137
|
+
group: "motion",
|
|
1138
|
+
signature: "impact(t, at, { amount, angle, scale, freq, damping }) → { x, y, scale, k }",
|
|
1139
|
+
note: "10 px first swing ≈ 30 ms after the hit (7 Hz, damping 0.35): under 5 % in ≈ 0.23 s — one hit, not a wobble",
|
|
1140
|
+
needs: ["motion.impact"],
|
|
1141
|
+
t0: 0,
|
|
1142
|
+
t1: 0.4,
|
|
1143
|
+
frames: [0, 0.03, 0.06, 0.1, 0.16, 0.3],
|
|
1144
|
+
view: "subject",
|
|
1145
|
+
rows: [
|
|
1146
|
+
{ label: "default", o: {} },
|
|
1147
|
+
{ label: "amount: 30", o: { amount: 30 } },
|
|
1148
|
+
{ label: "angle: 0", o: { angle: 0 } },
|
|
1149
|
+
{ label: "freq: 3, damping: 0.2", o: { freq: 3, damping: 0.2 } },
|
|
1150
|
+
],
|
|
1151
|
+
draw: (t, r) => {
|
|
1152
|
+
const k = M.impact(t, 0, r.o);
|
|
1153
|
+
return dim + home() + lifted(T(k.x, k.y, k.scale));
|
|
1154
|
+
},
|
|
1155
|
+
value: (t, r) => {
|
|
1156
|
+
const k = M.impact(t, 0, r.o);
|
|
1157
|
+
return Math.hypot(k.x, k.y) * Math.sign(k.k || 0);
|
|
1158
|
+
},
|
|
1159
|
+
valueLabel: "offset along the hit (px)",
|
|
1160
|
+
});
|
|
1161
|
+
|
|
1162
|
+
// the camera: the stage is its content, each cell its picture
|
|
1163
|
+
const content = { width: W, height: H };
|
|
1164
|
+
const subjBox = { x: S.x, y: S.y, width: S.width, height: S.height };
|
|
1165
|
+
// biome-ignore lint/suspicious/noExplicitAny: a camera of the film's kit
|
|
1166
|
+
const cams = new WeakMap<Row, any>();
|
|
1167
|
+
// biome-ignore lint/suspicious/noExplicitAny: a camera of the film's kit
|
|
1168
|
+
const camOf = (row: Row, make: (o: Record<string, unknown>) => any) => {
|
|
1169
|
+
let c = cams.get(row);
|
|
1170
|
+
if (!c) {
|
|
1171
|
+
c = make(row.o);
|
|
1172
|
+
cams.set(row, c);
|
|
1173
|
+
}
|
|
1174
|
+
return c;
|
|
1175
|
+
};
|
|
1176
|
+
const shot = (transform: string, extra = "") =>
|
|
1177
|
+
`<div class="void"></div><div class="layer" style="transform:${transform}">${pic()}${home()}${extra}</div>`;
|
|
1178
|
+
const camBlock = (
|
|
1179
|
+
b: Omit<Block, "group" | "draw" | "value" | "valueLabel" | "view"> & {
|
|
1180
|
+
// biome-ignore lint/suspicious/noExplicitAny: a camera of the film's kit
|
|
1181
|
+
make: (o: Record<string, unknown>) => any;
|
|
1182
|
+
// biome-ignore lint/suspicious/noExplicitAny: a camera of the film's kit
|
|
1183
|
+
draw?: (t: number, cam: any, row: Row) => string;
|
|
1184
|
+
// biome-ignore lint/suspicious/noExplicitAny: a camera of the film's kit
|
|
1185
|
+
value?: (t: number, cam: any, row: Row) => number;
|
|
1186
|
+
valueLabel?: string;
|
|
1187
|
+
},
|
|
1188
|
+
) =>
|
|
1189
|
+
add({
|
|
1190
|
+
...b,
|
|
1191
|
+
group: "camera",
|
|
1192
|
+
view: "full",
|
|
1193
|
+
draw: (t, r) => {
|
|
1194
|
+
const cam = camOf(r, b.make);
|
|
1195
|
+
return b.draw ? b.draw(t, cam, r) : shot(cam.transform(t));
|
|
1196
|
+
},
|
|
1197
|
+
value: (t, r) => {
|
|
1198
|
+
const cam = camOf(r, b.make);
|
|
1199
|
+
return b.value ? b.value(t, cam, r) : cam.at(t).scale;
|
|
1200
|
+
},
|
|
1201
|
+
valueLabel: b.valueLabel ?? "zoom (picture px per content px)",
|
|
1202
|
+
});
|
|
1203
|
+
const needCam = ["camera.camera"];
|
|
1204
|
+
camBlock({
|
|
1205
|
+
name: "camera.frame",
|
|
1206
|
+
signature: "cam.frame(box, { arrive | start, dur, ease, fill, fit }) · cam.transform(t)",
|
|
1207
|
+
note: "a push-in takes 0.73 s and settles its last 4 % into the hold (the take camera, frame-tracked off a reference); the box fills 60 %",
|
|
1208
|
+
needs: needCam,
|
|
1209
|
+
t0: 0,
|
|
1210
|
+
t1: 1.2,
|
|
1211
|
+
rows: [
|
|
1212
|
+
{ label: "default", o: {} },
|
|
1213
|
+
{ label: "dur: 0.3", o: { dur: 0.3 } },
|
|
1214
|
+
{ label: "dur: 1.6", o: { dur: 1.6 } },
|
|
1215
|
+
{ label: "ease: smooth, fill: 0.85", o: { ease: C.smooth, fill: 0.85 } },
|
|
1216
|
+
],
|
|
1217
|
+
make: (o) => {
|
|
1218
|
+
const cam = C.camera({ content });
|
|
1219
|
+
cam.frame(subjBox, { start: 0, ...o });
|
|
1220
|
+
return cam;
|
|
1221
|
+
},
|
|
1222
|
+
});
|
|
1223
|
+
camBlock({
|
|
1224
|
+
name: "camera.rest",
|
|
1225
|
+
signature: "cam.rest({ arrive | start, dur, ease })",
|
|
1226
|
+
note: "a pull-out takes 1.34 s (slower than a push: the eye has more to take in)",
|
|
1227
|
+
needs: needCam,
|
|
1228
|
+
t0: 0,
|
|
1229
|
+
t1: 1.6,
|
|
1230
|
+
rows: [
|
|
1231
|
+
{ label: "default", o: {} },
|
|
1232
|
+
{ label: "dur: 0.5", o: { dur: 0.5 } },
|
|
1233
|
+
{ label: 'zoom: "log"', o: { zoom: "log" } },
|
|
1234
|
+
{ label: "ease: smooth", o: { ease: C.smooth } },
|
|
1235
|
+
],
|
|
1236
|
+
make: (o) => {
|
|
1237
|
+
const cam = C.camera({ content });
|
|
1238
|
+
cam.cut(subjBox, 0, { fill: 0.6 });
|
|
1239
|
+
cam.rest({ start: 0, ...o });
|
|
1240
|
+
return cam;
|
|
1241
|
+
},
|
|
1242
|
+
});
|
|
1243
|
+
camBlock({
|
|
1244
|
+
name: "camera.cut",
|
|
1245
|
+
signature: "cam.cut(box, at, { fill, fit })",
|
|
1246
|
+
note: "no move: from `at` on the camera shows the box",
|
|
1247
|
+
needs: needCam,
|
|
1248
|
+
t0: 0,
|
|
1249
|
+
t1: 1,
|
|
1250
|
+
rows: [
|
|
1251
|
+
{ label: "default (fill 0.6)", o: {} },
|
|
1252
|
+
{ label: "fill: 0.3", o: { fill: 0.3 } },
|
|
1253
|
+
{ label: "fill: 0.95", o: { fill: 0.95 } },
|
|
1254
|
+
{ label: 'fit: "width", fill: 0.9', o: { fit: "width", fill: 0.9 } },
|
|
1255
|
+
],
|
|
1256
|
+
make: (o) => {
|
|
1257
|
+
const cam = C.camera({ content });
|
|
1258
|
+
cam.cut(subjBox, 0.5, o);
|
|
1259
|
+
return cam;
|
|
1260
|
+
},
|
|
1261
|
+
});
|
|
1262
|
+
camBlock({
|
|
1263
|
+
name: "camera.lead",
|
|
1264
|
+
signature: "camera({ content, lead }) · cam.frame(box, { arrive, lead })",
|
|
1265
|
+
note: "off by default (0): the camera arrives when asked; a lead gets it there first. The subject is pressed at 1.0 s",
|
|
1266
|
+
needs: needCam,
|
|
1267
|
+
t0: 0,
|
|
1268
|
+
t1: 1.4,
|
|
1269
|
+
rows: [
|
|
1270
|
+
{ label: "lead: 0 (default)", o: {} },
|
|
1271
|
+
{ label: "lead: 0.15", o: { lead: 0.15 } },
|
|
1272
|
+
{ label: "lead: 0.35", o: { lead: 0.35 } },
|
|
1273
|
+
{ label: "lead: -0.2 (late)", o: { lead: -0.2 } },
|
|
1274
|
+
],
|
|
1275
|
+
make: (o) => {
|
|
1276
|
+
const cam = C.camera({ content, ...o });
|
|
1277
|
+
cam.frame(subjBox, { arrive: 1 });
|
|
1278
|
+
return cam;
|
|
1279
|
+
},
|
|
1280
|
+
draw: (t, cam) => {
|
|
1281
|
+
const p = M.press?.(t, 1) ?? { scale: 1, y: 0 };
|
|
1282
|
+
return shot(cam.transform(t), lifted(T(0, p.y, p.scale)));
|
|
1283
|
+
},
|
|
1284
|
+
});
|
|
1285
|
+
camBlock({
|
|
1286
|
+
name: "camera.zoom",
|
|
1287
|
+
signature: 'camera({ content, zoom: "linear" | "log" }) · cam.frame(box, { zoom })',
|
|
1288
|
+
note: 'linear by default (the take camera); "log" runs a big scale change at an even pace',
|
|
1289
|
+
needs: needCam,
|
|
1290
|
+
t0: 0,
|
|
1291
|
+
t1: 1.6,
|
|
1292
|
+
rows: [
|
|
1293
|
+
{ label: "linear (default), fill 0.9", o: { fill: 0.9 } },
|
|
1294
|
+
{ label: 'zoom: "log", fill 0.9', o: { fill: 0.9, zoom: "log" } },
|
|
1295
|
+
{ label: "linear, dur 1.4, smooth", o: { fill: 0.9, dur: 1.4, ease: C.smooth } },
|
|
1296
|
+
{ label: '"log", dur 1.4, smooth', o: { fill: 0.9, dur: 1.4, ease: C.smooth, zoom: "log" } },
|
|
1297
|
+
],
|
|
1298
|
+
make: (o) => {
|
|
1299
|
+
const cam = C.camera({ content });
|
|
1300
|
+
cam.frame(subjBox, { start: 0, ...o });
|
|
1301
|
+
return cam;
|
|
1302
|
+
},
|
|
1303
|
+
value: (t, cam) => Math.log2(cam.at(t).scale),
|
|
1304
|
+
valueLabel: "zoom in stops (log2 of the scale)",
|
|
1305
|
+
});
|
|
1306
|
+
const corner = { x: 0, y: 0, width: W * 0.14, height: H * 0.14 };
|
|
1307
|
+
camBlock({
|
|
1308
|
+
name: "camera.keepInside",
|
|
1309
|
+
signature: "camera({ content, keepInside }) · cam.frame(box, { keepInside })",
|
|
1310
|
+
note: "on by default: a view stops at the content's edge; false lets it centre a box at the edge and look past it",
|
|
1311
|
+
needs: needCam,
|
|
1312
|
+
t0: 0,
|
|
1313
|
+
t1: 1,
|
|
1314
|
+
rows: [
|
|
1315
|
+
{ label: "keepInside (default)", o: {} },
|
|
1316
|
+
{ label: "keepInside: false", o: { keepInside: false } },
|
|
1317
|
+
{ label: "fill: 0.3", o: { fill: 0.3 } },
|
|
1318
|
+
{ label: "keepInside: false, fill: 0.3", o: { keepInside: false, fill: 0.3 } },
|
|
1319
|
+
],
|
|
1320
|
+
make: (o) => {
|
|
1321
|
+
const cam = C.camera({ content });
|
|
1322
|
+
cam.frame(corner, { start: 0, ...o });
|
|
1323
|
+
return cam;
|
|
1324
|
+
},
|
|
1325
|
+
draw: (t, cam) =>
|
|
1326
|
+
shot(
|
|
1327
|
+
cam.transform(t),
|
|
1328
|
+
`<div class="home" style="left:${corner.x}px;top:${corner.y}px;width:${corner.width}px;height:${corner.height}px"></div>`,
|
|
1329
|
+
),
|
|
1330
|
+
value: (t, cam) => cam.at(t).cx,
|
|
1331
|
+
valueLabel: "view centre x (content px)",
|
|
1332
|
+
});
|
|
1333
|
+
const held = { cx: sc.x, cy: sc.y, w: W * 0.6 };
|
|
1334
|
+
camBlock({
|
|
1335
|
+
name: "camera.handheld",
|
|
1336
|
+
signature: "camera({ content, handheld: { amp, rot, period, seed } }) · cam.jitter(t)",
|
|
1337
|
+
note: "off by default; given, 3 px of slow, never-repeating wander, a turn about every 2.5 s",
|
|
1338
|
+
needs: needCam,
|
|
1339
|
+
t0: 0,
|
|
1340
|
+
t1: 3,
|
|
1341
|
+
rows: [
|
|
1342
|
+
{ label: "{} (amp 3)", o: {} },
|
|
1343
|
+
{ label: "amp: 10", o: { amp: 10 } },
|
|
1344
|
+
{ label: "amp: 3, rot: 0.5", o: { rot: 0.5 } },
|
|
1345
|
+
{ label: "amp: 6, period: 0.6", o: { amp: 6, period: 0.6 } },
|
|
1346
|
+
],
|
|
1347
|
+
make: (o) => {
|
|
1348
|
+
const cam = C.camera({ content, handheld: o });
|
|
1349
|
+
cam.cut(held, 0);
|
|
1350
|
+
return cam;
|
|
1351
|
+
},
|
|
1352
|
+
value: (t, cam) => cam.jitter(t).x,
|
|
1353
|
+
valueLabel: "hand's x offset (picture px)",
|
|
1354
|
+
});
|
|
1355
|
+
camBlock({
|
|
1356
|
+
name: "camera.shake",
|
|
1357
|
+
signature: "cam.shake(at, { amp, rot, dur, freq, seed })",
|
|
1358
|
+
note: "off until asked; a jolt of 10 px dying away over 0.45 s, about 16 turns a second",
|
|
1359
|
+
needs: needCam,
|
|
1360
|
+
t0: 0,
|
|
1361
|
+
t1: 0.6,
|
|
1362
|
+
rows: [
|
|
1363
|
+
{ label: "default", o: {} },
|
|
1364
|
+
{ label: "amp: 30", o: { amp: 30 } },
|
|
1365
|
+
{ label: "amp: 4, rot: 1.5", o: { amp: 4, rot: 1.5 } },
|
|
1366
|
+
{ label: "dur: 1, freq: 6", o: { dur: 1, freq: 6 } },
|
|
1367
|
+
],
|
|
1368
|
+
make: (o) => {
|
|
1369
|
+
const cam = C.camera({ content });
|
|
1370
|
+
cam.cut(held, 0);
|
|
1371
|
+
cam.shake(0, o);
|
|
1372
|
+
return cam;
|
|
1373
|
+
},
|
|
1374
|
+
value: (t, cam) => cam.jitter(t).x,
|
|
1375
|
+
valueLabel: "shake's x offset (picture px)",
|
|
1376
|
+
});
|
|
1377
|
+
camBlock({
|
|
1378
|
+
name: "camera.depth",
|
|
1379
|
+
signature: "cam.depth(k).transform(t) — a layer that moves k of the way",
|
|
1380
|
+
note: "1 moves with the content, 0 holds still, 0.3 is far behind, 1.5 passes in front; each row is the same push seen on a layer at k",
|
|
1381
|
+
needs: needCam,
|
|
1382
|
+
t0: 0,
|
|
1383
|
+
t1: 1,
|
|
1384
|
+
rows: [
|
|
1385
|
+
{ label: "k: 1 (the content)", o: { k: 1 } },
|
|
1386
|
+
{ label: "k: 0.3", o: { k: 0.3 } },
|
|
1387
|
+
{ label: "k: 0", o: { k: 0 } },
|
|
1388
|
+
{ label: "k: 1.5", o: { k: 1.5 } },
|
|
1389
|
+
],
|
|
1390
|
+
make: () => {
|
|
1391
|
+
const cam = C.camera({ content });
|
|
1392
|
+
cam.frame(subjBox, { start: 0 });
|
|
1393
|
+
return cam;
|
|
1394
|
+
},
|
|
1395
|
+
draw: (t, cam, r) => shot(cam.depth(r.o.k).transform(t)),
|
|
1396
|
+
value: (t, cam, r) => {
|
|
1397
|
+
const d = cam.depth(r.o.k);
|
|
1398
|
+
return d.toView(1, 0, t)[0] - d.toView(0, 0, t)[0];
|
|
1399
|
+
},
|
|
1400
|
+
valueLabel: "layer scale",
|
|
1401
|
+
});
|
|
1402
|
+
|
|
1403
|
+
// kit/cut.js: where cuts fall, and what a match cut frames
|
|
1404
|
+
const X = kit.cut;
|
|
1405
|
+
if (X && typeof X.grid === "function") {
|
|
1406
|
+
const O = mat.other;
|
|
1407
|
+
const G = X.grid(beats ?? { bpm: 100 });
|
|
1408
|
+
const pulse = beats
|
|
1409
|
+
? "on the film's music (--beats)"
|
|
1410
|
+
: "on a stand-in pulse of 100 bpm, for drawing only (--beats <file> draws on the film's music)";
|
|
1411
|
+
const from = G.bar(0);
|
|
1412
|
+
const to = G.bar(4);
|
|
1413
|
+
const beatsIn: number[] = G.between(from, to);
|
|
1414
|
+
const viewOf = (b: GalleryBox, fill: number) => ({
|
|
1415
|
+
cx: b.x + b.width / 2,
|
|
1416
|
+
cy: b.y + b.height / 2,
|
|
1417
|
+
w: Math.max(b.width, (b.height * W) / H) / fill,
|
|
1418
|
+
});
|
|
1419
|
+
/** the picture of a view of the stage: as a camera would put it */
|
|
1420
|
+
const look = (v: { cx: number; cy: number; w: number }) => {
|
|
1421
|
+
const k = W / v.w;
|
|
1422
|
+
return `translate(${n3(W / 2 - v.cx * k)}px,${n3(H / 2 - v.cy * k)}px) scale(${n3(k)})`;
|
|
1423
|
+
};
|
|
1424
|
+
// the shots a cut moves between: the whole, the subject, the other, corners
|
|
1425
|
+
const shots = [
|
|
1426
|
+
{ cx: W / 2, cy: H / 2, w: W },
|
|
1427
|
+
viewOf(S, 0.6),
|
|
1428
|
+
viewOf(O, 0.6),
|
|
1429
|
+
{ cx: W * 0.3, cy: H * 0.3, w: W * 0.5 },
|
|
1430
|
+
viewOf(S, 0.25),
|
|
1431
|
+
{ cx: W * 0.7, cy: H * 0.7, w: W * 0.5 },
|
|
1432
|
+
];
|
|
1433
|
+
const timesFor = new WeakMap<Row, number[]>();
|
|
1434
|
+
const timesOf = (row: Row): number[] => {
|
|
1435
|
+
let ts = timesFor.get(row);
|
|
1436
|
+
if (!ts) {
|
|
1437
|
+
ts = X.density(G, [{ from, to, intent: row.o.intent }]) as number[];
|
|
1438
|
+
timesFor.set(row, ts);
|
|
1439
|
+
}
|
|
1440
|
+
return ts;
|
|
1441
|
+
};
|
|
1442
|
+
const cutsBy = (row: Row, t: number) => timesOf(row).filter((c) => c <= t + 1e-9).length;
|
|
1443
|
+
const span = (xs: number[]) => xs.slice(1).map((x, i) => x - xs[i]!);
|
|
1444
|
+
add({
|
|
1445
|
+
name: "cut.density",
|
|
1446
|
+
group: "cut",
|
|
1447
|
+
signature: "density(grid, [{ from, to, intent, on, start }]) → cut times · cuts(tl, times)",
|
|
1448
|
+
note: `beats between cuts: a word (hold, calm 8, steady 4, pulse 2, burst 1, flurry ½), a number or { every: [first, last] }, each cut on the grid — ${pulse}; cuts(tl, times) declares them as cut events. A cell a shot, each shot another framing of the stage`,
|
|
1449
|
+
needs: ["cut.grid", "cut.density"],
|
|
1450
|
+
t0: from,
|
|
1451
|
+
t1: to,
|
|
1452
|
+
view: "full",
|
|
1453
|
+
rows: [
|
|
1454
|
+
{ label: '"hold"', o: { intent: "hold" } },
|
|
1455
|
+
{ label: '"steady" (4 beats)', o: { intent: "steady" } },
|
|
1456
|
+
{ label: '"burst" (1 beat)', o: { intent: "burst" } },
|
|
1457
|
+
{ label: "{ every: [4, 0.5] } (a build)", o: { intent: { every: [4, 0.5] } } },
|
|
1458
|
+
],
|
|
1459
|
+
frames: (r) => {
|
|
1460
|
+
// the middle of each of the first six shots: one cell a shot
|
|
1461
|
+
const edges = [...timesOf(r), to];
|
|
1462
|
+
const mids = edges.slice(0, -1).map((a, i) => (a + edges[i + 1]!) / 2);
|
|
1463
|
+
return mids.length >= 6
|
|
1464
|
+
? mids.slice(0, 6)
|
|
1465
|
+
: [
|
|
1466
|
+
...mids,
|
|
1467
|
+
...Array.from(
|
|
1468
|
+
{ length: 6 - mids.length },
|
|
1469
|
+
(_, i) => from + ((to - from) * (i + mids.length + 0.5)) / 6,
|
|
1470
|
+
),
|
|
1471
|
+
].sort((a, b) => a - b);
|
|
1472
|
+
},
|
|
1473
|
+
draw: (t, r) =>
|
|
1474
|
+
`<div class="void"></div><div class="layer" style="transform:${look(shots[(cutsBy(r, t) - 1 + shots.length) % shots.length]!)}">${pic()}</div>`,
|
|
1475
|
+
value: (t, r) => cutsBy(r, t),
|
|
1476
|
+
valueLabel: "cuts so far",
|
|
1477
|
+
speedOver: 2 * G.period,
|
|
1478
|
+
marks: beatsIn,
|
|
1479
|
+
describe: (r) => {
|
|
1480
|
+
const ts = timesOf(r);
|
|
1481
|
+
const shotsLong = span([...ts, to]);
|
|
1482
|
+
return [
|
|
1483
|
+
`${ts.length} cut${ts.length === 1 ? "" : "s"} in ${(to - from).toFixed(2)} s (the section's start is one)`,
|
|
1484
|
+
shotsLong.length
|
|
1485
|
+
? `shots ${Math.min(...shotsLong).toFixed(2)}–${Math.max(...shotsLong).toFixed(2)} s`
|
|
1486
|
+
: "",
|
|
1487
|
+
"computed by density()",
|
|
1488
|
+
]
|
|
1489
|
+
.filter(Boolean)
|
|
1490
|
+
.join(" · ");
|
|
1491
|
+
},
|
|
1492
|
+
});
|
|
1493
|
+
const marksFor = (row: Row): number[] =>
|
|
1494
|
+
G.between(from, G.bar(2), { to: row.o.to }) as number[];
|
|
1495
|
+
const lastMark = (row: Row, t: number) => {
|
|
1496
|
+
const ms = marksFor(row).filter((m) => m <= t + 1e-9);
|
|
1497
|
+
return ms.length ? ms[ms.length - 1]! : Number.NEGATIVE_INFINITY;
|
|
1498
|
+
};
|
|
1499
|
+
const onsets = G.onsets.length > 0;
|
|
1500
|
+
add({
|
|
1501
|
+
name: "cut.grid",
|
|
1502
|
+
group: "cut",
|
|
1503
|
+
signature:
|
|
1504
|
+
"grid(beatsJson | { bpm, offset, beatsPerBar }) → { beat(n), bar(n), snap(t, { to, within }), between(a, b, { to }) }",
|
|
1505
|
+
note: `the music's grid: beats, halves, quarters, bars, and what the music has (onsets, sections, drops); ${pulse}. The subject is pressed on each mark`,
|
|
1506
|
+
needs: ["cut.grid"],
|
|
1507
|
+
t0: from,
|
|
1508
|
+
t1: G.bar(2),
|
|
1509
|
+
view: "subject",
|
|
1510
|
+
rows: [
|
|
1511
|
+
{ label: '{ to: "beat" }', o: { to: "beat" } },
|
|
1512
|
+
{ label: '{ to: "half" }', o: { to: "half" } },
|
|
1513
|
+
{ label: '{ to: "bar" }', o: { to: "bar" } },
|
|
1514
|
+
onsets
|
|
1515
|
+
? { label: '{ to: "onset" }', o: { to: "onset" } }
|
|
1516
|
+
: { label: '{ to: "quarter" }', o: { to: "quarter" } },
|
|
1517
|
+
],
|
|
1518
|
+
draw: (t, r) => {
|
|
1519
|
+
const p = M.press?.(t, lastMark(r, t)) ?? { scale: 1, y: 0 };
|
|
1520
|
+
return dim + lifted(T(0, p.y, p.scale));
|
|
1521
|
+
},
|
|
1522
|
+
value: (t, r) => marksFor(r).filter((m) => m <= t + 1e-9).length,
|
|
1523
|
+
valueLabel: "marks so far",
|
|
1524
|
+
speedOver: 0.5,
|
|
1525
|
+
marks: beatsIn.filter((b) => b <= G.bar(2)),
|
|
1526
|
+
describe: (r) => {
|
|
1527
|
+
const n = marksFor(r).length;
|
|
1528
|
+
const len = G.bar(2) - from;
|
|
1529
|
+
return `${n} marks in ${len.toFixed(2)} s (${(n / len).toFixed(2)} a second) · computed by grid()`;
|
|
1530
|
+
},
|
|
1531
|
+
});
|
|
1532
|
+
if (typeof X.matchCut === "function") {
|
|
1533
|
+
const tCut = 0.6;
|
|
1534
|
+
const content = { width: W, height: H };
|
|
1535
|
+
// biome-ignore lint/suspicious/noExplicitAny: cameras of the film's kit
|
|
1536
|
+
const pairs = new WeakMap<Row, { a: any; b: any; left: GalleryBox }>();
|
|
1537
|
+
const pairOf = (row: Row) => {
|
|
1538
|
+
let p = pairs.get(row);
|
|
1539
|
+
if (!p) {
|
|
1540
|
+
const a = C.camera({ content });
|
|
1541
|
+
a.frame(
|
|
1542
|
+
{ x: S.x, y: S.y, width: S.width, height: S.height },
|
|
1543
|
+
{ start: 0, dur: 1.2, fill: 0.35 },
|
|
1544
|
+
);
|
|
1545
|
+
const [x0, y0] = a.toView(S.x, S.y, tCut);
|
|
1546
|
+
const [x1, y1] = a.toView(S.x + S.width, S.y + S.height, tCut);
|
|
1547
|
+
const left = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
|
|
1548
|
+
const b = C.camera({ content });
|
|
1549
|
+
b.cut(X.matchCut(left, O, content, row.o), tCut, { keepInside: false });
|
|
1550
|
+
p = { a, b, left };
|
|
1551
|
+
pairs.set(row, p);
|
|
1552
|
+
}
|
|
1553
|
+
return p;
|
|
1554
|
+
};
|
|
1555
|
+
/** where the box the shot follows is in the picture at t */
|
|
1556
|
+
const tracked = (row: Row, t: number) => {
|
|
1557
|
+
const { a, b } = pairOf(row);
|
|
1558
|
+
const [cam, box] = t < tCut ? [a, S] : [b, O];
|
|
1559
|
+
const [x0, y0] = cam.toView(box.x, box.y, t);
|
|
1560
|
+
const [x1, y1] = cam.toView(box.x + box.width, box.y + box.height, t);
|
|
1561
|
+
return { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
|
|
1562
|
+
};
|
|
1563
|
+
add({
|
|
1564
|
+
name: "cut.matchCut",
|
|
1565
|
+
group: "cut",
|
|
1566
|
+
signature:
|
|
1567
|
+
"matchCut(fromPictureBox, toBox, view, { fit }) → { cx, cy, w } — cam.cut(v, t, { keepInside: false })",
|
|
1568
|
+
note: `the incoming shot framed so ${O.label} lands where the subject left the last one (centres meet; fit says what "as big" means). Solid outline: where the subject was in the picture at the cut`,
|
|
1569
|
+
needs: ["cut.matchCut", "camera.camera"],
|
|
1570
|
+
t0: 0,
|
|
1571
|
+
t1: 1.2,
|
|
1572
|
+
frames: [0, 0.3, 0.55, 0.6, 0.85, 1.2],
|
|
1573
|
+
view: "full",
|
|
1574
|
+
rows: [
|
|
1575
|
+
{ label: 'fit: "area" (default)', o: {} },
|
|
1576
|
+
{ label: 'fit: "width"', o: { fit: "width" } },
|
|
1577
|
+
{ label: 'fit: "contain"', o: { fit: "contain" } },
|
|
1578
|
+
{ label: 'fit: "cover"', o: { fit: "cover" } },
|
|
1579
|
+
],
|
|
1580
|
+
draw: (t, r) => {
|
|
1581
|
+
const { a, b, left } = pairOf(r);
|
|
1582
|
+
const before = t < tCut;
|
|
1583
|
+
return `<div class="void"></div><div class="layer" style="transform:${(before ? a : b).transform(t)}">${pic()}${home(before ? S : O)}</div><div class="edge" style="left:${left.x}px;top:${left.y}px;width:${left.width}px;height:${left.height}px"></div>`;
|
|
1584
|
+
},
|
|
1585
|
+
value: (t, r) => tracked(r, t).x + tracked(r, t).width / 2,
|
|
1586
|
+
valueLabel: "the followed box's centre x in the picture (px)",
|
|
1587
|
+
describe: (r) => {
|
|
1588
|
+
const a = tracked(r, tCut - 1e-6);
|
|
1589
|
+
const b = tracked(r, tCut);
|
|
1590
|
+
const moved = Math.hypot(
|
|
1591
|
+
b.x + b.width / 2 - (a.x + a.width / 2),
|
|
1592
|
+
b.y + b.height / 2 - (a.y + a.height / 2),
|
|
1593
|
+
);
|
|
1594
|
+
return `across the cut: centre moves ${moved.toFixed(1)} px · width ×${(b.width / a.width).toFixed(2)}, height ×${(b.height / a.height).toFixed(2)} · computed through the cameras`;
|
|
1595
|
+
},
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
// kit/draw.js: marks and light on the picture
|
|
1601
|
+
const svg = (inner: string) =>
|
|
1602
|
+
`<svg style="position:absolute;left:0;top:0;overflow:visible" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">${inner}</svg>`;
|
|
1603
|
+
const sw = Math.max(3, Math.min(W, H) * 0.006);
|
|
1604
|
+
const D = kit.draw;
|
|
1605
|
+
if (D && typeof D.stroke === "function") {
|
|
1606
|
+
const mark = (d: string, s: { dasharray: string; dashoffset: number; visible: boolean }) =>
|
|
1607
|
+
s.visible
|
|
1608
|
+
? `<path d="${d}" pathLength="1" fill="none" stroke="#e8462a" stroke-width="${n3(sw)}" stroke-linecap="round" stroke-linejoin="round" style="stroke-dasharray:${s.dasharray};stroke-dashoffset:${s.dashoffset}"/>`
|
|
1609
|
+
: "";
|
|
1610
|
+
const far = {
|
|
1611
|
+
x: S.x - Math.max(S.width, W * 0.12),
|
|
1612
|
+
y: S.y + S.height + Math.max(S.height * 2, H * 0.12),
|
|
1613
|
+
};
|
|
1614
|
+
add({
|
|
1615
|
+
name: "draw.stroke",
|
|
1616
|
+
group: "draw",
|
|
1617
|
+
signature:
|
|
1618
|
+
"scribble(box, { kind, pad, turns, wobble, seed, from }) → d · stroke(t, start, { dur, off, offDur }) → { dasharray, dashoffset }",
|
|
1619
|
+
note: "a pen's mark round the subject: drawn on in 0.4 s, held, drawn off from its start in 0.3 s (pathLength 1)",
|
|
1620
|
+
needs: ["draw.scribble", "draw.stroke"],
|
|
1621
|
+
t0: 0,
|
|
1622
|
+
t1: 1.4,
|
|
1623
|
+
view: "full",
|
|
1624
|
+
rows: [
|
|
1625
|
+
{ label: 'kind: "circle", off: 1', o: { kind: "circle", off: 1 } },
|
|
1626
|
+
{ label: 'kind: "circle", turns: 2.1', o: { kind: "circle", turns: 2.1 } },
|
|
1627
|
+
{ label: 'kind: "underline"', o: { kind: "underline" } },
|
|
1628
|
+
{ label: 'kind: "arrow"', o: { kind: "arrow", from: far } },
|
|
1629
|
+
],
|
|
1630
|
+
draw: (t, r) => {
|
|
1631
|
+
const { off, ...o } = r.o as { off?: number };
|
|
1632
|
+
return pic() + svg(mark(D.scribble(S, o), D.stroke(t, 0, { off })));
|
|
1633
|
+
},
|
|
1634
|
+
value: (t, r) => D.stroke(t, 0, { off: (r.o as { off?: number }).off }).p,
|
|
1635
|
+
valueLabel: "drawn (0 → 1 on, → 2 off)",
|
|
1636
|
+
});
|
|
1637
|
+
add({
|
|
1638
|
+
name: "draw.spotlight",
|
|
1639
|
+
group: "draw",
|
|
1640
|
+
signature:
|
|
1641
|
+
"spotlight(t, start, box, { amount, in, release, out, color, spread }) → { background, k }",
|
|
1642
|
+
note: "the rest dimmed round the subject: 55 % dark at the edge, on in 0.3 s, off in 0.5 s from `release`",
|
|
1643
|
+
needs: ["draw.spotlight"],
|
|
1644
|
+
t0: 0,
|
|
1645
|
+
t1: 1.6,
|
|
1646
|
+
view: "full",
|
|
1647
|
+
rows: [
|
|
1648
|
+
{ label: "release: 1", o: { release: 1 } },
|
|
1649
|
+
{ label: "amount: 0.8", o: { amount: 0.8 } },
|
|
1650
|
+
{ label: "spread: 1.1", o: { spread: 1.1 } },
|
|
1651
|
+
{ label: "in: 0.8", o: { in: 0.8 } },
|
|
1652
|
+
],
|
|
1653
|
+
draw: (t, r) =>
|
|
1654
|
+
pic() +
|
|
1655
|
+
`<div style="position:absolute;left:0;top:0;width:${W}px;height:${H}px;background:${D.spotlight(t, 0, S, r.o).background}"></div>`,
|
|
1656
|
+
value: (t, r) => D.spotlight(t, 0, S, r.o).k,
|
|
1657
|
+
valueLabel: "on (0 → 1)",
|
|
1658
|
+
});
|
|
1659
|
+
const before = pic("filter:grayscale(1) contrast(0.7) brightness(1.15)");
|
|
1660
|
+
add({
|
|
1661
|
+
name: "draw.sweep",
|
|
1662
|
+
group: "draw",
|
|
1663
|
+
signature: "sweep(t, start, end, frame, { dir, ease }) → { clip, at, p, moving }",
|
|
1664
|
+
note: "a line sweeping the after over the before on the same picture, 0.5 s (here: before = the picture in grey)",
|
|
1665
|
+
needs: ["draw.sweep"],
|
|
1666
|
+
t0: 0,
|
|
1667
|
+
t1: 0.7,
|
|
1668
|
+
view: "full",
|
|
1669
|
+
rows: [
|
|
1670
|
+
{ label: "default", o: {} },
|
|
1671
|
+
{ label: 'dir: "left"', o: { dir: "left" } },
|
|
1672
|
+
{ label: 'dir: "down"', o: { dir: "down" } },
|
|
1673
|
+
{ label: "ease: linear", o: { ease: (p: number) => Math.max(0, Math.min(1, p)) } },
|
|
1674
|
+
],
|
|
1675
|
+
draw: (t, r) => {
|
|
1676
|
+
const w = D.sweep(t, 0, 0.6, { width: W, height: H }, r.o);
|
|
1677
|
+
const dir = (r.o as { dir?: string }).dir ?? "right";
|
|
1678
|
+
const v = dir === "right" || dir === "left";
|
|
1679
|
+
const line = w.moving
|
|
1680
|
+
? `<div style="position:absolute;${v ? `left:${n3(w.at - sw / 2)}px;top:0;width:${n3(sw)}px;height:${H}px` : `top:${n3(w.at - sw / 2)}px;left:0;height:${n3(sw)}px;width:${W}px`};background:#fff;box-shadow:0 0 ${n3(sw * 5)}px #fff"></div>`
|
|
1681
|
+
: "";
|
|
1682
|
+
return `${before}${pic(`clip-path:${w.clip}`)}${line}`;
|
|
1683
|
+
},
|
|
1684
|
+
value: (t, r) => D.sweep(t, 0, 0.6, { width: W, height: H }, r.o).p,
|
|
1685
|
+
valueLabel: "swept (0 → 1)",
|
|
1686
|
+
});
|
|
1687
|
+
add({
|
|
1688
|
+
name: "draw.lightSweep",
|
|
1689
|
+
group: "draw",
|
|
1690
|
+
signature:
|
|
1691
|
+
"lightSweep(t, start, end, frame, { angle, soft, glint, dim, ease }) → { mask, glint, dim }",
|
|
1692
|
+
note: "a band of light leaving the picture lit: 115°, the lit part 700 px behind the front (scaled to the picture here), unlit at 7 %, 1.3 s",
|
|
1693
|
+
needs: ["draw.lightSweep"],
|
|
1694
|
+
t0: 0,
|
|
1695
|
+
t1: 1.5,
|
|
1696
|
+
view: "full",
|
|
1697
|
+
rows: [
|
|
1698
|
+
{ label: "soft: ⅓ of the width", o: { soft: W / 3 } },
|
|
1699
|
+
{ label: "angle: 90", o: { angle: 90, soft: W / 3 } },
|
|
1700
|
+
{ label: "glint: 0", o: { glint: 0, soft: W / 3 } },
|
|
1701
|
+
{ label: "dim: 0.3", o: { dim: 0.3, soft: W / 3 } },
|
|
1702
|
+
],
|
|
1703
|
+
draw: (t, r) => {
|
|
1704
|
+
const l = D.lightSweep(t, 0, 1.3, { width: W, height: H }, r.o);
|
|
1705
|
+
return `${pic(`filter:brightness(${l.dim})`)}${pic(`-webkit-mask-image:${l.mask};mask-image:${l.mask}`)}<div style="position:absolute;left:0;top:0;width:${W}px;height:${H}px;background:${l.glint};mix-blend-mode:screen"></div>`;
|
|
1706
|
+
},
|
|
1707
|
+
value: (t, r) => D.lightSweep(t, 0, 1.3, { width: W, height: H }, r.o).p,
|
|
1708
|
+
valueLabel: "lit (0 → 1)",
|
|
1709
|
+
});
|
|
1710
|
+
add({
|
|
1711
|
+
name: "draw.flash",
|
|
1712
|
+
group: "draw",
|
|
1713
|
+
signature: "flash(t, at, { attack, decay, peak }) → { opacity }",
|
|
1714
|
+
note: "punctuation on a beat: up in 40 ms, gone over 0.3 s, peaking at 0.55",
|
|
1715
|
+
needs: ["draw.flash"],
|
|
1716
|
+
t0: -0.1,
|
|
1717
|
+
t1: 0.5,
|
|
1718
|
+
frames: [-0.05, -0.02, 0, 0.06, 0.15, 0.3],
|
|
1719
|
+
view: "full",
|
|
1720
|
+
rows: [
|
|
1721
|
+
{ label: "default", o: {} },
|
|
1722
|
+
{ label: "peak: 1", o: { peak: 1 } },
|
|
1723
|
+
{ label: "decay: 0.12", o: { decay: 0.12 } },
|
|
1724
|
+
{ label: "attack: 0", o: { attack: 0 } },
|
|
1725
|
+
],
|
|
1726
|
+
draw: (t, r) =>
|
|
1727
|
+
`${pic()}<div style="position:absolute;left:0;top:0;width:${W}px;height:${H}px;background:#fff;opacity:${D.flash(t, 0, r.o).opacity}"></div>`,
|
|
1728
|
+
value: (t, r) => D.flash(t, 0, r.o).opacity,
|
|
1729
|
+
valueLabel: "opacity",
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
// kit/map.js: places switching on, a line travelling between them
|
|
1734
|
+
const P = kit.map;
|
|
1735
|
+
if (P && typeof P.switchOn === "function") {
|
|
1736
|
+
// stand-in places scattered over the picture, seeded: the gallery has no map of the film's
|
|
1737
|
+
const spots: { x: number; y: number }[] = [];
|
|
1738
|
+
for (let i = 0; i < 24; i++) {
|
|
1739
|
+
const a = Math.sin(i * 12.9898 + 78.233) * 43758.5453;
|
|
1740
|
+
const b = Math.sin(i * 39.3468 + 11.135) * 24634.6345;
|
|
1741
|
+
spots.push({
|
|
1742
|
+
x: W * (0.08 + 0.84 * (a - Math.floor(a))),
|
|
1743
|
+
y: H * (0.1 + 0.8 * (b - Math.floor(b))),
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
spots.sort((p, q) => Math.hypot(p.x - sc.x, p.y - sc.y) - Math.hypot(q.x - sc.x, q.y - sc.y));
|
|
1747
|
+
const dot = Math.max(6, Math.min(W, H) * 0.014);
|
|
1748
|
+
add({
|
|
1749
|
+
name: "map.switchOn",
|
|
1750
|
+
group: "map",
|
|
1751
|
+
signature:
|
|
1752
|
+
"switchOn(t, start, n, { over, accel, fade, flashFor }) → { items: [{ on, flash, at }], lit, done }",
|
|
1753
|
+
note: "24 stand-in places by distance from the subject, the picture dimmed: each fades on in 0.22 s with a flash, the gaps shrinking (accel 1.6)",
|
|
1754
|
+
needs: ["map.switchOn"],
|
|
1755
|
+
t0: 0,
|
|
1756
|
+
t1: 2.2,
|
|
1757
|
+
view: "full",
|
|
1758
|
+
rows: [
|
|
1759
|
+
{ label: "over: 2", o: { over: 2 } },
|
|
1760
|
+
{ label: "over: 2, accel: 1", o: { over: 2, accel: 1 } },
|
|
1761
|
+
{ label: "over: 2, accel: 3", o: { over: 2, accel: 3 } },
|
|
1762
|
+
{ label: "over: 1, flashFor: 0", o: { over: 1, flashFor: 0 } },
|
|
1763
|
+
],
|
|
1764
|
+
draw: (t, r) => {
|
|
1765
|
+
const s = P.switchOn(t, 0, spots.length, r.o);
|
|
1766
|
+
return (
|
|
1767
|
+
pic("filter:brightness(0.25) saturate(0.4)") +
|
|
1768
|
+
s.items
|
|
1769
|
+
.map((it: { on: number; flash: number }, i: number) =>
|
|
1770
|
+
it.on > 0
|
|
1771
|
+
? `<div style="position:absolute;left:${n3(spots[i]!.x - dot)}px;top:${n3(spots[i]!.y - dot)}px;width:${n3(dot * 2)}px;height:${n3(dot * 2)}px;border-radius:50%;background:rgb(${n3(255)},${n3(170 + 85 * it.flash)},${n3(60 + 195 * it.flash)});opacity:${n3(it.on)};box-shadow:0 0 ${n3(dot * (1 + 3 * it.flash))}px rgba(255,200,120,0.9)"></div>`
|
|
1772
|
+
: "",
|
|
1773
|
+
)
|
|
1774
|
+
.join("")
|
|
1775
|
+
);
|
|
1776
|
+
},
|
|
1777
|
+
value: (t, r) => P.switchOn(t, 0, spots.length, r.o).lit,
|
|
1778
|
+
valueLabel: "places fully on",
|
|
1779
|
+
});
|
|
1780
|
+
const route = [spots[spots.length - 1]!, { x: sc.x, y: spots[spots.length - 1]!.y }, sc];
|
|
1781
|
+
add({
|
|
1782
|
+
name: "map.along",
|
|
1783
|
+
group: "map",
|
|
1784
|
+
signature:
|
|
1785
|
+
"along(t, start, end, points, { ease }) → { tip, angle, length, total, p } · pathOf(points)",
|
|
1786
|
+
note: "a line from a far place to the subject, drawn ahead of its tip, a figure rolling with it (count at p)",
|
|
1787
|
+
needs: ["map.along", "map.pathOf"],
|
|
1788
|
+
t0: 0,
|
|
1789
|
+
t1: 1.4,
|
|
1790
|
+
view: "full",
|
|
1791
|
+
rows: [
|
|
1792
|
+
{ label: "default", o: {} },
|
|
1793
|
+
{ label: "ease: linear", o: { ease: (p: number) => Math.max(0, Math.min(1, p)) } },
|
|
1794
|
+
{ label: "ease: easeOut", o: { ease: M.easeOut } },
|
|
1795
|
+
{ label: "ease: easeIn", o: { ease: M.easeIn } },
|
|
1796
|
+
],
|
|
1797
|
+
draw: (t, r) => {
|
|
1798
|
+
const a = P.along(t, 0, 1.2, route, r.o);
|
|
1799
|
+
const m = Math.round(420 * a.p);
|
|
1800
|
+
return (
|
|
1801
|
+
pic("filter:brightness(0.6)") +
|
|
1802
|
+
svg(
|
|
1803
|
+
`<path d="${P.pathOf(route)}" pathLength="1" fill="none" stroke="#fff" stroke-width="${n3(sw)}" stroke-linecap="round" style="stroke-dasharray:1 1;stroke-dashoffset:${n3(1 - a.p)}"/><circle cx="${n3(a.tip.x)}" cy="${n3(a.tip.y)}" r="${n3(dot)}" fill="#e8462a"/><text x="${n3(a.tip.x + dot * 2)}" y="${n3(a.tip.y - dot * 2)}" font-size="${n3(dot * 4)}" font-family="system-ui" font-weight="700" fill="#fff">${m} m</text>`,
|
|
1804
|
+
)
|
|
1805
|
+
);
|
|
1806
|
+
},
|
|
1807
|
+
value: (t, r) => P.along(t, 0, 1.2, route, r.o).length,
|
|
1808
|
+
valueLabel: "drawn (px)",
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
// kit/stage.js: parts of the picture as slabs in depth
|
|
1813
|
+
const ST = kit.stage;
|
|
1814
|
+
if (ST && typeof ST.stage === "function") {
|
|
1815
|
+
// a card: the subject with room round it, at least about a third of the
|
|
1816
|
+
// picture, inside it; the regions of the same size round the other
|
|
1817
|
+
// element and the picture's far corner are what other slabs show
|
|
1818
|
+
const cw = Math.min(W, Math.max(S.width * 1.6, W * 0.36));
|
|
1819
|
+
const ch = Math.min(H, Math.max(S.height * 1.6, H * 0.3));
|
|
1820
|
+
const around = (cx: number, cy: number): GalleryBox => ({
|
|
1821
|
+
x: Math.max(0, Math.min(W - cw, cx - cw / 2)),
|
|
1822
|
+
y: Math.max(0, Math.min(H - ch, cy - ch / 2)),
|
|
1823
|
+
width: cw,
|
|
1824
|
+
height: ch,
|
|
1825
|
+
});
|
|
1826
|
+
const O = mat.other;
|
|
1827
|
+
const card = around(sc.x, sc.y);
|
|
1828
|
+
const second = around(O.x + O.width / 2, O.y + O.height / 2);
|
|
1829
|
+
const third = around(sc.x < W / 2 ? W - cw / 2 : cw / 2, sc.y < H / 2 ? H - ch / 2 : ch / 2);
|
|
1830
|
+
// the picture in tiles, 3 × 2: a layout of parts, none bigger than a sixth
|
|
1831
|
+
const tiles: GalleryBox[] = [];
|
|
1832
|
+
for (let j = 0; j < 2; j++)
|
|
1833
|
+
for (let i = 0; i < 3; i++)
|
|
1834
|
+
tiles.push({ x: (i * W) / 3, y: (j * H) / 2, width: W / 3, height: H / 2 });
|
|
1835
|
+
// biome-ignore lint/suspicious/noExplicitAny: a stage of the film's kit
|
|
1836
|
+
type Built = { st: any; slabs: { sl: any; crop: GalleryBox }[] };
|
|
1837
|
+
const built = new Map<Row, Built>();
|
|
1838
|
+
const stageOf = (row: Row, make: (o: Record<string, unknown>) => Built) => {
|
|
1839
|
+
let b = built.get(row);
|
|
1840
|
+
if (!b) {
|
|
1841
|
+
b = make(row.o);
|
|
1842
|
+
built.set(row, b);
|
|
1843
|
+
}
|
|
1844
|
+
return b;
|
|
1845
|
+
};
|
|
1846
|
+
/** a stage with slabs on given boxes, each showing a crop of the picture */
|
|
1847
|
+
const build = (
|
|
1848
|
+
parts: { box: GalleryBox; crop?: GalleryBox; o?: Record<string, unknown> }[],
|
|
1849
|
+
) => {
|
|
1850
|
+
const st = ST.stage({ width: W, height: H });
|
|
1851
|
+
const slabs = parts.map((p, i) => ({
|
|
1852
|
+
sl: st.slab(null, { box: p.box, name: `slab ${i + 1}`, ...(p.o ?? {}) }),
|
|
1853
|
+
crop: p.crop ?? p.box,
|
|
1854
|
+
}));
|
|
1855
|
+
return { st, slabs };
|
|
1856
|
+
};
|
|
1857
|
+
const drawStage = (b: Built, t: number, backdrop = pic("opacity:0.32")) => {
|
|
1858
|
+
const states = b.st.at(t) as {
|
|
1859
|
+
style: Record<string, string>;
|
|
1860
|
+
sheen: { background: string; opacity: number } | null;
|
|
1861
|
+
}[];
|
|
1862
|
+
return (
|
|
1863
|
+
backdrop +
|
|
1864
|
+
states
|
|
1865
|
+
.map((s, i) => {
|
|
1866
|
+
const { sl, crop } = b.slabs[i]!;
|
|
1867
|
+
const box = sl.box as { w: number; h: number };
|
|
1868
|
+
const st = s.style;
|
|
1869
|
+
return `<div style="position:absolute;left:0;top:0;width:${n3(box.w)}px;height:${n3(box.h)}px;overflow:hidden;transform-origin:0 0;backface-visibility:hidden;transform:${st.transform};opacity:${st.opacity};visibility:${st.visibility};z-index:${st.zIndex};filter:${st.filter};box-shadow:${st.boxShadow};outline:var(--px) solid rgba(255,255,255,0.35)">${pic(`left:${-crop.x}px;top:${-crop.y}px`)}${s.sheen ? `<div style="position:absolute;inset:0;background:${s.sheen.background};opacity:${s.sheen.opacity}"></div>` : ""}</div>`;
|
|
1870
|
+
})
|
|
1871
|
+
.join("")
|
|
1872
|
+
);
|
|
1873
|
+
};
|
|
1874
|
+
const stageBlock = (
|
|
1875
|
+
b: Omit<Block, "group" | "draw" | "value" | "view"> & {
|
|
1876
|
+
view?: Block["view"];
|
|
1877
|
+
make: (o: Record<string, unknown>) => Built;
|
|
1878
|
+
value: (t: number, b: Built, row: Row) => number;
|
|
1879
|
+
backdrop?: string;
|
|
1880
|
+
},
|
|
1881
|
+
) =>
|
|
1882
|
+
add({
|
|
1883
|
+
focus: card,
|
|
1884
|
+
...b,
|
|
1885
|
+
group: "stage",
|
|
1886
|
+
view: b.view ?? "subject",
|
|
1887
|
+
draw: (t, r) => drawStage(stageOf(r, b.make), t, b.backdrop),
|
|
1888
|
+
value: (t, r) => b.value(t, stageOf(r, b.make), r),
|
|
1889
|
+
});
|
|
1890
|
+
const angle = (p: { rx: number; ry: number }) => Math.hypot(p.rx, p.ry);
|
|
1891
|
+
stageBlock({
|
|
1892
|
+
name: "stage.tilt",
|
|
1893
|
+
signature:
|
|
1894
|
+
"stage({ el, camera, perspective }) · st.slab(node, { crop | box }) · slab.to({ rx, ry, rz, z, scale }, { start | arrive, dur, ease | spring })",
|
|
1895
|
+
note: "one part as a slab turning into depth, its content live; a lens 2000 px away (the middle of 1600–2800 px measured); no default angle — these are the films' (rx ≈20°, ry −20…−35°; a table ≈40°)",
|
|
1896
|
+
needs: ["stage.stage"],
|
|
1897
|
+
t0: 0,
|
|
1898
|
+
t1: 1.2,
|
|
1899
|
+
rows: [
|
|
1900
|
+
{ label: "rx: 20, ry: -28", o: { rx: 20, ry: -28 } },
|
|
1901
|
+
{ label: "ry: -35", o: { ry: -35 } },
|
|
1902
|
+
{ label: "rx: 40 (a table)", o: { rx: 40 } },
|
|
1903
|
+
{
|
|
1904
|
+
label: "rx: 20, ry: -28, spring overshoot 0.2",
|
|
1905
|
+
o: { rx: 20, ry: -28, spring: { overshoot: 0.2 } },
|
|
1906
|
+
},
|
|
1907
|
+
],
|
|
1908
|
+
make: (o) => {
|
|
1909
|
+
const b = build([{ box: card, o: { sheen: 0.6, shadow: 1 } }]);
|
|
1910
|
+
const { spring: sp, ...pose } = o as { spring?: unknown };
|
|
1911
|
+
b.slabs[0]!.sl.to(pose, sp ? { start: 0, spring: sp } : { start: 0 });
|
|
1912
|
+
return b;
|
|
1913
|
+
},
|
|
1914
|
+
value: (t, b) => angle(b.slabs[0]!.sl.pose(t)),
|
|
1915
|
+
valueLabel: "its angle (degrees)",
|
|
1916
|
+
});
|
|
1917
|
+
stageBlock({
|
|
1918
|
+
name: "stage.explode",
|
|
1919
|
+
view: "full",
|
|
1920
|
+
signature:
|
|
1921
|
+
"explode(slabs, { start | arrive, gap, spread, every }) · together(slabs, when) · st.turn({ rx, ry }, when)",
|
|
1922
|
+
note: "three parts lifting apart, 120 px a layer (about a sixteenth of the lens's distance), as the stage turns rx 24°, ry −18°",
|
|
1923
|
+
needs: ["stage.stage", "stage.explode"],
|
|
1924
|
+
t0: 0,
|
|
1925
|
+
t1: 1.4,
|
|
1926
|
+
rows: [
|
|
1927
|
+
{ label: "default", o: {} },
|
|
1928
|
+
{ label: "gap: 260", o: { gap: 260 } },
|
|
1929
|
+
{ label: "spread: 0.3", o: { spread: 0.3 } },
|
|
1930
|
+
{ label: "every: 0.12, then together", o: { every: 0.12, back: true } },
|
|
1931
|
+
],
|
|
1932
|
+
make: (o) => {
|
|
1933
|
+
const b = build([{ box: third }, { box: second }, { box: card }]);
|
|
1934
|
+
const { back, ...e } = o as { back?: boolean };
|
|
1935
|
+
b.st.turn({ rx: 24, ry: -18 }, { start: 0, dur: 0.9 });
|
|
1936
|
+
ST.explode(
|
|
1937
|
+
b.slabs.map((x) => x.sl),
|
|
1938
|
+
{ start: 0.1, ...e },
|
|
1939
|
+
);
|
|
1940
|
+
if (back)
|
|
1941
|
+
ST.together(
|
|
1942
|
+
b.slabs.map((x) => x.sl),
|
|
1943
|
+
{ start: 0.85, dur: 0.45 },
|
|
1944
|
+
);
|
|
1945
|
+
return b;
|
|
1946
|
+
},
|
|
1947
|
+
value: (t, b) => b.slabs[2]!.sl.pose(t).z,
|
|
1948
|
+
valueLabel: "the front layer's height (px toward the lens)",
|
|
1949
|
+
});
|
|
1950
|
+
stageBlock({
|
|
1951
|
+
name: "stage.drop",
|
|
1952
|
+
signature: "drop(slab, { start | arrive, from, z, tilt, spring | ease })",
|
|
1953
|
+
note: "lowered like a print: from 400 px up (1.25× under the 2000 px lens), a 2 Hz spring swinging 12 % of its fall (a 3 % bounce), its shadow tightening",
|
|
1954
|
+
needs: ["stage.stage", "stage.drop"],
|
|
1955
|
+
t0: 0,
|
|
1956
|
+
t1: 1,
|
|
1957
|
+
rows: [
|
|
1958
|
+
{ label: "default", o: {} },
|
|
1959
|
+
{ label: "from: 900", o: { from: 900 } },
|
|
1960
|
+
{ label: "tilt: { rz: -8, rx: 12 }", o: { tilt: { rz: -8, rx: 12 } } },
|
|
1961
|
+
{
|
|
1962
|
+
label: "spring: { freq: 1.2, overshoot: 0.3 }",
|
|
1963
|
+
o: { spring: { freq: 1.2, overshoot: 0.3 } },
|
|
1964
|
+
},
|
|
1965
|
+
],
|
|
1966
|
+
make: (o) => {
|
|
1967
|
+
const b = build([{ box: card, o: { shadow: 1 } }]);
|
|
1968
|
+
ST.drop(b.slabs[0]!.sl, { start: 0, ...o });
|
|
1969
|
+
return b;
|
|
1970
|
+
},
|
|
1971
|
+
value: (t, b) => b.slabs[0]!.sl.pose(t).z,
|
|
1972
|
+
valueLabel: "height (px toward the lens)",
|
|
1973
|
+
});
|
|
1974
|
+
stageBlock({
|
|
1975
|
+
name: "stage.stack",
|
|
1976
|
+
view: "full",
|
|
1977
|
+
signature: "stack(slabs, { start | arrive, every, gap, from, rz })",
|
|
1978
|
+
note: "three cards dropped in turn on one place, 0.16 s apart (labels in those films stacked one every ≈0.16 s), 6 px a sheet; the stage turned 30° so the pile has thickness",
|
|
1979
|
+
needs: ["stage.stage", "stage.stack"],
|
|
1980
|
+
t0: 0,
|
|
1981
|
+
t1: 1.4,
|
|
1982
|
+
rows: [
|
|
1983
|
+
{ label: "default", o: {} },
|
|
1984
|
+
{ label: "rz: [-5, 4, -1]", o: { rz: [-5, 4, -1] } },
|
|
1985
|
+
{ label: "every: 0.32", o: { every: 0.32 } },
|
|
1986
|
+
{ label: "gap: 40", o: { gap: 40 } },
|
|
1987
|
+
],
|
|
1988
|
+
make: (o) => {
|
|
1989
|
+
const b = build([
|
|
1990
|
+
{ box: card, crop: third, o: { shadow: 1 } },
|
|
1991
|
+
{ box: card, crop: second, o: { shadow: 1 } },
|
|
1992
|
+
{ box: card, crop: card, o: { shadow: 1 } },
|
|
1993
|
+
]);
|
|
1994
|
+
b.st.turn({ rx: 30 }, { start: 0, dur: 0.01 });
|
|
1995
|
+
ST.stack(
|
|
1996
|
+
b.slabs.map((x) => x.sl),
|
|
1997
|
+
{ start: 0, ...o },
|
|
1998
|
+
);
|
|
1999
|
+
return b;
|
|
2000
|
+
},
|
|
2001
|
+
value: (t, b) => b.slabs[2]!.sl.pose(t).z,
|
|
2002
|
+
valueLabel: "the last card's height (px)",
|
|
2003
|
+
});
|
|
2004
|
+
stageBlock({
|
|
2005
|
+
name: "stage.flip",
|
|
2006
|
+
signature: "flip(front, back, { start | arrive, dur, axis, dir, lift })",
|
|
2007
|
+
note: "the card turns over to the other region on its back, 0.73 s with the camera's settle; each side hidden while it faces away",
|
|
2008
|
+
needs: ["stage.stage", "stage.flip"],
|
|
2009
|
+
t0: 0,
|
|
2010
|
+
t1: 1.1,
|
|
2011
|
+
rows: [
|
|
2012
|
+
{ label: "default (axis y)", o: {} },
|
|
2013
|
+
{ label: 'axis: "x"', o: { axis: "x" } },
|
|
2014
|
+
{ label: "lift: 300", o: { lift: 300 } },
|
|
2015
|
+
{ label: "dur: 0.4, ease: linear", o: { dur: 0.4, ease: (p: number) => p } },
|
|
2016
|
+
],
|
|
2017
|
+
make: (o) => {
|
|
2018
|
+
const b = build([
|
|
2019
|
+
{ box: card, crop: card, o: { sheen: 0.6 } },
|
|
2020
|
+
{ box: card, crop: second, o: { sheen: 0.6 } },
|
|
2021
|
+
]);
|
|
2022
|
+
ST.flip(b.slabs[0]!.sl, b.slabs[1]!.sl, { start: 0, ...o });
|
|
2023
|
+
return b;
|
|
2024
|
+
},
|
|
2025
|
+
value: (t, b, r) => {
|
|
2026
|
+
const p = b.slabs[0]!.sl.pose(t);
|
|
2027
|
+
return (r.o as { axis?: string }).axis === "x" ? p.rx : p.ry;
|
|
2028
|
+
},
|
|
2029
|
+
valueLabel: "the front's turn (degrees)",
|
|
2030
|
+
});
|
|
2031
|
+
stageBlock({
|
|
2032
|
+
name: "stage.turn",
|
|
2033
|
+
view: "full",
|
|
2034
|
+
signature:
|
|
2035
|
+
"st.turn({ rx, ry, rz }, { start | arrive, dur, ease | spring }) — the whole stage about its pivot",
|
|
2036
|
+
note: "the picture as six tiles (none bigger than a sixth of it) turning into a table — the films turned a layout ≈40°, then back to flat",
|
|
2037
|
+
needs: ["stage.stage"],
|
|
2038
|
+
t0: 0,
|
|
2039
|
+
t1: 1.2,
|
|
2040
|
+
rows: [
|
|
2041
|
+
{ label: "rx: 40", o: { rx: 40 } },
|
|
2042
|
+
{ label: "rx: 40, ry: -20", o: { rx: 40, ry: -20 } },
|
|
2043
|
+
{ label: "rx: 30, rz: 12", o: { rx: 30, rz: 12 } },
|
|
2044
|
+
{ label: "rx: 40, tiles lifted 60 px apart", o: { rx: 40, lift: 60 } },
|
|
2045
|
+
],
|
|
2046
|
+
backdrop: "",
|
|
2047
|
+
make: (o) => {
|
|
2048
|
+
const b = build(tiles.map((box) => ({ box, o: { shadow: 0.8 } })));
|
|
2049
|
+
const { lift, ...w } = o as { lift?: number };
|
|
2050
|
+
b.st.turn(w, { start: 0 });
|
|
2051
|
+
if (lift)
|
|
2052
|
+
ST.explode(
|
|
2053
|
+
b.slabs.map((x) => x.sl),
|
|
2054
|
+
{ start: 0.2, gap: lift },
|
|
2055
|
+
);
|
|
2056
|
+
return b;
|
|
2057
|
+
},
|
|
2058
|
+
value: (t, b) => angle(b.st.world(t)),
|
|
2059
|
+
valueLabel: "the stage's angle (degrees)",
|
|
2060
|
+
});
|
|
2061
|
+
stageBlock({
|
|
2062
|
+
name: "stage.dolly",
|
|
2063
|
+
view: "full",
|
|
2064
|
+
signature: "st.dolly(z, { start | arrive, dur, ease | spring })",
|
|
2065
|
+
note: "the lens travels 2200 px past the card into the tiles 1600 px behind it; a slab fades over the last quarter of the way to the lens; square on, it is drawn in 2D at any size",
|
|
2066
|
+
needs: ["stage.stage"],
|
|
2067
|
+
t0: 0,
|
|
2068
|
+
t1: 1.4,
|
|
2069
|
+
rows: [
|
|
2070
|
+
{ label: "default (0.73 s)", o: {} },
|
|
2071
|
+
{ label: "dur: 1.2", o: { dur: 1.2 } },
|
|
2072
|
+
{ label: "z: 1500 (stops at the card)", o: { z: 1500 } },
|
|
2073
|
+
{ label: "ease: linear", o: { ease: (p: number) => p } },
|
|
2074
|
+
],
|
|
2075
|
+
backdrop: "",
|
|
2076
|
+
make: (o) => {
|
|
2077
|
+
const b = build([
|
|
2078
|
+
...tiles.map((box) => ({ box, o: { rest: { z: -1600 } } })),
|
|
2079
|
+
{ box: card, o: { shadow: 1 } },
|
|
2080
|
+
]);
|
|
2081
|
+
const { z = 2200, ...w } = o as { z?: number };
|
|
2082
|
+
b.st.dolly(z, { start: 0, ...w });
|
|
2083
|
+
return b;
|
|
2084
|
+
},
|
|
2085
|
+
value: (t, b) => b.st.world(t).z,
|
|
2086
|
+
valueLabel: "the lens's travel (px)",
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
// kit/seams.js: one scene handing over to the next — the picture as the
|
|
2091
|
+
// outgoing scene, the other element's region of it, filling the frame, as
|
|
2092
|
+
// the incoming one
|
|
2093
|
+
const SE = kit.seams;
|
|
2094
|
+
if (SE && typeof SE.curve === "function") {
|
|
2095
|
+
const O = mat.other;
|
|
2096
|
+
// the incoming scene: the other region, scaled to cover the frame
|
|
2097
|
+
const k = Math.max(W / Math.max(1, O.width), H / Math.max(1, O.height));
|
|
2098
|
+
const sceneB = `<img class="m" src="${img}" style="transform-origin:0 0;transform:translate(${n3(W / 2 - (O.x + O.width / 2) * k)}px,${n3(H / 2 - (O.y + O.height / 2) * k)}px) scale(${n3(k)})">`;
|
|
2099
|
+
let blurId = 0;
|
|
2100
|
+
/** one side of a seam as a full-frame layer; an axis blur as an SVG filter of its own */
|
|
2101
|
+
const sideDiv = (
|
|
2102
|
+
sd: {
|
|
2103
|
+
visible: boolean;
|
|
2104
|
+
opacity: number;
|
|
2105
|
+
transform: string;
|
|
2106
|
+
filter: string;
|
|
2107
|
+
blur: number;
|
|
2108
|
+
blurAxis: "x" | "y" | null;
|
|
2109
|
+
},
|
|
2110
|
+
inner: string,
|
|
2111
|
+
z = 0,
|
|
2112
|
+
) => {
|
|
2113
|
+
if (!sd.visible) return "";
|
|
2114
|
+
let filter = sd.filter === "none" ? "" : sd.filter;
|
|
2115
|
+
let defs = "";
|
|
2116
|
+
if (sd.blurAxis && sd.blur > 0) {
|
|
2117
|
+
const id = `sb${++blurId}`;
|
|
2118
|
+
defs = `<svg width="0" height="0" style="position:absolute"><filter id="${id}" x="-20%" width="140%" y="-20%" height="140%"><feGaussianBlur stdDeviation="${sd.blurAxis === "x" ? `${n3(sd.blur)} 0` : `0 ${n3(sd.blur)}`}"/></filter></svg>`;
|
|
2119
|
+
filter = `url(#${id})${filter ? ` ${filter}` : ""}`;
|
|
2120
|
+
}
|
|
2121
|
+
return `${defs}<div style="position:absolute;left:0;top:0;width:${W}px;height:${H}px;overflow:hidden;background:#f2f2ef;z-index:${z};transform-origin:50% 50%;transform:${sd.transform};opacity:${n3(sd.opacity)};filter:${filter || "none"}">${inner}</div>`;
|
|
2122
|
+
};
|
|
2123
|
+
const AT = 0.4;
|
|
2124
|
+
/** the six instants round a cut: before, on its way, its last frame, its first, after */
|
|
2125
|
+
const round = [AT - 0.3, AT - 0.12, AT - 1 / 60, AT, AT + 0.12, AT + 0.35];
|
|
2126
|
+
const pair = (r: { a: Parameters<typeof sideDiv>[0]; b: Parameters<typeof sideDiv>[0] }) =>
|
|
2127
|
+
`<div style="position:absolute;inset:0;background:#e9e9e4"></div>${sideDiv(r.a, pic())}${sideDiv(r.b, sceneB, 1)}`;
|
|
2128
|
+
const along = (r: {
|
|
2129
|
+
a: { visible: boolean; x: number; y: number };
|
|
2130
|
+
b: { x: number; y: number };
|
|
2131
|
+
}) => (r.a.visible ? r.a.x + r.a.y : r.b.x + r.b.y);
|
|
2132
|
+
add({
|
|
2133
|
+
name: "seams.curve",
|
|
2134
|
+
group: "seams",
|
|
2135
|
+
signature: "curve(t, at, { dir, dist, dur, fade, enter }) → { a, b, speed }",
|
|
2136
|
+
note: "the cut at the fastest frame: out on p⁴, in on its mirror, 4·dist/dur both sides (230 px, 0.30 s → ≈ 3070 px/s; HyperFrames' cut catalog)",
|
|
2137
|
+
needs: ["seams.curve"],
|
|
2138
|
+
t0: 0,
|
|
2139
|
+
t1: 0.8,
|
|
2140
|
+
frames: round,
|
|
2141
|
+
view: "full",
|
|
2142
|
+
rows: [
|
|
2143
|
+
{ label: "default (left)", o: {} },
|
|
2144
|
+
{ label: 'dir: "up"', o: { dir: "up" } },
|
|
2145
|
+
{ label: "dist: 460", o: { dist: 460 } },
|
|
2146
|
+
{ label: "dur: 0.2", o: { dur: 0.2 } },
|
|
2147
|
+
],
|
|
2148
|
+
draw: (t, r) => pair(SE.curve(t, AT, r.o)),
|
|
2149
|
+
// the travel of the one move: the outgoing's offset, then the incoming's
|
|
2150
|
+
// plus both distances — one line through the cut, its speed the same on both sides
|
|
2151
|
+
value: (t, r) => {
|
|
2152
|
+
const c = SE.curve(t, AT, r.o);
|
|
2153
|
+
const d = (r.o.dist as number | undefined) ?? 230;
|
|
2154
|
+
const sgn = r.o.dir === "up" || r.o.dir === undefined || r.o.dir === "left" ? -1 : 1;
|
|
2155
|
+
return c.a.visible ? along(c) : along(c) + sgn * 2 * d;
|
|
2156
|
+
},
|
|
2157
|
+
valueLabel: "travel of the move (px)",
|
|
2158
|
+
});
|
|
2159
|
+
const words = (mat.text || DEFAULT_TEXT).split(/\s+/).filter(Boolean).slice(0, 6);
|
|
2160
|
+
const next = ["the", "next", "line", "arrives"];
|
|
2161
|
+
const fs = Math.round(H * 0.12);
|
|
2162
|
+
const line = (
|
|
2163
|
+
ws: string[],
|
|
2164
|
+
sides: { visible: boolean; transform: string; opacity: number }[],
|
|
2165
|
+
) => {
|
|
2166
|
+
let x = W * 0.08;
|
|
2167
|
+
return ws
|
|
2168
|
+
.map((w, i) => {
|
|
2169
|
+
const sd = sides[i]!;
|
|
2170
|
+
const left = x;
|
|
2171
|
+
x += (w.length + 1) * fs * 0.56;
|
|
2172
|
+
return sd.visible
|
|
2173
|
+
? `<span style="position:absolute;left:${n3(left)}px;top:${n3(H * 0.42)}px;font:700 ${fs}px/1 system-ui,sans-serif;color:#111;white-space:pre;transform:${sd.transform === "none" ? "none" : sd.transform};opacity:${n3(sd.opacity)}">${esc(w)}</span>`
|
|
2174
|
+
: "";
|
|
2175
|
+
})
|
|
2176
|
+
.join("");
|
|
2177
|
+
};
|
|
2178
|
+
add({
|
|
2179
|
+
name: "seams.waterfall",
|
|
2180
|
+
group: "seams",
|
|
2181
|
+
signature:
|
|
2182
|
+
"waterfall(t, at, nOut, nIn, { dir, dist, outDur, inDur, fade, stagger, gap, shrink }) → { out, in, end }",
|
|
2183
|
+
note: "word by word: out 0.34 s each, 0.022 s apart, the last gone at the cut; in 0.30 s each, gaps from 0.05 s shrinking ×0.84 (HyperFrames' waterfall)",
|
|
2184
|
+
needs: ["seams.waterfall"],
|
|
2185
|
+
t0: 0,
|
|
2186
|
+
t1: 0.9,
|
|
2187
|
+
frames: [AT - 0.3, AT - 0.15, AT - 0.05, AT + 0.05, AT + 0.15, AT + 0.45],
|
|
2188
|
+
view: "full",
|
|
2189
|
+
rows: [
|
|
2190
|
+
{ label: "default", o: {} },
|
|
2191
|
+
{ label: "stagger: 0.05", o: { stagger: 0.05 } },
|
|
2192
|
+
{ label: "gap: 0.1", o: { gap: 0.1 } },
|
|
2193
|
+
{ label: 'dir: "up", dist: 120', o: { dir: "up", dist: 120 } },
|
|
2194
|
+
],
|
|
2195
|
+
draw: (t, r) => {
|
|
2196
|
+
const w = SE.waterfall(t, AT, words.length, next.length, r.o);
|
|
2197
|
+
return `<div style="position:absolute;inset:0;background:#f7f7f4"></div>${line(words, w.out)}${line(next, w.in)}`;
|
|
2198
|
+
},
|
|
2199
|
+
// the last word out, then the first word in, as one travel
|
|
2200
|
+
value: (t, r) => {
|
|
2201
|
+
const w = SE.waterfall(t, AT, words.length, next.length, r.o);
|
|
2202
|
+
const last = (w.out as { x: number; y: number }[])[words.length - 1]!;
|
|
2203
|
+
const first = (w.in as { x: number; y: number }[])[0]!;
|
|
2204
|
+
const d = (r.o.dist as number | undefined) ?? 230;
|
|
2205
|
+
return t < AT ? last.x + last.y : first.x + first.y - 2 * d;
|
|
2206
|
+
},
|
|
2207
|
+
valueLabel: "travel of the last word out, then the first in (px)",
|
|
2208
|
+
});
|
|
2209
|
+
add({
|
|
2210
|
+
name: "seams.whip",
|
|
2211
|
+
group: "seams",
|
|
2212
|
+
signature: "whip(t, at, view, { dir, dur, blur, power }) → { a, b, speed, edge }",
|
|
2213
|
+
note: "one strip, the next scene a frame beyond: 3·W/dur at the middle (0.55 s → ≈ 10 500 px/s at 1920); the master's shutter smears it, `blur` adds one along the path (HyperFrames' whip-pan)",
|
|
2214
|
+
needs: ["seams.whip"],
|
|
2215
|
+
t0: 0,
|
|
2216
|
+
t1: 0.8,
|
|
2217
|
+
frames: [AT - 0.3, AT - 0.15, AT - 0.05, AT + 0.05, AT + 0.15, AT + 0.3],
|
|
2218
|
+
view: "full",
|
|
2219
|
+
rows: [
|
|
2220
|
+
{ label: "default (left)", o: {} },
|
|
2221
|
+
{ label: "blur: 16", o: { blur: 16 } },
|
|
2222
|
+
{ label: 'dir: "up"', o: { dir: "up" } },
|
|
2223
|
+
{ label: "dur: 0.3", o: { dur: 0.3 } },
|
|
2224
|
+
],
|
|
2225
|
+
draw: (t, r) => pair(SE.whip(t, AT, { width: W, height: H }, r.o)),
|
|
2226
|
+
value: (t, r) => {
|
|
2227
|
+
const w = SE.whip(t, AT, { width: W, height: H }, r.o);
|
|
2228
|
+
const size = r.o.dir === "up" || r.o.dir === "down" ? H : W;
|
|
2229
|
+
return -size * w.p;
|
|
2230
|
+
},
|
|
2231
|
+
valueLabel: "the strip's offset (px)",
|
|
2232
|
+
});
|
|
2233
|
+
add({
|
|
2234
|
+
name: "seams.depth",
|
|
2235
|
+
group: "seams",
|
|
2236
|
+
signature:
|
|
2237
|
+
"depth(t, at, { inverse, outDur, inDur, outScale, inScale, blur, dim }) → { a, b }",
|
|
2238
|
+
note: "into the lens and out of the same blur: out 0.2 s to ×1.2, blur 10; in 0.5 s from ×0.75 (HyperFrames' zoom-through); 10 px for text, 18–20 for a full frame",
|
|
2239
|
+
needs: ["seams.depth"],
|
|
2240
|
+
t0: 0,
|
|
2241
|
+
t1: 1,
|
|
2242
|
+
frames: [AT - 0.3, AT - 0.1, AT - 1 / 60, AT, AT + 0.12, AT + 0.5],
|
|
2243
|
+
view: "full",
|
|
2244
|
+
rows: [
|
|
2245
|
+
{ label: "default", o: {} },
|
|
2246
|
+
{ label: "inverse: true", o: { inverse: true } },
|
|
2247
|
+
{ label: "blur: 18", o: { blur: 18 } },
|
|
2248
|
+
{ label: "inDur: 0.3", o: { inDur: 0.3 } },
|
|
2249
|
+
],
|
|
2250
|
+
draw: (t, r) => pair(SE.depth(t, AT, r.o)),
|
|
2251
|
+
value: (t, r) => {
|
|
2252
|
+
const d = SE.depth(t, AT, r.o);
|
|
2253
|
+
return d.a.visible ? d.a.blur : d.b.blur;
|
|
2254
|
+
},
|
|
2255
|
+
valueLabel: "blur (px)",
|
|
2256
|
+
});
|
|
2257
|
+
const big = Math.round(H * 0.13);
|
|
2258
|
+
const word = (
|
|
2259
|
+
txt: string,
|
|
2260
|
+
sd: { visible: boolean; transform: string; opacity: number },
|
|
2261
|
+
sp: number | null,
|
|
2262
|
+
) =>
|
|
2263
|
+
sd.visible
|
|
2264
|
+
? `<div style="position:absolute;left:0;top:0;width:${W}px;height:${H}px;display:flex;align-items:center;justify-content:center;transform-origin:50% 50%;transform:${sd.transform};opacity:${n3(sd.opacity)}"><span style="font:800 ${big}px/1 system-ui,sans-serif;color:#111;white-space:pre;letter-spacing:${sp == null ? "normal" : `${n3(sp)}em`}">${esc(txt)}</span></div>`
|
|
2265
|
+
: "";
|
|
2266
|
+
const firstWord = words[0] ?? "before";
|
|
2267
|
+
add({
|
|
2268
|
+
name: "seams.matchText",
|
|
2269
|
+
group: "seams",
|
|
2270
|
+
signature:
|
|
2271
|
+
"matchText(t, start, end, { mode, k, dir, dist, from, to, ease }) → { a, b, cut, spacing }",
|
|
2272
|
+
note: "one line becomes another on one curve, cubic-bezier(.85, 0, .15, 1), swapped at its fastest middle (HyperFrames' text-match-cut); 2 s here",
|
|
2273
|
+
needs: ["seams.matchText"],
|
|
2274
|
+
t0: 0,
|
|
2275
|
+
t1: 2,
|
|
2276
|
+
frames: [0.2, 0.7, 0.98, 1.02, 1.3, 1.9],
|
|
2277
|
+
view: "full",
|
|
2278
|
+
rows: [
|
|
2279
|
+
{ label: 'mode: "zoom" (k 1.7)', o: {} },
|
|
2280
|
+
{ label: "k: 0.6", o: { k: 0.6 } },
|
|
2281
|
+
{ label: 'mode: "slide"', o: { mode: "slide" } },
|
|
2282
|
+
{ label: 'mode: "track"', o: { mode: "track" } },
|
|
2283
|
+
],
|
|
2284
|
+
draw: (t, r) => {
|
|
2285
|
+
const m = SE.matchText(t, 0, 2, r.o);
|
|
2286
|
+
return `<div style="position:absolute;inset:0;background:#f7f7f4"></div>${word(firstWord, m.a, m.spacing)}${word("after", m.b, m.spacing)}`;
|
|
2287
|
+
},
|
|
2288
|
+
value: (t, r) => SE.matchText(t, 0, 2, r.o).p,
|
|
2289
|
+
valueLabel: "the one curve, 0 → 1 (the swap at its fastest)",
|
|
2290
|
+
});
|
|
2291
|
+
// a card (the subject) growing into a panel; the subject's own picture is the part both hold
|
|
2292
|
+
const panel = { x: W * 0.15, y: H * 0.12, w: W * 0.7, h: H * 0.76, r: 24 };
|
|
2293
|
+
const cardR = { x: S.x, y: S.y, w: S.width, h: S.height, r: 12 };
|
|
2294
|
+
const partIn = { x: panel.x + panel.w * 0.06, y: panel.y + panel.h * 0.08, w: panel.w * 0.4 };
|
|
2295
|
+
const partInPanel = { ...partIn, h: (partIn.w * S.height) / Math.max(1, S.width) };
|
|
2296
|
+
add({
|
|
2297
|
+
name: "seams.morph",
|
|
2298
|
+
group: "seams",
|
|
2299
|
+
signature:
|
|
2300
|
+
"morph(t, start, end, card, panel, { snappy, ease, aOut, bIn }) → { container, a, b, part(inCard, inPanel) }",
|
|
2301
|
+
note: "the panel at full size shrunk onto the card and grown back; a part both hold moves at its own size, not stretched (HyperFrames' modal-morph); 0.6–1.2 s in the films",
|
|
2302
|
+
needs: ["seams.morph"],
|
|
2303
|
+
t0: 0,
|
|
2304
|
+
t1: 1,
|
|
2305
|
+
view: "full",
|
|
2306
|
+
rows: [
|
|
2307
|
+
{ label: "default (smooth)", o: {} },
|
|
2308
|
+
{ label: "snappy: true", o: { snappy: true } },
|
|
2309
|
+
{ label: "aOut: 0.5, bIn: 0.5", o: { aOut: 0.5, bIn: 0.5 } },
|
|
2310
|
+
{ label: "ease: easeOut", o: { ease: M.easeOut } },
|
|
2311
|
+
],
|
|
2312
|
+
draw: (t, r) => {
|
|
2313
|
+
const m = SE.morph(t, 0, 0.8, cardR, panel, r.o);
|
|
2314
|
+
const pt = m.part(cardR, partInPanel);
|
|
2315
|
+
const own = `<div style="position:absolute;left:0;top:0;width:${n3(panel.w)}px;height:${n3(panel.h)}px;overflow:hidden;opacity:${n3(m.b.opacity)}"><div style="position:absolute;left:${n3(-panel.x)}px;top:${n3(-panel.y)}px;width:${W}px;height:${H}px">${sceneB}</div></div>`;
|
|
2316
|
+
const shared = `<div style="position:absolute;left:${n3(partInPanel.x - panel.x)}px;top:${n3(partInPanel.y - panel.y)}px;width:${n3(partInPanel.w)}px;height:${n3(partInPanel.h)}px;overflow:hidden;transform-origin:0 0;transform:${pt.transform};outline:var(--px) solid rgba(194,65,12,0.9)"><img class="m" src="${img}" style="transform-origin:0 0;transform:scale(${n3(partInPanel.w / Math.max(1, S.width))}) translate(${-S.x}px,${-S.y}px)"></div>`;
|
|
2317
|
+
return `${pic("opacity:0.32")}<div style="position:absolute;left:${n3(panel.x)}px;top:${n3(panel.y)}px;width:${n3(panel.w)}px;height:${n3(panel.h)}px;overflow:hidden;background:#fff;transform-origin:0 0;transform:${m.container.transform};border-radius:${m.container.radius};box-shadow:0 20px 60px rgba(0,0,0,0.25)">${own}${shared}</div>`;
|
|
2318
|
+
},
|
|
2319
|
+
value: (t, r) => SE.morph(t, 0, 0.8, cardR, panel, r.o).container.box.w,
|
|
2320
|
+
valueLabel: "the card's width (px)",
|
|
2321
|
+
});
|
|
2322
|
+
// the picture in a 3 × 3 grid; the middle tile becomes the incoming scene
|
|
2323
|
+
const gap = Math.round(W * 0.012);
|
|
2324
|
+
const tw = (W - 4 * gap) / 3;
|
|
2325
|
+
const th = (H - 4 * gap) / 3;
|
|
2326
|
+
const grid: GalleryBox[] = [];
|
|
2327
|
+
for (let j = 0; j < 3; j++)
|
|
2328
|
+
for (let i = 0; i < 3; i++)
|
|
2329
|
+
grid.push({ x: gap + i * (tw + gap), y: gap + j * (th + gap), width: tw, height: th });
|
|
2330
|
+
const mid = grid[4]!;
|
|
2331
|
+
const rest = grid.filter((_, i) => i !== 4);
|
|
2332
|
+
add({
|
|
2333
|
+
name: "seams.parallax",
|
|
2334
|
+
group: "seams",
|
|
2335
|
+
signature:
|
|
2336
|
+
"parallax(t, start, end, card, others, view, { reverse, push, shrink, radius, ease }) → { scene, focal, others, radius }",
|
|
2337
|
+
note: "one tile becomes the scene, built at full size and shrunk onto it; the rest pushed 900 px a tile outward, to 0.6 and gone (HyperFrames' parallax-zoom); reverse: a dolly-out",
|
|
2338
|
+
needs: ["seams.parallax"],
|
|
2339
|
+
t0: 0,
|
|
2340
|
+
t1: 1.4,
|
|
2341
|
+
view: "full",
|
|
2342
|
+
rows: [
|
|
2343
|
+
{ label: "default", o: {} },
|
|
2344
|
+
{ label: "reverse: true", o: { reverse: true } },
|
|
2345
|
+
{ label: "push: 400", o: { push: 400 } },
|
|
2346
|
+
{ label: "ease: easeIn", o: { ease: M.easeIn } },
|
|
2347
|
+
],
|
|
2348
|
+
draw: (t, r) => {
|
|
2349
|
+
const p = SE.parallax(t, 0, 1.2, mid, rest, { width: W, height: H }, r.o);
|
|
2350
|
+
const others = rest
|
|
2351
|
+
.map((b, i) => {
|
|
2352
|
+
const sd = p.others[i] as { visible: boolean; transform: string; opacity: number };
|
|
2353
|
+
return sd.visible
|
|
2354
|
+
? `<div style="position:absolute;left:${n3(b.x)}px;top:${n3(b.y)}px;width:${n3(b.width)}px;height:${n3(b.height)}px;overflow:hidden;border-radius:16px;transform-origin:50% 50%;transform:${sd.transform};opacity:${n3(sd.opacity)}">${pic(`left:${n3(-b.x)}px;top:${n3(-b.y)}px`)}</div>`
|
|
2355
|
+
: "";
|
|
2356
|
+
})
|
|
2357
|
+
.join("");
|
|
2358
|
+
return `<div style="position:absolute;inset:0;background:#e9e9e4"></div>${others}<div style="position:absolute;left:0;top:0;width:${W}px;height:${H}px;overflow:hidden;transform-origin:0 0;transform:${p.scene.transform};border-radius:${p.scene.radius}">${sceneB}</div>`;
|
|
2359
|
+
},
|
|
2360
|
+
value: (t, r) => SE.parallax(t, 0, 1.2, mid, rest, { width: W, height: H }, r.o).scene.scale,
|
|
2361
|
+
valueLabel: "the scene's scale",
|
|
2362
|
+
});
|
|
2363
|
+
add({
|
|
2364
|
+
name: "seams.pushCut",
|
|
2365
|
+
group: "seams",
|
|
2366
|
+
signature: "pushCut(t, at, { dur, push, flash, colour, fps }) → { a, b, flash }",
|
|
2367
|
+
note: "a hard cut that reads as meant: both sides keep pushing in (1 → 1.04, then from 1.04/1.07 to 1), a 0.2 flash over the cut's frames (Remotion's pushCut numbers)",
|
|
2368
|
+
needs: ["seams.pushCut"],
|
|
2369
|
+
t0: 0,
|
|
2370
|
+
t1: 0.8,
|
|
2371
|
+
frames: [AT - 0.15, AT - 0.05, AT - 1 / 60, AT, AT + 1 / 60, AT + 0.2],
|
|
2372
|
+
view: "full",
|
|
2373
|
+
rows: [
|
|
2374
|
+
{ label: "default", o: {} },
|
|
2375
|
+
{ label: "push: 1.08", o: { push: 1.08 } },
|
|
2376
|
+
{ label: "flash: 0.5", o: { flash: 0.5 } },
|
|
2377
|
+
{ label: 'colour: "#000"', o: { colour: "#000" } },
|
|
2378
|
+
],
|
|
2379
|
+
draw: (t, r) => {
|
|
2380
|
+
const p = SE.pushCut(t, AT, r.o);
|
|
2381
|
+
return `${pair(p)}<div style="position:absolute;inset:0;z-index:3;background:${p.flash.colour};opacity:${n3(p.flash.opacity)}"></div>`;
|
|
2382
|
+
},
|
|
2383
|
+
value: (t, r) => {
|
|
2384
|
+
const p = SE.pushCut(t, AT, r.o);
|
|
2385
|
+
return p.a.visible ? p.a.scale : p.b.scale;
|
|
2386
|
+
},
|
|
2387
|
+
valueLabel: "scale",
|
|
2388
|
+
});
|
|
2389
|
+
add({
|
|
2390
|
+
name: "seams.dipCut",
|
|
2391
|
+
group: "seams",
|
|
2392
|
+
signature: "dipCut(t, at, { frames, level, settle, settleDur, fps }) → { a, b }",
|
|
2393
|
+
note: "the outgoing frame ≈ 40 % darker for its last 3 frames, then the cut (HyperFrames' motion notes); settle: the incoming lands from a little large",
|
|
2394
|
+
needs: ["seams.dipCut"],
|
|
2395
|
+
t0: 0,
|
|
2396
|
+
t1: 0.8,
|
|
2397
|
+
frames: [AT - 0.1, AT - 3 / 60, AT - 1 / 60, AT, AT + 0.08, AT + 0.3],
|
|
2398
|
+
view: "full",
|
|
2399
|
+
rows: [
|
|
2400
|
+
{ label: "default", o: {} },
|
|
2401
|
+
{ label: "settle: 1.03", o: { settle: 1.03 } },
|
|
2402
|
+
{ label: "level: 0.3", o: { level: 0.3 } },
|
|
2403
|
+
{ label: "frames: 6", o: { frames: 6 } },
|
|
2404
|
+
],
|
|
2405
|
+
draw: (t, r) => pair(SE.dipCut(t, AT, r.o)),
|
|
2406
|
+
value: (t, r) => {
|
|
2407
|
+
const d = SE.dipCut(t, AT, r.o);
|
|
2408
|
+
return d.a.visible ? d.a.brightness : d.b.scale;
|
|
2409
|
+
},
|
|
2410
|
+
valueLabel: "brightness · scale",
|
|
2411
|
+
});
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
// kit/world.js: stage.js's slabs drawn in WebGL — the picture on slabs and
|
|
2415
|
+
// in devices. Each cell is a WebGL frame: its numbers (world.frame(t)) are
|
|
2416
|
+
// worked out here, and the page draws them with the kit's world.js and
|
|
2417
|
+
// three.js (paintWorlds)
|
|
2418
|
+
const WO = kit.world;
|
|
2419
|
+
if (WO && typeof WO.world === "function") {
|
|
2420
|
+
type Def = {
|
|
2421
|
+
box: GalleryBox;
|
|
2422
|
+
crop: GalleryBox;
|
|
2423
|
+
name: string;
|
|
2424
|
+
o?: Record<string, unknown>;
|
|
2425
|
+
device?: { kind: string; o?: Record<string, unknown> };
|
|
2426
|
+
};
|
|
2427
|
+
// biome-ignore lint/suspicious/noExplicitAny: a world of the film's kit
|
|
2428
|
+
type WBuilt = { w: any; defs: Def[]; slabs: any[] };
|
|
2429
|
+
const wbuilt = new Map<Row, WBuilt>();
|
|
2430
|
+
const worldOf = (row: Row, make: (o: Record<string, unknown>) => WBuilt) => {
|
|
2431
|
+
let b = wbuilt.get(row);
|
|
2432
|
+
if (!b) {
|
|
2433
|
+
b = make(row.o);
|
|
2434
|
+
wbuilt.set(row, b);
|
|
2435
|
+
}
|
|
2436
|
+
return b;
|
|
2437
|
+
};
|
|
2438
|
+
const asBox = (b: GalleryBox) => ({ x: b.x, y: b.y, w: b.width, h: b.height });
|
|
2439
|
+
/** a world with slabs on given boxes, each a crop of the picture, some in a device */
|
|
2440
|
+
const wbuild = (parts: Omit<Def, "name">[]): WBuilt => {
|
|
2441
|
+
const w = WO.world({ width: W, height: H });
|
|
2442
|
+
const defs = parts.map((p, i) => ({ ...p, name: `slab ${i + 1}` }));
|
|
2443
|
+
const slabs = defs.map((d) => {
|
|
2444
|
+
const sl = w.slab(img, {
|
|
2445
|
+
box: asBox(d.box),
|
|
2446
|
+
crop: asBox(d.crop),
|
|
2447
|
+
name: d.name,
|
|
2448
|
+
source: { file: mat.source ?? img },
|
|
2449
|
+
...(d.o ?? {}),
|
|
2450
|
+
});
|
|
2451
|
+
if (d.device) w.device(d.device.kind, sl, d.device.o ?? {});
|
|
2452
|
+
return sl;
|
|
2453
|
+
});
|
|
2454
|
+
return { w, defs, slabs };
|
|
2455
|
+
};
|
|
2456
|
+
// the card stage.js's blocks lift: the subject with room round it
|
|
2457
|
+
const cw = Math.min(W, Math.max(S.width * 1.6, W * 0.36));
|
|
2458
|
+
const ch = Math.min(H, Math.max(S.height * 1.6, H * 0.3));
|
|
2459
|
+
const card: GalleryBox = {
|
|
2460
|
+
x: Math.max(0, Math.min(W - cw, sc.x - cw / 2)),
|
|
2461
|
+
y: Math.max(0, Math.min(H - ch, sc.y - ch / 2)),
|
|
2462
|
+
width: cw,
|
|
2463
|
+
height: ch,
|
|
2464
|
+
};
|
|
2465
|
+
const whole: GalleryBox = { x: 0, y: 0, width: W, height: H };
|
|
2466
|
+
// a phone's screen: a tall region round the subject, 9:19.5 as phones are
|
|
2467
|
+
const phH = H * 0.86;
|
|
2468
|
+
const phW = Math.min(W, (phH * 9) / 19.5);
|
|
2469
|
+
const phone: GalleryBox = {
|
|
2470
|
+
x: Math.max(0, Math.min(W - phW, sc.x - phW / 2)),
|
|
2471
|
+
y: (H - phH) / 2,
|
|
2472
|
+
width: phW,
|
|
2473
|
+
height: phH,
|
|
2474
|
+
};
|
|
2475
|
+
const drawWorld = (b: WBuilt, t: number, backdrop: string) => {
|
|
2476
|
+
const data = { defs: b.defs, frame: b.w.frame(t), width: W, height: H };
|
|
2477
|
+
return `${backdrop}<canvas class="wgl" data-world="${esc(JSON.stringify(data))}" style="position:absolute;left:0;top:0;width:${W}px;height:${H}px"></canvas>`;
|
|
2478
|
+
};
|
|
2479
|
+
const worldBlock = (
|
|
2480
|
+
b: Omit<Block, "group" | "draw" | "value" | "view"> & {
|
|
2481
|
+
view?: Block["view"];
|
|
2482
|
+
make: (o: Record<string, unknown>) => WBuilt;
|
|
2483
|
+
value: (t: number, b: WBuilt, row: Row) => number;
|
|
2484
|
+
backdrop?: string;
|
|
2485
|
+
},
|
|
2486
|
+
) =>
|
|
2487
|
+
add({
|
|
2488
|
+
...b,
|
|
2489
|
+
group: "world",
|
|
2490
|
+
view: b.view ?? "full",
|
|
2491
|
+
draw: (t, r) => drawWorld(worldOf(r, b.make), t, b.backdrop ?? '<div class="void"></div>'),
|
|
2492
|
+
value: (t, r) => b.value(t, worldOf(r, b.make), r),
|
|
2493
|
+
});
|
|
2494
|
+
const angle = (p: { rx: number; ry: number }) => Math.hypot(p.rx, p.ry);
|
|
2495
|
+
/** from a pose to square on, a cut then a move */
|
|
2496
|
+
const fromPose = (
|
|
2497
|
+
sl: { set: (to: object, at: number) => unknown; to: (to: object, when: object) => unknown },
|
|
2498
|
+
o: Record<string, unknown>,
|
|
2499
|
+
start = 0.1,
|
|
2500
|
+
) => {
|
|
2501
|
+
const { spring: sp, dur, ...pose } = o as { spring?: unknown; dur?: number };
|
|
2502
|
+
sl.set(pose, Number.NEGATIVE_INFINITY);
|
|
2503
|
+
const back = Object.fromEntries(
|
|
2504
|
+
Object.keys(pose)
|
|
2505
|
+
.filter((k) => k !== "scale" && k !== "y" && k !== "x")
|
|
2506
|
+
.map((k) => [k, 0]),
|
|
2507
|
+
);
|
|
2508
|
+
sl.to(back, sp ? { start, spring: sp } : { start, ...(dur ? { dur } : {}) });
|
|
2509
|
+
};
|
|
2510
|
+
worldBlock({
|
|
2511
|
+
name: "world.tilt",
|
|
2512
|
+
view: "subject",
|
|
2513
|
+
focus: card,
|
|
2514
|
+
signature:
|
|
2515
|
+
"world({ three, el, camera, perspective }) · w.slab(picture, { box, crop, source }) · slab.to({ rx, ry, rz, z, scale }, when)",
|
|
2516
|
+
note: "stage.tilt drawn in WebGL: a picture, not live DOM — mipmaps and 16× anisotropy keep a tilted picture clean; the same lens (2000 px) and moves as stage.js; every slab names its source",
|
|
2517
|
+
needs: ["world.world"],
|
|
2518
|
+
t0: 0,
|
|
2519
|
+
t1: 1.2,
|
|
2520
|
+
backdrop: pic("opacity:0.32"),
|
|
2521
|
+
rows: [
|
|
2522
|
+
{ label: "rx: 20, ry: -28", o: { rx: 20, ry: -28 } },
|
|
2523
|
+
{ label: "ry: -35", o: { ry: -35 } },
|
|
2524
|
+
{ label: "rx: 40 (a table)", o: { rx: 40 } },
|
|
2525
|
+
{
|
|
2526
|
+
label: "rx: 20, ry: -28, spring overshoot 0.2",
|
|
2527
|
+
o: { rx: 20, ry: -28, spring: { overshoot: 0.2 } },
|
|
2528
|
+
},
|
|
2529
|
+
],
|
|
2530
|
+
make: (o) => {
|
|
2531
|
+
const b = wbuild([{ box: card, crop: card }]);
|
|
2532
|
+
const { spring: sp, ...pose } = o as { spring?: unknown };
|
|
2533
|
+
b.slabs[0].to(pose, sp ? { start: 0, spring: sp } : { start: 0 });
|
|
2534
|
+
return b;
|
|
2535
|
+
},
|
|
2536
|
+
value: (t, b) => angle(b.slabs[0].pose(t)),
|
|
2537
|
+
valueLabel: "its angle (degrees)",
|
|
2538
|
+
});
|
|
2539
|
+
worldBlock({
|
|
2540
|
+
name: "world.laptop",
|
|
2541
|
+
signature: 'w.device("laptop", slab, { open, color }) — moves with its slab',
|
|
2542
|
+
note: "the whole picture as a laptop's screen, at half size, turning to square on in 0.73 s; the lid open 100° from the keys; a plain shape, no logo — the most common launch-film picture: fine when the product lives on a laptop",
|
|
2543
|
+
needs: ["world.world"],
|
|
2544
|
+
t0: 0,
|
|
2545
|
+
t1: 1.2,
|
|
2546
|
+
rows: [
|
|
2547
|
+
{ label: "ry: 40 → 0", o: { ry: 40 } },
|
|
2548
|
+
{ label: "ry: -30, rx: -15 → 0", o: { ry: -30, rx: -15 } },
|
|
2549
|
+
{ label: "ry: 40 → 0, open: 125", o: { ry: 40, open: 125 } },
|
|
2550
|
+
{ label: "rx: -30 → 0 (seen from above), dur 1", o: { rx: -30, dur: 1 } },
|
|
2551
|
+
],
|
|
2552
|
+
make: (o) => {
|
|
2553
|
+
const { open, ...pose } = o as { open?: number };
|
|
2554
|
+
const b = wbuild([
|
|
2555
|
+
{
|
|
2556
|
+
box: whole,
|
|
2557
|
+
crop: whole,
|
|
2558
|
+
device: { kind: "laptop", o: open ? { open } : {} },
|
|
2559
|
+
o: { rest: { scale: 0.5, y: -0.1 * H } },
|
|
2560
|
+
},
|
|
2561
|
+
]);
|
|
2562
|
+
fromPose(b.slabs[0], pose);
|
|
2563
|
+
return b;
|
|
2564
|
+
},
|
|
2565
|
+
value: (t, b) => angle(b.slabs[0].pose(t)),
|
|
2566
|
+
valueLabel: "its angle (degrees)",
|
|
2567
|
+
});
|
|
2568
|
+
worldBlock({
|
|
2569
|
+
name: "world.phone",
|
|
2570
|
+
signature: 'w.device("phone", slab, { color }) — its screen gets round corners',
|
|
2571
|
+
note: "a tall region round the subject as a phone's screen (9:19.5), border 4.5 % and 10 % thick of its width; no notch, no logo",
|
|
2572
|
+
needs: ["world.world"],
|
|
2573
|
+
t0: 0,
|
|
2574
|
+
t1: 1.2,
|
|
2575
|
+
rows: [
|
|
2576
|
+
{ label: "ry: -30 → 0", o: { ry: -30 } },
|
|
2577
|
+
{ label: "ry: 35, rz: 8 → 0", o: { ry: 35, rz: 8 } },
|
|
2578
|
+
{ label: "rx: -25, ry: 20 → 0", o: { rx: -25, ry: 20 } },
|
|
2579
|
+
{ label: "ry: 180 → 0 (turned round), dur 1", o: { ry: 180, dur: 1 } },
|
|
2580
|
+
],
|
|
2581
|
+
make: (o) => {
|
|
2582
|
+
const b = wbuild([
|
|
2583
|
+
{
|
|
2584
|
+
box: phone,
|
|
2585
|
+
crop: phone,
|
|
2586
|
+
device: { kind: "phone" },
|
|
2587
|
+
o: { rest: { scale: 0.85 }, backface: "visible" },
|
|
2588
|
+
},
|
|
2589
|
+
]);
|
|
2590
|
+
fromPose(b.slabs[0], o);
|
|
2591
|
+
return b;
|
|
2592
|
+
},
|
|
2593
|
+
value: (t, b) => angle(b.slabs[0].pose(t)),
|
|
2594
|
+
valueLabel: "its angle (degrees)",
|
|
2595
|
+
});
|
|
2596
|
+
worldBlock({
|
|
2597
|
+
name: "world.browser",
|
|
2598
|
+
signature: 'w.device("browser", slab, { tone, color }) — a bar above the slab',
|
|
2599
|
+
note: "the picture in a plain browser window — three grey dots and an address field, no browser's own look — swinging square on",
|
|
2600
|
+
needs: ["world.world"],
|
|
2601
|
+
t0: 0,
|
|
2602
|
+
t1: 1.2,
|
|
2603
|
+
rows: [
|
|
2604
|
+
{ label: "ry: -25, rx: 10 → 0", o: { ry: -25, rx: 10 } },
|
|
2605
|
+
{ label: "rx: 35 → 0", o: { rx: 35 } },
|
|
2606
|
+
{ label: 'tone: "dark", ry: 25 → 0', o: { ry: 25, tone: "dark" } },
|
|
2607
|
+
{ label: "z: -1200 → 0, ry: -20", o: { ry: -20, z: -1200 } },
|
|
2608
|
+
],
|
|
2609
|
+
make: (o) => {
|
|
2610
|
+
const { tone, ...pose } = o as { tone?: string };
|
|
2611
|
+
const b = wbuild([
|
|
2612
|
+
{
|
|
2613
|
+
box: whole,
|
|
2614
|
+
crop: whole,
|
|
2615
|
+
device: { kind: "browser", o: tone ? { tone } : {} },
|
|
2616
|
+
o: { rest: { scale: 0.72, y: 0.03 * H } },
|
|
2617
|
+
},
|
|
2618
|
+
]);
|
|
2619
|
+
fromPose(b.slabs[0], pose);
|
|
2620
|
+
return b;
|
|
2621
|
+
},
|
|
2622
|
+
value: (t, b) => angle(b.slabs[0].pose(t)),
|
|
2623
|
+
valueLabel: "its angle (degrees)",
|
|
2624
|
+
});
|
|
2625
|
+
worldBlock({
|
|
2626
|
+
name: "world.dolly",
|
|
2627
|
+
signature:
|
|
2628
|
+
"w.dolly(z, { start | arrive, dur, ease | spring }) · w.turn({ rx, ry, rz }, when)",
|
|
2629
|
+
note: "stage.dolly in WebGL: the lens travels 2200 px past the card into the tiles 1600 px behind it, the stage turned 20° so the tiles recede; a slab fades over the last quarter of the way to the lens",
|
|
2630
|
+
needs: ["world.world"],
|
|
2631
|
+
t0: 0,
|
|
2632
|
+
t1: 1.4,
|
|
2633
|
+
rows: [
|
|
2634
|
+
{ label: "default (0.73 s)", o: {} },
|
|
2635
|
+
{ label: "dur: 1.2", o: { dur: 1.2 } },
|
|
2636
|
+
{ label: "z: 1500 (stops at the card)", o: { z: 1500 } },
|
|
2637
|
+
{ label: "ease: linear", o: { ease: (p: number) => p } },
|
|
2638
|
+
],
|
|
2639
|
+
make: (o) => {
|
|
2640
|
+
const tiles: GalleryBox[] = [];
|
|
2641
|
+
for (let j = 0; j < 2; j++)
|
|
2642
|
+
for (let i = 0; i < 3; i++)
|
|
2643
|
+
tiles.push({ x: (i * W) / 3, y: (j * H) / 2, width: W / 3, height: H / 2 });
|
|
2644
|
+
const b = wbuild([
|
|
2645
|
+
...tiles.map((box) => ({ box, crop: box, o: { rest: { z: -1600 } } })),
|
|
2646
|
+
{ box: card, crop: card },
|
|
2647
|
+
]);
|
|
2648
|
+
b.w.turn({ ry: -20 }, { start: 0, dur: 0.01 });
|
|
2649
|
+
const { z = 2200, ...w } = o as { z?: number };
|
|
2650
|
+
b.w.dolly(z, { start: 0, ...w });
|
|
2651
|
+
return b;
|
|
2652
|
+
},
|
|
2653
|
+
value: (t, b) => b.w.world(t).z,
|
|
2654
|
+
valueLabel: "the lens's travel (px)",
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
return list;
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
// --- measuring -------------------------------------------------------------------------
|
|
2661
|
+
|
|
2662
|
+
const STEP = 0.001;
|
|
2663
|
+
|
|
2664
|
+
/** the numbers of one setting: where it starts and rests, when it settles,
|
|
2665
|
+
* how far it swings past, its top speed — on samples 1 ms apart */
|
|
2666
|
+
export function measureRow(
|
|
2667
|
+
f: (t: number) => number,
|
|
2668
|
+
start: number,
|
|
2669
|
+
span: number,
|
|
2670
|
+
/** the speed is the change over this many s (central) */
|
|
2671
|
+
speedOver = 2 * STEP,
|
|
2672
|
+
): GalleryStats {
|
|
2673
|
+
const window = Math.max(4, span * 3);
|
|
2674
|
+
const n = Math.round(window / STEP);
|
|
2675
|
+
const v = new Float64Array(n + 1);
|
|
2676
|
+
for (let i = 0; i <= n; i++) {
|
|
2677
|
+
const x = f(start + i * STEP);
|
|
2678
|
+
v[i] = Number.isFinite(x) ? x : Number.NaN;
|
|
2679
|
+
}
|
|
2680
|
+
const from = v[0]!;
|
|
2681
|
+
// the rest: where the window ends
|
|
2682
|
+
const to = v[n]!;
|
|
2683
|
+
const travel = to - from;
|
|
2684
|
+
// a move comes back when it ends where it began, next to how far it went (a
|
|
2685
|
+
// kick whose tail is still a hair off 0 at the window's end comes back)
|
|
2686
|
+
let reach = 0;
|
|
2687
|
+
for (let i = 0; i <= n; i++) reach = Math.max(reach, Math.abs(v[i]! - from));
|
|
2688
|
+
const back =
|
|
2689
|
+
Math.abs(travel) < Math.max(1e-6 * Math.max(1, Math.abs(from), Math.abs(to)), 1e-3 * reach);
|
|
2690
|
+
let peak = 0;
|
|
2691
|
+
for (let i = 0; i <= n; i++) peak = Math.max(peak, Math.abs(v[i]! - to));
|
|
2692
|
+
const ref = back ? peak : Math.abs(travel);
|
|
2693
|
+
let last = -1;
|
|
2694
|
+
if (ref > 0) for (let i = 0; i <= n; i++) if (Math.abs(v[i]! - to) > 0.01 * ref) last = i;
|
|
2695
|
+
// still moving within half a second of the window's end: never seen settling
|
|
2696
|
+
const settle = last < 0 ? 0 : last * STEP > window - 0.5 ? null : (last + 1) * STEP;
|
|
2697
|
+
// a swing past the rest and a peak from it need a rest: none for what never settles
|
|
2698
|
+
let swing: number | null = null;
|
|
2699
|
+
if (!back && settle != null) {
|
|
2700
|
+
let past = 0;
|
|
2701
|
+
for (let i = 0; i <= n; i++)
|
|
2702
|
+
past = Math.max(past, ((v[i]! - to) * Math.sign(travel)) / Math.abs(travel));
|
|
2703
|
+
swing = past > 1e-4 ? past : 0;
|
|
2704
|
+
}
|
|
2705
|
+
// a value that steps (characters shown, cuts so far) has a rate only over a
|
|
2706
|
+
// window: up to four of its steps, when they come closer than the window asked for
|
|
2707
|
+
const steps = speedOver > 2 * STEP;
|
|
2708
|
+
let over = speedOver;
|
|
2709
|
+
if (steps) {
|
|
2710
|
+
const changes: number[] = [];
|
|
2711
|
+
for (let i = 1; i <= n; i++) if (v[i] !== v[i - 1]) changes.push(i * STEP);
|
|
2712
|
+
const gaps = changes
|
|
2713
|
+
.slice(1)
|
|
2714
|
+
.map((c, i) => c - changes[i]!)
|
|
2715
|
+
.sort((a, b) => a - b);
|
|
2716
|
+
if (gaps.length)
|
|
2717
|
+
over = Math.min(
|
|
2718
|
+
over,
|
|
2719
|
+
Math.max(2 * STEP, Math.min(4, changes.length) * gaps[gaps.length >> 1]!),
|
|
2720
|
+
);
|
|
2721
|
+
}
|
|
2722
|
+
// a continuous value that changes by a quarter of all it spans within 1 ms
|
|
2723
|
+
// is a jump (a cut)
|
|
2724
|
+
let jump: number | null = null;
|
|
2725
|
+
let lo = v[0]!;
|
|
2726
|
+
let hi = v[0]!;
|
|
2727
|
+
for (let i = 0; i <= n; i++) {
|
|
2728
|
+
lo = Math.min(lo, v[i]!);
|
|
2729
|
+
hi = Math.max(hi, v[i]!);
|
|
2730
|
+
}
|
|
2731
|
+
if (!steps && hi > lo) {
|
|
2732
|
+
let big = 0;
|
|
2733
|
+
for (let i = 1; i <= n; i++) {
|
|
2734
|
+
const d = Math.abs(v[i]! - v[i - 1]!);
|
|
2735
|
+
if (d > big) {
|
|
2736
|
+
big = d;
|
|
2737
|
+
if (d >= 0.25 * (hi - lo)) jump = i * STEP;
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
let peakSpeed = 0;
|
|
2742
|
+
let peakSpeedAt = 0;
|
|
2743
|
+
const half = Math.max(1, Math.round(over / 2 / STEP));
|
|
2744
|
+
for (let i = half; i <= n - half; i++) {
|
|
2745
|
+
const s = Math.abs(v[i + half]! - v[i - half]!) / (2 * half * STEP);
|
|
2746
|
+
if (s > peakSpeed) {
|
|
2747
|
+
peakSpeed = s;
|
|
2748
|
+
peakSpeedAt = i * STEP;
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
return {
|
|
2752
|
+
from,
|
|
2753
|
+
to,
|
|
2754
|
+
settle,
|
|
2755
|
+
swing,
|
|
2756
|
+
peak: back && settle != null ? peak : null,
|
|
2757
|
+
peakSpeed,
|
|
2758
|
+
peakSpeedAt,
|
|
2759
|
+
speedOver: over,
|
|
2760
|
+
jump,
|
|
2761
|
+
window,
|
|
2762
|
+
};
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
/** a setting's numbers as a line: each says it was measured, or not detected */
|
|
2766
|
+
export function formatStats(s: GalleryStats | null): string {
|
|
2767
|
+
if (!s) return "not measured";
|
|
2768
|
+
const num = (x: number) =>
|
|
2769
|
+
Math.abs(x) >= 100 ? x.toFixed(0) : Math.abs(x) >= 10 ? x.toFixed(1) : x.toFixed(3);
|
|
2770
|
+
const parts = [
|
|
2771
|
+
s.settle == null
|
|
2772
|
+
? `settles: not detected in ${s.window.toFixed(1)} s`
|
|
2773
|
+
: `settles (1 %) at ${s.settle.toFixed(3)} s`,
|
|
2774
|
+
];
|
|
2775
|
+
if (s.swing != null)
|
|
2776
|
+
parts.push(
|
|
2777
|
+
s.swing > 0
|
|
2778
|
+
? `swings ${(s.swing * 100).toFixed(1)} % past its rest`
|
|
2779
|
+
: "no swing past its rest",
|
|
2780
|
+
);
|
|
2781
|
+
if (s.peak != null) parts.push(`peak ${num(s.peak)} from rest`);
|
|
2782
|
+
parts.push(
|
|
2783
|
+
s.jump != null
|
|
2784
|
+
? `jumps at ${s.jump.toFixed(3)} s (a cut: no speed)`
|
|
2785
|
+
: `top speed ${num(s.peakSpeed)}/s at ${s.peakSpeedAt.toFixed(3)} s`,
|
|
2786
|
+
);
|
|
2787
|
+
return parts.join(" · ");
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
// --- drawing ---------------------------------------------------------------------------
|
|
2791
|
+
|
|
2792
|
+
/** the window of the stage a cell shows */
|
|
2793
|
+
function windowOf(view: Block["view"], mat: GalleryMaterial, focus: GalleryBox): GalleryBox {
|
|
2794
|
+
const W = mat.width;
|
|
2795
|
+
const H = mat.height;
|
|
2796
|
+
if (view === "full") {
|
|
2797
|
+
// the whole stage, letterboxed to the cell's shape
|
|
2798
|
+
const w = Math.max(W, (H * CW) / CH);
|
|
2799
|
+
const h = (w * CH) / CW;
|
|
2800
|
+
return { x: (W - w) / 2, y: (H - h) / 2, width: w, height: h };
|
|
2801
|
+
}
|
|
2802
|
+
// a little over twice the subject, never under a fifth of the stage's width
|
|
2803
|
+
const w = Math.min(
|
|
2804
|
+
Math.max(W / 5, focus.width * 2.2, (focus.height * 2.2 * CW) / CH),
|
|
2805
|
+
Math.max(W, (H * CW) / CH),
|
|
2806
|
+
);
|
|
2807
|
+
const h = (w * CH) / CW;
|
|
2808
|
+
return {
|
|
2809
|
+
x: focus.x + focus.width / 2 - w / 2,
|
|
2810
|
+
y: focus.y + focus.height / 2 - h / 2,
|
|
2811
|
+
width: w,
|
|
2812
|
+
height: h,
|
|
2813
|
+
};
|
|
2814
|
+
}
|
|
2815
|
+
|
|
2816
|
+
function polyline(
|
|
2817
|
+
rows: { pts: [number, number][] }[],
|
|
2818
|
+
x0: number,
|
|
2819
|
+
y0: number,
|
|
2820
|
+
w: number,
|
|
2821
|
+
h: number,
|
|
2822
|
+
t0: number,
|
|
2823
|
+
t1: number,
|
|
2824
|
+
marks: number[],
|
|
2825
|
+
title: string,
|
|
2826
|
+
): string {
|
|
2827
|
+
const all = rows.flatMap((r) => r.pts.map((p) => p[1])).filter(Number.isFinite);
|
|
2828
|
+
let lo = all.length ? Math.min(...all) : 0;
|
|
2829
|
+
let hi = all.length ? Math.max(...all) : 1;
|
|
2830
|
+
if (hi - lo < 1e-9) {
|
|
2831
|
+
lo -= 1;
|
|
2832
|
+
hi += 1;
|
|
2833
|
+
}
|
|
2834
|
+
const m = (hi - lo) * 0.08;
|
|
2835
|
+
const X = (t: number) => x0 + ((t - t0) / (t1 - t0)) * w;
|
|
2836
|
+
const Y = (v: number) => y0 + h - ((v - (lo - m)) / (hi - lo + 2 * m)) * h;
|
|
2837
|
+
let s = `<rect x="${x0}" y="${y0}" width="${w}" height="${h}" fill="#fff" stroke="#d4d4d0"/>`;
|
|
2838
|
+
s += `<text x="${x0}" y="${y0 - 8}" class="pt">${esc(title)}</text>`;
|
|
2839
|
+
// an end within 1 % of the range from 0 is 0 (a spring's tail, not a value worth printing)
|
|
2840
|
+
const snap = (v: number) => (Math.abs(v) < (hi - lo) * 0.01 ? 0 : v);
|
|
2841
|
+
const ticks = [snap(lo), snap(hi), ...(lo < 0 && hi > 0 ? [0] : [])];
|
|
2842
|
+
for (const v of ticks)
|
|
2843
|
+
s += `<line x1="${x0}" x2="${x0 + w}" y1="${Y(v)}" y2="${Y(v)}" stroke="#ecece8"/><text x="${x0 - 6}" y="${Y(v) + 4}" class="tk" text-anchor="end">${+v.toPrecision(3)}</text>`;
|
|
2844
|
+
for (const t of marks)
|
|
2845
|
+
s += `<line x1="${X(t)}" x2="${X(t)}" y1="${y0}" y2="${y0 + h}" stroke="#bdbdb8" stroke-dasharray="3 3"/>`;
|
|
2846
|
+
rows.forEach((r, k) => {
|
|
2847
|
+
const pts = r.pts
|
|
2848
|
+
.filter((p) => Number.isFinite(p[1]))
|
|
2849
|
+
.map(([t, v]) => `${X(t).toFixed(1)},${Y(v).toFixed(1)}`)
|
|
2850
|
+
.join(" ");
|
|
2851
|
+
s += `<polyline fill="none" stroke="${COLOURS[k % COLOURS.length]}" stroke-width="${k ? 1.6 : 2.4}" points="${pts}"/>`;
|
|
2852
|
+
});
|
|
2853
|
+
s += `<text x="${x0 + w}" y="${y0 + h + 16}" class="tk" text-anchor="end">${(t1 - t0).toFixed(2)} s</text>`;
|
|
2854
|
+
return s;
|
|
2855
|
+
}
|
|
2856
|
+
|
|
2857
|
+
/** one block's page: header, a strip per setting, its value and its speed */
|
|
2858
|
+
function blockPage(
|
|
2859
|
+
b: Block,
|
|
2860
|
+
mat: GalleryMaterial,
|
|
2861
|
+
focus: GalleryBox,
|
|
2862
|
+
): { html: string; rows: GalleryRow[] } {
|
|
2863
|
+
const even = Array.from({ length: 6 }, (_, i) => b.t0 + ((b.t1 - b.t0) * i) / 5);
|
|
2864
|
+
const framesOf = (row: Row) =>
|
|
2865
|
+
typeof b.frames === "function" ? b.frames(row) : (b.frames ?? even);
|
|
2866
|
+
const frames = typeof b.frames === "function" ? even : (b.frames ?? even);
|
|
2867
|
+
const win = windowOf(b.view, mat, focus);
|
|
2868
|
+
const k = CW / win.width;
|
|
2869
|
+
const start = b.start ?? b.t0;
|
|
2870
|
+
const rows: GalleryRow[] = [];
|
|
2871
|
+
const values: { pts: [number, number][] }[] = [];
|
|
2872
|
+
const speeds: { pts: [number, number][] }[] = [];
|
|
2873
|
+
let strips = "";
|
|
2874
|
+
b.rows.slice(0, ROWS).forEach((row, ri) => {
|
|
2875
|
+
const y = HEAD_H + ri * ROW_H;
|
|
2876
|
+
let cells = "";
|
|
2877
|
+
let error: string | undefined;
|
|
2878
|
+
framesOf(row).forEach((t, i) => {
|
|
2879
|
+
let inner: string;
|
|
2880
|
+
try {
|
|
2881
|
+
inner = b.draw(t, row);
|
|
2882
|
+
} catch (e) {
|
|
2883
|
+
error ??= (e as Error).message.split("\n")[0];
|
|
2884
|
+
inner = "";
|
|
2885
|
+
}
|
|
2886
|
+
const x = LABEL_W + GAP + i * (CW + GAP);
|
|
2887
|
+
cells += `<div class="cell" style="left:${x}px;top:${y + 4}px"><div class="stage" style="--px:${n3(1 / k)}px;width:${mat.width}px;height:${mat.height}px;transform:scale(${k}) translate(${-win.x}px,${-win.y}px)">${inner}</div></div>`;
|
|
2888
|
+
cells += `<div class="tl" style="left:${x}px;top:${y + CH + 7}px">${(t - start).toFixed(3)} s</div>`;
|
|
2889
|
+
});
|
|
2890
|
+
let stats: GalleryStats | null = null;
|
|
2891
|
+
const pts: [number, number][] = [];
|
|
2892
|
+
const sp: [number, number][] = [];
|
|
2893
|
+
if (!error)
|
|
2894
|
+
try {
|
|
2895
|
+
const f = (t: number) => b.value(t, row);
|
|
2896
|
+
stats = measureRow(f, start, b.t1 - b.t0, b.speedOver);
|
|
2897
|
+
// the curve's speed over the window its numbers were measured over
|
|
2898
|
+
const h = stats.speedOver;
|
|
2899
|
+
const N = 300;
|
|
2900
|
+
for (let i = 0; i <= N; i++) {
|
|
2901
|
+
const t = b.t0 + ((b.t1 - b.t0) * i) / N;
|
|
2902
|
+
pts.push([t, f(t)]);
|
|
2903
|
+
sp.push([t, (f(t + h / 2) - f(t - h / 2)) / h]);
|
|
2904
|
+
}
|
|
2905
|
+
} catch (e) {
|
|
2906
|
+
error = (e as Error).message.split("\n")[0];
|
|
2907
|
+
}
|
|
2908
|
+
values.push({ pts });
|
|
2909
|
+
speeds.push({ pts: sp });
|
|
2910
|
+
let text = error ? `could not draw: ${error}` : formatStats(stats);
|
|
2911
|
+
if (!error && b.describe)
|
|
2912
|
+
try {
|
|
2913
|
+
text = b.describe(row);
|
|
2914
|
+
} catch (e) {
|
|
2915
|
+
error = (e as Error).message.split("\n")[0];
|
|
2916
|
+
text = `could not draw: ${error}`;
|
|
2917
|
+
}
|
|
2918
|
+
rows.push({ label: row.label, stats, text, ...(error ? { error } : {}) });
|
|
2919
|
+
const info = text.split(" · ").map(esc).join("<br>");
|
|
2920
|
+
strips += `<div class="rl" style="top:${y + 4}px;color:${COLOURS[ri % COLOURS.length]}"><b>${esc(row.label)}</b><small>${info}</small></div>${cells}`;
|
|
2921
|
+
});
|
|
2922
|
+
const py = HEAD_H + ROWS * ROW_H + PLOT_GAP - 8;
|
|
2923
|
+
const pw = PAGE_W - LABEL_W - GAP * 2;
|
|
2924
|
+
const svg =
|
|
2925
|
+
`<svg class="plots" width="${PAGE_W}" height="${2 * (PLOT_H + PLOT_GAP)}" style="top:${py - PLOT_GAP + 8}px">` +
|
|
2926
|
+
polyline(
|
|
2927
|
+
values,
|
|
2928
|
+
LABEL_W + GAP,
|
|
2929
|
+
PLOT_GAP - 8,
|
|
2930
|
+
pw,
|
|
2931
|
+
PLOT_H,
|
|
2932
|
+
b.t0,
|
|
2933
|
+
b.t1,
|
|
2934
|
+
b.marks ?? frames,
|
|
2935
|
+
b.valueLabel,
|
|
2936
|
+
) +
|
|
2937
|
+
polyline(
|
|
2938
|
+
speeds,
|
|
2939
|
+
LABEL_W + GAP,
|
|
2940
|
+
PLOT_H + 2 * PLOT_GAP - 8,
|
|
2941
|
+
pw,
|
|
2942
|
+
PLOT_H,
|
|
2943
|
+
b.t0,
|
|
2944
|
+
b.t1,
|
|
2945
|
+
b.marks ?? frames,
|
|
2946
|
+
`its speed (${b.valueLabel.replace(/\s*\(.*\)$/, "")} a second)`,
|
|
2947
|
+
) +
|
|
2948
|
+
`</svg>`;
|
|
2949
|
+
const legend = b.rows
|
|
2950
|
+
.slice(0, ROWS)
|
|
2951
|
+
.map((r, i) => `<span style="color:${COLOURS[i % COLOURS.length]}">■ ${esc(r.label)}</span>`)
|
|
2952
|
+
.join("");
|
|
2953
|
+
const html =
|
|
2954
|
+
`<div class="hd"><b>${esc(b.name)}</b> <code>${esc(b.signature)}</code><div>defaults (as shipped): ${esc(b.note)}</div>` +
|
|
2955
|
+
`<div class="win">each cell: ${b.view === "full" ? "the whole stage" : `${Math.round(win.width)}×${Math.round(win.height)} px of the stage around the subject`} · numbers measured on the function, 1 ms apart · none is a target</div></div>` +
|
|
2956
|
+
strips +
|
|
2957
|
+
svg +
|
|
2958
|
+
`<div class="lg" style="top:${PAGE_H - 22}px">${legend}</div>`;
|
|
2959
|
+
return { html, rows };
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2962
|
+
const CSS = `html,body{margin:0;background:#fff;width:${PAGE_W}px;height:${PAGE_H}px;overflow:hidden;font:12px/1.35 ui-monospace,Menlo,monospace;color:#1f1f1d}
|
|
2963
|
+
.hd{position:absolute;left:${GAP}px;top:8px;right:${GAP}px;height:${HEAD_H - 8}px}
|
|
2964
|
+
.hd b{font-size:17px}.hd code{color:#444;margin-left:8px}.hd div{color:#555;margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.hd .win{color:#888}
|
|
2965
|
+
.rl{position:absolute;left:${GAP}px;width:${LABEL_W - GAP}px;height:${CH}px;overflow:hidden}
|
|
2966
|
+
.rl b{display:block;font-size:12px;margin-bottom:4px}.rl small{color:#555;font-size:10.5px;line-height:1.35}
|
|
2967
|
+
.cell{position:absolute;width:${CW}px;height:${CH}px;overflow:hidden;background:#cfcfcb;outline:1px solid #c4c4c0}
|
|
2968
|
+
.stage{position:absolute;left:0;top:0;transform-origin:0 0;background:#f2f2ef}
|
|
2969
|
+
.m{position:absolute;left:0;top:0;width:var(--mw);height:var(--mh);max-width:none}
|
|
2970
|
+
.l{position:absolute;overflow:hidden}
|
|
2971
|
+
.layer{position:absolute;left:0;top:0;width:var(--mw);height:var(--mh);transform-origin:0 0}
|
|
2972
|
+
.void{position:absolute;left:-50000px;top:-50000px;width:100000px;height:100000px;background:#2b2b29}
|
|
2973
|
+
.home{position:absolute;outline:calc(1.5 * var(--px)) dashed rgba(194,65,12,0.7);outline-offset:var(--px)}
|
|
2974
|
+
.edge{position:absolute;outline:calc(1.5 * var(--px)) solid rgba(194,65,12,0.9)}
|
|
2975
|
+
.txt{position:absolute;background:#fff;color:#111;font-family:system-ui,sans-serif;white-space:pre;box-sizing:border-box;border:3px solid #9a9a95;border-radius:10px;overflow:hidden}
|
|
2976
|
+
.caret{display:inline-block;width:0.08em;height:1em;vertical-align:-0.12em;background:#c2410c;margin-left:0.04em}
|
|
2977
|
+
.tl{position:absolute;width:${CW}px;color:#666;font-size:11px}
|
|
2978
|
+
.plots{position:absolute;left:0}.pt{font-size:12px;fill:#333}.tk{font-size:10.5px;fill:#777}
|
|
2979
|
+
.lg{position:absolute;left:${LABEL_W + GAP}px}.lg span{margin-right:18px}`;
|
|
2980
|
+
|
|
2981
|
+
// --- the gallery ------------------------------------------------------------------------
|
|
2982
|
+
|
|
2983
|
+
/** every block name the gallery can draw with this kit (for --blocks) */
|
|
2984
|
+
export async function galleryBlockNames(kit?: string): Promise<string[]> {
|
|
2985
|
+
const k = await loadKit(galleryKitDir(kit));
|
|
2986
|
+
const mat = {
|
|
2987
|
+
kind: "placeholder",
|
|
2988
|
+
source: null,
|
|
2989
|
+
picture: null,
|
|
2990
|
+
width: 1920,
|
|
2991
|
+
height: 1080,
|
|
2992
|
+
subject: { x: 800, y: 500, width: 300, height: 80, label: "", how: "" },
|
|
2993
|
+
other: { x: 200, y: 100, width: 300, height: 300, label: "" },
|
|
2994
|
+
text: DEFAULT_TEXT,
|
|
2995
|
+
notes: [],
|
|
2996
|
+
} satisfies GalleryMaterial;
|
|
2997
|
+
return blocks(k, mat, "").map((b) => b.name);
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
/** the blocks a --blocks list names: a name, or a group (motion, camera, cut, draw, map, stage) */
|
|
3001
|
+
function chosen(all: Block[], names?: string[]): Block[] {
|
|
3002
|
+
if (!names?.length) return all;
|
|
3003
|
+
const out = new Set<Block>();
|
|
3004
|
+
for (const n of names) {
|
|
3005
|
+
let hit = all.filter((b) => b.name === n || b.group === n);
|
|
3006
|
+
// a camera option by its own name: shake for camera.shake
|
|
3007
|
+
if (!hit.length) hit = all.filter((b) => b.name === `camera.${n}`);
|
|
3008
|
+
// a seam by its own name: whip for seams.whip
|
|
3009
|
+
if (!hit.length) hit = all.filter((b) => b.name === `seams.${n}`);
|
|
3010
|
+
// "cut" with nothing drawn for it is said in the gallery itself (see filmGallery)
|
|
3011
|
+
if (!hit.length && n !== "cut")
|
|
3012
|
+
throw new Error(
|
|
3013
|
+
`film gallery: no block named ${n} — there are: ${all.map((b) => b.name).join(", ")} (or a group: ${[...new Set(all.map((b) => b.group))].join(", ")})`,
|
|
3014
|
+
);
|
|
3015
|
+
for (const b of hit) out.add(b);
|
|
3016
|
+
}
|
|
3017
|
+
return all.filter((b) => out.has(b));
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
const fileName = (name: string) => `${name.replace(/[^\w.-]+/g, "-")}.png`;
|
|
3021
|
+
|
|
3022
|
+
export async function filmGallery(opts: FilmGalleryOptions): Promise<FilmGalleryResult> {
|
|
3023
|
+
const kitDir = galleryKitDir(opts.kit);
|
|
3024
|
+
const kit = await loadKit(kitDir);
|
|
3025
|
+
const out = resolve(opts.out);
|
|
3026
|
+
await mkdir(out, { recursive: true });
|
|
3027
|
+
const tmp = await mkdtemp(join(tmpdir(), "open-take-gallery-"));
|
|
3028
|
+
try {
|
|
3029
|
+
const material = await resolveMaterial(opts, tmp);
|
|
3030
|
+
const img = basename(material.file);
|
|
3031
|
+
await writeFile(
|
|
3032
|
+
join(tmp, "gallery.html"),
|
|
3033
|
+
`<!doctype html><meta charset="utf-8"><style>${CSS}</style><body></body>`,
|
|
3034
|
+
);
|
|
3035
|
+
// kit/world.js's cells are drawn in the page by the kit's own world.js and
|
|
3036
|
+
// three.js, which load as modules: the page is served, not a file
|
|
3037
|
+
if (kit.world) {
|
|
3038
|
+
await mkdir(join(tmp, "kit"), { recursive: true });
|
|
3039
|
+
for (const f of ["world.js", "stage.js"])
|
|
3040
|
+
await copyFile(join(kitDir, f), join(tmp, "kit", f));
|
|
3041
|
+
const three = existsSync(join(kitDir, THREE_FILES[0])) ? kitDir : threeBuildDir();
|
|
3042
|
+
for (const f of THREE_FILES) await copyFile(join(three, f), join(tmp, "kit", f));
|
|
3043
|
+
}
|
|
3044
|
+
const server = await serveDirectory(tmp);
|
|
3045
|
+
// one Chrome for every page
|
|
3046
|
+
const browser = await launchHtmlBrowser({
|
|
3047
|
+
chromePath: opts.chromePath,
|
|
3048
|
+
url: `${server.url}/gallery.html`,
|
|
3049
|
+
width: PAGE_W,
|
|
3050
|
+
height: PAGE_H,
|
|
3051
|
+
profilePrefix: "open-take-gallery-",
|
|
3052
|
+
}).catch(async (e) => {
|
|
3053
|
+
await server.close();
|
|
3054
|
+
throw e;
|
|
3055
|
+
});
|
|
3056
|
+
const entries: GalleryEntry[] = [];
|
|
3057
|
+
try {
|
|
3058
|
+
if (!material.width) {
|
|
3059
|
+
// a picture's size is the picture's
|
|
3060
|
+
const size = await browser.evaluate<{ w: number; h: number }>(
|
|
3061
|
+
`new Promise((ok, no) => { const i = new Image(); i.onload = () => ok({ w: i.naturalWidth, h: i.naturalHeight }); i.onerror = () => no(new Error("the picture did not load")); i.src = ${JSON.stringify(img)}; })`,
|
|
3062
|
+
);
|
|
3063
|
+
material.width = size.w;
|
|
3064
|
+
material.height = size.h;
|
|
3065
|
+
const p = opts.subject
|
|
3066
|
+
? pickSubject({ viewport: { w: size.w, h: size.h, dpr: 1 }, elements: [] }, opts.subject)
|
|
3067
|
+
: {
|
|
3068
|
+
box: middle(size.w, size.h),
|
|
3069
|
+
label: "the middle of the picture",
|
|
3070
|
+
how: "a picture has no elements — the middle third (--subject x,y,w,h picks a region)",
|
|
3071
|
+
};
|
|
3072
|
+
material.subject = { ...p.box, label: p.label, how: p.how };
|
|
3073
|
+
material.other = mirrored(size.w, size.h, p.box);
|
|
3074
|
+
}
|
|
3075
|
+
await browser.evaluate(
|
|
3076
|
+
`document.documentElement.style.setProperty("--mw", "${material.width}px"); document.documentElement.style.setProperty("--mh", "${material.height}px");`,
|
|
3077
|
+
);
|
|
3078
|
+
const beats = opts.beats
|
|
3079
|
+
? JSON.parse(await readFile(resolve(opts.beats), "utf8"))
|
|
3080
|
+
: undefined;
|
|
3081
|
+
const all = blocks(kit, material, img, beats);
|
|
3082
|
+
const picked = chosen(all, opts.blocks);
|
|
3083
|
+
// a kit/cut.js whose helpers the gallery has no drawing for is said, not skipped quietly
|
|
3084
|
+
const cutNames = Object.keys(kit.cut ?? {}).filter((k) => typeof kit.cut?.[k] === "function");
|
|
3085
|
+
if (
|
|
3086
|
+
kit.cut &&
|
|
3087
|
+
!all.some((b) => b.group === "cut") &&
|
|
3088
|
+
(!opts.blocks?.length || opts.blocks.includes("cut"))
|
|
3089
|
+
)
|
|
3090
|
+
entries.push({
|
|
3091
|
+
name: "cut.js",
|
|
3092
|
+
group: "cut",
|
|
3093
|
+
signature: cutNames.join(", "),
|
|
3094
|
+
note: "the kit's cut helpers",
|
|
3095
|
+
value: "",
|
|
3096
|
+
png: null,
|
|
3097
|
+
rows: [],
|
|
3098
|
+
error: `not drawn — the gallery has no drawing for ${cutNames.length ? cutNames.join(", ") : "its exports"} yet; read kit/cut.js`,
|
|
3099
|
+
});
|
|
3100
|
+
const exports: Record<string, Mod> = {
|
|
3101
|
+
motion: kit.motion,
|
|
3102
|
+
camera: kit.camera,
|
|
3103
|
+
cut: kit.cut ?? {},
|
|
3104
|
+
draw: kit.draw ?? {},
|
|
3105
|
+
map: kit.map ?? {},
|
|
3106
|
+
stage: kit.stage ?? {},
|
|
3107
|
+
seams: kit.seams ?? {},
|
|
3108
|
+
world: kit.world ?? {},
|
|
3109
|
+
};
|
|
3110
|
+
for (const b of picked) {
|
|
3111
|
+
const entry: GalleryEntry = {
|
|
3112
|
+
name: b.name,
|
|
3113
|
+
group: b.group,
|
|
3114
|
+
signature: b.signature,
|
|
3115
|
+
note: b.note,
|
|
3116
|
+
value: b.valueLabel,
|
|
3117
|
+
png: null,
|
|
3118
|
+
rows: [],
|
|
3119
|
+
};
|
|
3120
|
+
entries.push(entry);
|
|
3121
|
+
const missing = b.needs.filter((n) => {
|
|
3122
|
+
const [m, f] = n.split(".") as [string, string];
|
|
3123
|
+
return typeof exports[m]?.[f] !== "function";
|
|
3124
|
+
});
|
|
3125
|
+
if (missing.length) {
|
|
3126
|
+
entry.error = `the kit has no ${missing.join(", ")}`;
|
|
3127
|
+
continue;
|
|
3128
|
+
}
|
|
3129
|
+
const focus = b.focus ?? (TEXT_BLOCKS.has(b.name) ? textFocus(material) : material.subject);
|
|
3130
|
+
const page = blockPage(b, material, focus);
|
|
3131
|
+
entry.rows = page.rows;
|
|
3132
|
+
const failed = page.rows.filter((r) => r.error);
|
|
3133
|
+
if (failed.length === page.rows.length) {
|
|
3134
|
+
entry.error = failed[0]!.error;
|
|
3135
|
+
continue;
|
|
3136
|
+
}
|
|
3137
|
+
try {
|
|
3138
|
+
await browser.evaluate(
|
|
3139
|
+
`(async () => { document.body.innerHTML = ${JSON.stringify(page.html)};
|
|
3140
|
+
await Promise.all([...document.images].map((i) => i.decode().catch(() => {})));
|
|
3141
|
+
${paintWorlds(img)}
|
|
3142
|
+
await new Promise((ok) => requestAnimationFrame(() => requestAnimationFrame(ok))); })()`,
|
|
3143
|
+
);
|
|
3144
|
+
} catch (e) {
|
|
3145
|
+
// one block that cannot draw here (no WebGL for a world) is that block's failure, not the gallery's
|
|
3146
|
+
entry.error = `it could not be drawn here: ${String((e as Error).message ?? e).split("\n")[0]}`;
|
|
3147
|
+
continue;
|
|
3148
|
+
}
|
|
3149
|
+
const png = join(out, fileName(b.name));
|
|
3150
|
+
await writeFile(png, await browser.screenshot({ format: "png" }));
|
|
3151
|
+
entry.png = png;
|
|
3152
|
+
}
|
|
3153
|
+
} finally {
|
|
3154
|
+
await browser.close();
|
|
3155
|
+
await server.close();
|
|
3156
|
+
}
|
|
3157
|
+
const { file: _file, ...mat } = material;
|
|
3158
|
+
const index = join(out, "index.md");
|
|
3159
|
+
const json = join(out, "gallery.json");
|
|
3160
|
+
await writeFile(index, galleryIndex(kitDir, mat, entries, out));
|
|
3161
|
+
await writeFile(
|
|
3162
|
+
json,
|
|
3163
|
+
`${JSON.stringify({ version: 1, kit: kitDir, material: mat, entries }, null, 2)}\n`,
|
|
3164
|
+
);
|
|
3165
|
+
return { out, index, json, kit: kitDir, material: mat, entries };
|
|
3166
|
+
} finally {
|
|
3167
|
+
await rm(tmp, { recursive: true, force: true });
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
/** The page's half of kit/world.js's cells: each <canvas class="wgl"> holds a
|
|
3172
|
+
* world's slabs and one frame of it (worked out by the kit in Node); the
|
|
3173
|
+
* kit's world.js, with three.js, draws the frame and the cell keeps a copy.
|
|
3174
|
+
* One world per setting, its WebGL context let go once its cells are drawn. */
|
|
3175
|
+
function paintWorlds(img: string): string {
|
|
3176
|
+
return `{
|
|
3177
|
+
const cells = [...document.querySelectorAll("canvas.wgl")];
|
|
3178
|
+
if (cells.length) {
|
|
3179
|
+
const [THREE, K] = await Promise.all([import("/kit/three.module.min.js"), import("/kit/world.js")]);
|
|
3180
|
+
const worlds = new Map();
|
|
3181
|
+
for (const c of cells) {
|
|
3182
|
+
const d = JSON.parse(c.dataset.world);
|
|
3183
|
+
const key = JSON.stringify(d.defs);
|
|
3184
|
+
let w = worlds.get(key);
|
|
3185
|
+
if (!w) {
|
|
3186
|
+
w = K.world({ three: THREE, width: d.width, height: d.height, pixelRatio: 1 });
|
|
3187
|
+
for (const s of d.defs) {
|
|
3188
|
+
const sl = w.slab(${JSON.stringify(img)}, { box: s.box, crop: s.crop, name: s.name, source: { file: ${JSON.stringify(img)} }, ...(s.o || {}) });
|
|
3189
|
+
if (s.device) w.device(s.device.kind, sl, s.device.o || {});
|
|
3190
|
+
}
|
|
3191
|
+
await w.ready();
|
|
3192
|
+
worlds.set(key, w);
|
|
3193
|
+
}
|
|
3194
|
+
w.draw(d.frame);
|
|
3195
|
+
const k = Math.min(1, 1920 / d.width);
|
|
3196
|
+
c.width = Math.round(d.width * k);
|
|
3197
|
+
c.height = Math.round(d.height * k);
|
|
3198
|
+
c.getContext("2d").drawImage(w.canvas, 0, 0, c.width, c.height);
|
|
3199
|
+
}
|
|
3200
|
+
for (const w of worlds.values()) { w.renderer.dispose(); w.renderer.forceContextLoss(); }
|
|
3201
|
+
}
|
|
3202
|
+
}`;
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
/** where type/untype's text box sits (the same sum as in blocks()) */
|
|
3206
|
+
/** the blocks drawn on a line of text, framed round it rather than the subject */
|
|
3207
|
+
const TEXT_BLOCKS = new Set(["type", "untype", "scramble", "odometer", "flap"]);
|
|
3208
|
+
|
|
3209
|
+
function textFocus(mat: GalleryMaterial): GalleryBox {
|
|
3210
|
+
const S = mat.subject;
|
|
3211
|
+
const fs = Math.max(18, Math.min(64, S.height * 0.5));
|
|
3212
|
+
return {
|
|
3213
|
+
x: S.x,
|
|
3214
|
+
y: S.y,
|
|
3215
|
+
width: Math.max(S.width, fs * 0.62 * Array.from(mat.text).length + fs * 1.4),
|
|
3216
|
+
height: Math.max(S.height, fs * 1.6),
|
|
3217
|
+
};
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3220
|
+
function galleryIndex(
|
|
3221
|
+
kitDir: string,
|
|
3222
|
+
mat: GalleryMaterial,
|
|
3223
|
+
entries: GalleryEntry[],
|
|
3224
|
+
out: string,
|
|
3225
|
+
): string {
|
|
3226
|
+
const s = mat.subject;
|
|
3227
|
+
const lines = [
|
|
3228
|
+
"# Film gallery",
|
|
3229
|
+
"",
|
|
3230
|
+
`- kit: \`${kitDir}\``,
|
|
3231
|
+
`- stage: ${mat.kind === "placeholder" ? "a neutral stand-in interface" : `${mat.kind} \`${mat.source}\``} (${mat.width}×${mat.height})`,
|
|
3232
|
+
`- subject: ${s.label} at ${Math.round(s.x)},${Math.round(s.y)} ${Math.round(s.width)}×${Math.round(s.height)} — ${s.how}`,
|
|
3233
|
+
...mat.notes.map((n) => `- ${n}`),
|
|
3234
|
+
"",
|
|
3235
|
+
"Each picture: the block at six instants (time since it starts under each cell), for its default and three other settings, then the value each setting gives over time and its speed. Dashed outline: where the subject sits in the picture. Every number is measured on the function's output, sampled every millisecond; a settle that never happens in the window is *not detected*. These say what a block does — none of them is a target, and the defaults are one choice among many: change any setting, or write the move yourself.",
|
|
3236
|
+
"",
|
|
3237
|
+
];
|
|
3238
|
+
for (const group of [
|
|
3239
|
+
"motion",
|
|
3240
|
+
"camera",
|
|
3241
|
+
"cut",
|
|
3242
|
+
"draw",
|
|
3243
|
+
"map",
|
|
3244
|
+
"stage",
|
|
3245
|
+
"seams",
|
|
3246
|
+
"world",
|
|
3247
|
+
] as const) {
|
|
3248
|
+
const es = entries.filter((e) => e.group === group);
|
|
3249
|
+
if (!es.length) continue;
|
|
3250
|
+
lines.push(`## kit/${group}.js`, "");
|
|
3251
|
+
for (const e of es) {
|
|
3252
|
+
lines.push(
|
|
3253
|
+
`### ${e.name}`,
|
|
3254
|
+
"",
|
|
3255
|
+
`\`${e.signature}\``,
|
|
3256
|
+
"",
|
|
3257
|
+
`Defaults (as shipped): ${e.note}.`,
|
|
3258
|
+
"",
|
|
3259
|
+
);
|
|
3260
|
+
if (e.error) {
|
|
3261
|
+
lines.push(`Could not be drawn: ${e.error}.`, "");
|
|
3262
|
+
continue;
|
|
3263
|
+
}
|
|
3264
|
+
if (e.png) lines.push(`})`, "");
|
|
3265
|
+
lines.push(`| setting | ${e.value}: from → rest | numbers |`, "|---|---|---|");
|
|
3266
|
+
for (const r of e.rows)
|
|
3267
|
+
lines.push(
|
|
3268
|
+
`| ${r.label.replace(/\|/g, "\\|")} | ${r.stats ? `${fmt(r.stats.from)} → ${r.stats.settle == null ? "no rest detected" : fmt(r.stats.to)}` : "—"} | ${r.text} |`,
|
|
3269
|
+
);
|
|
3270
|
+
lines.push("");
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
return `${lines.join("\n")}\n`;
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
const fmt = (v: number) => (Math.abs(v) >= 100 ? v.toFixed(0) : +v.toFixed(3));
|