@open-take/compositor 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdp-CzT5BKNY.js +3 -0
- package/dist/cdp-QXbQfXna.js +373 -0
- package/dist/cdp-QXbQfXna.js.map +1 -0
- package/dist/index.d.ts +4327 -195
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26282 -160
- package/dist/index.js.map +1 -1
- package/dist/server-841PMF2H.js +163 -0
- package/dist/server-841PMF2H.js.map +1 -0
- package/dist/server-C2aVv4-t.js +3 -0
- package/kit/audio.mjs +2366 -0
- package/kit/camera.js +587 -0
- package/kit/cursor.js +264 -0
- package/kit/cut.js +427 -0
- package/kit/draw.js +346 -0
- package/kit/look.js +589 -0
- package/kit/map.js +170 -0
- package/kit/media.js +3568 -0
- package/kit/motion.js +1115 -0
- package/kit/seams.js +1006 -0
- package/kit/stage.js +923 -0
- package/kit/time.js +812 -0
- package/kit/world.js +1072 -0
- package/package.json +7 -3
- package/src/ffmpeg.ts +63 -0
- package/src/film/beats.ts +1285 -0
- package/src/film/carry.ts +221 -0
- package/src/film/changes.ts +330 -0
- package/src/film/check.ts +996 -0
- package/src/film/clock.ts +2530 -0
- package/src/film/components-probe.ts +809 -0
- package/src/film/components.ts +1566 -0
- package/src/film/frames.ts +389 -0
- package/src/film/gallery.ts +3276 -0
- package/src/film/kit.ts +515 -0
- package/src/film/layout.ts +701 -0
- package/src/film/listen.ts +1979 -0
- package/src/film/look.ts +3829 -0
- package/src/film/materials.ts +976 -0
- package/src/film/moving.ts +248 -0
- package/src/film/part-files.ts +729 -0
- package/src/film/picture.ts +74 -0
- package/src/film/probe-text.ts +843 -0
- package/src/film/probe.ts +3456 -0
- package/src/film/provenance.ts +596 -0
- package/src/film/render.ts +2447 -0
- package/src/film/report.ts +1631 -0
- package/src/film/sheet.ts +156 -0
- package/src/film/study-declared.ts +123 -0
- package/src/film/study-picture.ts +791 -0
- package/src/film/study-sound.ts +416 -0
- package/src/film/study.ts +864 -0
- package/src/film/tuning.ts +155 -0
- package/src/film/viewer.ts +174 -0
- package/src/html/cdp.ts +575 -0
- package/src/html/server.ts +208 -0
- package/src/index.ts +202 -0
- package/src/launch-render.ts +3 -2
- package/src/math.ts +3 -3
- package/src/mjpeg-matroska.ts +228 -0
- package/src/render.ts +6 -4
- package/src/state-diff.ts +215 -0
- package/src/state-index.ts +99 -0
- package/src/types.ts +59 -1
- package/starter/PLAN.md +84 -0
- package/starter/START.md +460 -0
- package/starter/lib/anim.js +760 -0
- package/starter/lib/devices.js +1402 -0
- package/starter/lib/handoff.js +421 -0
- package/starter/lib/hud.js +1879 -0
- package/starter/lib/measure.mjs +154 -0
- package/starter/lib/moves.js +1095 -0
- package/starter/lib/palette.mjs +803 -0
- package/starter/lib/physics-seeds.mjs +198 -0
- package/starter/lib/physics.js +738 -0
- package/starter/lib/sampler.mjs +242 -0
- package/starter/lib/solid.js +727 -0
- package/starter/lib/space.js +1227 -0
- package/starter/lib/swarm.js +1398 -0
- package/starter/reference/motion.md +276 -0
- package/starter/reference/structure.md +466 -0
- package/starter/reference/travel/motion.md +433 -0
- package/starter/reference/travel/sound.md +241 -0
- package/starter/reference/travel/structure.md +518 -0
- package/starter/samples/NOTICE.txt +55 -0
- package/starter/samples/celli/celli_24_1.opus +0 -0
- package/starter/samples/celli/celli_24_3.opus +0 -0
- package/starter/samples/celli/celli_28_1.opus +0 -0
- package/starter/samples/celli/celli_28_3.opus +0 -0
- package/starter/samples/celli/celli_31_1.opus +0 -0
- package/starter/samples/celli/celli_31_3.opus +0 -0
- package/starter/samples/celli/celli_35_1.opus +0 -0
- package/starter/samples/celli/celli_35_3.opus +0 -0
- package/starter/samples/celli/celli_38_1.opus +0 -0
- package/starter/samples/celli/celli_38_3.opus +0 -0
- package/starter/samples/celli/celli_41_1.opus +0 -0
- package/starter/samples/celli/celli_41_3.opus +0 -0
- package/starter/samples/celli/celli_45_1.opus +0 -0
- package/starter/samples/celli/celli_45_3.opus +0 -0
- package/starter/samples/celli/celli_48_1.opus +0 -0
- package/starter/samples/celli/celli_48_3.opus +0 -0
- package/starter/samples/celli/celli_52_1.opus +0 -0
- package/starter/samples/celli/celli_52_3.opus +0 -0
- package/starter/samples/celli/celli_55_1.opus +0 -0
- package/starter/samples/celli/celli_55_3.opus +0 -0
- package/starter/samples/celli/celli_59_1.opus +0 -0
- package/starter/samples/celli/celli_59_3.opus +0 -0
- package/starter/samples/celli/celli_62_1.opus +0 -0
- package/starter/samples/celli/celli_62_3.opus +0 -0
- package/starter/samples/celli/celli_65_1.opus +0 -0
- package/starter/samples/celli/celli_65_3.opus +0 -0
- package/starter/samples/crash/crash_f_1.flac +0 -0
- package/starter/samples/crash/crash_fff_1.flac +0 -0
- package/starter/samples/ebass/ebass_0_x.flac +0 -0
- package/starter/samples/ebass/ebass_10_x.flac +0 -0
- package/starter/samples/ebass/ebass_11_x.flac +0 -0
- package/starter/samples/ebass/ebass_1_x.flac +0 -0
- package/starter/samples/ebass/ebass_2_x.flac +0 -0
- package/starter/samples/ebass/ebass_3_x.flac +0 -0
- package/starter/samples/ebass/ebass_4_x.flac +0 -0
- package/starter/samples/ebass/ebass_5_x.flac +0 -0
- package/starter/samples/ebass/ebass_6_x.flac +0 -0
- package/starter/samples/ebass/ebass_7_x.flac +0 -0
- package/starter/samples/ebass/ebass_8_x.flac +0 -0
- package/starter/samples/ebass/ebass_9_x.flac +0 -0
- package/starter/samples/ek_clap/ek_clap_1_1.flac +0 -0
- package/starter/samples/ek_hat/ek_hat_1_1.flac +0 -0
- package/starter/samples/ek_hat/ek_hat_1_2.flac +0 -0
- package/starter/samples/ek_kick/ek_kick_1_1.flac +0 -0
- package/starter/samples/ek_kick/ek_kick_1_2.flac +0 -0
- package/starter/samples/glock/glock_67_x.flac +0 -0
- package/starter/samples/glock/glock_72_x.flac +0 -0
- package/starter/samples/glock/glock_79_x.flac +0 -0
- package/starter/samples/glock/glock_84_x.flac +0 -0
- package/starter/samples/glock/glock_91_x.flac +0 -0
- package/starter/samples/glock/glock_96_x.flac +0 -0
- package/starter/samples/harp/harp_101_f.opus +0 -0
- package/starter/samples/harp/harp_28_f.opus +0 -0
- package/starter/samples/harp/harp_31_mp.opus +0 -0
- package/starter/samples/harp/harp_35_mf.opus +0 -0
- package/starter/samples/harp/harp_38_mf.opus +0 -0
- package/starter/samples/harp/harp_41_mf.opus +0 -0
- package/starter/samples/harp/harp_45_mf.opus +0 -0
- package/starter/samples/harp/harp_48_mf.opus +0 -0
- package/starter/samples/harp/harp_52_mf.opus +0 -0
- package/starter/samples/harp/harp_55_mf.opus +0 -0
- package/starter/samples/harp/harp_59_mf.opus +0 -0
- package/starter/samples/harp/harp_62_mf.opus +0 -0
- package/starter/samples/harp/harp_65_mf.opus +0 -0
- package/starter/samples/harp/harp_69_mf.opus +0 -0
- package/starter/samples/harp/harp_72_mf.opus +0 -0
- package/starter/samples/harp/harp_76_mf.opus +0 -0
- package/starter/samples/harp/harp_79_mf.opus +0 -0
- package/starter/samples/harp/harp_83_mf.opus +0 -0
- package/starter/samples/harp/harp_86_mf.opus +0 -0
- package/starter/samples/harp/harp_89_mf.opus +0 -0
- package/starter/samples/harp/harp_93_mf.opus +0 -0
- package/starter/samples/harp/harp_95_mf.opus +0 -0
- package/starter/samples/harp/harp_98_f.opus +0 -0
- package/starter/samples/manifest.json +2951 -0
- package/starter/samples/marimba/marimba_29_x.flac +0 -0
- package/starter/samples/marimba/marimba_36_x.flac +0 -0
- package/starter/samples/marimba/marimba_43_x.flac +0 -0
- package/starter/samples/marimba/marimba_47_x.flac +0 -0
- package/starter/samples/marimba/marimba_53_x.flac +0 -0
- package/starter/samples/marimba/marimba_60_x.flac +0 -0
- package/starter/samples/marimba/marimba_67_x.flac +0 -0
- package/starter/samples/marimba/marimba_71_x.flac +0 -0
- package/starter/samples/marimba/marimba_77_x.flac +0 -0
- package/starter/samples/marimba/marimba_84_x.flac +0 -0
- package/starter/samples/piano/piano_102_12.opus +0 -0
- package/starter/samples/piano/piano_102_16.opus +0 -0
- package/starter/samples/piano/piano_102_4.opus +0 -0
- package/starter/samples/piano/piano_102_8.opus +0 -0
- package/starter/samples/piano/piano_105_12.opus +0 -0
- package/starter/samples/piano/piano_105_16.opus +0 -0
- package/starter/samples/piano/piano_105_4.opus +0 -0
- package/starter/samples/piano/piano_105_8.opus +0 -0
- package/starter/samples/piano/piano_108_12.opus +0 -0
- package/starter/samples/piano/piano_108_16.opus +0 -0
- package/starter/samples/piano/piano_108_4.opus +0 -0
- package/starter/samples/piano/piano_108_8.opus +0 -0
- package/starter/samples/piano/piano_21_12.opus +0 -0
- package/starter/samples/piano/piano_21_16.opus +0 -0
- package/starter/samples/piano/piano_21_4.opus +0 -0
- package/starter/samples/piano/piano_21_8.opus +0 -0
- package/starter/samples/piano/piano_24_12.opus +0 -0
- package/starter/samples/piano/piano_24_16.opus +0 -0
- package/starter/samples/piano/piano_24_4.opus +0 -0
- package/starter/samples/piano/piano_24_8.opus +0 -0
- package/starter/samples/piano/piano_27_12.opus +0 -0
- package/starter/samples/piano/piano_27_16.opus +0 -0
- package/starter/samples/piano/piano_27_4.opus +0 -0
- package/starter/samples/piano/piano_27_8.opus +0 -0
- package/starter/samples/piano/piano_30_12.opus +0 -0
- package/starter/samples/piano/piano_30_16.opus +0 -0
- package/starter/samples/piano/piano_30_4.opus +0 -0
- package/starter/samples/piano/piano_30_8.opus +0 -0
- package/starter/samples/piano/piano_33_12.opus +0 -0
- package/starter/samples/piano/piano_33_16.opus +0 -0
- package/starter/samples/piano/piano_33_4.opus +0 -0
- package/starter/samples/piano/piano_33_8.opus +0 -0
- package/starter/samples/piano/piano_36_12.opus +0 -0
- package/starter/samples/piano/piano_36_16.opus +0 -0
- package/starter/samples/piano/piano_36_4.opus +0 -0
- package/starter/samples/piano/piano_36_8.opus +0 -0
- package/starter/samples/piano/piano_39_12.opus +0 -0
- package/starter/samples/piano/piano_39_16.opus +0 -0
- package/starter/samples/piano/piano_39_4.opus +0 -0
- package/starter/samples/piano/piano_39_8.opus +0 -0
- package/starter/samples/piano/piano_42_12.opus +0 -0
- package/starter/samples/piano/piano_42_16.opus +0 -0
- package/starter/samples/piano/piano_42_4.opus +0 -0
- package/starter/samples/piano/piano_42_8.opus +0 -0
- package/starter/samples/piano/piano_45_12.opus +0 -0
- package/starter/samples/piano/piano_45_16.opus +0 -0
- package/starter/samples/piano/piano_45_4.opus +0 -0
- package/starter/samples/piano/piano_45_8.opus +0 -0
- package/starter/samples/piano/piano_48_12.opus +0 -0
- package/starter/samples/piano/piano_48_16.opus +0 -0
- package/starter/samples/piano/piano_48_4.opus +0 -0
- package/starter/samples/piano/piano_48_8.opus +0 -0
- package/starter/samples/piano/piano_51_12.opus +0 -0
- package/starter/samples/piano/piano_51_16.opus +0 -0
- package/starter/samples/piano/piano_51_4.opus +0 -0
- package/starter/samples/piano/piano_51_8.opus +0 -0
- package/starter/samples/piano/piano_54_12.opus +0 -0
- package/starter/samples/piano/piano_54_16.opus +0 -0
- package/starter/samples/piano/piano_54_4.opus +0 -0
- package/starter/samples/piano/piano_54_8.opus +0 -0
- package/starter/samples/piano/piano_57_12.opus +0 -0
- package/starter/samples/piano/piano_57_16.opus +0 -0
- package/starter/samples/piano/piano_57_4.opus +0 -0
- package/starter/samples/piano/piano_57_8.opus +0 -0
- package/starter/samples/piano/piano_60_12.opus +0 -0
- package/starter/samples/piano/piano_60_16.opus +0 -0
- package/starter/samples/piano/piano_60_4.opus +0 -0
- package/starter/samples/piano/piano_60_8.opus +0 -0
- package/starter/samples/piano/piano_63_12.opus +0 -0
- package/starter/samples/piano/piano_63_16.opus +0 -0
- package/starter/samples/piano/piano_63_4.opus +0 -0
- package/starter/samples/piano/piano_63_8.opus +0 -0
- package/starter/samples/piano/piano_66_12.opus +0 -0
- package/starter/samples/piano/piano_66_16.opus +0 -0
- package/starter/samples/piano/piano_66_4.opus +0 -0
- package/starter/samples/piano/piano_66_8.opus +0 -0
- package/starter/samples/piano/piano_69_12.opus +0 -0
- package/starter/samples/piano/piano_69_16.opus +0 -0
- package/starter/samples/piano/piano_69_4.opus +0 -0
- package/starter/samples/piano/piano_69_8.opus +0 -0
- package/starter/samples/piano/piano_72_12.opus +0 -0
- package/starter/samples/piano/piano_72_16.opus +0 -0
- package/starter/samples/piano/piano_72_4.opus +0 -0
- package/starter/samples/piano/piano_72_8.opus +0 -0
- package/starter/samples/piano/piano_75_12.opus +0 -0
- package/starter/samples/piano/piano_75_16.opus +0 -0
- package/starter/samples/piano/piano_75_4.opus +0 -0
- package/starter/samples/piano/piano_75_8.opus +0 -0
- package/starter/samples/piano/piano_78_12.opus +0 -0
- package/starter/samples/piano/piano_78_16.opus +0 -0
- package/starter/samples/piano/piano_78_4.opus +0 -0
- package/starter/samples/piano/piano_78_8.opus +0 -0
- package/starter/samples/piano/piano_81_12.opus +0 -0
- package/starter/samples/piano/piano_81_16.opus +0 -0
- package/starter/samples/piano/piano_81_4.opus +0 -0
- package/starter/samples/piano/piano_81_8.opus +0 -0
- package/starter/samples/piano/piano_84_12.opus +0 -0
- package/starter/samples/piano/piano_84_16.opus +0 -0
- package/starter/samples/piano/piano_84_4.opus +0 -0
- package/starter/samples/piano/piano_84_8.opus +0 -0
- package/starter/samples/piano/piano_87_12.opus +0 -0
- package/starter/samples/piano/piano_87_16.opus +0 -0
- package/starter/samples/piano/piano_87_4.opus +0 -0
- package/starter/samples/piano/piano_87_8.opus +0 -0
- package/starter/samples/piano/piano_90_12.opus +0 -0
- package/starter/samples/piano/piano_90_16.opus +0 -0
- package/starter/samples/piano/piano_90_4.opus +0 -0
- package/starter/samples/piano/piano_90_8.opus +0 -0
- package/starter/samples/piano/piano_93_12.opus +0 -0
- package/starter/samples/piano/piano_93_16.opus +0 -0
- package/starter/samples/piano/piano_93_4.opus +0 -0
- package/starter/samples/piano/piano_93_8.opus +0 -0
- package/starter/samples/piano/piano_96_12.opus +0 -0
- package/starter/samples/piano/piano_96_16.opus +0 -0
- package/starter/samples/piano/piano_96_4.opus +0 -0
- package/starter/samples/piano/piano_96_8.opus +0 -0
- package/starter/samples/piano/piano_99_12.opus +0 -0
- package/starter/samples/piano/piano_99_16.opus +0 -0
- package/starter/samples/piano/piano_99_4.opus +0 -0
- package/starter/samples/piano/piano_99_8.opus +0 -0
- package/starter/samples/piano/piano_rel_102_x.opus +0 -0
- package/starter/samples/piano/piano_rel_105_x.opus +0 -0
- package/starter/samples/piano/piano_rel_108_x.opus +0 -0
- package/starter/samples/piano/piano_rel_21_x.opus +0 -0
- package/starter/samples/piano/piano_rel_24_x.opus +0 -0
- package/starter/samples/piano/piano_rel_27_x.opus +0 -0
- package/starter/samples/piano/piano_rel_30_x.opus +0 -0
- package/starter/samples/piano/piano_rel_33_x.opus +0 -0
- package/starter/samples/piano/piano_rel_36_x.opus +0 -0
- package/starter/samples/piano/piano_rel_39_x.opus +0 -0
- package/starter/samples/piano/piano_rel_42_x.opus +0 -0
- package/starter/samples/piano/piano_rel_45_x.opus +0 -0
- package/starter/samples/piano/piano_rel_48_x.opus +0 -0
- package/starter/samples/piano/piano_rel_51_x.opus +0 -0
- package/starter/samples/piano/piano_rel_54_x.opus +0 -0
- package/starter/samples/piano/piano_rel_57_x.opus +0 -0
- package/starter/samples/piano/piano_rel_60_x.opus +0 -0
- package/starter/samples/piano/piano_rel_63_x.opus +0 -0
- package/starter/samples/piano/piano_rel_66_x.opus +0 -0
- package/starter/samples/piano/piano_rel_69_x.opus +0 -0
- package/starter/samples/piano/piano_rel_72_x.opus +0 -0
- package/starter/samples/piano/piano_rel_75_x.opus +0 -0
- package/starter/samples/piano/piano_rel_78_x.opus +0 -0
- package/starter/samples/piano/piano_rel_81_x.opus +0 -0
- package/starter/samples/piano/piano_rel_84_x.opus +0 -0
- package/starter/samples/piano/piano_rel_87_x.opus +0 -0
- package/starter/samples/piano/piano_rel_90_x.opus +0 -0
- package/starter/samples/piano/piano_rel_93_x.opus +0 -0
- package/starter/samples/piano/piano_rel_96_x.opus +0 -0
- package/starter/samples/piano/piano_rel_99_x.opus +0 -0
- package/starter/samples/pizz/pizz_24_2.flac +0 -0
- package/starter/samples/pizz/pizz_28_2.flac +0 -0
- package/starter/samples/pizz/pizz_31_2.flac +0 -0
- package/starter/samples/pizz/pizz_35_2.flac +0 -0
- package/starter/samples/pizz/pizz_38_2.flac +0 -0
- package/starter/samples/pizz/pizz_41_2.flac +0 -0
- package/starter/samples/pizz/pizz_45_2.flac +0 -0
- package/starter/samples/pizz/pizz_48_2.flac +0 -0
- package/starter/samples/pizz/pizz_52_2.flac +0 -0
- package/starter/samples/pizz/pizz_57_2.flac +0 -0
- package/starter/samples/pizz/pizz_60_2.flac +0 -0
- package/starter/samples/pizz/pizz_64_2.flac +0 -0
- package/starter/samples/pizz/pizz_67_2.flac +0 -0
- package/starter/samples/pizz/pizz_71_2.flac +0 -0
- package/starter/samples/pizz/pizz_74_2.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_2_1.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_2_2.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_6_1.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_6_2.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_3_1.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_3_2.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_7_1.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_7_2.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_3_1.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_3_2.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_6_1.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_6_2.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_2_1.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_2_2.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_5_1.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_5_2.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_3_1.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_3_2.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_7_1.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_7_2.flac +0 -0
- package/starter/samples/shaker/shaker_1_1.flac +0 -0
- package/starter/samples/shaker/shaker_2_1.flac +0 -0
- package/starter/samples/snap/snap_r_1.flac +0 -0
- package/starter/samples/snap/snap_r_2.flac +0 -0
- package/starter/samples/snap/snap_r_3.flac +0 -0
- package/starter/samples/snap/snap_r_4.flac +0 -0
- package/starter/samples/snap/snap_r_5.flac +0 -0
- package/starter/samples/snap/snap_r_6.flac +0 -0
- package/starter/samples/tom/tom_3_1.flac +0 -0
- package/starter/samples/tom/tom_3_2.flac +0 -0
- package/starter/samples/tom/tom_4_1.flac +0 -0
- package/starter/samples/tom/tom_4_2.flac +0 -0
- package/starter/samples/vibes/vibes_41_1.opus +0 -0
- package/starter/samples/vibes/vibes_41_2.opus +0 -0
- package/starter/samples/vibes/vibes_45_1.opus +0 -0
- package/starter/samples/vibes/vibes_45_2.opus +0 -0
- package/starter/samples/vibes/vibes_48_1.opus +0 -0
- package/starter/samples/vibes/vibes_48_2.opus +0 -0
- package/starter/samples/vibes/vibes_52_1.opus +0 -0
- package/starter/samples/vibes/vibes_52_2.opus +0 -0
- package/starter/samples/vibes/vibes_55_1.opus +0 -0
- package/starter/samples/vibes/vibes_55_2.opus +0 -0
- package/starter/samples/vibes/vibes_59_1.opus +0 -0
- package/starter/samples/vibes/vibes_59_2.opus +0 -0
- package/starter/samples/vibes/vibes_62_1.opus +0 -0
- package/starter/samples/vibes/vibes_62_2.opus +0 -0
- package/starter/samples/vibes/vibes_65_1.opus +0 -0
- package/starter/samples/vibes/vibes_65_2.opus +0 -0
- package/starter/samples/vibes/vibes_69_1.opus +0 -0
- package/starter/samples/vibes/vibes_69_2.opus +0 -0
- package/starter/samples/vibes/vibes_72_1.opus +0 -0
- package/starter/samples/vibes/vibes_72_2.opus +0 -0
- package/starter/samples/vibes/vibes_76_1.opus +0 -0
- package/starter/samples/vibes/vibes_76_2.opus +0 -0
- package/starter/samples/violas/violas_36_1.opus +0 -0
- package/starter/samples/violas/violas_36_2.opus +0 -0
- package/starter/samples/violas/violas_38_1.opus +0 -0
- package/starter/samples/violas/violas_38_2.opus +0 -0
- package/starter/samples/violas/violas_40_1.opus +0 -0
- package/starter/samples/violas/violas_40_2.opus +0 -0
- package/starter/samples/violas/violas_43_1.opus +0 -0
- package/starter/samples/violas/violas_43_2.opus +0 -0
- package/starter/samples/violas/violas_47_1.opus +0 -0
- package/starter/samples/violas/violas_47_2.opus +0 -0
- package/starter/samples/violas/violas_50_1.opus +0 -0
- package/starter/samples/violas/violas_50_2.opus +0 -0
- package/starter/samples/violas/violas_53_1.opus +0 -0
- package/starter/samples/violas/violas_53_2.opus +0 -0
- package/starter/samples/violas/violas_57_1.opus +0 -0
- package/starter/samples/violas/violas_57_2.opus +0 -0
- package/starter/samples/violas/violas_60_1.opus +0 -0
- package/starter/samples/violas/violas_60_2.opus +0 -0
- package/starter/samples/violas/violas_64_1.opus +0 -0
- package/starter/samples/violas/violas_64_2.opus +0 -0
- package/starter/samples/violas/violas_67_1.opus +0 -0
- package/starter/samples/violas/violas_67_2.opus +0 -0
- package/starter/samples/violas/violas_71_1.opus +0 -0
- package/starter/samples/violas/violas_71_2.opus +0 -0
- package/starter/samples/violas/violas_74_1.opus +0 -0
- package/starter/samples/violas/violas_74_2.opus +0 -0
- package/starter/samples/violins/violins_43_1.opus +0 -0
- package/starter/samples/violins/violins_43_2.opus +0 -0
- package/starter/samples/violins/violins_45_1.opus +0 -0
- package/starter/samples/violins/violins_45_2.opus +0 -0
- package/starter/samples/violins/violins_47_1.opus +0 -0
- package/starter/samples/violins/violins_47_2.opus +0 -0
- package/starter/samples/violins/violins_50_1.opus +0 -0
- package/starter/samples/violins/violins_50_2.opus +0 -0
- package/starter/samples/violins/violins_54_1.opus +0 -0
- package/starter/samples/violins/violins_54_2.opus +0 -0
- package/starter/samples/violins/violins_57_1.opus +0 -0
- package/starter/samples/violins/violins_57_2.opus +0 -0
- package/starter/samples/violins/violins_60_1.opus +0 -0
- package/starter/samples/violins/violins_60_2.opus +0 -0
- package/starter/samples/violins/violins_64_1.opus +0 -0
- package/starter/samples/violins/violins_64_2.opus +0 -0
- package/starter/samples/violins/violins_67_1.opus +0 -0
- package/starter/samples/violins/violins_67_2.opus +0 -0
- package/starter/samples/violins/violins_71_1.opus +0 -0
- package/starter/samples/violins/violins_71_2.opus +0 -0
- package/starter/samples/violins/violins_74_1.opus +0 -0
- package/starter/samples/violins/violins_74_2.opus +0 -0
- package/starter/samples/woodblock/woodblock_f_1.flac +0 -0
- package/starter/samples/woodblock/woodblock_f_2.flac +0 -0
package/kit/draw.js
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Marks and light on a film page — open-take's film kit. What a hand or a
|
|
3
|
+
// light does to a picture, as plain functions of time: a stroke drawn round
|
|
4
|
+
// something and drawn off again, a leader out to a label, the rest of the
|
|
5
|
+
// picture dimmed round one part, a line that sweeps an after over a before,
|
|
6
|
+
// a band of light that uncovers a screen, a flash on a beat. They return
|
|
7
|
+
// numbers and CSS strings; where they go (an SVG over a saved screen, a
|
|
8
|
+
// canvas, a mask) is the page's. Nothing here is a style: the colour, the
|
|
9
|
+
// width, whether to use any of it at all are the film's.
|
|
10
|
+
//
|
|
11
|
+
// import { scribble, stroke, spotlight, sweep, lightSweep, flash } from "./kit/draw.js";
|
|
12
|
+
// // a circle drawn round the price at 8.2 s, held, drawn off at 9.6 s
|
|
13
|
+
// path.setAttribute("d", scribble(screen.box(".price"), { kind: "circle" }));
|
|
14
|
+
// path.setAttribute("pathLength", "1");
|
|
15
|
+
// const s = stroke(t, 8.2, { off: 9.6 });
|
|
16
|
+
// path.style.strokeDasharray = s.dasharray; path.style.strokeDashoffset = String(s.dashoffset);
|
|
17
|
+
// // the after layer swept over the before, 4 → 4.5 s
|
|
18
|
+
// after.style.clipPath = sweep(t, 4, 4.5, { width: 1920, height: 1080 }).clip;
|
|
19
|
+
//
|
|
20
|
+
// The numbers come from widely shared launch films, measured frame by frame (`skill
|
|
21
|
+
// film craft`); each is an option of its call.
|
|
22
|
+
|
|
23
|
+
/** @typedef {{ x: number, y: number }} Pt */
|
|
24
|
+
/** @typedef {{ x: number, y: number, w?: number, h?: number, width?: number, height?: number }} BoxLike */
|
|
25
|
+
/** @typedef {{ width: number, height: number }} Size */
|
|
26
|
+
|
|
27
|
+
/** @param {number} x */
|
|
28
|
+
const clamp01 = (x) => Math.max(0, Math.min(1, x));
|
|
29
|
+
/** @param {number} a @param {number} b @param {number} p */
|
|
30
|
+
const lerp = (a, b, p) => a + (b - a) * p;
|
|
31
|
+
/** smootherstep */
|
|
32
|
+
/** @param {number} p */
|
|
33
|
+
const smooth = (p) => {
|
|
34
|
+
const x = clamp01(p);
|
|
35
|
+
return x * x * x * (x * (x * 6 - 15) + 10);
|
|
36
|
+
};
|
|
37
|
+
/** @param {number} p */
|
|
38
|
+
const easeOut = (p) => 1 - (1 - clamp01(p)) ** 3;
|
|
39
|
+
/** @param {BoxLike} b */
|
|
40
|
+
const boxOf = (b) => ({ x: b.x, y: b.y, w: b.w ?? b.width ?? 0, h: b.h ?? b.height ?? 0 });
|
|
41
|
+
const f2 = (/** @type {number} */ v) => +v.toFixed(2);
|
|
42
|
+
|
|
43
|
+
/** a seeded number in [0, 1) for (i, seed): the same every render */
|
|
44
|
+
/** @param {number} i @param {number} seed */
|
|
45
|
+
function hash(i, seed) {
|
|
46
|
+
let h = Math.imul(i ^ 0x9e3779b9, 0x85ebca6b) ^ Math.imul(seed + 0x632be5ab, 0xc2b2ae35);
|
|
47
|
+
h ^= h >>> 15;
|
|
48
|
+
h = Math.imul(h, 0x2c1b3c6d);
|
|
49
|
+
h ^= h >>> 12;
|
|
50
|
+
return (h >>> 0) / 4294967296;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** smooth seeded wobble along u (about -1..1), a few bumps per turn */
|
|
54
|
+
/** @param {number} u @param {number} seed */
|
|
55
|
+
function wobble(u, seed) {
|
|
56
|
+
const i = Math.floor(u);
|
|
57
|
+
const f = u - i;
|
|
58
|
+
const s = f * f * (3 - 2 * f);
|
|
59
|
+
return lerp(hash(i, seed) * 2 - 1, hash(i + 1, seed) * 2 - 1, s);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// --- strokes ---------------------------------------------------------------------
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A hand-drawn mark as an SVG path `d`, round or under a box: deterministic
|
|
66
|
+
* per `seed`, slightly uneven like a quick stroke of a pen. Draw it with
|
|
67
|
+
* `pathLength="1"` and `stroke()`.
|
|
68
|
+
*
|
|
69
|
+
* - "circle": an ellipse round the box, `pad` px outside it, starting a little
|
|
70
|
+
* above-left and running past its start (`turns` 1.1: the end overlaps the
|
|
71
|
+
* beginning, as a quick circle does; 2.1 is a double scribble);
|
|
72
|
+
* - "underline": a slightly bowed line under the box;
|
|
73
|
+
* - "box": a rough rectangle round it;
|
|
74
|
+
* - "strike": a line through its middle;
|
|
75
|
+
* - "arrow": from `from` to the box's nearest edge, bowed, with a head.
|
|
76
|
+
*
|
|
77
|
+
* `wobble` is how far the hand strays, in px (default 3% of the box's short
|
|
78
|
+
* side, at least 2): marks in those films strayed a few px, never
|
|
79
|
+
* enough to read as shaky.
|
|
80
|
+
* @param {BoxLike} box
|
|
81
|
+
* @param {{ kind?: "circle" | "underline" | "box" | "strike" | "arrow", pad?: number,
|
|
82
|
+
* turns?: number, wobble?: number, seed?: number, from?: Pt, bow?: number, head?: number }} [opts]
|
|
83
|
+
* @returns {string}
|
|
84
|
+
*/
|
|
85
|
+
export function scribble(box, opts = {}) {
|
|
86
|
+
const b = boxOf(box);
|
|
87
|
+
const { kind = "circle", seed = 1 } = opts;
|
|
88
|
+
const short = Math.max(1, Math.min(b.w, b.h));
|
|
89
|
+
const wob = opts.wobble ?? Math.max(2, short * 0.03);
|
|
90
|
+
const cx = b.x + b.w / 2;
|
|
91
|
+
const cy = b.y + b.h / 2;
|
|
92
|
+
/** @type {Pt[]} */
|
|
93
|
+
const pts = [];
|
|
94
|
+
if (kind === "circle") {
|
|
95
|
+
const pad = opts.pad ?? Math.max(8, short * 0.18);
|
|
96
|
+
// an ellipse round a box passes outside its corners at √2 × the half sizes
|
|
97
|
+
const rx = (b.w / 2) * Math.SQRT2 + pad;
|
|
98
|
+
const ry = (b.h / 2) * Math.SQRT2 + pad;
|
|
99
|
+
const turns = opts.turns ?? 1.1;
|
|
100
|
+
const n = Math.ceil(48 * turns);
|
|
101
|
+
const a0 = -2.4; // starts upper left, as a right hand does
|
|
102
|
+
for (let i = 0; i <= n; i++) {
|
|
103
|
+
const u = i / n;
|
|
104
|
+
const a = a0 + u * turns * Math.PI * 2;
|
|
105
|
+
// each lap a little off the last, as a hand never closes on itself
|
|
106
|
+
const k = 1 + wobble(u * turns * 5, seed) * (wob / Math.min(rx, ry)) + u * 0.04;
|
|
107
|
+
pts.push({ x: cx + Math.cos(a) * rx * k, y: cy + Math.sin(a) * ry * k });
|
|
108
|
+
}
|
|
109
|
+
} else if (kind === "underline" || kind === "strike") {
|
|
110
|
+
const y0 = kind === "strike" ? cy : b.y + b.h + (opts.pad ?? Math.max(4, b.h * 0.12));
|
|
111
|
+
const x0 = b.x - b.w * 0.03;
|
|
112
|
+
const x1 = b.x + b.w * 1.03;
|
|
113
|
+
const bow = opts.bow ?? b.w * 0.015;
|
|
114
|
+
for (let i = 0; i <= 24; i++) {
|
|
115
|
+
const u = i / 24;
|
|
116
|
+
pts.push({
|
|
117
|
+
x: lerp(x0, x1, u),
|
|
118
|
+
y: y0 + Math.sin(u * Math.PI) * bow + wobble(u * 4, seed) * wob * 0.6 + u * wob,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
} else if (kind === "box") {
|
|
122
|
+
const pad = opts.pad ?? Math.max(6, short * 0.12);
|
|
123
|
+
const c = [
|
|
124
|
+
{ x: b.x - pad, y: b.y - pad },
|
|
125
|
+
{ x: b.x + b.w + pad, y: b.y - pad },
|
|
126
|
+
{ x: b.x + b.w + pad, y: b.y + b.h + pad },
|
|
127
|
+
{ x: b.x - pad, y: b.y + b.h + pad },
|
|
128
|
+
{ x: b.x - pad, y: b.y - pad },
|
|
129
|
+
];
|
|
130
|
+
for (let s = 0; s < 4; s++)
|
|
131
|
+
for (let i = s ? 1 : 0; i <= 12; i++) {
|
|
132
|
+
const u = i / 12;
|
|
133
|
+
const c0 = /** @type {{ x: number, y: number }} */ (c[s]);
|
|
134
|
+
const c1 = /** @type {{ x: number, y: number }} */ (c[s + 1]);
|
|
135
|
+
pts.push({
|
|
136
|
+
x: lerp(c0.x, c1.x, u) + wobble(s * 3 + u * 2, seed) * wob,
|
|
137
|
+
y: lerp(c0.y, c1.y, u) + wobble(s * 3 + u * 2, seed + 7) * wob,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
} else if (kind === "arrow") {
|
|
141
|
+
const from = opts.from ?? { x: b.x - b.w, y: b.y + b.h * 2 };
|
|
142
|
+
// land on the box's edge nearest the start, a little outside it
|
|
143
|
+
const to = {
|
|
144
|
+
x: Math.max(b.x - 6, Math.min(b.x + b.w + 6, from.x)),
|
|
145
|
+
y: Math.max(b.y - 6, Math.min(b.y + b.h + 6, from.y)),
|
|
146
|
+
};
|
|
147
|
+
if (to.x === from.x && to.y === from.y) to.y = b.y - 6;
|
|
148
|
+
const dx = to.x - from.x;
|
|
149
|
+
const dy = to.y - from.y;
|
|
150
|
+
const len = Math.hypot(dx, dy) || 1;
|
|
151
|
+
const nx = -dy / len;
|
|
152
|
+
const ny = dx / len;
|
|
153
|
+
const bow = opts.bow ?? len * 0.12;
|
|
154
|
+
for (let i = 0; i <= 24; i++) {
|
|
155
|
+
const u = i / 24;
|
|
156
|
+
const off = Math.sin(u * Math.PI) * bow + wobble(u * 3, seed) * wob * 0.5;
|
|
157
|
+
pts.push({ x: from.x + dx * u + nx * off, y: from.y + dy * u + ny * off });
|
|
158
|
+
}
|
|
159
|
+
// the head: two short strokes back from the tip, along the last direction
|
|
160
|
+
const a = /** @type {{ x: number, y: number }} */ (pts[pts.length - 1]);
|
|
161
|
+
const p = /** @type {{ x: number, y: number }} */ (pts[pts.length - 3]);
|
|
162
|
+
const ang = Math.atan2(a.y - p.y, a.x - p.x);
|
|
163
|
+
const h = opts.head ?? Math.max(10, Math.min(28, len * 0.12));
|
|
164
|
+
const d = `M${pts.map((q) => `${f2(q.x)} ${f2(q.y)}`).join(" L")}`;
|
|
165
|
+
const wing = (/** @type {number} */ s) =>
|
|
166
|
+
`M${f2(a.x)} ${f2(a.y)} L${f2(a.x - Math.cos(ang + s * 0.5) * h)} ${f2(a.y - Math.sin(ang + s * 0.5) * h)}`;
|
|
167
|
+
return `${d} ${wing(1)} ${wing(-1)}`;
|
|
168
|
+
} else {
|
|
169
|
+
throw new Error(`scribble: no kind "${kind}" (circle, underline, box, strike, arrow)`);
|
|
170
|
+
}
|
|
171
|
+
return `M${pts.map((q) => `${f2(q.x)} ${f2(q.y)}`).join(" L")}`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* A stroke drawn on and, if `off` is given, drawn off again from where it
|
|
176
|
+
* began — the way a pen's mark is taken back, not faded. For a path with
|
|
177
|
+
* `pathLength="1"`: put `dasharray` and `dashoffset` on its style.
|
|
178
|
+
* Defaults: on in 0.4 s (marks in the films measured drew on in 0.3–0.5 s),
|
|
179
|
+
* off in 0.3 s, eased in and out.
|
|
180
|
+
*
|
|
181
|
+
* const s = stroke(t, 8.2, { off: 9.6 });
|
|
182
|
+
* @param {number} t
|
|
183
|
+
* @param {number} start when it begins to draw
|
|
184
|
+
* @param {{ dur?: number, off?: number, offDur?: number, ease?: (p: number) => number }} [opts]
|
|
185
|
+
* @returns {{ dasharray: string, dashoffset: number, visible: boolean, p: number }}
|
|
186
|
+
* p: 0 → 1 drawn on, 1 → 2 drawn off
|
|
187
|
+
*/
|
|
188
|
+
export function stroke(t, start, opts = {}) {
|
|
189
|
+
const { dur = 0.4, offDur = 0.3, ease = smooth } = opts;
|
|
190
|
+
const on = ease(dur > 0 ? (t - start) / dur : t >= start ? 1 : 0);
|
|
191
|
+
const gone =
|
|
192
|
+
opts.off == null ? 0 : ease(offDur > 0 ? (t - opts.off) / offDur : t >= opts.off ? 1 : 0);
|
|
193
|
+
// pathLength 1: the dash is the whole path and so is the gap; the offset
|
|
194
|
+
// slides it on (1 → 0) and then on past its start (0 → −1)
|
|
195
|
+
const dashoffset = gone > 0 ? -gone : 1 - on;
|
|
196
|
+
return {
|
|
197
|
+
dasharray: "1 1",
|
|
198
|
+
dashoffset: +dashoffset.toFixed(5),
|
|
199
|
+
visible: t >= start && gone < 1,
|
|
200
|
+
p: gone > 0 ? 1 + gone : on,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* A leader from a point on the subject out to where its label sits: a short
|
|
206
|
+
* diagonal, then level — the way labels on a teardown or a map are drawn.
|
|
207
|
+
* Returns the path (`pathLength="1"`, drawn with `stroke`) and where the
|
|
208
|
+
* label's text starts.
|
|
209
|
+
* @param {Pt} at the point on the subject
|
|
210
|
+
* @param {Pt} label where the leader ends
|
|
211
|
+
* @param {{ rise?: number, gap?: number }} [opts] rise: share of the way
|
|
212
|
+
* spent on the diagonal (default 0.35); gap: px between the line's end and the text
|
|
213
|
+
* @returns {{ d: string, text: Pt, side: "left" | "right" }}
|
|
214
|
+
*/
|
|
215
|
+
export function leader(at, label, opts = {}) {
|
|
216
|
+
const { rise = 0.35, gap = 12 } = opts;
|
|
217
|
+
const dx = label.x - at.x;
|
|
218
|
+
const knee = { x: at.x + dx * rise, y: label.y };
|
|
219
|
+
const side = dx >= 0 ? "right" : "left";
|
|
220
|
+
return {
|
|
221
|
+
d: `M${f2(at.x)} ${f2(at.y)} L${f2(knee.x)} ${f2(knee.y)} L${f2(label.x)} ${f2(label.y)}`,
|
|
222
|
+
text: { x: label.x + (side === "right" ? gap : -gap), y: label.y },
|
|
223
|
+
side,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// --- light -----------------------------------------------------------------------
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The rest of the picture dimmed round one part: a soft ellipse, clear over
|
|
231
|
+
* the part, darkening outside. Coming on over `in` s from `start` and, if
|
|
232
|
+
* `release` is given, going off over `out` s from then. Returns a CSS
|
|
233
|
+
* background for a full-frame layer over the picture (`pointer-events:
|
|
234
|
+
* none`). Measure the part each frame (`box()` on a saved screen,
|
|
235
|
+
* `throughCamera` through the camera) so the light stays on it as the
|
|
236
|
+
* camera pushes in. Defaults from a film's spotlight: 55 % dark at the
|
|
237
|
+
* edge, on in 0.3 s, off in 0.5 s.
|
|
238
|
+
* @param {number} t
|
|
239
|
+
* @param {number} start
|
|
240
|
+
* @param {BoxLike} box the part, in the picture's px
|
|
241
|
+
* @param {{ amount?: number, in?: number, release?: number, out?: number, color?: string, spread?: number }} [opts]
|
|
242
|
+
* color: the dark, as "r,g,b" (default "0,0,0"); spread: how far past the part the clear centre reaches (default 1.6 × its size)
|
|
243
|
+
* @returns {{ background: string, k: number }}
|
|
244
|
+
*/
|
|
245
|
+
export function spotlight(t, start, box, opts = {}) {
|
|
246
|
+
const { amount = 0.55, color = "0,0,0", spread = 1.6 } = opts;
|
|
247
|
+
const b = boxOf(box);
|
|
248
|
+
const kIn = smooth(opts.in === 0 ? (t >= start ? 1 : 0) : (t - start) / (opts.in ?? 0.3));
|
|
249
|
+
const kOut =
|
|
250
|
+
opts.release == null ? 0 : smooth((t - opts.release) / Math.max(1e-6, opts.out ?? 0.5));
|
|
251
|
+
const k = clamp01(kIn - kOut);
|
|
252
|
+
const rx = Math.max(1, (b.w / 2) * spread + 40);
|
|
253
|
+
const ry = Math.max(1, (b.h / 2) * spread + 40);
|
|
254
|
+
const cx = b.x + b.w / 2;
|
|
255
|
+
const cy = b.y + b.h / 2;
|
|
256
|
+
const a = +(amount * k).toFixed(4);
|
|
257
|
+
return {
|
|
258
|
+
background: `radial-gradient(ellipse ${f2(rx)}px ${f2(ry)}px at ${f2(cx)}px ${f2(cy)}px, rgba(${color},0) 60%, rgba(${color},${a}) 100%), rgba(${color},${a})`,
|
|
259
|
+
k,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* A line sweeping across the frame with the changed picture behind it: the
|
|
265
|
+
* before and the after on the same material, so the change cannot be missed.
|
|
266
|
+
* Put `clip` on the after layer (stacked over the before) and draw the line
|
|
267
|
+
* at `at` (x for "right"/"left", y for "down"/"up"). Default 0.5 s,
|
|
268
|
+
* smootherstep (the films measured swept in 0.45–0.6 s).
|
|
269
|
+
* @param {number} t
|
|
270
|
+
* @param {number} start
|
|
271
|
+
* @param {number} end
|
|
272
|
+
* @param {Size} frame
|
|
273
|
+
* @param {{ dir?: "right" | "left" | "down" | "up", ease?: (p: number) => number }} [opts]
|
|
274
|
+
* @returns {{ clip: string, at: number, p: number, moving: boolean }}
|
|
275
|
+
*/
|
|
276
|
+
export function sweep(t, start, end, frame, opts = {}) {
|
|
277
|
+
const { dir = "right", ease = smooth } = opts;
|
|
278
|
+
const p = end > start ? ease(clamp01((t - start) / (end - start))) : t >= end ? 1 : 0;
|
|
279
|
+
const pct = (/** @type {number} */ v) => `${(v * 100).toFixed(3)}%`;
|
|
280
|
+
/** @type {string} */
|
|
281
|
+
let clip;
|
|
282
|
+
/** @type {number} */
|
|
283
|
+
let at;
|
|
284
|
+
if (dir === "right") {
|
|
285
|
+
clip = `inset(0 ${pct(1 - p)} 0 0)`;
|
|
286
|
+
at = p * frame.width;
|
|
287
|
+
} else if (dir === "left") {
|
|
288
|
+
clip = `inset(0 0 0 ${pct(1 - p)})`;
|
|
289
|
+
at = (1 - p) * frame.width;
|
|
290
|
+
} else if (dir === "down") {
|
|
291
|
+
clip = `inset(0 0 ${pct(1 - p)} 0)`;
|
|
292
|
+
at = p * frame.height;
|
|
293
|
+
} else {
|
|
294
|
+
clip = `inset(${pct(1 - p)} 0 0 0)`;
|
|
295
|
+
at = (1 - p) * frame.height;
|
|
296
|
+
}
|
|
297
|
+
return { clip, at, p, moving: p > 0 && p < 1 };
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* A band of light crossing a screen and leaving it lit: two copies of the
|
|
302
|
+
* screen, one dim (`filter: brightness(dim)`), one lit with `mask` as its
|
|
303
|
+
* `mask-image` (and `-webkit-mask-image`); `glint` is a soft bright band on
|
|
304
|
+
* the front, for a `mix-blend-mode: screen` layer over both. From a film's
|
|
305
|
+
* reveal: the band at 115°, the lit part trailing the front by 700 px, the
|
|
306
|
+
* unlit screen at 7 %, 1.3 s across. `frame` is the screen's own size.
|
|
307
|
+
* @param {number} t
|
|
308
|
+
* @param {number} start
|
|
309
|
+
* @param {number} end
|
|
310
|
+
* @param {Size} frame
|
|
311
|
+
* @param {{ angle?: number, soft?: number, glint?: number, dim?: number, ease?: (p: number) => number }} [opts]
|
|
312
|
+
* angle: of the band, degrees as CSS gradients count them; soft: px of the soft edge; glint: px of the bright band (0: none)
|
|
313
|
+
* @returns {{ mask: string, glint: string, dim: number, p: number }}
|
|
314
|
+
*/
|
|
315
|
+
export function lightSweep(t, start, end, frame, opts = {}) {
|
|
316
|
+
const { angle = 115, soft = 700, glint = 360, dim = 0.07, ease = smooth } = opts;
|
|
317
|
+
const p = end > start ? ease(clamp01((t - start) / (end - start))) : t >= end ? 1 : 0;
|
|
318
|
+
// the gradient line's length for this angle over this frame, as CSS works it out
|
|
319
|
+
const rad = (angle * Math.PI) / 180;
|
|
320
|
+
const L = Math.abs(frame.width * Math.sin(rad)) + Math.abs(frame.height * Math.cos(rad));
|
|
321
|
+
// the front runs from before the frame (nothing lit) to past it by `soft` (all lit)
|
|
322
|
+
const front = lerp(-glint, L + soft, p);
|
|
323
|
+
const lit = `linear-gradient(${angle}deg, #000 ${f2(front - soft)}px, transparent ${f2(front)}px)`;
|
|
324
|
+
const g =
|
|
325
|
+
glint > 0
|
|
326
|
+
? `linear-gradient(${angle}deg, rgba(255,255,255,0) ${f2(front - glint)}px, rgba(255,255,255,0.2) ${f2(front - glint / 2)}px, rgba(255,255,255,0) ${f2(front)}px)`
|
|
327
|
+
: "none";
|
|
328
|
+
return { mask: lit, glint: g, dim, p };
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* A flash on a beat: white (or any colour) over the frame, up in `attack` s
|
|
333
|
+
* and gone over `decay` s, eased out — punctuation that makes a hard cut read
|
|
334
|
+
* as meant. Defaults from the films measured: 40 ms up, 0.3 s down, peaking
|
|
335
|
+
* at 0.55 (a full white frame reads as an error on a phone).
|
|
336
|
+
* @param {number} t
|
|
337
|
+
* @param {number} at the beat
|
|
338
|
+
* @param {{ attack?: number, decay?: number, peak?: number }} [opts]
|
|
339
|
+
* @returns {{ opacity: number }}
|
|
340
|
+
*/
|
|
341
|
+
export function flash(t, at, opts = {}) {
|
|
342
|
+
const { attack = 0.04, decay = 0.3, peak = 0.55 } = opts;
|
|
343
|
+
if (t < at - attack || t > at + decay) return { opacity: 0 };
|
|
344
|
+
if (t < at) return { opacity: +(peak * clamp01((t - (at - attack)) / attack)).toFixed(4) };
|
|
345
|
+
return { opacity: +(peak * (1 - easeOut((t - at) / decay))).toFixed(4) };
|
|
346
|
+
}
|