@open-take/compositor 0.5.2 → 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,1879 @@
|
|
|
1
|
+
// hud.js — the words a launch film keeps on screen, pinned to the screen and
|
|
2
|
+
// not to the camera: a status chip saying what the agent is doing now, a
|
|
3
|
+
// status line swept in under a mask, a voice with its caption spoken word by
|
|
4
|
+
// word, a prompt typed fast then slow in fresh ink and sent with a press
|
|
5
|
+
// and a burst of pixels, agents' cursor labels pinned to a thing on screen or
|
|
6
|
+
// to a point in 3D, a detection box with its number counting, a title out of
|
|
7
|
+
// blur. Measured on launch films that keep words on screen all the time; each
|
|
8
|
+
// default says which film and where (24 fps films: one frame is 1/24 s, `F`).
|
|
9
|
+
//
|
|
10
|
+
// Made once, then drawn from film time: `draw(t)` writes the element and
|
|
11
|
+
// returns `at(t)`, the same numbers for the same t in any order — except
|
|
12
|
+
// where a piece is pinned to the page's own layout (`pinTo`), which reads
|
|
13
|
+
// where the element is when asked, and where a word's ink is read from the
|
|
14
|
+
// scene drawn under it; nothing here keeps time. A count in frames (a letter a frame, a step every 2) is counted
|
|
15
|
+
// on the frame it lands on, at 24, 30 or 60 fps alike. `host` is a
|
|
16
|
+
// screen-space layer (`layer()` makes one: the frame's size, above the
|
|
17
|
+
// scenes, never moved by the camera), so a chip stays put across a cut while
|
|
18
|
+
// the pictures change under it. null gives numbers only.
|
|
19
|
+
//
|
|
20
|
+
// import { layer, chip, voice, prompt } from "./lib/hud.js";
|
|
21
|
+
// const hud = layer();
|
|
22
|
+
// const status = chip(hud, { steps: [{ t: 1.2, text: "Drafting the blueprint" },
|
|
23
|
+
// { t: 4.0, text: "Building pages" }], out: 7.5 });
|
|
24
|
+
// const said = voice(hud, { t: 2.0, text: "Make it fly across the map", until: 4.4 });
|
|
25
|
+
// const box = prompt(hud, { t: 4.4, text: said.text, type: { t: 4.4, from: said.chars(4.4) }, send: 6.1 });
|
|
26
|
+
// window.__render = (t) => { status.draw(t); said.draw(t); box.draw(t); };
|
|
27
|
+
// window.__film = { duration: 8, width: 1080, height: 1920, ... };
|
|
28
|
+
//
|
|
29
|
+
// The frame's size is read when a piece is first drawn (or its numbers first
|
|
30
|
+
// asked for): `o.frame`, else the page's `window.__film` width and height,
|
|
31
|
+
// else 1920 × 1080. So `window.__film` may be set after the pieces are made,
|
|
32
|
+
// as above, and an upright 1080 × 1920 film lays its words out upright.
|
|
33
|
+
//
|
|
34
|
+
// layer(parent?, o?) the screen-space layer the rest go in; `accent`: the film's own colour
|
|
35
|
+
// chip(host, o) a status chip: dot → capsule, text from the middle out (or typed),
|
|
36
|
+
// changing text in place or sliding across, retracting to a dot or a line;
|
|
37
|
+
// `avoid`: the product's rects it keeps clear of
|
|
38
|
+
// counter(host, o) a count or a clock kept on screen: fields that change in place, only
|
|
39
|
+
// the characters that changed moving; a number can run to its next value
|
|
40
|
+
// clock(minutes, o) minutes since midnight as "6:42 PM" or "18:42", for a counter's field
|
|
41
|
+
// statusLine(host, o) one to three lines swept in left to right under a soft mask, fresh
|
|
42
|
+
// colour settling to ink, rising in; a thinking shimmer; leaving upward
|
|
43
|
+
// voice(host, o) an orb and a caption spoken word by word, grey → white per word;
|
|
44
|
+
// chars(t) is how much has been said, for the prompt that carries it on
|
|
45
|
+
// typeAt(t, t0, text, o) a typing performance: fast then slow, each character's birth time
|
|
46
|
+
// prompt(host, o) a prompt box: typed text in fresh ink, a send button's press,
|
|
47
|
+
// a light wave and a pixel burst on send, the box closing in after
|
|
48
|
+
// burst(host, o) a burst of pixels round a point (the prompt's send uses one),
|
|
49
|
+
// inside the frame
|
|
50
|
+
// agent(host, o) an agent's cursor and name label, popping in, pinned to a point
|
|
51
|
+
// pinTo(el, o) a point of an element, in the frame, for agent's `at`
|
|
52
|
+
// project(camera, p, o) a three.js camera's view of a 3D point, in the frame, for `at`
|
|
53
|
+
// detect(host, o) a detection box: label typed, outline drawn, number counting up
|
|
54
|
+
// on a plate of its colour
|
|
55
|
+
// title(host, o) a title whose letters come out of blur one after another
|
|
56
|
+
//
|
|
57
|
+
// Sizes default to shares of the frame's short side — its height in a
|
|
58
|
+
// landscape film (the films' own), its width in an upright one: a chip's text
|
|
59
|
+
// 0.04, a caption 0.06, a prompt's text 0.03, an agent's name 0.018. A
|
|
60
|
+
// landscape film seen on an upright phone is about 390 px across, a fifth of
|
|
61
|
+
// 1920: a chip's 43 px shows at about 9 px there, a caption's 65 px at 13 px;
|
|
62
|
+
// agents' names (19 px → 4 px) are a texture of many hands at work, not text to
|
|
63
|
+
// read (`film probe`'s text lane says what the film's own words come to).
|
|
64
|
+
// The defaults keep out of each other's way: a chip low at the left (0.9 H),
|
|
65
|
+
// a caption above it (0.8 H) wrapping inside 0.86 W, a title wrapping inside
|
|
66
|
+
// 0.9 W, a status line made smaller until it fits across.
|
|
67
|
+
//
|
|
68
|
+
// One accent, the film's own: `layer(parent, { accent: "#d97757" })`, or the
|
|
69
|
+
// CSS custom property `--hud-accent` on the layer or anything it sits in
|
|
70
|
+
// (`:root { --hud-accent: var(--brand) }`). The chip's mark, the status
|
|
71
|
+
// line's fresh ink and mark, the voice's orb, the prompt's send button,
|
|
72
|
+
// fresh ink, light wave and burst, and an agent's label all take it, each
|
|
73
|
+
// piece's own option (`accent`, `fresh`, `orbColour`, `burst`, `colour`)
|
|
74
|
+
// over it. With none given they are drawn without a colour of their own —
|
|
75
|
+
// the ink, lighter while fresh; a grey orb; a dark label — and never in the
|
|
76
|
+
// colours of the films these were measured on (those had an orange send
|
|
77
|
+
// button, a cyan burst, a yellow-to-magenta sweep: theirs, not yours). A
|
|
78
|
+
// detection box keeps its red, yellow and green: they say low, middling and
|
|
79
|
+
// high, whatever the film.
|
|
80
|
+
//
|
|
81
|
+
// Colours are any CSS colour (#hex, rgb(), hsl(), a name). Words with no
|
|
82
|
+
// backing of their own — a status line, a caption, a title, a detection
|
|
83
|
+
// box's label — take their ink from the scene under them when no `ink` /
|
|
84
|
+
// `colour` is given: dark on a light scene, light on a dark one, read from
|
|
85
|
+
// the colours the page paints there as each frame is drawn; over a picture
|
|
86
|
+
// (an <img>, <video> or <canvas>) light with a soft shadow. The chip and the
|
|
87
|
+
// prompt carry their own dark glass, and a detection box's number its own
|
|
88
|
+
// plate of the box's colour.
|
|
89
|
+
//
|
|
90
|
+
// Nothing here blurs on its own except a title's letters: the master's
|
|
91
|
+
// shutter smears a chip sliding across or a box closing in. Its eases and
|
|
92
|
+
// clamp are lib/anim.js's, which sits beside it; an agent pinned to a point
|
|
93
|
+
// of lib/space.js's stage takes `at: (t) => st.toFrame(p, t)`.
|
|
94
|
+
|
|
95
|
+
import { clamp, ease, gsapEase, lerp, prog } from "./anim.js";
|
|
96
|
+
|
|
97
|
+
/** @typedef {{ width: number, height: number }} Frame */
|
|
98
|
+
/** @typedef {[number, number]} Pt a point in the frame, px */
|
|
99
|
+
/** @typedef {Pt | ((t: number) => Pt | null)} Where a point, or one read from film time (null: not on screen) */
|
|
100
|
+
|
|
101
|
+
/** one frame of the 24 fps films the numbers were measured on, in seconds */
|
|
102
|
+
export const F = 1 / 24;
|
|
103
|
+
|
|
104
|
+
/** a microsecond: a time that lands on a frame counts as on it, whatever the float error of t − t0 */
|
|
105
|
+
const EPS = 1e-6;
|
|
106
|
+
/** t has reached `edge` (a frame's time computed another way still counts) @param {number} t @param {number} edge */
|
|
107
|
+
const on = (t, edge) => t >= edge - EPS;
|
|
108
|
+
/** whole steps of `per` seconds in dt, the step that lands on a frame counted on that frame @param {number} dt @param {number} per */
|
|
109
|
+
const count = (dt, per) => Math.floor(dt / per + EPS);
|
|
110
|
+
|
|
111
|
+
const clamp01 = (/** @type {number} */ x) => clamp(x);
|
|
112
|
+
const { out2, out3, in2, in3 } = ease;
|
|
113
|
+
/** back.out: past 1 by about 10 % and back */
|
|
114
|
+
const backOut = /** @type {(u: number) => number} */ (gsapEase("back.out(1.7)"));
|
|
115
|
+
/** a number 0..1 from integers, the same every time @param {number} a @param {number} [b] */
|
|
116
|
+
const hash = (a, b = 0) => {
|
|
117
|
+
const s = Math.sin(a * 127.1 + b * 311.7) * 43758.5453;
|
|
118
|
+
return s - Math.floor(s);
|
|
119
|
+
};
|
|
120
|
+
const esc = (/** @type {string} */ s) =>
|
|
121
|
+
s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c] ?? c);
|
|
122
|
+
const r1 = (/** @type {number} */ n) => Math.round(n * 10) / 10;
|
|
123
|
+
|
|
124
|
+
/** @type {Intl.Segmenter | null | undefined} */
|
|
125
|
+
let segmenter;
|
|
126
|
+
/** the characters a reader sees (an emoji, a flag, an accented letter: one each) @param {string} s @returns {string[]} */
|
|
127
|
+
function glyphs(s) {
|
|
128
|
+
if (segmenter === undefined)
|
|
129
|
+
segmenter = typeof Intl !== "undefined" && "Segmenter" in Intl ? new Intl.Segmenter(undefined, { granularity: "grapheme" }) : null;
|
|
130
|
+
return segmenter ? Array.from(segmenter.segment(s), (g) => g.segment) : Array.from(s);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** the frame: o.frame, else the page's __film size, else 1920 × 1080 @param {Frame} [f] @returns {Frame} */
|
|
134
|
+
function frameOf(f) {
|
|
135
|
+
if (f) return f;
|
|
136
|
+
const film = /** @type {{ __film?: { width?: number, height?: number } }} */ (globalThis).__film;
|
|
137
|
+
return { width: film?.width ?? 1920, height: film?.height ?? 1080 };
|
|
138
|
+
}
|
|
139
|
+
/** the frame's short side: its height in a landscape film, its width in an upright one @param {Frame} fr */
|
|
140
|
+
const short = (fr) => Math.min(fr.width, fr.height);
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Sizes made from the frame, worked out when first asked for and again only
|
|
144
|
+
* if the frame changes — so a page may declare `window.__film` after it made
|
|
145
|
+
* its words.
|
|
146
|
+
* @template T @param {Frame | undefined} f @param {(fr: Frame) => T} make @returns {() => T}
|
|
147
|
+
*/
|
|
148
|
+
function later(f, make) {
|
|
149
|
+
let key = "";
|
|
150
|
+
/** @type {T | undefined} */
|
|
151
|
+
let got;
|
|
152
|
+
return () => {
|
|
153
|
+
const fr = frameOf(f);
|
|
154
|
+
const k = `${fr.width}x${fr.height}`;
|
|
155
|
+
if (k !== key || got === undefined) {
|
|
156
|
+
key = k;
|
|
157
|
+
got = make(fr);
|
|
158
|
+
}
|
|
159
|
+
return got;
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** a point read at t @param {Where | undefined} w @param {number} t @returns {Pt | null} */
|
|
164
|
+
const where = (w, t) => (typeof w === "function" ? w(t) : (w ?? null));
|
|
165
|
+
|
|
166
|
+
// --- colours ------------------------------------------------------------------
|
|
167
|
+
|
|
168
|
+
const NAMED =
|
|
169
|
+
"aliceblue:f0f8ff antiquewhite:faebd7 aqua:00ffff aquamarine:7fffd4 azure:f0ffff beige:f5f5dc bisque:ffe4c4 " +
|
|
170
|
+
"black:000000 blanchedalmond:ffebcd blue:0000ff blueviolet:8a2be2 brown:a52a2a burlywood:deb887 cadetblue:5f9ea0 " +
|
|
171
|
+
"chartreuse:7fff00 chocolate:d2691e coral:ff7f50 cornflowerblue:6495ed cornsilk:fff8dc crimson:dc143c cyan:00ffff " +
|
|
172
|
+
"darkblue:00008b darkcyan:008b8b darkgoldenrod:b8860b darkgray:a9a9a9 darkgreen:006400 darkgrey:a9a9a9 " +
|
|
173
|
+
"darkkhaki:bdb76b darkmagenta:8b008b darkolivegreen:556b2f darkorange:ff8c00 darkorchid:9932cc darkred:8b0000 " +
|
|
174
|
+
"darksalmon:e9967a darkseagreen:8fbc8f darkslateblue:483d8b darkslategray:2f4f4f darkslategrey:2f4f4f " +
|
|
175
|
+
"darkturquoise:00ced1 darkviolet:9400d3 deeppink:ff1493 deepskyblue:00bfff dimgray:696969 dimgrey:696969 " +
|
|
176
|
+
"dodgerblue:1e90ff firebrick:b22222 floralwhite:fffaf0 forestgreen:228b22 fuchsia:ff00ff gainsboro:dcdcdc " +
|
|
177
|
+
"ghostwhite:f8f8ff gold:ffd700 goldenrod:daa520 gray:808080 green:008000 greenyellow:adff2f grey:808080 " +
|
|
178
|
+
"honeydew:f0fff0 hotpink:ff69b4 indianred:cd5c5c indigo:4b0082 ivory:fffff0 khaki:f0e68c lavender:e6e6fa " +
|
|
179
|
+
"lavenderblush:fff0f5 lawngreen:7cfc00 lemonchiffon:fffacd lightblue:add8e6 lightcoral:f08080 lightcyan:e0ffff " +
|
|
180
|
+
"lightgoldenrodyellow:fafad2 lightgray:d3d3d3 lightgreen:90ee90 lightgrey:d3d3d3 lightpink:ffb6c1 lightsalmon:ffa07a " +
|
|
181
|
+
"lightseagreen:20b2aa lightskyblue:87cefa lightslategray:778899 lightslategrey:778899 lightsteelblue:b0c4de " +
|
|
182
|
+
"lightyellow:ffffe0 lime:00ff00 limegreen:32cd32 linen:faf0e6 magenta:ff00ff maroon:800000 mediumaquamarine:66cdaa " +
|
|
183
|
+
"mediumblue:0000cd mediumorchid:ba55d3 mediumpurple:9370db mediumseagreen:3cb371 mediumslateblue:7b68ee " +
|
|
184
|
+
"mediumspringgreen:00fa9a mediumturquoise:48d1cc mediumvioletred:c71585 midnightblue:191970 mintcream:f5fffa " +
|
|
185
|
+
"mistyrose:ffe4e1 moccasin:ffe4b5 navajowhite:ffdead navy:000080 oldlace:fdf5e6 olive:808000 olivedrab:6b8e23 " +
|
|
186
|
+
"orange:ffa500 orangered:ff4500 orchid:da70d6 palegoldenrod:eee8aa palegreen:98fb98 paleturquoise:afeeee " +
|
|
187
|
+
"palevioletred:db7093 papayawhip:ffefd5 peachpuff:ffdab9 peru:cd853f pink:ffc0cb plum:dda0dd powderblue:b0e0e6 " +
|
|
188
|
+
"purple:800080 rebeccapurple:663399 red:ff0000 rosybrown:bc8f8f royalblue:4169e1 saddlebrown:8b4513 salmon:fa8072 " +
|
|
189
|
+
"sandybrown:f4a460 seagreen:2e8b57 seashell:fff5ee sienna:a0522d silver:c0c0c0 skyblue:87ceeb slateblue:6a5acd " +
|
|
190
|
+
"slategray:708090 slategrey:708090 snow:fffafa springgreen:00ff7f steelblue:4682b4 tan:d2b48c teal:008080 " +
|
|
191
|
+
"thistle:d8bfd8 tomato:ff6347 turquoise:40e0d0 violet:ee82ee wheat:f5deb3 white:ffffff whitesmoke:f5f5f5 yellow:ffff00 " +
|
|
192
|
+
"yellowgreen:9acd32";
|
|
193
|
+
/** @type {Map<string, string> | null} */
|
|
194
|
+
let names = null;
|
|
195
|
+
/** @type {CanvasRenderingContext2D | null | undefined} */
|
|
196
|
+
let probeCtx;
|
|
197
|
+
|
|
198
|
+
/** @typedef {[number, number, number, number]} Rgba 0..255 each, alpha 0..1 */
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* [r, g, b, a] of a CSS colour — #rgb, #rgba, #rrggbb, #rrggbbaa, rgb()/rgba(),
|
|
202
|
+
* hsl()/hsla(), a named colour, `transparent`; in a page, anything else the
|
|
203
|
+
* browser reads (color(), oklch() …). null when it is not one.
|
|
204
|
+
* @param {string} c @returns {Rgba | null}
|
|
205
|
+
*/
|
|
206
|
+
export function readColour(c) {
|
|
207
|
+
const s = String(c).trim().toLowerCase();
|
|
208
|
+
if (s === "transparent") return [0, 0, 0, 0];
|
|
209
|
+
const hex = /^#([0-9a-f]+)$/.exec(s);
|
|
210
|
+
if (hex) {
|
|
211
|
+
let h = /** @type {string} */ (hex[1]);
|
|
212
|
+
if (h.length === 3 || h.length === 4) h = [...h].map((x) => x + x).join("");
|
|
213
|
+
if (h.length !== 6 && h.length !== 8) return null;
|
|
214
|
+
const n = (/** @type {number} */ i) => parseInt(h.slice(i, i + 2), 16);
|
|
215
|
+
return [n(0), n(2), n(4), h.length === 8 ? n(6) / 255 : 1];
|
|
216
|
+
}
|
|
217
|
+
const fn = /^(rgba?|hsla?)\(([^)]*)\)$/.exec(s);
|
|
218
|
+
if (fn) {
|
|
219
|
+
const parts = /** @type {string} */ (fn[2]).split(/[\s,/]+/).filter(Boolean);
|
|
220
|
+
if (parts.length < 3) return null;
|
|
221
|
+
const num = (/** @type {string} */ p, /** @type {number} */ full) => (p.endsWith("%") ? (parseFloat(p) / 100) * full : parseFloat(p));
|
|
222
|
+
const a = parts[3] == null ? 1 : num(parts[3], 1);
|
|
223
|
+
/** @type {number[]} */
|
|
224
|
+
let ch;
|
|
225
|
+
if (/** @type {string} */ (fn[1]).startsWith("rgb")) ch = [0, 1, 2].map((i) => num(/** @type {string} */ (parts[i]), 255));
|
|
226
|
+
else {
|
|
227
|
+
const h = ((parseFloat(/** @type {string} */ (parts[0])) % 360) + 360) % 360;
|
|
228
|
+
const sat = num(/** @type {string} */ (parts[1]), 1);
|
|
229
|
+
const l = num(/** @type {string} */ (parts[2]), 1);
|
|
230
|
+
const k = (/** @type {number} */ n) => (n + h / 30) % 12;
|
|
231
|
+
const q = sat * Math.min(l, 1 - l);
|
|
232
|
+
ch = [0, 8, 4].map((n) => 255 * (l - q * Math.max(-1, Math.min(k(n) - 3, 9 - k(n), 1))));
|
|
233
|
+
}
|
|
234
|
+
if ([...ch, a].some((v) => !Number.isFinite(v))) return null;
|
|
235
|
+
return [clamp(ch[0] ?? 0, 0, 255), clamp(ch[1] ?? 0, 0, 255), clamp(ch[2] ?? 0, 0, 255), clamp01(a)];
|
|
236
|
+
}
|
|
237
|
+
names ??= new Map(NAMED.split(" ").map((p) => /** @type {[string, string]} */ (p.split(":"))));
|
|
238
|
+
const named = names.get(s);
|
|
239
|
+
if (named) return readColour(`#${named}`);
|
|
240
|
+
// anything else CSS knows: the browser's own reading of it
|
|
241
|
+
if (typeof document !== "undefined") {
|
|
242
|
+
if (probeCtx === undefined) probeCtx = document.createElement("canvas").getContext("2d");
|
|
243
|
+
if (probeCtx) {
|
|
244
|
+
probeCtx.fillStyle = "#010203";
|
|
245
|
+
probeCtx.fillStyle = c;
|
|
246
|
+
const got = String(probeCtx.fillStyle);
|
|
247
|
+
if (got !== "#010203" && /^(#|rgb)/.test(got)) return readColour(got);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** a colour read, or a clear error @param {string} c @param {string} what @returns {Rgba} */
|
|
254
|
+
function colourOf(c, what) {
|
|
255
|
+
const v = readColour(c);
|
|
256
|
+
if (!v) throw new Error(`hud: ${what} "${c}" is not a colour it can read (#hex, rgb(), hsl() or a CSS name)`);
|
|
257
|
+
return v;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** two colours mixed at u, as rgb() (rgba() when either is see-through) @param {string} a @param {string} b @param {number} u */
|
|
261
|
+
function mix(a, b, u) {
|
|
262
|
+
const A = colourOf(a, "colour");
|
|
263
|
+
const B = colourOf(b, "colour");
|
|
264
|
+
const ch = [0, 1, 2].map((i) => Math.round(lerp(/** @type {number} */ (A[i]), /** @type {number} */ (B[i]), u)));
|
|
265
|
+
const al = lerp(A[3], B[3], u);
|
|
266
|
+
return al >= 1 ? `rgb(${ch.join(", ")})` : `rgba(${ch.join(", ")}, ${Math.round(al * 1000) / 1000})`;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** a colour at `alpha` of its own opacity, as rgba() @param {string} c @param {number} alpha */
|
|
270
|
+
function faded(c, alpha) {
|
|
271
|
+
const [r, g, b, a] = colourOf(c, "colour");
|
|
272
|
+
return `rgba(${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}, ${Math.round(a * alpha * 1000) / 1000})`;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* The film's accent for the pieces of a layer: `--hud-accent` as the layer
|
|
277
|
+
* computes it (layer()'s `accent`, or the page's own CSS), null when there
|
|
278
|
+
* is none or no page.
|
|
279
|
+
* @param {HTMLElement | null} host @returns {string | null}
|
|
280
|
+
*/
|
|
281
|
+
function accentOf(host) {
|
|
282
|
+
if (!host || typeof getComputedStyle !== "function") return null;
|
|
283
|
+
const v = getComputedStyle(host).getPropertyValue("--hud-accent").trim();
|
|
284
|
+
return v && readColour(v) ? v : null;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** an accent with a lighter and a deeper tone of itself (a highlight, a shade) @param {string} c */
|
|
288
|
+
const tones = (c) => ({ light: mix(c, "#ffffff", 0.45), mid: c, deep: mix(c, "#000000", 0.35) });
|
|
289
|
+
|
|
290
|
+
/** black or white, whichever stands further from `c` (the WCAG contrast ratio) @param {string} c */
|
|
291
|
+
function inkOn(c) {
|
|
292
|
+
const L = luminance(colourOf(c, "colour"));
|
|
293
|
+
return (L + 0.05) / 0.05 >= 1.05 / (L + 0.05) ? "#000000" : "#ffffff";
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// --- the scene under the words --------------------------------------------------
|
|
297
|
+
|
|
298
|
+
/** the inks for words with no backing: on a light scene, on a dark one */
|
|
299
|
+
const INK = { onLight: "#1c1c21", onDark: "#f4f2f6" };
|
|
300
|
+
|
|
301
|
+
/** relative luminance 0..1 of a colour @param {Rgba} c */
|
|
302
|
+
function luminance(c) {
|
|
303
|
+
const f = (/** @type {number} */ c8) => {
|
|
304
|
+
const v = c8 / 255;
|
|
305
|
+
return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
|
|
306
|
+
};
|
|
307
|
+
return 0.2126 * f(c[0]) + 0.7152 * f(c[1]) + 0.0722 * f(c[2]);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** the luminance the page paints at a point of the viewport; null under a picture or where it paints nothing it says @param {number} x @param {number} y */
|
|
311
|
+
function paintedAt(x, y) {
|
|
312
|
+
for (const e of document.elementsFromPoint(x, y)) {
|
|
313
|
+
if (e.closest(".hud-layer")) continue;
|
|
314
|
+
if (/^(img|video|canvas|iframe|picture|object|embed|image)$/i.test(e.tagName)) return null;
|
|
315
|
+
const cs = getComputedStyle(e);
|
|
316
|
+
const img = cs.backgroundImage;
|
|
317
|
+
if (img && img !== "none") {
|
|
318
|
+
if (img.includes("url(")) return null;
|
|
319
|
+
const stops = (img.match(/rgba?\([^)]*\)/g) ?? []).map(readColour).filter((c) => c != null && c[3] > 0.3);
|
|
320
|
+
if (stops.length) return stops.reduce((s, c) => s + luminance(/** @type {Rgba} */ (c)), 0) / stops.length;
|
|
321
|
+
}
|
|
322
|
+
const bg = readColour(cs.backgroundColor);
|
|
323
|
+
if (bg && bg[3] > 0.5) return luminance(bg);
|
|
324
|
+
}
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* "light" or "dark": the scene behind these elements of the layer, from the
|
|
330
|
+
* colours the page paints there; null when it cannot tell (a picture, or no page).
|
|
331
|
+
* @param {(Element | null | undefined)[]} els @returns {"light" | "dark" | null}
|
|
332
|
+
*/
|
|
333
|
+
function sceneBehind(els) {
|
|
334
|
+
if (typeof document === "undefined" || typeof document.elementsFromPoint !== "function") return null;
|
|
335
|
+
let l = Infinity, t = Infinity, r = -Infinity, b = -Infinity;
|
|
336
|
+
for (const e of els) {
|
|
337
|
+
if (!e) continue;
|
|
338
|
+
const q = e.getBoundingClientRect();
|
|
339
|
+
l = Math.min(l, q.left); t = Math.min(t, q.top); r = Math.max(r, q.right); b = Math.max(b, q.bottom);
|
|
340
|
+
}
|
|
341
|
+
if (!Number.isFinite(l)) return null;
|
|
342
|
+
/** @type {number[]} */
|
|
343
|
+
const seen = [];
|
|
344
|
+
for (const [u, v] of [[0.5, 0.5], [0.12, 0.3], [0.88, 0.3], [0.12, 0.75], [0.88, 0.75]]) {
|
|
345
|
+
const L = paintedAt(lerp(l, r, /** @type {number} */ (u)), lerp(t, b, /** @type {number} */ (v)));
|
|
346
|
+
if (L != null) seen.push(L);
|
|
347
|
+
}
|
|
348
|
+
if (!seen.length) return null;
|
|
349
|
+
return seen.reduce((s, x) => s + x, 0) / seen.length > 0.36 ? "light" : "dark";
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** the ink for words on a scene, and the shadow that keeps light ink legible where the scene is not known @param {"light" | "dark" | null} scene */
|
|
353
|
+
const inkFor = (scene) =>
|
|
354
|
+
scene === "light"
|
|
355
|
+
? { ink: INK.onLight, shadow: "none" }
|
|
356
|
+
: { ink: INK.onDark, shadow: scene === "dark" ? "0 2px 18px rgba(0,0,0,0.35)" : "0 1px 3px rgba(0,0,0,0.55), 0 2px 16px rgba(0,0,0,0.45)" };
|
|
357
|
+
|
|
358
|
+
const FONT = `"Inter", "Helvetica Neue", Helvetica, Arial, sans-serif`;
|
|
359
|
+
const CSS = `
|
|
360
|
+
.hud-layer { position: absolute; left: 0; top: 0; pointer-events: none; overflow: hidden; isolation: isolate; z-index: 50; }
|
|
361
|
+
.hud-layer * { box-sizing: border-box; }
|
|
362
|
+
.hud-chip { position: absolute; left: 0; top: 0; display: flex; align-items: center; white-space: nowrap;
|
|
363
|
+
border-radius: 999px; font-weight: 600; letter-spacing: -0.01em; }
|
|
364
|
+
.hud-chip svg { flex: none; }
|
|
365
|
+
.hud-counter { position: absolute; left: 0; top: 0; display: flex; align-items: center; white-space: pre;
|
|
366
|
+
border-radius: 999px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
|
|
367
|
+
.hud-counter .hud-cell { position: relative; display: inline-block; }
|
|
368
|
+
.hud-counter .hud-cell > span { display: inline-block; }
|
|
369
|
+
.hud-counter .hud-cell > b { position: absolute; left: -1em; right: -1em; top: 0; text-align: center; font-weight: inherit; }
|
|
370
|
+
.hud-counter .hud-cell.hud-whole > b { left: 0; right: -60em; text-align: left; }
|
|
371
|
+
.hud-status { position: absolute; left: 0; top: 0; }
|
|
372
|
+
.hud-status .hud-line { position: absolute; left: 0; white-space: nowrap; line-height: 1.15; letter-spacing: -0.02em;
|
|
373
|
+
-webkit-background-clip: text; background-clip: text; color: transparent; }
|
|
374
|
+
.hud-voice { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; }
|
|
375
|
+
.hud-orb { position: relative; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
|
|
376
|
+
.hud-orb i { display: block; border-radius: 99px; background: #fff; }
|
|
377
|
+
.hud-caption { white-space: normal; text-align: center; line-height: 1.2; font-weight: 500; letter-spacing: -0.01em; }
|
|
378
|
+
.hud-prompt { position: absolute; left: 0; top: 0; overflow: hidden; }
|
|
379
|
+
.hud-prompt .hud-text { position: absolute; white-space: pre-wrap; overflow-wrap: break-word; }
|
|
380
|
+
.hud-prompt .hud-caret { display: inline-block; width: 0.08em; height: 1.05em; vertical-align: -0.17em; margin-left: 0.04em; }
|
|
381
|
+
.hud-prompt .hud-foot { position: absolute; display: flex; align-items: center; gap: 0.6em; font-weight: 500; }
|
|
382
|
+
.hud-prompt .hud-send { position: absolute; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; }
|
|
383
|
+
.hud-prompt .hud-wave { position: absolute; inset: 0; }
|
|
384
|
+
.hud-burst { position: absolute; left: 0; top: 0; }
|
|
385
|
+
.hud-agent { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
|
|
386
|
+
.hud-agent span { position: absolute; white-space: nowrap; font-weight: 700; border-radius: 0.3em; }
|
|
387
|
+
.hud-detect { position: absolute; left: 0; top: 0; }
|
|
388
|
+
.hud-detect svg { position: absolute; left: 0; top: 0; overflow: visible; }
|
|
389
|
+
.hud-detect b { position: absolute; white-space: nowrap; line-height: 1; letter-spacing: -0.02em; }
|
|
390
|
+
.hud-title { position: absolute; left: 0; top: 0; white-space: normal; line-height: 1.05; }
|
|
391
|
+
.hud-title .hud-word { display: inline-block; white-space: nowrap; }
|
|
392
|
+
.hud-title span span { display: inline-block; white-space: pre; }
|
|
393
|
+
`;
|
|
394
|
+
|
|
395
|
+
/** the module's styles, once per document */
|
|
396
|
+
function styles() {
|
|
397
|
+
if (typeof document === "undefined" || document.getElementById("hud-css")) return;
|
|
398
|
+
const s = document.createElement("style");
|
|
399
|
+
s.id = "hud-css";
|
|
400
|
+
s.textContent = CSS;
|
|
401
|
+
document.head.appendChild(s);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** an element of class cls in parent @param {string} tag @param {string} cls @param {Element | null} parent @returns {HTMLElement} */
|
|
405
|
+
function mk(tag, cls, parent) {
|
|
406
|
+
const e = document.createElement(tag);
|
|
407
|
+
if (cls) e.className = cls;
|
|
408
|
+
parent?.appendChild(e);
|
|
409
|
+
return e;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** a layer() made without a frame takes the frame's size once it is known @param {HTMLElement | null} host @param {Frame} fr */
|
|
413
|
+
function fit(host, fr) {
|
|
414
|
+
if (host?.dataset.hudFit !== "page") return;
|
|
415
|
+
host.style.width = `${fr.width}px`;
|
|
416
|
+
host.style.height = `${fr.height}px`;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** an asterisk of six spokes, the agent's "working" mark @param {number} px @param {string} colour */
|
|
420
|
+
const star = (px, colour) =>
|
|
421
|
+
`<svg width="${px}" height="${px}" viewBox="-12 -12 24 24"><g stroke="${esc(colour)}" stroke-width="2.6" stroke-linecap="round">` +
|
|
422
|
+
[0, 30, 60, 90, 120, 150]
|
|
423
|
+
.map((a) => {
|
|
424
|
+
const c = Math.cos((a * Math.PI) / 180) * 10;
|
|
425
|
+
const s = Math.sin((a * Math.PI) / 180) * 10;
|
|
426
|
+
return `<line x1="${r1(-c)}" y1="${r1(-s)}" x2="${r1(c)}" y2="${r1(s)}"/>`;
|
|
427
|
+
})
|
|
428
|
+
.join("") +
|
|
429
|
+
`</g></svg>`;
|
|
430
|
+
|
|
431
|
+
// --- the layer ----------------------------------------------------------------
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* The screen-space layer the words go in: the frame's size at its top-left,
|
|
435
|
+
* above everything the page has drawn so far, never under the camera. Put it
|
|
436
|
+
* last in the page (or give it a higher zIndex) and keep the scenes and the
|
|
437
|
+
* camera in elements of their own; then a chip, a caption or a label stays
|
|
438
|
+
* where it is on screen through a cut, a push or a whip. Without `frame` it
|
|
439
|
+
* takes the size `window.__film` declares, when the first piece in it draws.
|
|
440
|
+
* `accent`: the film's own colour, which every piece in the layer takes for
|
|
441
|
+
* its mark, fresh ink, button, orb or label (it is set as `--hud-accent` on
|
|
442
|
+
* the layer; a page that sets that property in its own CSS needs no option).
|
|
443
|
+
* @param {Element | null} [parent] default document.body
|
|
444
|
+
* @param {{ frame?: Frame, z?: number, accent?: string }} [o]
|
|
445
|
+
* @returns {HTMLElement | null}
|
|
446
|
+
*/
|
|
447
|
+
export function layer(parent, o = {}) {
|
|
448
|
+
if (typeof document === "undefined") return null;
|
|
449
|
+
styles();
|
|
450
|
+
const el = mk("div", "hud-layer", parent ?? document.body);
|
|
451
|
+
if (!o.frame) el.dataset.hudFit = "page";
|
|
452
|
+
const fr = frameOf(o.frame);
|
|
453
|
+
el.style.width = `${fr.width}px`;
|
|
454
|
+
el.style.height = `${fr.height}px`;
|
|
455
|
+
if (o.z != null) el.style.zIndex = String(o.z);
|
|
456
|
+
if (o.accent) {
|
|
457
|
+
colourOf(o.accent, "layer accent");
|
|
458
|
+
el.style.setProperty("--hud-accent", o.accent);
|
|
459
|
+
}
|
|
460
|
+
return el;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// --- typing -------------------------------------------------------------------
|
|
464
|
+
|
|
465
|
+
// A prompt typed in a launch film (Df-JzBcCrDo 7.46–8.38 s, read frame by
|
|
466
|
+
// frame): characters on screen at each 24 fps frame from the first. A brief
|
|
467
|
+
// run-up, then 4–6 characters a frame, slowing to one every other frame at the
|
|
468
|
+
// end: 43 characters in 22 frames, 48 a second on average.
|
|
469
|
+
const MEASURED_TYPING = [0, 2, 3, 6, 10, 16, 20, 24, 27, 30, 32, 34, 35, 36, 36, 38, 39, 40, 40, 41, 41, 42, 43];
|
|
470
|
+
|
|
471
|
+
/** the measured typing as a progress 0..1 → share of the characters @param {number} u */
|
|
472
|
+
function typedShare(u) {
|
|
473
|
+
const n = MEASURED_TYPING.length - 1;
|
|
474
|
+
const x = clamp01(u) * n;
|
|
475
|
+
const i = Math.min(n - 1, Math.floor(x));
|
|
476
|
+
const last = /** @type {number} */ (MEASURED_TYPING[n]);
|
|
477
|
+
return lerp(/** @type {number} */ (MEASURED_TYPING[i]), /** @type {number} */ (MEASURED_TYPING[i + 1]), x - i) / last;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* @typedef {object} Typed a typing performance at t
|
|
482
|
+
* @property {number} n characters on screen
|
|
483
|
+
* @property {string} text the text typed so far
|
|
484
|
+
* @property {number} start when the typing starts (t0)
|
|
485
|
+
* @property {number} end when the last character lands
|
|
486
|
+
* @property {boolean} done
|
|
487
|
+
* @property {(i: number) => number} born when character i appeared (−Infinity for those there before)
|
|
488
|
+
*/
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* A typing performance: `text` typed from t0, fast then slow as a person
|
|
492
|
+
* types a request they know (curve "measured", the default: Df-JzBcCrDo's
|
|
493
|
+
* prompt, 48 characters a second on average) or at an even rate (curve
|
|
494
|
+
* "even": the one line the film wants read, Dfj2vYxC1pE's key command at one
|
|
495
|
+
* character a 24 fps frame, `{ curve: "even", cps: 24 }`). `from`: characters
|
|
496
|
+
* already there at t0 — a line a voice said in the shot before, carried on.
|
|
497
|
+
* Characters are the ones a reader sees: an emoji is one.
|
|
498
|
+
* `typeAt(t, 4.4, "Make it fly across the map", { from: 12 }).text`
|
|
499
|
+
* @param {number} t @param {number} t0 @param {string} text
|
|
500
|
+
* @param {{ cps?: number, curve?: "measured" | "even" | ((u: number) => number), from?: number }} [o]
|
|
501
|
+
* @returns {Typed}
|
|
502
|
+
*/
|
|
503
|
+
export function typeAt(t, t0, text, o = {}) {
|
|
504
|
+
const chars = glyphs(text);
|
|
505
|
+
const len = chars.length;
|
|
506
|
+
const from = Math.max(0, Math.min(len, Math.round(o.from ?? 0)));
|
|
507
|
+
const rest = len - from;
|
|
508
|
+
const cps = o.cps ?? (o.curve === "even" ? 24 : 48);
|
|
509
|
+
if (!(cps > 0)) throw new Error(`hud.typeAt: cps is characters a second, above 0 (got ${cps})`);
|
|
510
|
+
const dur = rest / cps;
|
|
511
|
+
const curve = typeof o.curve === "function" ? o.curve : o.curve === "even" ? (/** @type {number} */ u) => u : typedShare;
|
|
512
|
+
const typed = (/** @type {number} */ u) => Math.floor(rest * curve(u) + EPS);
|
|
513
|
+
const nAt = (/** @type {number} */ tt) => from + (on(tt, t0) ? Math.min(rest, typed(prog(tt, t0, t0 + dur))) : 0);
|
|
514
|
+
const n = nAt(t);
|
|
515
|
+
const born = (/** @type {number} */ i) => {
|
|
516
|
+
if (i < from) return -Infinity;
|
|
517
|
+
// the first u at which character i is on screen (the curve only climbs)
|
|
518
|
+
let lo = 0;
|
|
519
|
+
let hi = 1;
|
|
520
|
+
for (let k = 0; k < 30; k++) {
|
|
521
|
+
const mid = (lo + hi) / 2;
|
|
522
|
+
if (from + typed(mid) > i) hi = mid;
|
|
523
|
+
else lo = mid;
|
|
524
|
+
}
|
|
525
|
+
return t0 + hi * dur;
|
|
526
|
+
};
|
|
527
|
+
return { n, text: chars.slice(0, n).join(""), start: t0, end: t0 + dur, done: n >= len, born };
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Typed text as HTML, its newest characters in fresh ink cooling to `ink`:
|
|
532
|
+
* Df-JzBcCrDo's prompts show the last 4–10 characters in its orange, white
|
|
533
|
+
* within 4–8 frames (`freshFor` 6 frames, the default); its error line used
|
|
534
|
+
* green. `fresh` is that colour — the film's accent; with none, the ink at
|
|
535
|
+
* half strength, so new characters come in light and fill. Escaped; a caret
|
|
536
|
+
* after it while `caret` is true.
|
|
537
|
+
* @param {number} t @param {Typed} ty
|
|
538
|
+
* @param {{ ink?: string, fresh?: string, freshFor?: number, caret?: boolean, caretColour?: string }} [o]
|
|
539
|
+
*/
|
|
540
|
+
export function inkHtml(t, ty, o = {}) {
|
|
541
|
+
const ink = o.ink ?? "#f4f2f6";
|
|
542
|
+
const fresh = o.fresh ?? faded(ink, 0.5);
|
|
543
|
+
const freshFor = o.freshFor ?? 6 * F;
|
|
544
|
+
const chars = glyphs(ty.text);
|
|
545
|
+
let k = ty.n;
|
|
546
|
+
while (k > 0 && t - ty.born(k - 1) < freshFor) k--;
|
|
547
|
+
let html = esc(chars.slice(0, k).join(""));
|
|
548
|
+
for (let i = k; i < ty.n; i++) {
|
|
549
|
+
const age = t - ty.born(i);
|
|
550
|
+
html += `<span style="color:${mix(fresh, ink, clamp01(age / freshFor))}">${esc(chars[i] ?? "")}</span>`;
|
|
551
|
+
}
|
|
552
|
+
if (o.caret) html += `<i class="hud-caret" style="background:${esc(o.caretColour ?? o.fresh ?? ink)}"></i>`;
|
|
553
|
+
return html;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// --- status chip --------------------------------------------------------------
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* @typedef {object} ChipStep one thing the chip says, from t
|
|
560
|
+
* @property {number} t
|
|
561
|
+
* @property {string} text
|
|
562
|
+
* @property {number} [x] slide to here as it changes (frame px; default where it was)
|
|
563
|
+
* @property {number} [y]
|
|
564
|
+
*/
|
|
565
|
+
/**
|
|
566
|
+
* @typedef {object} ChipAt the chip at t
|
|
567
|
+
* @property {boolean} visible
|
|
568
|
+
* @property {number} x @property {number} y the anchor point in the frame
|
|
569
|
+
* @property {number} scale growing from a dot / shrinking back to one
|
|
570
|
+
* @property {number} scaleY 1, or less while retracting to a line
|
|
571
|
+
* @property {number} open 0 a circle … 1 the whole capsule (mode "open")
|
|
572
|
+
* @property {string} text what it shows
|
|
573
|
+
* @property {number} step which step's text (−1 before the first)
|
|
574
|
+
* @property {number} spin the icon's turn, degrees
|
|
575
|
+
* @property {number} ink how much of the text shows, 0..1 (less while the capsule is nearly shut)
|
|
576
|
+
*/
|
|
577
|
+
/** @typedef {{ x: number, y: number, w: number, h: number }} Box a rect of the frame, px */
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* A status chip: what the agent is doing now, in a few words ("Drafting the
|
|
581
|
+
* blueprint"), low on the screen in screen space. It grows from a dot
|
|
582
|
+
* (2 frames: Df-JzBcCrDo 19.79 s, a dot one frame, the circle the next),
|
|
583
|
+
* opens into a capsule with its text revealed from the middle out
|
|
584
|
+
* (6 frames, Df-JzBcCrDo 19.75–36.75 s), changes its text by closing
|
|
585
|
+
* and reopening, can slide across the frame as it changes (about 990 px in
|
|
586
|
+
* 7 frames there), and retracts — to a dot (exit "dot") or to a line
|
|
587
|
+
* (exit "line", about 10 frames). mode "type" types its text instead, as
|
|
588
|
+
* Dfj2vYxC1pE's chips do: about 125 characters a second in, deleted at about
|
|
589
|
+
* 110 a second out, the capsule following the text; a change, or `out`,
|
|
590
|
+
* deletes what is on screen then, typed in full or not.
|
|
591
|
+
* Dark glass, white semi-bold text 0.04 of the short side (the films:
|
|
592
|
+
* 0.03–0.05 H), a turning asterisk in the film's accent (the text's colour
|
|
593
|
+
* with none); colours and size are options.
|
|
594
|
+
* While the capsule closes and opens, the text's ends fade into the glass
|
|
595
|
+
* about a letter's width inside its edge, so a frame caught in the 6 frames
|
|
596
|
+
* of a change shows words thinning out toward the ends, never a letter cut
|
|
597
|
+
* through by the capsule's edge (`at(t).ink` is how much of the text shows).
|
|
598
|
+
* `avoid`: rects of the frame the chip keeps clear of — the product's
|
|
599
|
+
* buttons, the line being read, a face: [{ x, y, w, h }], or a function of t
|
|
600
|
+
* giving them (null entries skipped). For each step, at that step's time,
|
|
601
|
+
* the chip takes its own place if it is clear by `gap` px; else the first
|
|
602
|
+
* clear one of: low left, low right, low middle, high left, high right, high
|
|
603
|
+
* middle (0.035 W in, 0.9 H or 0.1 H); else the one that covers least. It
|
|
604
|
+
* slides there as it changes (7 frames), and stays until its next step, so
|
|
605
|
+
* it never wanders mid-sentence. Its width is reckoned from its text (0.58
|
|
606
|
+
* of the size a character), not read from the page, so the same t gives the
|
|
607
|
+
* same place with or without one; a function reading the page's layout is
|
|
608
|
+
* read for the step's time only if the page is drawn at it — give numbers,
|
|
609
|
+
* or compute them from t. A step with its own x or y goes where it says.
|
|
610
|
+
* @param {HTMLElement | null} host
|
|
611
|
+
* @param {{ steps?: ChipStep[], t?: number, text?: string, out?: number, x?: number, y?: number,
|
|
612
|
+
* anchor?: "left" | "center" | "right", mode?: "open" | "type", exit?: "dot" | "line",
|
|
613
|
+
* size?: number, icon?: boolean, bg?: string, colour?: string, accent?: string, font?: string, frame?: Frame,
|
|
614
|
+
* avoid?: (Box | null)[] | ((t: number) => (Box | null)[]), gap?: number }} o
|
|
615
|
+
* steps: [{ t, text, x?, y? }] in time order (or t and text for one); out: when it retracts;
|
|
616
|
+
* x, y: its anchor (default 0.035 W, 0.9 H, its left end); anchor: which end of it x is;
|
|
617
|
+
* gap: how far it keeps from what it avoids (default 0.3 of its height)
|
|
618
|
+
*/
|
|
619
|
+
export function chip(host, o) {
|
|
620
|
+
const steps = o.steps ?? [{ t: o.t ?? 0, text: o.text ?? "" }];
|
|
621
|
+
const first = steps[0];
|
|
622
|
+
if (!first) throw new Error("hud.chip: give it steps [{ t, text }] or t and text");
|
|
623
|
+
const mode = o.mode ?? "open";
|
|
624
|
+
const exitKind = o.exit ?? "dot";
|
|
625
|
+
const anchor = o.anchor ?? "left";
|
|
626
|
+
const geo = later(o.frame, (fr) => {
|
|
627
|
+
const size = o.size ?? Math.round(0.04 * short(fr));
|
|
628
|
+
return { fr, size, h: Math.round(size * 1.9), x0: o.x ?? Math.round(0.035 * fr.width), y0: o.y ?? Math.round(0.9 * fr.height) };
|
|
629
|
+
});
|
|
630
|
+
const grow = 2 * F; // dot → circle (Df-JzBcCrDo 19.79 s)
|
|
631
|
+
const openDur = 6 * F; // text from the middle out (Df-JzBcCrDo)
|
|
632
|
+
const closeDur = 4 * F;
|
|
633
|
+
const shrink = 3 * F; // circle → dot → gone
|
|
634
|
+
const lineDur = 10 * F; // retracting to a line (Df-JzBcCrDo)
|
|
635
|
+
const slide = 7 * F; // sliding across as it changes (Df-JzBcCrDo f544–551)
|
|
636
|
+
const typeCps = 125; // Dfj2vYxC1pE: in at ~125 characters a second
|
|
637
|
+
const delCps = 110; // out at ~110
|
|
638
|
+
|
|
639
|
+
/** the chip's width with `text` in it, reckoned (no page needed) @param {string} text @param {number} size @param {number} h */
|
|
640
|
+
const widthOf = (text, size, h) =>
|
|
641
|
+
Math.round(h * 0.72 + (o.icon === false ? 0 : size * 1.35) + 0.58 * size * glyphs(text).length);
|
|
642
|
+
/** how much of box a the rect b covers, px² @param {Box} a @param {Box} b */
|
|
643
|
+
const overlap = (a, b) =>
|
|
644
|
+
Math.max(0, Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x)) * Math.max(0, Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y));
|
|
645
|
+
/** where step i sits when it keeps clear of `avoid`: its anchor point, or null to stay where the chip is
|
|
646
|
+
* @param {number} i @returns {Pt | null} */
|
|
647
|
+
const clearOf = (i) => {
|
|
648
|
+
if (!o.avoid) return null;
|
|
649
|
+
const st = /** @type {ChipStep} */ (steps[i]);
|
|
650
|
+
const { fr, size, h, x0, y0 } = geo();
|
|
651
|
+
const rects = /** @type {Box[]} */ ((typeof o.avoid === "function" ? o.avoid(st.t) : o.avoid).filter(Boolean));
|
|
652
|
+
const w = widthOf(st.text, size, h);
|
|
653
|
+
const gap = o.gap ?? Math.round(0.3 * h);
|
|
654
|
+
const left = (/** @type {number} */ ax) => (anchor === "left" ? ax : anchor === "center" ? ax - w / 2 : ax - w);
|
|
655
|
+
const mx = Math.round(0.035 * fr.width);
|
|
656
|
+
const lo = Math.round(0.9 * fr.height), hi = Math.round(0.1 * fr.height);
|
|
657
|
+
/** @type {[number, number][]} the box's left and its middle line: its own place, then the six */
|
|
658
|
+
const spots = [[left(x0), y0], [mx, lo], [fr.width - mx - w, lo], [(fr.width - w) / 2, lo], [mx, hi], [fr.width - mx - w, hi], [(fr.width - w) / 2, hi]];
|
|
659
|
+
let best = /** @type {[number, number]} */ (spots[0]);
|
|
660
|
+
let least = Infinity;
|
|
661
|
+
for (const sp of spots) {
|
|
662
|
+
const grown = { x: sp[0] - gap, y: sp[1] - h / 2 - gap, w: w + 2 * gap, h: h + 2 * gap };
|
|
663
|
+
const covered = rects.reduce((sum, r) => sum + overlap(grown, r), 0);
|
|
664
|
+
if (covered < least) {
|
|
665
|
+
least = covered;
|
|
666
|
+
best = sp;
|
|
667
|
+
}
|
|
668
|
+
if (covered === 0) break;
|
|
669
|
+
}
|
|
670
|
+
return [anchor === "left" ? best[0] : anchor === "center" ? best[0] + w / 2 : best[0] + w, best[1]];
|
|
671
|
+
};
|
|
672
|
+
/** where it is at t: each step's slide from the place before @param {number} t @returns {Pt} */
|
|
673
|
+
const place = (t) => {
|
|
674
|
+
let { x0: x, y0: y } = geo();
|
|
675
|
+
for (let i = 0; i < steps.length; i++) {
|
|
676
|
+
const s = /** @type {ChipStep} */ (steps[i]);
|
|
677
|
+
if (!on(t, s.t)) break;
|
|
678
|
+
const clear = s.x == null && s.y == null ? clearOf(i) : null;
|
|
679
|
+
// it first shows where it is clear; later steps slide there
|
|
680
|
+
const u = clear && i === 0 ? 1 : out3(prog(t, s.t, s.t + slide));
|
|
681
|
+
x = lerp(x, s.x ?? clear?.[0] ?? x, u);
|
|
682
|
+
y = lerp(y, s.y ?? clear?.[1] ?? y, u);
|
|
683
|
+
}
|
|
684
|
+
return [x, y];
|
|
685
|
+
};
|
|
686
|
+
/** the step current at t @param {number} t */
|
|
687
|
+
const stepAt = (t) => {
|
|
688
|
+
let i = 0;
|
|
689
|
+
while (i + 1 < steps.length && on(t, /** @type {ChipStep} */ (steps[i + 1]).t)) i++;
|
|
690
|
+
return i;
|
|
691
|
+
};
|
|
692
|
+
/** mode "type": the text on screen at t while step i is current — what was there at the change deleted, then the new text typed
|
|
693
|
+
* @param {number} t @param {number} i @returns {string} */
|
|
694
|
+
const typed = (t, i) => {
|
|
695
|
+
const cur = /** @type {ChipStep} */ (steps[i]);
|
|
696
|
+
const text = glyphs(cur.text);
|
|
697
|
+
if (i === 0) return text.slice(0, count(Math.max(0, t - first.t - grow), 1 / typeCps)).join("");
|
|
698
|
+
const was = glyphs(typed(cur.t, i - 1));
|
|
699
|
+
const left = was.length - count(t - cur.t, 1 / delCps);
|
|
700
|
+
if (left > 0) return was.slice(0, left).join("");
|
|
701
|
+
const gone = cur.t + was.length / delCps;
|
|
702
|
+
return text.slice(0, count(Math.max(0, t - gone), 1 / typeCps)).join("");
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
/** @param {number} t @returns {ChipAt} */
|
|
706
|
+
const at = (t) => {
|
|
707
|
+
const a = shape(t);
|
|
708
|
+
// the text shows in full once the capsule has opened past its fading ends (about a third of the way)
|
|
709
|
+
return { ...a, ink: !a.visible ? 0 : mode === "type" ? 1 : clamp01(a.open / 0.35) };
|
|
710
|
+
};
|
|
711
|
+
/** @param {number} t @returns {Omit<ChipAt, "ink">} */
|
|
712
|
+
const shape = (t) => {
|
|
713
|
+
const [x, y] = place(t);
|
|
714
|
+
const spin = (t * 300) % 360;
|
|
715
|
+
const none = { visible: false, x, y, scale: 0, scaleY: 1, open: 0, text: "", step: -1, spin };
|
|
716
|
+
if (!on(t, first.t)) return none;
|
|
717
|
+
const i = stepAt(t);
|
|
718
|
+
const cur = /** @type {ChipStep} */ (steps[i]);
|
|
719
|
+
const prev = steps[i - 1];
|
|
720
|
+
const out = o.out ?? Infinity;
|
|
721
|
+
const scale = out2(prog(t, first.t, first.t + grow));
|
|
722
|
+
if (mode === "type") {
|
|
723
|
+
if (on(t, out)) {
|
|
724
|
+
// what is on screen at `out` is deleted, then the circle shrinks away
|
|
725
|
+
const iOut = stepAt(out);
|
|
726
|
+
const shown = glyphs(typed(out, iOut));
|
|
727
|
+
const left = Math.max(0, shown.length - count(t - out, 1 / delCps));
|
|
728
|
+
const empty = out + shown.length / delCps;
|
|
729
|
+
if (on(t, empty + shrink)) return none;
|
|
730
|
+
return { visible: true, x, y, scale: 1 - in2(prog(t, empty, empty + shrink)), scaleY: 1, open: 1, text: shown.slice(0, left).join(""), step: iOut, spin };
|
|
731
|
+
}
|
|
732
|
+
return { visible: true, x, y, scale, scaleY: 1, open: 1, text: typed(t, i), step: i, spin };
|
|
733
|
+
}
|
|
734
|
+
// "open": the capsule opens from the middle, the text uncovered with it
|
|
735
|
+
let open;
|
|
736
|
+
let text = cur.text;
|
|
737
|
+
let step = i;
|
|
738
|
+
if (i === 0) open = out3(prog(t, first.t + grow, first.t + grow + openDur));
|
|
739
|
+
else if (!on(t, cur.t + closeDur)) {
|
|
740
|
+
open = 1 - in2(prog(t, cur.t, cur.t + closeDur));
|
|
741
|
+
text = /** @type {ChipStep} */ (prev).text;
|
|
742
|
+
step = i - 1;
|
|
743
|
+
} else open = out3(prog(t, cur.t + closeDur, cur.t + closeDur + openDur));
|
|
744
|
+
if (on(t, out)) {
|
|
745
|
+
if (exitKind === "line") {
|
|
746
|
+
if (on(t, out + lineDur)) return none;
|
|
747
|
+
return { visible: true, x, y, scale, scaleY: lerp(1, 0.06, in3(prog(t, out, out + lineDur))), open, text, step, spin };
|
|
748
|
+
}
|
|
749
|
+
const shut = open * (1 - in2(prog(t, out, out + closeDur)));
|
|
750
|
+
if (on(t, out + closeDur + shrink)) return none;
|
|
751
|
+
return {
|
|
752
|
+
visible: true, x, y,
|
|
753
|
+
scale: scale * (1 - in2(prog(t, out + closeDur, out + closeDur + shrink))),
|
|
754
|
+
scaleY: 1, open: shut, text, step, spin,
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
return { visible: true, x, y, scale, scaleY: 1, open, text, step, spin };
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
if (!host || typeof document === "undefined") return { el: null, at, draw: at };
|
|
761
|
+
styles();
|
|
762
|
+
const el = mk("div", "hud-chip", host);
|
|
763
|
+
el.style.visibility = "hidden";
|
|
764
|
+
const icon = o.icon === false ? null : mk("span", "", el);
|
|
765
|
+
const label = mk("span", "", el);
|
|
766
|
+
/** @type {unknown} */
|
|
767
|
+
let builtFor = null;
|
|
768
|
+
let shown = "";
|
|
769
|
+
/** @param {number} t */
|
|
770
|
+
const draw = (t) => {
|
|
771
|
+
const g = geo();
|
|
772
|
+
if (builtFor !== g) {
|
|
773
|
+
builtFor = g;
|
|
774
|
+
fit(host, g.fr);
|
|
775
|
+
Object.assign(el.style, {
|
|
776
|
+
height: `${g.h}px`,
|
|
777
|
+
padding: `0 ${Math.round(g.h * 0.42)}px 0 ${Math.round(g.h * 0.3)}px`,
|
|
778
|
+
gap: `${Math.round(g.size * 0.4)}px`,
|
|
779
|
+
background: o.bg ?? "rgba(22, 22, 28, 0.78)",
|
|
780
|
+
color: o.colour ?? "#ffffff",
|
|
781
|
+
fontFamily: o.font ?? FONT,
|
|
782
|
+
fontSize: `${g.size}px`,
|
|
783
|
+
backdropFilter: "blur(14px) saturate(1.3)",
|
|
784
|
+
boxShadow: "inset 0 0 0 1px rgba(255,255,255,0.12), 0 6px 24px rgba(0,0,0,0.25)",
|
|
785
|
+
});
|
|
786
|
+
if (icon) {
|
|
787
|
+
icon.innerHTML = star(Math.round(g.size * 0.95), o.accent ?? accentOf(host) ?? o.colour ?? "#ffffff");
|
|
788
|
+
icon.style.display = "flex";
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
const { h } = g;
|
|
792
|
+
const a = at(t);
|
|
793
|
+
// shown as its layer is: a layer put inside a scene is hidden with that scene
|
|
794
|
+
el.style.visibility = a.visible ? "inherit" : "hidden";
|
|
795
|
+
if (!a.visible) return a;
|
|
796
|
+
if (a.text !== shown) label.textContent = shown = a.text;
|
|
797
|
+
label.style.display = a.text ? "" : "none";
|
|
798
|
+
if (icon) icon.style.transform = `rotate(${r1(a.spin)}deg)`;
|
|
799
|
+
const w = el.offsetWidth;
|
|
800
|
+
const ox = anchor === "left" ? 0 : anchor === "center" ? w / 2 : w;
|
|
801
|
+
// mode "open" grows about its middle, "type" about its circle at the left
|
|
802
|
+
const origin = mode === "open" ? "50% 50%" : `${h / 2}px 50%`;
|
|
803
|
+
el.style.transformOrigin = origin;
|
|
804
|
+
el.style.transform = `translate(${r1(a.x - ox)}px, ${r1(a.y - h / 2)}px) scale(${a.scale.toFixed(4)}, ${(a.scale * a.scaleY).toFixed(4)})`;
|
|
805
|
+
const shut = mode === "open" && a.open < 1;
|
|
806
|
+
el.style.clipPath = shut ? `inset(0 calc((100% - ${h}px) * ${((1 - a.open) / 2).toFixed(4)}) round ${h / 2}px)` : "";
|
|
807
|
+
// the text's ends fade into the glass inside the capsule's closing ends: no letter is cut by its edge
|
|
808
|
+
let mask = "";
|
|
809
|
+
if (shut && a.text) {
|
|
810
|
+
const cut = ((w - h) * (1 - a.open)) / 2;
|
|
811
|
+
const soft = g.size * 1.1;
|
|
812
|
+
const l0 = cut + h * 0.15 - label.offsetLeft;
|
|
813
|
+
const r0 = w - cut - h * 0.15 - label.offsetLeft;
|
|
814
|
+
const full = clamp01((r0 - l0) / (2 * soft));
|
|
815
|
+
mask =
|
|
816
|
+
full >= 1
|
|
817
|
+
? `linear-gradient(90deg, transparent ${r1(l0)}px, #000 ${r1(l0 + soft)}px, #000 ${r1(r0 - soft)}px, transparent ${r1(r0)}px)`
|
|
818
|
+
: `linear-gradient(90deg, transparent ${r1(l0)}px, rgba(0,0,0,${full.toFixed(3)}) ${r1((l0 + r0) / 2)}px, transparent ${r1(Math.max(l0, r0))}px)`;
|
|
819
|
+
}
|
|
820
|
+
label.style.maskImage = mask;
|
|
821
|
+
label.style.webkitMaskImage = mask;
|
|
822
|
+
return a;
|
|
823
|
+
};
|
|
824
|
+
return { el, at, draw };
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// --- counter ------------------------------------------------------------------
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Minutes since midnight as a clock reads them: `clock(1122)` → "6:42 PM",
|
|
831
|
+
* `clock(1122, { h24: true })` → "18:42". For a counter's field, whose value
|
|
832
|
+
* can then run from one time to the next.
|
|
833
|
+
* @param {number} minutes @param {{ h24?: boolean }} [o]
|
|
834
|
+
*/
|
|
835
|
+
export function clock(minutes, o = {}) {
|
|
836
|
+
const m = ((Math.round(minutes) % 1440) + 1440) % 1440;
|
|
837
|
+
const h = Math.floor(m / 60);
|
|
838
|
+
const mm = String(m % 60).padStart(2, "0");
|
|
839
|
+
if (o.h24) return `${String(h).padStart(2, "0")}:${mm}`;
|
|
840
|
+
return `${h % 12 === 0 ? 12 : h % 12}:${mm} ${h < 12 ? "AM" : "PM"}`;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* @typedef {object} CounterField one part of a counter
|
|
845
|
+
* @property {{ t: number, text?: string, value?: number }[]} steps what it says from each t: a text, or a
|
|
846
|
+
* number for `format`
|
|
847
|
+
* @property {(n: number) => string} [format] a value as text (default the number itself)
|
|
848
|
+
* @property {number} [run] seconds a value takes to run to the next (default 0: it changes at once)
|
|
849
|
+
*/
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* A count or a clock kept on screen — "6:42 PM · 0 of 3 checks" — that
|
|
853
|
+
* changes in place: the film's own measure of how far along it is, in a
|
|
854
|
+
* corner, through every cut. `fields` sit side by side with `sep` between;
|
|
855
|
+
* each has its own steps, so the clock can move on while the count stays.
|
|
856
|
+
* When a field changes, only the characters that differ move — the old one
|
|
857
|
+
* up and out, the new one up and in, 4 frames — and the rest stand still
|
|
858
|
+
* (digits are set at one width, so nothing beside them shifts); a text of a
|
|
859
|
+
* different length changes as a whole. A number with `run` counts to its
|
|
860
|
+
* next value over that many seconds, a new figure every 2 frames (the step
|
|
861
|
+
* the detection box's count was measured at), fast then slowing.
|
|
862
|
+
* A status chip closes and reopens its whole capsule to change, which is
|
|
863
|
+
* right for a sentence and wrong for a number that ticks: this is for the
|
|
864
|
+
* number. Not measured on the films, which keep their counts inside the
|
|
865
|
+
* product's own interface; the capsule and its 2-frame growth are the
|
|
866
|
+
* chip's, top right by default (0.965 W, 0.1 H, its right end) where the
|
|
867
|
+
* chip is low left. `bg: "none"` drops the glass and takes the ink from the
|
|
868
|
+
* scene under it.
|
|
869
|
+
* `counter(hud, { fields: [{ steps: [{ t: 1.6, value: 18 * 60 + 42 }, { t: 6.5, value: 21 * 60 + 15 }], format: clock, run: 0.5 },
|
|
870
|
+
* { steps: [{ t: 1.6, value: 0 }, { t: 8, value: 1 }], format: (n) => `${n} of 3 checks` }], out: 35 })`
|
|
871
|
+
* @param {HTMLElement | null} host
|
|
872
|
+
* @param {{ fields: CounterField[], sep?: string, t?: number, out?: number, x?: number, y?: number,
|
|
873
|
+
* anchor?: "left" | "center" | "right", size?: number, roll?: number, bg?: string, colour?: string,
|
|
874
|
+
* font?: string, frame?: Frame }} o
|
|
875
|
+
* t: when it appears (default its earliest step); out: when it goes (4 frames); x, y: its anchor;
|
|
876
|
+
* anchor: which end of it x is (default "right"); size: text px (default 0.036 of the short side);
|
|
877
|
+
* roll: seconds a changed character takes (default 4 frames of 24)
|
|
878
|
+
*/
|
|
879
|
+
export function counter(host, o) {
|
|
880
|
+
if (!o.fields?.length || o.fields.some((f) => !f.steps?.length))
|
|
881
|
+
throw new Error("hud.counter: give it fields [{ steps: [{ t, text }] }] (or { t, value } with a format)");
|
|
882
|
+
const sep = o.sep ?? " · ";
|
|
883
|
+
const roll = o.roll ?? 4 * F;
|
|
884
|
+
const anchor = o.anchor ?? "right";
|
|
885
|
+
const t0 = o.t ?? Math.min(...o.fields.map((f) => /** @type {{ t: number }} */ (f.steps[0]).t));
|
|
886
|
+
const grow = 2 * F;
|
|
887
|
+
const fade = 4 * F;
|
|
888
|
+
const geo = later(o.frame, (fr) => {
|
|
889
|
+
const size = o.size ?? Math.round(0.036 * short(fr));
|
|
890
|
+
return { fr, size, h: Math.round(size * 1.9), x: o.x ?? Math.round(0.965 * fr.width), y: o.y ?? Math.round(0.1 * fr.height) };
|
|
891
|
+
});
|
|
892
|
+
/** what a step says, its value shown as `v` @param {CounterField} f @param {{ text?: string, value?: number }} st @param {number} [v] */
|
|
893
|
+
const say = (f, st, v) => (st.value != null ? (f.format ? f.format(v ?? st.value) : String(v ?? st.value)) : (st.text ?? ""));
|
|
894
|
+
/** one field at t @param {CounterField} f @param {number} t */
|
|
895
|
+
const fieldAt = (f, t) => {
|
|
896
|
+
let i = -1;
|
|
897
|
+
while (i + 1 < f.steps.length && on(t, /** @type {{ t: number }} */ (f.steps[i + 1]).t)) i++;
|
|
898
|
+
if (i < 0) return { text: "", was: "", p: 1, step: -1 };
|
|
899
|
+
const cur = /** @type {{ t: number, text?: string, value?: number }} */ (f.steps[i]);
|
|
900
|
+
const prev = f.steps[i - 1];
|
|
901
|
+
const run = f.run ?? 0;
|
|
902
|
+
if (prev && run > 0 && cur.value != null && prev.value != null) {
|
|
903
|
+
// a new figure every 2 frames, the last on the frame the run ends
|
|
904
|
+
const n = Math.max(1, Math.round(run / (2 * F)));
|
|
905
|
+
const k = Math.min(n, count(t - cur.t, 2 * F) + 1);
|
|
906
|
+
return { text: say(f, cur, Math.round(lerp(prev.value, cur.value, out2(k / n)))), was: "", p: 1, step: i };
|
|
907
|
+
}
|
|
908
|
+
return { text: say(f, cur), was: prev ? say(f, prev) : "", p: prev ? out2(prog(t, cur.t, cur.t + roll)) : 1, step: i };
|
|
909
|
+
};
|
|
910
|
+
/** @param {number} t */
|
|
911
|
+
const at = (t) => {
|
|
912
|
+
const { x, y } = geo();
|
|
913
|
+
const out = o.out ?? Infinity;
|
|
914
|
+
const fields = o.fields.map((f) => fieldAt(f, t));
|
|
915
|
+
const shown = fields.filter((f) => f.step >= 0);
|
|
916
|
+
return {
|
|
917
|
+
visible: on(t, t0) && !on(t, out + fade) && shown.length > 0,
|
|
918
|
+
x,
|
|
919
|
+
y,
|
|
920
|
+
scale: out2(prog(t, t0, t0 + grow)),
|
|
921
|
+
opacity: 1 - prog(t, out, out + fade),
|
|
922
|
+
text: shown.map((f) => f.text).join(sep),
|
|
923
|
+
fields,
|
|
924
|
+
};
|
|
925
|
+
};
|
|
926
|
+
if (!host || typeof document === "undefined") return { el: null, at, draw: at };
|
|
927
|
+
styles();
|
|
928
|
+
const el = mk("div", "hud-counter", host);
|
|
929
|
+
el.style.visibility = "hidden";
|
|
930
|
+
const plain = o.bg === "none";
|
|
931
|
+
/** @type {unknown} */
|
|
932
|
+
let builtFor = null;
|
|
933
|
+
let lastHtml = "";
|
|
934
|
+
/** @param {number} t */
|
|
935
|
+
const draw = (t) => {
|
|
936
|
+
const g = geo();
|
|
937
|
+
if (builtFor !== g) {
|
|
938
|
+
builtFor = g;
|
|
939
|
+
fit(host, g.fr);
|
|
940
|
+
Object.assign(el.style, { height: `${g.h}px`, fontFamily: o.font ?? FONT, fontSize: `${g.size}px` });
|
|
941
|
+
if (!plain)
|
|
942
|
+
Object.assign(el.style, {
|
|
943
|
+
padding: `0 ${Math.round(g.h * 0.42)}px`,
|
|
944
|
+
background: o.bg ?? "rgba(22, 22, 28, 0.78)",
|
|
945
|
+
color: o.colour ?? "#ffffff",
|
|
946
|
+
backdropFilter: "blur(14px) saturate(1.3)",
|
|
947
|
+
boxShadow: "inset 0 0 0 1px rgba(255,255,255,0.12), 0 6px 24px rgba(0,0,0,0.25)",
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
const a = at(t);
|
|
951
|
+
el.style.visibility = a.visible ? "inherit" : "hidden";
|
|
952
|
+
if (!a.visible) return a;
|
|
953
|
+
let html = "";
|
|
954
|
+
for (const f of a.fields) {
|
|
955
|
+
if (f.step < 0) continue;
|
|
956
|
+
if (html) html += esc(sep);
|
|
957
|
+
const now = glyphs(f.text);
|
|
958
|
+
const was = glyphs(f.was);
|
|
959
|
+
const rolling = f.p < 1;
|
|
960
|
+
// the same length: each character that differs changes on its own; else the field as a whole
|
|
961
|
+
const each = rolling && was.length === now.length;
|
|
962
|
+
/** one moving character over the one it replaces @param {string} neu @param {string} old */
|
|
963
|
+
const cell = (neu, old, whole = false) =>
|
|
964
|
+
`<span class="hud-cell${whole ? " hud-whole" : ""}"><b style="opacity:${(1 - f.p).toFixed(3)};transform:translateY(${(-0.35 * f.p).toFixed(3)}em)">${esc(old)}</b>` +
|
|
965
|
+
`<span style="opacity:${f.p.toFixed(3)};transform:translateY(${(0.35 * (1 - f.p)).toFixed(3)}em)">${esc(neu)}</span></span>`;
|
|
966
|
+
if (!rolling) html += esc(f.text);
|
|
967
|
+
else if (each) html += now.map((c, i) => (c === was[i] ? esc(c) : cell(c, was[i] ?? ""))).join("");
|
|
968
|
+
else html += cell(f.text, f.was, true);
|
|
969
|
+
}
|
|
970
|
+
if (html !== lastHtml) el.innerHTML = lastHtml = html;
|
|
971
|
+
if (plain) {
|
|
972
|
+
const { ink, shadow } = o.colour ? { ink: o.colour, shadow: "none" } : inkFor(sceneBehind([el]));
|
|
973
|
+
el.style.color = ink;
|
|
974
|
+
el.style.textShadow = shadow;
|
|
975
|
+
}
|
|
976
|
+
el.style.opacity = String(r1(a.opacity * 100) / 100);
|
|
977
|
+
const w = el.offsetWidth;
|
|
978
|
+
const ox = anchor === "left" ? 0 : anchor === "center" ? w / 2 : w;
|
|
979
|
+
el.style.transformOrigin = anchor === "left" ? "0 50%" : anchor === "center" ? "50% 50%" : "100% 50%";
|
|
980
|
+
el.style.transform = `translate(${r1(a.x - ox)}px, ${r1(a.y - g.h / 2)}px) scale(${a.scale.toFixed(4)})`;
|
|
981
|
+
return a;
|
|
982
|
+
};
|
|
983
|
+
return { el, at, draw };
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
// --- status line --------------------------------------------------------------
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* A status line: one to three lines of what is happening, each swept in left
|
|
990
|
+
* to right under a soft-edged mask while the block rises into place, the
|
|
991
|
+
* fresh ink behind the sweep's edge settling to the ink colour (the film's
|
|
992
|
+
* went yellow → pink → magenta, its own colours; here a light tone of the
|
|
993
|
+
* layer's accent, the accent, a deep tone of it — or `fresh`, three colours
|
|
994
|
+
* — and with no accent the ink itself, faint at the edge and filling); then still,
|
|
995
|
+
* a grey shimmer passing over it while it "thinks", and out by drifting up
|
|
996
|
+
* faster and faster. opus55-monster-truck shot 5: line 1 swept 9.17–9.38 s,
|
|
997
|
+
* line 2 9.38–9.63 s, the block up 175 px over 0.62 s (ease-out), the shimmer
|
|
998
|
+
* 1 s left to right; shot 14 leaves upward, fading in its last 2 frames.
|
|
999
|
+
* The ink is dark on a light scene (the film's own, white) and light on a
|
|
1000
|
+
* dark one, read from the scene under it, unless `ink` says.
|
|
1001
|
+
* @param {HTMLElement | null} host
|
|
1002
|
+
* @param {{ lines: string[], t: number, x?: number, y?: number, size?: number, sweep?: number,
|
|
1003
|
+
* rise?: number, out?: number, exitDy?: number, exitDur?: number, shimmer?: [number, number],
|
|
1004
|
+
* ink?: string, fresh?: [string, string, string], shimmerColour?: string, icon?: boolean,
|
|
1005
|
+
* accent?: string, weight?: number, font?: string, frame?: Frame }} o
|
|
1006
|
+
* x, y: the block's top-left at rest, its icon first and the lines after it (default 0.1 W,
|
|
1007
|
+
* 0.42 H); size: text px (default 0.048 of the short side, smaller if a line would run past
|
|
1008
|
+
* the frame's right edge); sweep: seconds a line takes (default 0.23); out: when it leaves
|
|
1009
|
+
*/
|
|
1010
|
+
export function statusLine(host, o) {
|
|
1011
|
+
const sweep = o.sweep ?? 0.23;
|
|
1012
|
+
const exitDur = o.exitDur ?? 0.87;
|
|
1013
|
+
const settle = 0.6;
|
|
1014
|
+
const geo = later(o.frame, (fr) => ({
|
|
1015
|
+
fr,
|
|
1016
|
+
size: o.size ?? Math.round(0.048 * short(fr)),
|
|
1017
|
+
rise: o.rise ?? Math.round(0.162 * short(fr)),
|
|
1018
|
+
exitDy: o.exitDy ?? Math.round(0.064 * short(fr)),
|
|
1019
|
+
x: o.x ?? Math.round(0.1 * fr.width),
|
|
1020
|
+
y: o.y ?? Math.round(0.42 * fr.height),
|
|
1021
|
+
}));
|
|
1022
|
+
|
|
1023
|
+
/** @param {number} t */
|
|
1024
|
+
const at = (t) => {
|
|
1025
|
+
const { x, y, rise, exitDy } = geo();
|
|
1026
|
+
const out = o.out ?? Infinity;
|
|
1027
|
+
const visible = on(t, o.t) && !on(t, out + exitDur);
|
|
1028
|
+
const lift = rise * (1 - out3(prog(t, o.t, o.t + 0.62)));
|
|
1029
|
+
const e = in3(prog(t, out, out + exitDur));
|
|
1030
|
+
const lines = o.lines.map((_, i) => {
|
|
1031
|
+
const s = o.t + i * sweep;
|
|
1032
|
+
return { p: out3(prog(t, s, s + sweep)), cool: prog(t, s + sweep, s + sweep + settle) };
|
|
1033
|
+
});
|
|
1034
|
+
const sh = o.shimmer ? prog(t, o.shimmer[0], o.shimmer[1]) : 0;
|
|
1035
|
+
const shimmer = o.shimmer && on(t, o.shimmer[0]) && !on(t, o.shimmer[1]) ? sh : null;
|
|
1036
|
+
return {
|
|
1037
|
+
visible,
|
|
1038
|
+
x,
|
|
1039
|
+
y: y + lift - exitDy * e,
|
|
1040
|
+
opacity: !on(t, out) ? 1 : 1 - prog(t, out + exitDur - 2 * F, out + exitDur),
|
|
1041
|
+
lines,
|
|
1042
|
+
shimmer,
|
|
1043
|
+
};
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
if (!host || typeof document === "undefined") return { el: null, at, draw: at };
|
|
1047
|
+
styles();
|
|
1048
|
+
const el = mk("div", "hud-status", host);
|
|
1049
|
+
el.style.visibility = "hidden";
|
|
1050
|
+
el.style.fontFamily = o.font ?? FONT;
|
|
1051
|
+
el.style.fontWeight = String(o.weight ?? 600);
|
|
1052
|
+
const ic = o.icon === false ? null : mk("div", "", el);
|
|
1053
|
+
const lineEls = o.lines.map((text) => {
|
|
1054
|
+
const l = mk("div", "hud-line", el);
|
|
1055
|
+
l.textContent = text;
|
|
1056
|
+
return l;
|
|
1057
|
+
});
|
|
1058
|
+
/** @param {number} size */
|
|
1059
|
+
const lay = (size) => {
|
|
1060
|
+
el.style.fontSize = `${size}px`;
|
|
1061
|
+
const lead = ic ? Math.round(size * 1.5) : 0;
|
|
1062
|
+
if (ic) {
|
|
1063
|
+
ic.innerHTML = star(Math.round(size * 1.05), mark);
|
|
1064
|
+
Object.assign(ic.style, { position: "absolute", left: "0px", top: `${Math.round(size * 0.08)}px` });
|
|
1065
|
+
}
|
|
1066
|
+
lineEls.forEach((l, i) => {
|
|
1067
|
+
l.style.left = `${lead}px`;
|
|
1068
|
+
l.style.top = `${Math.round(i * size * 1.2)}px`;
|
|
1069
|
+
});
|
|
1070
|
+
return lead;
|
|
1071
|
+
};
|
|
1072
|
+
/** @type {unknown} */
|
|
1073
|
+
let builtFor = null;
|
|
1074
|
+
/** the layer's accent, read when first drawn @type {string | null} */
|
|
1075
|
+
let accent = null;
|
|
1076
|
+
let mark = o.accent ?? "currentColor";
|
|
1077
|
+
/** @param {number} t */
|
|
1078
|
+
const draw = (t) => {
|
|
1079
|
+
const g = geo();
|
|
1080
|
+
if (builtFor !== g) {
|
|
1081
|
+
builtFor = g;
|
|
1082
|
+
fit(host, g.fr);
|
|
1083
|
+
accent = o.accent ?? accentOf(host);
|
|
1084
|
+
let lead = lay(g.size);
|
|
1085
|
+
if (o.size == null) {
|
|
1086
|
+
// made smaller until its longest line ends inside the frame (an upright film's narrow width)
|
|
1087
|
+
const room = g.fr.width * 0.95 - g.x;
|
|
1088
|
+
const wide = lead + Math.max(0, ...lineEls.map((l) => l.scrollWidth));
|
|
1089
|
+
if (wide > room && room > 0) lead = lay(Math.max(8, Math.floor((g.size * room) / wide)));
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
const a = at(t);
|
|
1093
|
+
el.style.visibility = a.visible ? "inherit" : "hidden";
|
|
1094
|
+
if (!a.visible) return a;
|
|
1095
|
+
el.style.transform = `translate(${r1(a.x)}px, ${r1(a.y)}px)`;
|
|
1096
|
+
el.style.opacity = String(r1(a.opacity * 100) / 100);
|
|
1097
|
+
const scene = o.ink ? null : sceneBehind(lineEls);
|
|
1098
|
+
const { ink, shadow } = o.ink ? { ink: o.ink, shadow: "none" } : inkFor(scene);
|
|
1099
|
+
el.style.filter = shadow === "none" ? "" : "drop-shadow(0 1px 4px rgba(0,0,0,0.5))";
|
|
1100
|
+
// the fresh band, from the sweep's edge back: given, or the accent's tones, or the ink coming in faint
|
|
1101
|
+
const tone = accent ? tones(accent) : null;
|
|
1102
|
+
const [f1, f2, f3] = o.fresh ?? (tone ? [tone.light, tone.mid, tone.deep] : [faded(ink, 0.3), faded(ink, 0.55), faded(ink, 0.8)]);
|
|
1103
|
+
if (ic && mark !== (accent ?? ink)) {
|
|
1104
|
+
mark = accent ?? ink;
|
|
1105
|
+
lay(parseFloat(el.style.fontSize));
|
|
1106
|
+
}
|
|
1107
|
+
const shimmerColour = o.shimmerColour ?? (scene === "light" || o.ink ? "rgba(255,255,255,0.85)" : "rgba(110,110,122,0.9)");
|
|
1108
|
+
a.lines.forEach((ln, i) => {
|
|
1109
|
+
const l = /** @type {HTMLElement} */ (lineEls[i]);
|
|
1110
|
+
const edge = ln.p * 115;
|
|
1111
|
+
const mask = ln.p >= 1 ? "none" : `linear-gradient(90deg, #000 ${r1(edge - 15)}%, transparent ${r1(edge)}%)`;
|
|
1112
|
+
l.style.maskImage = mask;
|
|
1113
|
+
l.style.webkitMaskImage = mask;
|
|
1114
|
+
// the fresh band rides just behind the sweep's edge, then cools to ink
|
|
1115
|
+
const c3 = mix(f3, ink, ln.cool);
|
|
1116
|
+
const c2 = mix(f2, ink, ln.cool);
|
|
1117
|
+
const c1 = mix(f1, ink, ln.cool);
|
|
1118
|
+
const e = ln.p * 100;
|
|
1119
|
+
const fill = `linear-gradient(90deg, ${c3} ${r1(e - 45)}%, ${c2} ${r1(e - 20)}%, ${c1} ${r1(e)}%)`;
|
|
1120
|
+
const shine =
|
|
1121
|
+
a.shimmer == null
|
|
1122
|
+
? ""
|
|
1123
|
+
: `linear-gradient(90deg, transparent ${r1(a.shimmer * 130 - 30)}%, ${shimmerColour} ${r1(a.shimmer * 130 - 15)}%, transparent ${r1(a.shimmer * 130)}%), `;
|
|
1124
|
+
l.style.backgroundImage = shine + fill;
|
|
1125
|
+
});
|
|
1126
|
+
return a;
|
|
1127
|
+
};
|
|
1128
|
+
return { el, at, draw };
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
// --- voice --------------------------------------------------------------------
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* A voice: an orb that wakes, and a caption of what it says, word by word.
|
|
1135
|
+
* DdT1-vziRp3: the orb grows in 2 frames; each word turns grey → white in
|
|
1136
|
+
* 2 frames; words 3–16 frames apart, irregular, about 2.5 a second; the line
|
|
1137
|
+
* laid out at its final width from the start (no word pushes another); gone a
|
|
1138
|
+
* frame before the cut (`until`). The caption 0.06 of the short side, medium,
|
|
1139
|
+
* centred; the films hold it at 0.86–0.93 H where no chip is, and it sits at
|
|
1140
|
+
* 0.8 H here, above a chip's place, wrapping inside 0.86 W; the orb above it,
|
|
1141
|
+
* its bars moving as the words land. White on a dark scene, near black on a
|
|
1142
|
+
* light one (read from the scene under it), unless `colour` says. The orb is
|
|
1143
|
+
* the layer's accent (`orbColour` over it), grey with none.
|
|
1144
|
+
* `times`: each word's own time (from a voice track) in place of the drawn
|
|
1145
|
+
* gaps. `chars(t)` is how much of `text` has been said by t, so the next
|
|
1146
|
+
* shot's prompt box can carry the sentence on: prompt's `type.from`.
|
|
1147
|
+
* @param {HTMLElement | null} host
|
|
1148
|
+
* @param {{ t: number, text: string, times?: number[], until?: number, gaps?: [number, number],
|
|
1149
|
+
* seed?: number, x?: number, y?: number, size?: number, orb?: boolean, colour?: string,
|
|
1150
|
+
* grey?: string, orbColour?: string, font?: string, frame?: Frame }} o
|
|
1151
|
+
* t: when the orb wakes (the first word 0.2 s later unless `times`); x, y: the middle of the
|
|
1152
|
+
* caption's last line (default 0.5 W, 0.8 H)
|
|
1153
|
+
*/
|
|
1154
|
+
export function voice(host, o) {
|
|
1155
|
+
const words = o.text.split(/\s+/).filter(Boolean);
|
|
1156
|
+
const [g0, g1] = o.gaps ?? [3 * F, 16 * F];
|
|
1157
|
+
const seed = o.seed ?? 1;
|
|
1158
|
+
/** @type {number[]} */
|
|
1159
|
+
const times = [];
|
|
1160
|
+
for (let i = 0; i < words.length; i++) {
|
|
1161
|
+
const given = o.times?.[i];
|
|
1162
|
+
if (given != null) times.push(given);
|
|
1163
|
+
else times.push(i === 0 ? o.t + 0.2 : /** @type {number} */ (times[i - 1]) + lerp(g0, g1, hash(i, seed)));
|
|
1164
|
+
}
|
|
1165
|
+
const until = o.until ?? (times[times.length - 1] ?? o.t) + 1.2;
|
|
1166
|
+
const geo = later(o.frame, (fr) => ({
|
|
1167
|
+
fr,
|
|
1168
|
+
size: o.size ?? Math.round(0.06 * short(fr)),
|
|
1169
|
+
cx: o.x ?? fr.width / 2,
|
|
1170
|
+
cy: o.y ?? Math.round(0.8 * fr.height),
|
|
1171
|
+
}));
|
|
1172
|
+
const BARS = 5;
|
|
1173
|
+
|
|
1174
|
+
/** how many words are said by t @param {number} t */
|
|
1175
|
+
const said = (t) => {
|
|
1176
|
+
let k = 0;
|
|
1177
|
+
while (k < times.length && on(t, /** @type {number} */ (times[k]))) k++;
|
|
1178
|
+
return k;
|
|
1179
|
+
};
|
|
1180
|
+
/** the characters of `text` (spaces between words counted) said by t @param {number} t */
|
|
1181
|
+
const chars = (t) => {
|
|
1182
|
+
const k = said(t);
|
|
1183
|
+
return k === 0 ? 0 : glyphs(words.slice(0, k).join(" ")).length + (k < words.length ? 1 : 0);
|
|
1184
|
+
};
|
|
1185
|
+
|
|
1186
|
+
/** @param {number} t */
|
|
1187
|
+
const at = (t) => {
|
|
1188
|
+
const { cx, cy } = geo();
|
|
1189
|
+
const visible = on(t, o.t) && !on(t, until - F);
|
|
1190
|
+
const orb = out2(prog(t, o.t, o.t + 2 * F));
|
|
1191
|
+
// the bars: what was just said, decaying in 0.22 s, jittered 12 times a second
|
|
1192
|
+
let act = 0.12;
|
|
1193
|
+
for (const wt of times) if (on(t, wt)) act = Math.max(act, Math.exp(-Math.max(0, t - wt) / 0.22));
|
|
1194
|
+
const tick = Math.floor(t * 12 + EPS);
|
|
1195
|
+
const bars = Array.from({ length: BARS }, (_, j) => {
|
|
1196
|
+
const shape = 1 - Math.abs(j - (BARS - 1) / 2) / BARS;
|
|
1197
|
+
return r1((0.22 + 0.78 * act * shape * (0.45 + 0.55 * hash(tick, j + 7 * seed))) * 100) / 100;
|
|
1198
|
+
});
|
|
1199
|
+
return {
|
|
1200
|
+
visible,
|
|
1201
|
+
x: cx,
|
|
1202
|
+
y: cy,
|
|
1203
|
+
orb,
|
|
1204
|
+
bars,
|
|
1205
|
+
words: words.map((w, i) => {
|
|
1206
|
+
const wt = /** @type {number} */ (times[i]);
|
|
1207
|
+
return { text: w, shown: on(t, wt), white: prog(t, wt, wt + 2 * F) };
|
|
1208
|
+
}),
|
|
1209
|
+
said: said(t),
|
|
1210
|
+
};
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
/** @type {{ el: HTMLElement | null, at: typeof at, draw: (t: number) => ReturnType<typeof at>, text: string, times: number[], chars: typeof chars, until: number }} */
|
|
1214
|
+
const api = { el: null, at, draw: at, text: words.join(" "), times, chars, until };
|
|
1215
|
+
if (!host || typeof document === "undefined") return api;
|
|
1216
|
+
styles();
|
|
1217
|
+
const el = mk("div", "hud-voice", host);
|
|
1218
|
+
el.style.visibility = "hidden";
|
|
1219
|
+
const orbEl = o.orb === false ? null : mk("div", "hud-orb", el);
|
|
1220
|
+
/** @type {HTMLElement[]} */
|
|
1221
|
+
const barEls = [];
|
|
1222
|
+
if (orbEl) for (let j = 0; j < BARS; j++) barEls.push(mk("i", "", orbEl));
|
|
1223
|
+
const cap = mk("div", "hud-caption", el);
|
|
1224
|
+
const wordEls = words.map((w, i) => {
|
|
1225
|
+
const s = mk("span", "", cap);
|
|
1226
|
+
s.textContent = i < words.length - 1 ? `${w} ` : w;
|
|
1227
|
+
return s;
|
|
1228
|
+
});
|
|
1229
|
+
let orbSize = 0;
|
|
1230
|
+
/** @type {unknown} */
|
|
1231
|
+
let builtFor = null;
|
|
1232
|
+
/** @param {number} t */
|
|
1233
|
+
api.draw = (t) => {
|
|
1234
|
+
const g = geo();
|
|
1235
|
+
const { size } = g;
|
|
1236
|
+
if (builtFor !== g) {
|
|
1237
|
+
builtFor = g;
|
|
1238
|
+
fit(host, g.fr);
|
|
1239
|
+
el.style.gap = `${Math.round(size * 0.35)}px`;
|
|
1240
|
+
orbSize = Math.round(size * 1.15);
|
|
1241
|
+
if (orbEl) {
|
|
1242
|
+
// the film's accent, lit from the upper left; with none, a grey that takes no side
|
|
1243
|
+
const c = o.orbColour ?? accentOf(host) ?? "#8d929b";
|
|
1244
|
+
const tone = tones(c);
|
|
1245
|
+
Object.assign(orbEl.style, {
|
|
1246
|
+
width: `${orbSize}px`,
|
|
1247
|
+
height: `${orbSize}px`,
|
|
1248
|
+
gap: `${Math.round(orbSize * 0.07)}px`,
|
|
1249
|
+
background: `radial-gradient(circle at 35% 30%, ${tone.light}, ${c} 55%, ${tone.deep})`,
|
|
1250
|
+
boxShadow: `0 0 ${Math.round(orbSize * 0.5)}px ${faded(c, 0.53)}`,
|
|
1251
|
+
});
|
|
1252
|
+
for (const b of barEls) b.style.width = `${Math.round(orbSize * 0.07)}px`;
|
|
1253
|
+
}
|
|
1254
|
+
Object.assign(cap.style, { fontFamily: o.font ?? FONT, fontSize: `${size}px`, maxWidth: `${Math.round(g.fr.width * 0.86)}px` });
|
|
1255
|
+
}
|
|
1256
|
+
const a = at(t);
|
|
1257
|
+
el.style.visibility = a.visible ? "inherit" : "hidden";
|
|
1258
|
+
if (!a.visible) return a;
|
|
1259
|
+
// centred on x, the caption's last line on y, the orb above it
|
|
1260
|
+
el.style.transform = `translate(calc(${r1(a.x)}px - 50%), calc(${r1(a.y)}px - 100% + ${Math.round(size * 0.6)}px))`;
|
|
1261
|
+
if (orbEl) orbEl.style.transform = `scale(${a.orb.toFixed(4)})`;
|
|
1262
|
+
barEls.forEach((b, j) => {
|
|
1263
|
+
b.style.height = `${Math.round(orbSize * 0.5 * (a.bars[j] ?? 0))}px`;
|
|
1264
|
+
});
|
|
1265
|
+
const scene = o.colour ? null : sceneBehind([cap]);
|
|
1266
|
+
const { ink, shadow } = o.colour ? { ink: o.colour, shadow: "0 2px 18px rgba(0,0,0,0.35)" } : inkFor(scene);
|
|
1267
|
+
const grey = o.grey ?? (scene === "light" ? "#a3a6ad" : "#8d929b");
|
|
1268
|
+
cap.style.textShadow = shadow;
|
|
1269
|
+
a.words.forEach((w, i) => {
|
|
1270
|
+
const s = /** @type {HTMLElement} */ (wordEls[i]);
|
|
1271
|
+
s.style.opacity = w.shown ? "1" : "0";
|
|
1272
|
+
s.style.color = mix(grey, ink, w.white);
|
|
1273
|
+
});
|
|
1274
|
+
return a;
|
|
1275
|
+
};
|
|
1276
|
+
api.el = el;
|
|
1277
|
+
return api;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
// --- burst --------------------------------------------------------------------
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* A burst of pixels round a point: a send's flash. DdT1-vziRp3 (9.375 s and
|
|
1284
|
+
* 26.08 s, the same both times): coloured squares covering 1.2 % of the
|
|
1285
|
+
* frame grow to 11–13 % in 5 frames, then thin out and draw back over 7–10
|
|
1286
|
+
* frames. Its largest squares there are about 0.07 H across, soft and few
|
|
1287
|
+
* among many smaller; drawn all that size, a dozen of them read as blocks,
|
|
1288
|
+
* not pixels, so a square here is 0.02 of the short side (about 25 across
|
|
1289
|
+
* the burst at its widest). The area is a share of a landscape frame of the
|
|
1290
|
+
* same short side, so an upright film's burst is as large against its width
|
|
1291
|
+
* as a landscape film's against its height; it never reaches past the
|
|
1292
|
+
* frame's edges (a send button near the edge gives a smaller burst). Drawn
|
|
1293
|
+
* on a canvas the frame's size in `host`, in `colour`: by default a light
|
|
1294
|
+
* tone of the layer's accent, near white with none (the film's was its own
|
|
1295
|
+
* cyan), a few of its pixels white.
|
|
1296
|
+
* @param {HTMLElement | null} host
|
|
1297
|
+
* @param {{ t: number, at: Where, colour?: string | (() => string), area?: number, cell?: number, seed?: number, frame?: Frame }} o
|
|
1298
|
+
* colour: a CSS colour, or a function giving one when the burst is first drawn; area: the share of a landscape frame it covers at its widest (default 0.12); cell: a
|
|
1299
|
+
* pixel's px (default 0.02 of the short side; 2 at the least)
|
|
1300
|
+
*/
|
|
1301
|
+
export function burst(host, o) {
|
|
1302
|
+
const geo = later(o.frame, (fr) => {
|
|
1303
|
+
const A = short(fr) ** 2 * (16 / 9);
|
|
1304
|
+
const asked = o.cell ?? Math.round(0.02 * short(fr));
|
|
1305
|
+
return {
|
|
1306
|
+
fr,
|
|
1307
|
+
rMin: Math.sqrt((0.012 * A) / Math.PI),
|
|
1308
|
+
rMax: Math.sqrt(((o.area ?? 0.12) * A) / Math.PI),
|
|
1309
|
+
cell: asked >= 2 ? asked : 2,
|
|
1310
|
+
};
|
|
1311
|
+
});
|
|
1312
|
+
const seed = o.seed ?? 3;
|
|
1313
|
+
const up = 5 * F;
|
|
1314
|
+
const down = 9 * F;
|
|
1315
|
+
/** @param {number} t */
|
|
1316
|
+
const at = (t) => {
|
|
1317
|
+
const { fr, rMin, rMax, cell } = geo();
|
|
1318
|
+
const p = where(o.at, t);
|
|
1319
|
+
const visible = p != null && on(t, o.t) && !on(t, o.t + up + down);
|
|
1320
|
+
const grown = !on(t, o.t + up) ? lerp(rMin, rMax, out2(prog(t, o.t, o.t + up))) : lerp(rMax, rMax * 0.7, prog(t, o.t + up, o.t + up + down));
|
|
1321
|
+
// inside the frame: no square past its nearest edge
|
|
1322
|
+
const room = p ? Math.min(p[0], fr.width - p[0], p[1], fr.height - p[1]) - cell : grown;
|
|
1323
|
+
const r = Math.max(Math.min(cell, grown), Math.min(grown, room));
|
|
1324
|
+
const level = 1 - prog(t, o.t + up, o.t + up + down);
|
|
1325
|
+
return { visible, x: p?.[0] ?? 0, y: p?.[1] ?? 0, r, level, tick: Math.floor(t * 24 + EPS) };
|
|
1326
|
+
};
|
|
1327
|
+
if (!host || typeof document === "undefined") return { el: null, at, draw: at };
|
|
1328
|
+
styles();
|
|
1329
|
+
const cv = /** @type {HTMLCanvasElement} */ (mk("canvas", "hud-burst", host));
|
|
1330
|
+
const ctx = cv.getContext("2d");
|
|
1331
|
+
if (typeof o.colour === "string") colourOf(o.colour, "burst colour");
|
|
1332
|
+
/** read when first drawn: the layer's accent may be set in the page's CSS @type {Rgba | null} */
|
|
1333
|
+
let rgb = null;
|
|
1334
|
+
const colour = () => {
|
|
1335
|
+
const acc = accentOf(host);
|
|
1336
|
+
const c = (typeof o.colour === "function" ? o.colour() : o.colour) ?? (acc ? mix(acc, "#ffffff", 0.3) : "#f4f2f6");
|
|
1337
|
+
return colourOf(c, "burst colour");
|
|
1338
|
+
};
|
|
1339
|
+
let dirty = false;
|
|
1340
|
+
/** @param {number} t */
|
|
1341
|
+
const draw = (t) => {
|
|
1342
|
+
const { fr, cell } = geo();
|
|
1343
|
+
if (cv.width !== fr.width || cv.height !== fr.height) {
|
|
1344
|
+
fit(host, fr);
|
|
1345
|
+
cv.width = fr.width;
|
|
1346
|
+
cv.height = fr.height;
|
|
1347
|
+
}
|
|
1348
|
+
const a = at(t);
|
|
1349
|
+
if (!ctx) return a;
|
|
1350
|
+
if (dirty) ctx.clearRect(0, 0, fr.width, fr.height);
|
|
1351
|
+
dirty = a.visible;
|
|
1352
|
+
if (!a.visible) return a;
|
|
1353
|
+
rgb ??= colour();
|
|
1354
|
+
const [cr, cg, cb] = rgb.map(Math.round);
|
|
1355
|
+
const n = Math.ceil(a.r / cell) + 1;
|
|
1356
|
+
const gx0 = Math.round(a.x / cell);
|
|
1357
|
+
const gy0 = Math.round(a.y / cell);
|
|
1358
|
+
for (let j = -n; j <= n; j++)
|
|
1359
|
+
for (let i = -n; i <= n; i++) {
|
|
1360
|
+
const px = (gx0 + i) * cell;
|
|
1361
|
+
const py = (gy0 + j) * cell;
|
|
1362
|
+
const d = Math.hypot(px - a.x, py - a.y) / a.r;
|
|
1363
|
+
const h1 = hash(gx0 + i + 1000 * seed, gy0 + j);
|
|
1364
|
+
// a ragged edge, sparser toward it, each pixel flickering on its own
|
|
1365
|
+
if (d > 0.55 + 0.45 * h1) continue;
|
|
1366
|
+
const flick = hash(i * 31 + j, a.tick + seed);
|
|
1367
|
+
if (flick < 0.25 + 0.5 * d) continue;
|
|
1368
|
+
const alpha = a.level * (1 - 0.6 * d) * (0.55 + 0.45 * flick);
|
|
1369
|
+
const hot = flick > 0.93 ? 1 : 0;
|
|
1370
|
+
ctx.fillStyle = hot ? `rgba(255,255,255,${alpha.toFixed(3)})` : `rgba(${cr},${cg},${cb},${alpha.toFixed(3)})`;
|
|
1371
|
+
ctx.fillRect(px - cell / 2, py - cell / 2, cell - 1, cell - 1);
|
|
1372
|
+
}
|
|
1373
|
+
return a;
|
|
1374
|
+
};
|
|
1375
|
+
return { el: /** @type {HTMLElement} */ (cv), at, draw };
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
// --- prompt box ---------------------------------------------------------------
|
|
1379
|
+
|
|
1380
|
+
/**
|
|
1381
|
+
* A prompt box: a request typed in, then sent. Df-JzBcCrDo's three: dark
|
|
1382
|
+
* glass 0.57–0.69 W wide, a 1 px light edge, brighter along the top, an
|
|
1383
|
+
* orange send button, the model's name in a small chip; text 0.024–0.035 H.
|
|
1384
|
+
* It rises 28 px (of a 1080 frame) into place in 3 frames; the text types on
|
|
1385
|
+
* `typeAt`'s measured curve in fresh ink (`inkHtml`). On `send`: the
|
|
1386
|
+
* button presses to 0.61× in 2 frames, holds 4 (its arrow turned to a
|
|
1387
|
+
* spark), lets go in 3 with no rebound; a light wave crosses the box right
|
|
1388
|
+
* to left (about 640 px of a 1920 frame in 8 frames: a third of the frame's
|
|
1389
|
+
* width); a burst of pixels leaves the button (DdT1-vziRp3); with
|
|
1390
|
+
* `collapse`, the box then closes in to 0.63 of its width, faster and faster
|
|
1391
|
+
* (863 → 540 px).
|
|
1392
|
+
* The film's button, fresh ink and wave are its orange and its burst cyan;
|
|
1393
|
+
* here all four are the layer's accent (`accent` over it; `fresh` and
|
|
1394
|
+
* `burst` each on their own), and with no accent the button is the ink's
|
|
1395
|
+
* colour with a dark arrow, the fresh ink the ink at half strength, the
|
|
1396
|
+
* wave and the burst near white.
|
|
1397
|
+
* `type.from` carries on a line said in the shot before (voice's chars(t)).
|
|
1398
|
+
* The films' prompt text is small (0.03 H: about 6.5 px on an upright phone)
|
|
1399
|
+
* and they push in on it; a box held still at the frame's size reads better
|
|
1400
|
+
* with `size` larger.
|
|
1401
|
+
* @param {HTMLElement | null} host
|
|
1402
|
+
* @param {{ t: number, text: string, type?: { t?: number, cps?: number, curve?: "measured" | "even" | ((u: number) => number), from?: number },
|
|
1403
|
+
* send?: number, collapse?: boolean, out?: number, x?: number, y?: number, w?: number, size?: number,
|
|
1404
|
+
* model?: string, placeholder?: string, ink?: string, fresh?: string, accent?: string, burst?: boolean | string,
|
|
1405
|
+
* bg?: string, font?: string, frame?: Frame }} o
|
|
1406
|
+
* x, y: its centre (default the frame's middle); w: its width (default 0.62 W, 0.86 W in an
|
|
1407
|
+
* upright film); out: when it goes
|
|
1408
|
+
*/
|
|
1409
|
+
export function prompt(host, o) {
|
|
1410
|
+
const geo = later(o.frame, (fr) => {
|
|
1411
|
+
const size = o.size ?? Math.round(0.03 * short(fr));
|
|
1412
|
+
const w = o.w ?? Math.round((fr.width < fr.height ? 0.86 : 0.62) * fr.width);
|
|
1413
|
+
const h = Math.round(size * 6.2);
|
|
1414
|
+
const cx = o.x ?? fr.width / 2;
|
|
1415
|
+
const cy = o.y ?? fr.height / 2;
|
|
1416
|
+
const btn = Math.round(size * 1.45);
|
|
1417
|
+
const pad = Math.round(size * 1.2);
|
|
1418
|
+
/** @type {Pt} */
|
|
1419
|
+
const button = [cx + w / 2 - pad - btn / 2, cy + h / 2 - pad * 0.8 - btn / 2];
|
|
1420
|
+
return { fr, size, w, h, cx, cy, btn, pad, button, rise: Math.round((28 / 1080) * short(fr)), travel: fr.width / 3 };
|
|
1421
|
+
});
|
|
1422
|
+
const typeT = o.type?.t ?? o.t + 4 * F;
|
|
1423
|
+
const send = o.send ?? Infinity;
|
|
1424
|
+
const ink = o.ink ?? "#f4f2f6";
|
|
1425
|
+
/** the film's accent, read when first drawn; null: none @type {string | null} */
|
|
1426
|
+
let accent = o.accent ?? null;
|
|
1427
|
+
const flash =
|
|
1428
|
+
o.burst === false || !Number.isFinite(send)
|
|
1429
|
+
? null
|
|
1430
|
+
: burst(host, {
|
|
1431
|
+
t: send,
|
|
1432
|
+
at: () => geo().button,
|
|
1433
|
+
...(typeof o.burst === "string" ? { colour: o.burst } : o.accent ? { colour: mix(o.accent, "#ffffff", 0.3) } : {}),
|
|
1434
|
+
...(o.frame ? { frame: o.frame } : {}),
|
|
1435
|
+
});
|
|
1436
|
+
|
|
1437
|
+
/** @param {number} t */
|
|
1438
|
+
const at = (t) => {
|
|
1439
|
+
const { w, h, cx, cy, rise: lift, travel } = geo();
|
|
1440
|
+
const out = o.out ?? Infinity;
|
|
1441
|
+
const visible = on(t, o.t) && !on(t, out);
|
|
1442
|
+
const rise = lift * (1 - out3(prog(t, o.t, o.t + 3 * F)));
|
|
1443
|
+
const typed = typeAt(t, typeT, o.text, o.type ?? {});
|
|
1444
|
+
const d = t - send;
|
|
1445
|
+
const k = count(d, F); // whole frames since the send
|
|
1446
|
+
// the press: 2 frames in, 4 held, 3 out, no rebound (Df-JzBcCrDo 72.6–72.96 s)
|
|
1447
|
+
const press = k < 0 ? 1 : k < 2 ? lerp(1, 0.61, out2(clamp01(d / (2 * F)))) : k < 6 ? 0.61 : lerp(0.61, 1, out2(prog(d, 6 * F, 9 * F)));
|
|
1448
|
+
const wave = k >= 1 && k < 9 ? prog(d, F, 9 * F) : null;
|
|
1449
|
+
const width = o.collapse ? w * lerp(1, 0.63, in2(prog(d, 6 * F, 11 * F))) : w;
|
|
1450
|
+
return {
|
|
1451
|
+
visible,
|
|
1452
|
+
x: cx,
|
|
1453
|
+
y: cy + rise,
|
|
1454
|
+
w: width,
|
|
1455
|
+
h,
|
|
1456
|
+
typed,
|
|
1457
|
+
caret: visible && k < 0 && t < typed.end + 0.5 && on(t, typeT - 0.2),
|
|
1458
|
+
press,
|
|
1459
|
+
pressed: k >= 2 && k < 6,
|
|
1460
|
+
wave,
|
|
1461
|
+
// the wave's middle in the frame: from the box's right end, a third of the frame's width to the left
|
|
1462
|
+
waveX: wave == null ? null : cx + w / 2 - wave * travel,
|
|
1463
|
+
burst: flash ? flash.at(t) : null,
|
|
1464
|
+
};
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1467
|
+
if (!host || typeof document === "undefined") return { el: null, at, draw: at };
|
|
1468
|
+
styles();
|
|
1469
|
+
const el = mk("div", "hud-prompt", host);
|
|
1470
|
+
el.style.visibility = "hidden";
|
|
1471
|
+
const text = mk("div", "hud-text", el);
|
|
1472
|
+
const foot = mk("div", "hud-foot", el);
|
|
1473
|
+
const sendEl = mk("div", "hud-send", el);
|
|
1474
|
+
const wave = mk("div", "hud-wave", el);
|
|
1475
|
+
if (flash?.el) host.appendChild(flash.el); // the burst over the box, not under it
|
|
1476
|
+
/** @type {unknown} */
|
|
1477
|
+
let builtFor = null;
|
|
1478
|
+
let lastHtml = "";
|
|
1479
|
+
let lastIcon = "";
|
|
1480
|
+
/** @param {number} t */
|
|
1481
|
+
const draw = (t) => {
|
|
1482
|
+
const g = geo();
|
|
1483
|
+
if (builtFor !== g) {
|
|
1484
|
+
builtFor = g;
|
|
1485
|
+
const { size, w, h, btn, pad } = g;
|
|
1486
|
+
fit(host, g.fr);
|
|
1487
|
+
accent = o.accent ?? accentOf(host);
|
|
1488
|
+
const button = accent ?? ink;
|
|
1489
|
+
Object.assign(el.style, {
|
|
1490
|
+
height: `${h}px`,
|
|
1491
|
+
borderRadius: `${Math.round(size * 0.95)}px`,
|
|
1492
|
+
background: o.bg ?? "linear-gradient(180deg, rgba(40,37,46,0.92), rgba(22,20,27,0.94))",
|
|
1493
|
+
boxShadow: "inset 0 1px 0 rgba(255,255,255,0.22), inset 0 0 0 1px rgba(255,255,255,0.09), 0 24px 60px rgba(0,0,0,0.35)",
|
|
1494
|
+
backdropFilter: "blur(18px)",
|
|
1495
|
+
fontFamily: o.font ?? FONT,
|
|
1496
|
+
fontSize: `${size}px`,
|
|
1497
|
+
color: ink,
|
|
1498
|
+
});
|
|
1499
|
+
// held to the box's right end at its full width, so a box closing in covers the text, not reflows it
|
|
1500
|
+
Object.assign(text.style, { width: `${w - 2 * pad - btn}px`, top: `${Math.round(pad * 0.85)}px`, right: `${pad + btn}px`, lineHeight: "1.3" });
|
|
1501
|
+
Object.assign(foot.style, { left: `${pad}px`, bottom: `${Math.round(pad * 0.8)}px`, fontSize: `${Math.round(size * 0.62)}px`, color: "rgba(230,228,236,0.8)" });
|
|
1502
|
+
foot.innerHTML =
|
|
1503
|
+
`<span style="display:flex;width:1.7em;height:1.7em;border-radius:50%;background:rgba(255,255,255,0.1);align-items:center;justify-content:center">+</span>` +
|
|
1504
|
+
(o.model ? `<span>${star(Math.round(size * 0.6), button)}</span><span>${esc(o.model)}</span>` : "");
|
|
1505
|
+
Object.assign(sendEl.style, {
|
|
1506
|
+
width: `${btn}px`, height: `${btn}px`, right: `${pad}px`, bottom: `${Math.round(pad * 0.8)}px`,
|
|
1507
|
+
background: button, color: inkOn(button), fontSize: `${Math.round(btn * 0.55)}px`,
|
|
1508
|
+
});
|
|
1509
|
+
}
|
|
1510
|
+
const a = at(t);
|
|
1511
|
+
flash?.draw(t);
|
|
1512
|
+
el.style.visibility = a.visible ? "inherit" : "hidden";
|
|
1513
|
+
if (!a.visible) return a;
|
|
1514
|
+
el.style.width = `${r1(a.w)}px`;
|
|
1515
|
+
// collapsing keeps the right end (the button) where it was
|
|
1516
|
+
el.style.transform = `translate(${r1(a.x + g.w / 2 - a.w)}px, ${r1(a.y - g.h / 2)}px)`;
|
|
1517
|
+
const html =
|
|
1518
|
+
a.typed.n === 0 && o.placeholder && !a.caret
|
|
1519
|
+
? `<span style="opacity:0.45">${esc(o.placeholder)}</span>`
|
|
1520
|
+
: inkHtml(t, a.typed, { ink, ...(o.fresh || accent ? { fresh: /** @type {string} */ (o.fresh ?? accent) } : {}), caret: a.caret });
|
|
1521
|
+
if (html !== lastHtml) text.innerHTML = lastHtml = html;
|
|
1522
|
+
const icon = a.pressed ? "✦" : "↑";
|
|
1523
|
+
if (icon !== lastIcon) sendEl.textContent = lastIcon = icon;
|
|
1524
|
+
sendEl.style.transform = `scale(${a.press.toFixed(3)})`;
|
|
1525
|
+
if (a.wave == null || a.waveX == null) wave.style.background = "";
|
|
1526
|
+
else {
|
|
1527
|
+
const c = (100 * (a.waveX - (a.x + g.w / 2 - a.w))) / a.w;
|
|
1528
|
+
const light = faded(accent ? mix(accent, "#ffffff", 0.35) : "#ffffff", 0.5 * (1 - a.wave));
|
|
1529
|
+
wave.style.background = `linear-gradient(90deg, transparent ${r1(c - 14)}%, ${light} ${r1(c)}%, transparent ${r1(c + 14)}%)`;
|
|
1530
|
+
}
|
|
1531
|
+
return a;
|
|
1532
|
+
};
|
|
1533
|
+
return { el, at, draw };
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
// --- agent cursor labels ------------------------------------------------------
|
|
1537
|
+
|
|
1538
|
+
/**
|
|
1539
|
+
* A point of an element, in the frame: for `agent`'s `at`, so a label stays
|
|
1540
|
+
* on a thing while the camera moves it. ux, uy: where in its box (0..1,
|
|
1541
|
+
* default the middle). It reads the page's layout when called, not film
|
|
1542
|
+
* time: the point is where the element is at that moment, so draw the
|
|
1543
|
+
* scene for t before the agents pinned to it, and the agent's `at(t)` is
|
|
1544
|
+
* where the element was last laid out rather than a function of t alone.
|
|
1545
|
+
* `agent(hud, { name: "wrist_ik.R", t: 3, at: pinTo(card, { ux: 0.8, uy: 0.2 }) })`
|
|
1546
|
+
* @param {Element} el @param {{ ux?: number, uy?: number, host?: Element | null }} [o]
|
|
1547
|
+
* host: the layer the frame is measured from (default the page's top-left)
|
|
1548
|
+
* @returns {(t: number) => Pt | null}
|
|
1549
|
+
*/
|
|
1550
|
+
export function pinTo(el, o = {}) {
|
|
1551
|
+
return () => {
|
|
1552
|
+
const r = el.getBoundingClientRect();
|
|
1553
|
+
if (r.width === 0 && r.height === 0) return null;
|
|
1554
|
+
const h = o.host?.getBoundingClientRect() ?? { left: 0, top: 0 };
|
|
1555
|
+
return [r.left - h.left + r.width * (o.ux ?? 0.5), r.top - h.top + r.height * (o.uy ?? 0.5)];
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
/**
|
|
1560
|
+
* Where a 3D point is in the frame, seen by a three.js camera (anything with
|
|
1561
|
+
* `projectionMatrix.elements` and `matrixWorldInverse.elements`, column-major;
|
|
1562
|
+
* call camera.updateMatrixWorld() first). Perspective or orthographic. null
|
|
1563
|
+
* behind the lens (for an orthographic camera: nearer than its near plane) or
|
|
1564
|
+
* past its far plane. `at: (t) => project(rig.camera, [0.4, 1.2, 0])`
|
|
1565
|
+
* @param {{ projectionMatrix: { elements: ArrayLike<number> }, matrixWorldInverse: { elements: ArrayLike<number> } }} camera
|
|
1566
|
+
* @param {[number, number, number]} p
|
|
1567
|
+
* @param {{ frame?: Frame }} [o]
|
|
1568
|
+
* @returns {Pt | null}
|
|
1569
|
+
*/
|
|
1570
|
+
export function project(camera, p, o = {}) {
|
|
1571
|
+
const fr = frameOf(o.frame);
|
|
1572
|
+
const V = camera.matrixWorldInverse.elements;
|
|
1573
|
+
const P = camera.projectionMatrix.elements;
|
|
1574
|
+
/** a column-major 4×4 matrix times a vector @param {ArrayLike<number>} M @param {[number, number, number, number]} v
|
|
1575
|
+
* @returns {[number, number, number, number]} */
|
|
1576
|
+
const m = (M, v) => {
|
|
1577
|
+
const e = (/** @type {number} */ i) => M[i] ?? 0;
|
|
1578
|
+
const row = (/** @type {number} */ r) => e(r) * v[0] + e(4 + r) * v[1] + e(8 + r) * v[2] + e(12 + r) * v[3];
|
|
1579
|
+
return [row(0), row(1), row(2), row(3)];
|
|
1580
|
+
};
|
|
1581
|
+
// an orthographic projection keeps w at 1: its bottom row is 0 0 0 1
|
|
1582
|
+
const ortho = (P[3] ?? 0) === 0 && (P[7] ?? 0) === 0 && (P[11] ?? 0) === 0 && (P[15] ?? 0) === 1;
|
|
1583
|
+
const [cx, cy, cz, cw] = m(P, m(V, [p[0], p[1], p[2], 1]));
|
|
1584
|
+
if (cw <= 1e-9) return null;
|
|
1585
|
+
const z = cz / cw;
|
|
1586
|
+
if (z > 1 || (ortho && z < -1)) return null;
|
|
1587
|
+
return [((cx / cw + 1) / 2) * fr.width, ((1 - cy / cw) / 2) * fr.height];
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* An agent's cursor: an arrow and its name on a saturated block, pinned to a
|
|
1592
|
+
* point (Df-JzBcCrDo: 39 of them, 28 names — `foliage_palms`, `wrist_ik.R` —
|
|
1593
|
+
* on 3D points, the same size however close the camera; name 0.017–0.018 H on
|
|
1594
|
+
* a 0.031 H block). It pops in over 3 frames, its first frame at `t` already
|
|
1595
|
+
* on screen, rides its point, and goes in 3 frames when its part is done
|
|
1596
|
+
* (f33–36). Many at once read as many hands working, not as words to read.
|
|
1597
|
+
* Its block is `colour` — the layer's accent, a dark grey with none (the
|
|
1598
|
+
* film gave each agent a colour of its own: give each its `colour`) — and
|
|
1599
|
+
* its name black or white, whichever reads on it, unless `ink` says.
|
|
1600
|
+
* @param {HTMLElement | null} host
|
|
1601
|
+
* @param {{ name: string, t: number, out?: number, at: Where, colour?: string, ink?: string, size?: number,
|
|
1602
|
+
* font?: string, frame?: Frame }} o
|
|
1603
|
+
* at: the arrow's tip — a point, a function of t (pinTo, project), null while off screen
|
|
1604
|
+
*/
|
|
1605
|
+
export function agent(host, o) {
|
|
1606
|
+
const geo = later(o.frame, (fr) => ({ fr, size: o.size ?? Math.round(0.018 * short(fr)) }));
|
|
1607
|
+
const pop = 3 * F;
|
|
1608
|
+
/** @param {number} t */
|
|
1609
|
+
const at = (t) => {
|
|
1610
|
+
const out = o.out ?? Infinity;
|
|
1611
|
+
const live = on(t, o.t) && !on(t, out + pop);
|
|
1612
|
+
const p = live ? where(o.at, t) : null;
|
|
1613
|
+
// frames t, t + F, t + 2F: a third, two thirds (past full size), whole
|
|
1614
|
+
const scale = !on(t, out) ? backOut(prog(t, o.t - F, o.t + pop - F)) : 1 - in2(prog(t, out, out + pop));
|
|
1615
|
+
return { visible: p != null, x: p?.[0] ?? 0, y: p?.[1] ?? 0, scale };
|
|
1616
|
+
};
|
|
1617
|
+
if (!host || typeof document === "undefined") return { el: null, at, draw: at };
|
|
1618
|
+
styles();
|
|
1619
|
+
const el = mk("div", "hud-agent", host);
|
|
1620
|
+
el.style.visibility = "hidden";
|
|
1621
|
+
/** @type {unknown} */
|
|
1622
|
+
let builtFor = null;
|
|
1623
|
+
/** @param {number} t */
|
|
1624
|
+
const draw = (t) => {
|
|
1625
|
+
const g = geo();
|
|
1626
|
+
if (builtFor !== g) {
|
|
1627
|
+
builtFor = g;
|
|
1628
|
+
fit(host, g.fr);
|
|
1629
|
+
const { size } = g;
|
|
1630
|
+
const colour = o.colour ?? accentOf(host) ?? "#3a3c44";
|
|
1631
|
+
const arrow = Math.round(size * 1.35);
|
|
1632
|
+
el.innerHTML =
|
|
1633
|
+
`<svg width="${arrow}" height="${arrow}" viewBox="0 0 20 20" style="position:absolute;left:-2px;top:-2px;overflow:visible">` +
|
|
1634
|
+
`<path d="M2 2 L17 9 L10 11 L7 18 Z" fill="${esc(colour)}" stroke="#fff" stroke-width="1.6" stroke-linejoin="round"/></svg>`;
|
|
1635
|
+
const tag = mk("span", "", el);
|
|
1636
|
+
tag.textContent = o.name;
|
|
1637
|
+
Object.assign(tag.style, {
|
|
1638
|
+
left: `${Math.round(arrow * 0.8)}px`,
|
|
1639
|
+
top: `${Math.round(arrow * 0.85)}px`,
|
|
1640
|
+
height: `${Math.round(size * 1.72)}px`,
|
|
1641
|
+
lineHeight: `${Math.round(size * 1.72)}px`,
|
|
1642
|
+
padding: `0 ${Math.round(size * 0.5)}px`,
|
|
1643
|
+
fontSize: `${size}px`,
|
|
1644
|
+
fontFamily: o.font ?? FONT,
|
|
1645
|
+
background: colour,
|
|
1646
|
+
color: o.ink ?? inkOn(colour),
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
const a = at(t);
|
|
1650
|
+
el.style.visibility = a.visible ? "inherit" : "hidden";
|
|
1651
|
+
if (a.visible) el.style.transform = `translate(${r1(a.x)}px, ${r1(a.y)}px) scale(${a.scale.toFixed(3)})`;
|
|
1652
|
+
return a;
|
|
1653
|
+
};
|
|
1654
|
+
return { el, at, draw };
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
// --- detection box ------------------------------------------------------------
|
|
1658
|
+
|
|
1659
|
+
/** the colour a measure is shown in by its value: low red, middling yellow, high green (opus55-monster-truck) @param {number} v */
|
|
1660
|
+
export const gauge = (v) => (v < 34 ? "#ea1a4c" : v < 75 ? "#f8e53e" : "#7ad13a");
|
|
1661
|
+
|
|
1662
|
+
/**
|
|
1663
|
+
* A detection box: a label typed a letter a frame above it, a rounded outline
|
|
1664
|
+
* drawn round the thing (about 0.25 s, about 6 px of a 1080 frame), a number
|
|
1665
|
+
* counting up inside its top-right corner in steps every 2 frames
|
|
1666
|
+
* (48 → 60 → 72 → 84 → 96 %: from half the value, `steps` 4), the box filled
|
|
1667
|
+
* with a pale tint of its colour when it lands. opus55-monster-truck shots
|
|
1668
|
+
* 11–13 ("Condition" at 67 % yellow, 16 % red, 96 % green; the number about
|
|
1669
|
+
* the label's size). The label is black on the film's white; here it takes
|
|
1670
|
+
* its ink from the scene under it unless `ink` says. The film's number sits
|
|
1671
|
+
* in its colour straight on the photograph; here it sits on a small plate of
|
|
1672
|
+
* that colour, in black or white, whichever stands further from it (black
|
|
1673
|
+
* on the gauge's three: 4.75:1 on its red, more on the others), so it reads
|
|
1674
|
+
* over whatever the box frames. `rect` may be a function of t, to ride a camera that moves.
|
|
1675
|
+
* @param {HTMLElement | null} host
|
|
1676
|
+
* @param {{ t: number, rect: { x: number, y: number, w: number, h: number } | ((t: number) => { x: number, y: number, w: number, h: number }),
|
|
1677
|
+
* label?: string, value: number, unit?: string, steps?: number, colour?: string, fill?: number, out?: number,
|
|
1678
|
+
* size?: number, ink?: string, font?: string, frame?: Frame }} o
|
|
1679
|
+
* fill: when the tint comes in (default none); size: the label's px (default 0.05 of the short
|
|
1680
|
+
* side; the number 0.9×); steps: how many 2-frame steps the count takes (1 at the least)
|
|
1681
|
+
*/
|
|
1682
|
+
export function detect(host, o) {
|
|
1683
|
+
const geo = later(o.frame, (fr) => ({ fr, size: o.size ?? Math.round(0.05 * short(fr)), stroke: Math.max(2, Math.round(0.0055 * short(fr))) }));
|
|
1684
|
+
const label = glyphs(o.label ?? "");
|
|
1685
|
+
const steps = Math.max(1, Math.round(o.steps ?? 4));
|
|
1686
|
+
const unit = o.unit ?? "%";
|
|
1687
|
+
const colour = o.colour ?? gauge(o.value);
|
|
1688
|
+
const countAt = o.t + 6 * F;
|
|
1689
|
+
/** @param {number} t */
|
|
1690
|
+
const at = (t) => {
|
|
1691
|
+
const out = o.out ?? Infinity;
|
|
1692
|
+
const rect = typeof o.rect === "function" ? o.rect(t) : o.rect;
|
|
1693
|
+
const k = !on(t, countAt) ? -1 : Math.min(steps, count(t - countAt, 2 * F));
|
|
1694
|
+
const value = k < 0 ? null : Math.round(lerp(o.value / 2, o.value, k / steps));
|
|
1695
|
+
return {
|
|
1696
|
+
visible: on(t, o.t) && !on(t, out + 4 * F),
|
|
1697
|
+
rect,
|
|
1698
|
+
label: label.slice(0, !on(t, o.t) ? 0 : count(t - o.t, F) + 1).join(""),
|
|
1699
|
+
stroke: out3(prog(t, o.t + 2 * F, o.t + 2 * F + 0.25)),
|
|
1700
|
+
value,
|
|
1701
|
+
text: value == null ? "" : `${value}${unit}`,
|
|
1702
|
+
fill: o.fill == null ? 0 : 0.16 * out3(prog(t, o.fill, o.fill + 0.33)),
|
|
1703
|
+
opacity: 1 - prog(t, out, out + 4 * F),
|
|
1704
|
+
};
|
|
1705
|
+
};
|
|
1706
|
+
if (!host || typeof document === "undefined") return { el: null, at, draw: at };
|
|
1707
|
+
styles();
|
|
1708
|
+
const el = mk("div", "hud-detect", host);
|
|
1709
|
+
el.style.visibility = "hidden";
|
|
1710
|
+
el.style.fontFamily = o.font ?? FONT;
|
|
1711
|
+
const NS = "http://www.w3.org/2000/svg";
|
|
1712
|
+
const svg = document.createElementNS(NS, "svg");
|
|
1713
|
+
const box = document.createElementNS(NS, "rect");
|
|
1714
|
+
box.setAttribute("pathLength", "1");
|
|
1715
|
+
box.setAttribute("stroke", colour);
|
|
1716
|
+
box.setAttribute("stroke-dasharray", "1 1");
|
|
1717
|
+
svg.appendChild(box);
|
|
1718
|
+
el.appendChild(svg);
|
|
1719
|
+
const lab = mk("b", "", el);
|
|
1720
|
+
const num = mk("b", "", el);
|
|
1721
|
+
const [cr, cg, cb] = colourOf(colour, "detect colour");
|
|
1722
|
+
// the number's ink on its plate: black or white, whichever stands further
|
|
1723
|
+
// from the plate's colour
|
|
1724
|
+
const L = luminance([cr, cg, cb, 1]);
|
|
1725
|
+
const contrast = (/** @type {string} */ ink) => {
|
|
1726
|
+
const l = luminance(colourOf(ink, "ink"));
|
|
1727
|
+
return (Math.max(l, L) + 0.05) / (Math.min(l, L) + 0.05);
|
|
1728
|
+
};
|
|
1729
|
+
const numInk = contrast("#000") >= contrast("#fff") ? "#000" : "#fff";
|
|
1730
|
+
/** @type {unknown} */
|
|
1731
|
+
let builtFor = null;
|
|
1732
|
+
/** @param {number} t */
|
|
1733
|
+
const draw = (t) => {
|
|
1734
|
+
const g = geo();
|
|
1735
|
+
const { size } = g;
|
|
1736
|
+
if (builtFor !== g) {
|
|
1737
|
+
builtFor = g;
|
|
1738
|
+
fit(host, g.fr);
|
|
1739
|
+
box.setAttribute("stroke-width", String(g.stroke));
|
|
1740
|
+
Object.assign(lab.style, { fontSize: `${size}px`, fontWeight: "700" });
|
|
1741
|
+
const pad = Math.round(size * 0.12);
|
|
1742
|
+
Object.assign(num.style, {
|
|
1743
|
+
fontSize: `${Math.round(size * 0.9)}px`,
|
|
1744
|
+
fontWeight: "600",
|
|
1745
|
+
color: numInk,
|
|
1746
|
+
background: colour,
|
|
1747
|
+
padding: `${pad}px ${Math.round(pad * 2)}px`,
|
|
1748
|
+
borderRadius: `${Math.round(size * 0.2)}px`,
|
|
1749
|
+
lineHeight: "1",
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
const a = at(t);
|
|
1753
|
+
el.style.visibility = a.visible ? "inherit" : "hidden";
|
|
1754
|
+
if (!a.visible) return a;
|
|
1755
|
+
const { x, y, w, h } = a.rect;
|
|
1756
|
+
el.style.opacity = String(r1(a.opacity * 100) / 100);
|
|
1757
|
+
svg.setAttribute("width", String(Math.ceil(x + w + 20)));
|
|
1758
|
+
svg.setAttribute("height", String(Math.ceil(y + h + 20)));
|
|
1759
|
+
for (const [k, v] of Object.entries({ x, y, width: w, height: h, rx: Math.round(size * 0.4) })) box.setAttribute(k, String(r1(v)));
|
|
1760
|
+
box.setAttribute("stroke-dashoffset", String(1 - a.stroke));
|
|
1761
|
+
box.setAttribute("fill", a.fill > 0 ? `rgba(${cr},${cg},${cb},${a.fill.toFixed(3)})` : "none");
|
|
1762
|
+
lab.textContent = a.label;
|
|
1763
|
+
lab.style.transform = `translate(${r1(x)}px, ${r1(y - size * 1.2)}px)`;
|
|
1764
|
+
lab.style.color = o.ink ?? inkFor(sceneBehind([lab])).ink;
|
|
1765
|
+
num.textContent = a.text;
|
|
1766
|
+
// inside the box's top-right corner
|
|
1767
|
+
const inset = Math.round(size * 0.22);
|
|
1768
|
+
num.style.transform = `translate(${r1(x + w - inset - num.offsetWidth)}px, ${r1(y + inset)}px)`;
|
|
1769
|
+
return a;
|
|
1770
|
+
};
|
|
1771
|
+
return { el, at, draw };
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
// --- title --------------------------------------------------------------------
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* A title whose letters come out of blur one after another: Df-JzBcCrDo's
|
|
1778
|
+
* title, a letter every ~1.5 frames, each sharp in 3–4 frames, the line done
|
|
1779
|
+
* in 0.7 s. A launch film's titles appear in 0.1–0.2 s (dots-creative-crew:
|
|
1780
|
+
* a 30–36 character line, rising 19–40 px) and hold 0.8–2.5 s: for that,
|
|
1781
|
+
* `by: "word"` with a smaller stagger. Out: up and away, accelerating
|
|
1782
|
+
* (0.3 s), the letters blurring as they go. It wraps between words inside
|
|
1783
|
+
* 0.9 W. White on a dark scene, near black on a light one (read from the
|
|
1784
|
+
* scene under it), unless `colour` says.
|
|
1785
|
+
* @param {HTMLElement | null} host
|
|
1786
|
+
* @param {{ text: string, t: number, out?: number, x?: number, y?: number, align?: "left" | "center" | "right",
|
|
1787
|
+
* by?: "char" | "word", stagger?: number, each?: number, blur?: number, dy?: number, size?: number,
|
|
1788
|
+
* weight?: number, colour?: string, font?: string, frame?: Frame }} o
|
|
1789
|
+
* x, y: its anchor (default the frame's middle; align says which part of it sits on x);
|
|
1790
|
+
* size: default 0.09 of the short side
|
|
1791
|
+
*/
|
|
1792
|
+
export function title(host, o) {
|
|
1793
|
+
const by = o.by ?? "char";
|
|
1794
|
+
const parts = by === "word" ? o.text.split(/(\s+)/).filter(Boolean) : glyphs(o.text);
|
|
1795
|
+
const stagger = o.stagger ?? 1.5 * F;
|
|
1796
|
+
const each = o.each ?? 3.5 * F;
|
|
1797
|
+
const outDur = 0.3;
|
|
1798
|
+
const geo = later(o.frame, (fr) => {
|
|
1799
|
+
const size = o.size ?? Math.round(0.09 * short(fr));
|
|
1800
|
+
return { fr, size, blur: o.blur ?? Math.round(size * 0.22), dy: o.dy ?? Math.round(size * 0.25) };
|
|
1801
|
+
});
|
|
1802
|
+
/** @param {number} t */
|
|
1803
|
+
const at = (t) => {
|
|
1804
|
+
const { blur, dy } = geo();
|
|
1805
|
+
const out = o.out ?? Infinity;
|
|
1806
|
+
const e = in3(prog(t, out, out + outDur));
|
|
1807
|
+
let j = 0;
|
|
1808
|
+
const letters = parts.map((p) => {
|
|
1809
|
+
if (/^\s+$/.test(p)) return { text: p, opacity: 1, blur: 0, y: 0 };
|
|
1810
|
+
const s = o.t + j++ * stagger;
|
|
1811
|
+
const k = out3(prog(t, s, s + each));
|
|
1812
|
+
return { text: p, opacity: k * (1 - e), blur: r1((1 - k) * blur + e * blur * 0.6), y: r1((1 - k) * dy - e * dy * 2) };
|
|
1813
|
+
});
|
|
1814
|
+
return { visible: on(t, o.t) && !on(t, out + outDur), letters, done: o.t + Math.max(0, j - 1) * stagger + each };
|
|
1815
|
+
};
|
|
1816
|
+
if (!host || typeof document === "undefined") return { el: null, at, draw: at };
|
|
1817
|
+
styles();
|
|
1818
|
+
const el = mk("div", "hud-title", host);
|
|
1819
|
+
el.style.visibility = "hidden";
|
|
1820
|
+
// letters inside words that do not break; the spaces between them do
|
|
1821
|
+
/** @type {(HTMLElement | null)[]} */
|
|
1822
|
+
const spans = [];
|
|
1823
|
+
/** @type {HTMLElement | null} */
|
|
1824
|
+
let word = null;
|
|
1825
|
+
for (const p of parts) {
|
|
1826
|
+
if (/^\s+$/.test(p)) {
|
|
1827
|
+
el.appendChild(document.createTextNode(" "));
|
|
1828
|
+
word = null;
|
|
1829
|
+
spans.push(null);
|
|
1830
|
+
continue;
|
|
1831
|
+
}
|
|
1832
|
+
word ??= mk("span", "hud-word", el);
|
|
1833
|
+
const s = mk("span", "", word);
|
|
1834
|
+
s.textContent = p;
|
|
1835
|
+
spans.push(s);
|
|
1836
|
+
}
|
|
1837
|
+
const align = o.align ?? "center";
|
|
1838
|
+
el.style.textAlign = align;
|
|
1839
|
+
/** @type {unknown} */
|
|
1840
|
+
let builtFor = null;
|
|
1841
|
+
/** @param {number} t */
|
|
1842
|
+
const draw = (t) => {
|
|
1843
|
+
const g = geo();
|
|
1844
|
+
if (builtFor !== g) {
|
|
1845
|
+
builtFor = g;
|
|
1846
|
+
fit(host, g.fr);
|
|
1847
|
+
Object.assign(el.style, {
|
|
1848
|
+
fontFamily: o.font ?? FONT,
|
|
1849
|
+
fontSize: `${g.size}px`,
|
|
1850
|
+
fontWeight: String(o.weight ?? 700),
|
|
1851
|
+
letterSpacing: "-0.02em",
|
|
1852
|
+
maxWidth: `${Math.round(g.fr.width * 0.9)}px`,
|
|
1853
|
+
width: "max-content",
|
|
1854
|
+
});
|
|
1855
|
+
const x = o.x ?? g.fr.width / 2;
|
|
1856
|
+
const y = o.y ?? g.fr.height / 2;
|
|
1857
|
+
const shift = align === "left" ? "0%" : align === "center" ? "-50%" : "-100%";
|
|
1858
|
+
el.style.transform = `translate(${r1(x)}px, ${r1(y)}px) translate(${shift}, -50%)`;
|
|
1859
|
+
}
|
|
1860
|
+
const a = at(t);
|
|
1861
|
+
el.style.visibility = a.visible ? "inherit" : "hidden";
|
|
1862
|
+
if (!a.visible) return a;
|
|
1863
|
+
if (o.colour) el.style.color = o.colour;
|
|
1864
|
+
else {
|
|
1865
|
+
const { ink, shadow } = inkFor(sceneBehind([el]));
|
|
1866
|
+
el.style.color = ink;
|
|
1867
|
+
el.style.textShadow = shadow === "none" ? "" : shadow;
|
|
1868
|
+
}
|
|
1869
|
+
a.letters.forEach((l, i) => {
|
|
1870
|
+
const s = spans[i];
|
|
1871
|
+
if (!s) return;
|
|
1872
|
+
s.style.opacity = String(r1(l.opacity * 1000) / 1000);
|
|
1873
|
+
s.style.filter = l.blur > 0.05 ? `blur(${l.blur}px)` : "";
|
|
1874
|
+
s.style.transform = l.y ? `translateY(${l.y}px)` : "";
|
|
1875
|
+
});
|
|
1876
|
+
return a;
|
|
1877
|
+
};
|
|
1878
|
+
return { el, at, draw };
|
|
1879
|
+
}
|