@auscera/cleoedits 0.0.0-stage → 0.1.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/README.md +62 -2
- package/cli.mjs +149 -0
- package/lib/dependencies.mjs +384 -0
- package/lib/run.mjs +114 -0
- package/lib/workspace.mjs +167 -0
- package/package.json +240 -3
- package/workspace/.agents/skills/cleoedits/SKILL.md +29 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/audiogram.json +41 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/facebook.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/linkedin.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/podcast.json +23 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/reels.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/shorts.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/tiktok.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/x.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/youtube-shorts.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/youtube.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/assets/LICENSE-SimpleIcons +30 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/assets/logos.json +1 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Anton-Regular.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/ArchivoBlack-Regular.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/InstrumentSerif-Italic.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Inter.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/LICENSE-PermanentMarker.txt +202 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Montserrat.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Anton.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-ArchivoBlack.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-InstrumentSerif.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Inter.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Montserrat.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-PlayfairDisplay.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Poppins.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-SpaceMono.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PermanentMarker-Regular.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PlayfairDisplay-Italic.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PlayfairDisplay.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-Black.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-Bold.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-ExtraBold.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/SpaceMono-Bold.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/LICENSE-MediaPipe +218 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/LICENSE-YuNet +21 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/NOTICE.md +4 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/selfie_segmenter.tflite +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/yunet.onnx +0 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/LICENSE +21 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/audio-app-ui/STYLE.md +65 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/STYLE.md +53 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/index.html +328 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/data-story/STYLE.md +65 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/data-story/index.html +575 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/design-app-ui/STYLE.md +68 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/editor-ui/STYLE.md +73 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/STYLE.md +54 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/index.html +189 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/explainer-diagram/STYLE.md +64 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/explainer-diagram/index.html +620 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/STYLE.md +55 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/index.html +238 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/growing-city/STYLE.md +66 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/growing-city/index.html +602 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/ink-line/STYLE.md +66 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/ink-line/index.html +777 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/STYLE.md +56 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/index.html +186 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/motion-app-ui/STYLE.md +68 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/STYLE.md +56 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/index.html +244 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-world/STYLE.md +67 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-world/index.html +663 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/particle-field/STYLE.md +59 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/particle-field/index.html +395 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/STYLE.md +52 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/index.html +194 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/STYLE.md +58 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/index.html +242 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/STYLE.md +53 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/index.html +138 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-kinetic/STYLE.md +63 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-kinetic/index.html +599 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/time-travel/STYLE.md +65 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/time-travel/index.html +1297 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/weather-widget/STYLE.md +69 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/weather-widget/index.html +674 -0
- package/workspace/.agents/skills/cleoedits/references/audio-clearervoice-elevenlabs.md +11 -0
- package/workspace/.agents/skills/cleoedits/references/ffmpeg-and-reels.md +15 -0
- package/workspace/.agents/skills/cleoedits/references/hyperframes-workflows.md +13 -0
- package/workspace/.agents/skills/cleoedits/references/kdenlive-cli-and-mcp.md +12 -0
- package/workspace/.agents/skills/cleoedits/references/motion-design-pipeline.md +7 -0
- package/workspace/.agents/skills/cleoedits/references/motion-taste-emil.md +5 -0
- package/workspace/.agents/skills/cleoedits/references/playwright-demo-capture.md +9 -0
- package/workspace/.agents/skills/cleoedits/references/remotion-workflows.md +13 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/LICENSE +21 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_ass_overlay.py +399 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/__init__.py +235 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/alpha.py +560 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/asr.py +1237 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/color.py +540 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/decision.py +2452 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/drawtext.py +290 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/emit.py +1309 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/emoji.py +518 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/fonts.py +875 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/pacing.py +263 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/pacing_edit.py +432 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/probe.py +1613 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/runner.py +3994 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/text.py +73 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/timeline.py +721 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/wrap.py +981 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_contract.py +2454 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_platforms.py +258 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_review.html +754 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_review.py +258 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_smartcut.py +450 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/audio.py +867 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/background.py +136 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/batch.py +1409 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/broll.py +282 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/caption.py +2207 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/check.py +815 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/color.py +695 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/crop.py +91 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/cropdetect.py +214 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/cut.py +2076 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/deinterlace.py +90 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/denoise.py +94 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/export.py +1033 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/fit.py +729 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/freeze.py +197 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/graphics.py +920 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/grid.py +235 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/insert.py +142 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/join.py +1083 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/look.py +475 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/loop.py +395 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/loudness.py +397 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/metadata.py +416 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/multicam.py +414 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/overlay.py +766 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/pad.py +121 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/probe.py +145 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/proxy.py +93 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/redact.py +162 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/render.py +2424 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/report.py +354 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/reverse.py +114 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/scenes.py +439 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sequence.py +285 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/silence.py +945 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/speedramp.py +193 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sphere.py +137 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/stabilize.py +141 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/straighten.py +120 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sync.py +500 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/verify.py +411 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/waveform.py +502 -0
- package/workspace/.agents/skills/cleoedits/scripts/kdenlive_builder.py +284 -0
- package/workspace/.agents/skills/cleoedits/scripts/motion/LICENSE-claude-motion +21 -0
- package/workspace/.agents/skills/cleoedits/scripts/motion/LICENSE-motion-design +21 -0
- package/workspace/.agents/skills/cleoedits/scripts/motion/_media.py +43 -0
- package/workspace/.agents/skills/cleoedits/scripts/motion/pacing_check.py +90 -0
- package/workspace/.agents/skills/cleoedits/scripts/motion/storyboard.py +77 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/LICENSE +26 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/fx.py +2717 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/logos.py +194 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/sfx.py +105 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/trim.py +99 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/words.py +60 -0
- package/workspace/.claude/commands/blender-3d.md +12 -0
- package/workspace/.claude/commands/business-short-form-reels.md +12 -0
- package/workspace/.claude/commands/color-grade.md +12 -0
- package/workspace/.claude/commands/cutout-grid-reel.md +12 -0
- package/workspace/.claude/commands/depth-ui-reel.md +12 -0
- package/workspace/.claude/commands/explainer-panel-reel.md +12 -0
- package/workspace/.claude/commands/freeze-frame.md +12 -0
- package/workspace/.claude/commands/glass-graph.md +12 -0
- package/workspace/.claude/commands/over-the-shoulder.md +12 -0
- package/workspace/.claude/commands/personal-short-form-reels.md +12 -0
- package/workspace/.claude/commands/ranking-format.md +12 -0
- package/workspace/.claude/commands/relight.md +12 -0
- package/workspace/.claude/commands/reverse-engineer.md +12 -0
- package/workspace/.claude/commands/text-behind.md +12 -0
- package/workspace/.claude/commands/tier-list.md +12 -0
- package/workspace/.claude-plugin/plugin.json +8 -0
- package/workspace/.npmignore +15 -0
- package/workspace/AGENTS.md +30 -0
- package/workspace/README.md +63 -0
- package/workspace/assets/fonts/TikTokSans-OFL.txt +93 -0
- package/workspace/assets/fonts/TikTokSans-Variable.ttf +0 -0
- package/workspace/assets/luts/clean_warm.cube +4917 -0
- package/workspace/assets/luts/golden_hour.cube +4917 -0
- package/workspace/assets/luts/moody_dark.cube +4917 -0
- package/workspace/assets/luts/teal_orange.cube +4917 -0
- package/workspace/assets/sfx/NOTICE.txt +1 -0
- package/workspace/assets/sfx/click.wav +0 -0
- package/workspace/assets/sfx/pop.wav +0 -0
- package/workspace/assets/sfx/riser.wav +0 -0
- package/workspace/assets/sfx/whoosh.wav +0 -0
- package/workspace/generators/hyperframes/index.html +39 -0
- package/workspace/generators/hyperframes/package.json +15 -0
- package/workspace/generators/hyperframes/pnpm-lock.yaml +1181 -0
- package/workspace/generators/hyperframes/pnpm-workspace.yaml +10 -0
- package/workspace/generators/remotion/eslint.config.mjs +3 -0
- package/workspace/generators/remotion/package.json +36 -0
- package/workspace/generators/remotion/pnpm-lock.yaml +4179 -0
- package/workspace/generators/remotion/pnpm-workspace.yaml +10 -0
- package/workspace/generators/remotion/remotion.config.ts +13 -0
- package/workspace/generators/remotion/src/Root.tsx +52 -0
- package/workspace/generators/remotion/src/index.css +1 -0
- package/workspace/generators/remotion/src/index.ts +4 -0
- package/workspace/generators/remotion/tsconfig.json +15 -0
- package/workspace/pipeline/scripts/_codec.py +28 -0
- package/workspace/pipeline/scripts/ai_media_api.py +109 -0
- package/workspace/pipeline/scripts/blender_render.py +166 -0
- package/workspace/pipeline/scripts/composite.py +49 -0
- package/workspace/pipeline/scripts/melt.sh +68 -0
- package/workspace/pipeline/scripts/normalize_audio.py +39 -0
- package/workspace/pipeline/scripts/person_matte.py +216 -0
- package/workspace/pipeline/scripts/record_demo.py +69 -0
- package/workspace/pipeline/scripts/whisper_cut.py +98 -0
- package/workspace-manifest.json +908 -0
|
@@ -0,0 +1,777 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=1920, height=1080" />
|
|
6
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
7
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
8
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@600&display=swap" />
|
|
9
|
+
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
|
|
10
|
+
<style>
|
|
11
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
12
|
+
html, body { margin: 0; width: 1920px; height: 1080px; overflow: hidden; background: #F4EFE6; }
|
|
13
|
+
#root { position: relative; width: 1920px; height: 1080px; overflow: hidden; background: #F4EFE6; }
|
|
14
|
+
#cv { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; display: block; }
|
|
15
|
+
</style>
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<div id="root" data-composition-id="main" data-start="0" data-duration="13.8" data-width="1920" data-height="1080">
|
|
19
|
+
<canvas id="cv" class="clip" data-start="0" data-duration="13.8" data-track-index="0" width="1920" height="1080"></canvas>
|
|
20
|
+
</div>
|
|
21
|
+
<script>
|
|
22
|
+
/*
|
|
23
|
+
* One ink line. 13.8 s, 1920x1080, one canvas drawn as a pure function of time, drawn on twos.
|
|
24
|
+
* A single sumi brush stroke that never lifts: bird > flight > stem > blossom > falling petals > ripples > enso > seal.
|
|
25
|
+
* Beat map:
|
|
26
|
+
* 0.0 to 2.0 pen sweeps in and draws a hummingbird in one stroke; 2.0 to 2.8 the bird hovers (a held beat)
|
|
27
|
+
* 2.8 to 5.3 bird climbs, dives, skims the water, climbs straight up; its trail becomes the stem
|
|
28
|
+
* 5.8 to 7.8 bird folds into a bud (hard expo.out zoom), five petals bloom, then sway
|
|
29
|
+
* 7.8 to 10.8 petals fall flat on the water, turn to ripples, ripples stand up and unwind into one enso
|
|
30
|
+
* 11.3 vermilion seal stamps down; hold, the line keeps boiling
|
|
31
|
+
* Change colours in PAPER, INK, SEAL_RED below (also the two CSS backgrounds). Change the seal glyph in SEAL_CHAR.
|
|
32
|
+
*/
|
|
33
|
+
(function () {
|
|
34
|
+
'use strict';
|
|
35
|
+
const PAPER = '#F4EFE6'; // warm washi paper
|
|
36
|
+
const INK = '#1C1C1C'; // sumi ink (TONES further down are its six darker/lighter shades)
|
|
37
|
+
const SEAL_RED = '#D23C2A'; // the one accent: vermilion seal
|
|
38
|
+
const SEAL_CHAR = '\u5186'; // the seal glyph (circle, enso)
|
|
39
|
+
const SEAL_FONT = '600 92px "Noto Serif JP", serif';
|
|
40
|
+
const DUR = 13.8, SW = 1920, SH = 1080;
|
|
41
|
+
const HOLD0 = 2.0, HOLD = 0.8; // a 0.8 s hover beat at 2.0 s; everything after shifts by 0.8 s
|
|
42
|
+
const remap = t => t < HOLD0 ? t : t < HOLD0 + HOLD ? HOLD0 : t - HOLD;
|
|
43
|
+
let TRQ = 0; // unremapped time on twos, for the hover flutter
|
|
44
|
+
const N_T = 600, N_SP = 90, N_PET = 162, N_B = N_SP + 5 * N_PET, N = N_T + N_B;
|
|
45
|
+
const cv = document.getElementById('cv'), ctx = cv.getContext('2d');
|
|
46
|
+
const ink = document.createElement('canvas'); ink.width = SW; ink.height = SH;
|
|
47
|
+
const ictx = ink.getContext('2d');
|
|
48
|
+
const ink2 = document.createElement('canvas'); ink2.width = SW; ink2.height = SH;
|
|
49
|
+
const i2 = ink2.getContext('2d');
|
|
50
|
+
const washC = document.createElement('canvas'); washC.width = SW; washC.height = SH;
|
|
51
|
+
const wctx = washC.getContext('2d');
|
|
52
|
+
|
|
53
|
+
// ---------- math ----------
|
|
54
|
+
const EZ = {};
|
|
55
|
+
const ez = n => EZ[n] || (EZ[n] = gsap.parseEase(n));
|
|
56
|
+
const clamp = (x, a, b) => x < a ? a : x > b ? b : x;
|
|
57
|
+
const lerp = (a, b, k) => a + (b - a) * k;
|
|
58
|
+
const sstep = (a, b, x) => { const k = clamp((x - a) / (b - a), 0, 1); return k * k * (3 - 2 * k); };
|
|
59
|
+
const seg = (t, a, b, e) => { const p = clamp((t - a) / (b - a), 0, 1); return e ? ez(e)(p) : p; };
|
|
60
|
+
function hash(i) { i = i | 0; i = Math.imul(i ^ (i >>> 16), 0x45d9f3b); i = Math.imul(i ^ (i >>> 16), 0x45d9f3b); i ^= i >>> 16; return (i >>> 0) / 4294967296; }
|
|
61
|
+
function vn(x, seed) { const i = Math.floor(x), f = x - i, u = f * f * (3 - 2 * f); return lerp(hash(i * 7919 + seed * 104729), hash((i + 1) * 7919 + seed * 104729), u); }
|
|
62
|
+
function mulberry(a) { return function () { a |= 0; a = a + 0x6D2B79F5 | 0; let t = Math.imul(a ^ a >>> 15, 1 | a); t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t; return ((t ^ t >>> 14) >>> 0) / 4294967296; }; }
|
|
63
|
+
|
|
64
|
+
// keyframe track: keys [[t, v, ease]]
|
|
65
|
+
function track(t, keys) {
|
|
66
|
+
if (t <= keys[0][0]) return keys[0][1];
|
|
67
|
+
for (let i = 1; i < keys.length; i++) {
|
|
68
|
+
if (t <= keys[i][0]) { const a = keys[i - 1], b = keys[i]; const k = (t - a[0]) / (b[0] - a[0]); return lerp(a[1], b[1], ez(b[2] || 'sine.inOut')(k)); }
|
|
69
|
+
}
|
|
70
|
+
return keys[keys.length - 1][1];
|
|
71
|
+
}
|
|
72
|
+
// monotone cubic through [t, v] points, zero end slopes
|
|
73
|
+
function monotone(pts) {
|
|
74
|
+
const n = pts.length, m = new Array(n).fill(0), d = [];
|
|
75
|
+
for (let i = 0; i < n - 1; i++) d.push((pts[i + 1][1] - pts[i][1]) / (pts[i + 1][0] - pts[i][0]));
|
|
76
|
+
for (let i = 1; i < n - 1; i++) m[i] = d[i - 1] * d[i] <= 0 ? 0 : 2 / (1 / d[i - 1] + 1 / d[i]);
|
|
77
|
+
return function (t) {
|
|
78
|
+
if (t <= pts[0][0]) return pts[0][1];
|
|
79
|
+
if (t >= pts[n - 1][0]) return pts[n - 1][1];
|
|
80
|
+
let i = 0; while (t > pts[i + 1][0]) i++;
|
|
81
|
+
const h = pts[i + 1][0] - pts[i][0], s = (t - pts[i][0]) / h, s2 = s * s, s3 = s2 * s;
|
|
82
|
+
return (2 * s3 - 3 * s2 + 1) * pts[i][1] + (s3 - 2 * s2 + s) * h * m[i] + (-2 * s3 + 3 * s2) * pts[i + 1][1] + (s3 - s2) * h * m[i + 1];
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ---------- centripetal Catmull-Rom path with channels ----------
|
|
87
|
+
function crPath(ctrl, sub) {
|
|
88
|
+
const n = ctrl.length, C = ctrl[0].length, pts = [], ci = [];
|
|
89
|
+
const get = i => {
|
|
90
|
+
if (i < 0) { const a = ctrl[0], b = ctrl[1]; return a.map((v, k) => 2 * v - b[k]); }
|
|
91
|
+
if (i >= n) { const a = ctrl[n - 1], b = ctrl[n - 2]; return a.map((v, k) => 2 * v - b[k]); }
|
|
92
|
+
return ctrl[i];
|
|
93
|
+
};
|
|
94
|
+
const dd = (a, b) => Math.pow(Math.hypot(b[0] - a[0], b[1] - a[1]) + 1e-4, 0.5);
|
|
95
|
+
for (let i = 0; i < n - 1; i++) {
|
|
96
|
+
const p0 = get(i - 1), p1 = get(i), p2 = get(i + 1), p3 = get(i + 2);
|
|
97
|
+
const t0 = 0, t1 = dd(p0, p1), t2 = t1 + dd(p1, p2), t3 = t2 + dd(p2, p3);
|
|
98
|
+
ci.push(pts.length);
|
|
99
|
+
for (let s = 0; s < sub; s++) {
|
|
100
|
+
const t = t1 + (t2 - t1) * s / sub, q = [];
|
|
101
|
+
for (let c = 0; c < 2; c++) {
|
|
102
|
+
const A1 = (t1 - t) / (t1 - t0) * p0[c] + (t - t0) / (t1 - t0) * p1[c];
|
|
103
|
+
const A2 = (t2 - t) / (t2 - t1) * p1[c] + (t - t1) / (t2 - t1) * p2[c];
|
|
104
|
+
const A3 = (t3 - t) / (t3 - t2) * p2[c] + (t - t2) / (t3 - t2) * p3[c];
|
|
105
|
+
const B1 = (t2 - t) / (t2 - t0) * A1 + (t - t0) / (t2 - t0) * A2;
|
|
106
|
+
const B2 = (t3 - t) / (t3 - t1) * A2 + (t - t1) / (t3 - t1) * A3;
|
|
107
|
+
q.push((t2 - t) / (t2 - t1) * B1 + (t - t1) / (t2 - t1) * B2);
|
|
108
|
+
}
|
|
109
|
+
const k = s / sub, ks = k * k * (3 - 2 * k);
|
|
110
|
+
for (let c = 2; c < C; c++) q.push(lerp(p1[c], p2[c], ks));
|
|
111
|
+
pts.push(q);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
ci.push(pts.length); pts.push(ctrl[n - 1].slice());
|
|
115
|
+
const cum = new Float64Array(pts.length);
|
|
116
|
+
for (let i = 1; i < pts.length; i++) cum[i] = cum[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]);
|
|
117
|
+
return { pts, cum, len: cum[pts.length - 1], ctrlS: ci.map(i => cum[i]), C };
|
|
118
|
+
}
|
|
119
|
+
function pathAt(P, s, out) {
|
|
120
|
+
const cum = P.cum, n = cum.length; s = clamp(s, 0, P.len);
|
|
121
|
+
let lo = 0, hi = n - 1; while (hi - lo > 1) { const m = (lo + hi) >> 1; if (cum[m] <= s) lo = m; else hi = m; }
|
|
122
|
+
const a = P.pts[lo], b = P.pts[hi], den = cum[hi] - cum[lo], k = den > 1e-9 ? (s - cum[lo]) / den : 0;
|
|
123
|
+
for (let c = 0; c < P.C; c++) out[c] = lerp(a[c], b[c], k);
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
const tmp = [0, 0, 0, 0, 0];
|
|
127
|
+
|
|
128
|
+
// ---------- the flight path (world px) ----------
|
|
129
|
+
const F = crPath([
|
|
130
|
+
[-460, 880], [-200, 800], [60, 726], [290, 660], // lead-in -> B0 (3)
|
|
131
|
+
[520, 560], [760, 430], [990, 352], [1170, 368], // climb, apex (7)
|
|
132
|
+
[1285, 462], [1330, 618], [1345, 760], [1372, 852], // dive (11)
|
|
133
|
+
[1420, 893], [1482, 886], [1522, 830], // skim the water, root (12)
|
|
134
|
+
[1534, 740], [1531, 640], [1525, 548], [1521, 476], // climb, stem top T (18)
|
|
135
|
+
[1519, 330], [1517, 160]
|
|
136
|
+
], 40);
|
|
137
|
+
const sB0 = F.ctrlS[3], sApex = F.ctrlS[7], sR = F.ctrlS[12], sT = F.ctrlS[18];
|
|
138
|
+
const R = pathAt(F, sR, [0, 0]).slice(), T = pathAt(F, sT, [0, 0]).slice();
|
|
139
|
+
const WATER = R[1];
|
|
140
|
+
|
|
141
|
+
// ---------- the hummingbird, one stroke (local px, facing +x) [x, y, width, wing] ----------
|
|
142
|
+
const birdCtrl = [
|
|
143
|
+
[-215, 82, 1.4, 0], [-160, 62, 5, 0], [-105, 52, 9, 0], [-45, 62, 12, 0], [15, 58, 13, 0],
|
|
144
|
+
[58, 36, 12, 0], [82, 10, 10, 0], [100, -8, 7.5, 0], [121, -22, 5, 0], [196, -14, 2.8, 0],
|
|
145
|
+
[276, -5, 1.1, 0], [197, -25, 2.5, 0], [123, -36, 4.5, 0], [112, -55, 6.5, 0], [88, -70, 7.5, 0],
|
|
146
|
+
[82, -54, 3.6, 0], [90, -45, 4.4, 0], [98, -52, 4.4, 0], [90, -60, 3.8, 0], [74, -64, 5.5, 0],
|
|
147
|
+
[48, -66, 7.5, 0], [22, -60, 8.5, 0], [0, -52, 9.5, 0],
|
|
148
|
+
[-28, -98, 9.5, 0.45], [-78, -166, 8.5, 0.85], [-140, -218, 5, 1], [-188, -244, 1.5, 1],
|
|
149
|
+
[-150, -203, 4, 1], [-100, -142, 7, 0.9], [-64, -90, 8.5, 0.6], [-44, -56, 9.5, 0.15],
|
|
150
|
+
[-92, -28, 8.5, 0], [-140, -6, 6.5, 0], [-196, 14, 4, 0], [-250, 24, 1.0, 0]
|
|
151
|
+
];
|
|
152
|
+
const BP = crPath(birdCtrl, 30);
|
|
153
|
+
const bx = new Float32Array(N_B), by = new Float32Array(N_B), bw = new Float32Array(N_B), bwing = new Float32Array(N_B);
|
|
154
|
+
const ax0 = birdCtrl[0][0], ay0 = birdCtrl[0][1];
|
|
155
|
+
for (let j = 0; j < N_B; j++) {
|
|
156
|
+
pathAt(BP, BP.len * j / (N_B - 1), tmp);
|
|
157
|
+
bx[j] = tmp[0] - ax0; by[j] = tmp[1] - ay0; bw[j] = tmp[2]; bwing[j] = tmp[3];
|
|
158
|
+
}
|
|
159
|
+
const SHX = 0 - ax0, SHY = -52 - ay0;
|
|
160
|
+
// pen-time cost along the bird: slower on tight curves and details
|
|
161
|
+
const birdCum = new Float32Array(N_B);
|
|
162
|
+
(function () {
|
|
163
|
+
let acc = 0;
|
|
164
|
+
for (let j = 1; j < N_B; j++) {
|
|
165
|
+
let turn = 0;
|
|
166
|
+
if (j > 1 && j < N_B - 1) {
|
|
167
|
+
const a1 = Math.atan2(by[j] - by[j - 1], bx[j] - bx[j - 1]), a2 = Math.atan2(by[j + 1] - by[j], bx[j + 1] - bx[j]);
|
|
168
|
+
let d = Math.abs(a2 - a1); if (d > Math.PI) d = 2 * Math.PI - d; turn = d;
|
|
169
|
+
}
|
|
170
|
+
acc += 1 + 9 * Math.min(turn, 0.6);
|
|
171
|
+
birdCum[j] = acc;
|
|
172
|
+
}
|
|
173
|
+
for (let j = 0; j < N_B; j++) birdCum[j] /= acc;
|
|
174
|
+
})();
|
|
175
|
+
|
|
176
|
+
// ---------- timing ----------
|
|
177
|
+
const sHead = monotone([[2.0, sB0], [2.95, sApex], [3.72, sR], [4.5, sT]]);
|
|
178
|
+
const DET = [7.0, 7.16, 7.06, 7.22, 7.11]; // petal detach times
|
|
179
|
+
const FD = 0.85; // fall duration
|
|
180
|
+
const LAND = [[-300, -18], [-130, 10], [40, -30], [200, 14], [350, -10]];
|
|
181
|
+
const RMAX = [150, 120, 175, 135, 160];
|
|
182
|
+
const SLIDE0 = 7.3, SLIDE1 = 8.45;
|
|
183
|
+
const C1 = [8.5, 9.25], KS = [8.95, 9.75], KU = [9.3, 10.0];
|
|
184
|
+
const SEAL_T = 10.5;
|
|
185
|
+
const Q = 0.24; // water-plane ellipse ratio
|
|
186
|
+
const RE = 360; // enso radius
|
|
187
|
+
const THS = 140 * Math.PI / 180, SPAN = 338 * Math.PI / 180;
|
|
188
|
+
const theta = j => THS + SPAN * j / (N - 1);
|
|
189
|
+
|
|
190
|
+
// ---------- state buffers ----------
|
|
191
|
+
function mk() { return { x: new Float32Array(N), y: new Float32Array(N), w: new Float32Array(N), d: new Float32Array(N) }; }
|
|
192
|
+
const S = mk(), SA = mk(), SB = mk(), SC = mk();
|
|
193
|
+
|
|
194
|
+
// dry brush where the pen moved fast: speed of the bird when it laid that part of the path
|
|
195
|
+
const DRY_STEP = 4, dryTab = new Float32Array(Math.ceil(F.len / DRY_STEP) + 2);
|
|
196
|
+
(function () {
|
|
197
|
+
for (let k = 0; k < dryTab.length; k++) { const sx = k * DRY_STEP; dryTab[k] = sx < sB0 ? 0.32 * sstep(sB0 - 500, sB0 - 120, sx) * 0 + 0.18 : 0; }
|
|
198
|
+
let prev = sB0;
|
|
199
|
+
for (let t = 2.0; t <= 4.5; t += 1 / 240) {
|
|
200
|
+
const sx = sHead(t), v = (sx - prev) * 240; prev = sx;
|
|
201
|
+
const k = Math.round(sx / DRY_STEP); if (k >= 0 && k < dryTab.length) dryTab[k] = Math.max(dryTab[k], clamp((v - 700) / 1500, 0, 0.62));
|
|
202
|
+
}
|
|
203
|
+
for (let it = 0; it < 6; it++) for (let k = 1; k < dryTab.length - 1; k++) dryTab[k] = Math.max(dryTab[k], (dryTab[k - 1] + dryTab[k + 1]) * 0.49);
|
|
204
|
+
})();
|
|
205
|
+
const dryAt = sx => dryTab[clamp(Math.round(sx / DRY_STEP), 0, dryTab.length - 1)];
|
|
206
|
+
function trailWidth(j) {
|
|
207
|
+
const k = j / (N_T - 1);
|
|
208
|
+
let w = 12.5 * (0.68 + 0.6 * vn(j * 0.022, 3));
|
|
209
|
+
w *= lerp(1, 0.22, sstep(0.9, 1, k));
|
|
210
|
+
return w;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// --- flight: trail + bird
|
|
214
|
+
function birdFigure(t, out, sh) {
|
|
215
|
+
const sig = t < 2 ? 1.45 : lerp(1.45, 0.95, seg(t, 2.0, 3.7, 'power2.inOut'));
|
|
216
|
+
const p0 = pathAt(F, sh, [0, 0]);
|
|
217
|
+
const a = pathAt(F, Math.min(sh + 150, F.len), [0, 0]), b = pathAt(F, Math.max(sh - 20, 0), [0, 0]);
|
|
218
|
+
let al = clamp(Math.atan2(a[1] - b[1], a[0] - b[0]), -Math.PI / 2 - 0.08, Math.PI / 2);
|
|
219
|
+
// hover: lift and bob once at the top
|
|
220
|
+
const hov = sstep(4.35, 4.7, t);
|
|
221
|
+
const bob = hov * (6 * Math.sin(2 * Math.PI * 1.7 * (t - 4.4)));
|
|
222
|
+
const flapAmt = sstep(2.0, 2.12, TRQ) * (1 - sstep(5.0, 5.2, t));
|
|
223
|
+
const psi = -1.25 * flapAmt * (0.5 - 0.5 * Math.cos(2 * Math.PI * 5 * TRQ));
|
|
224
|
+
const ca = Math.cos(al), sa = Math.sin(al), wsc = 1.05 + 0.35 * sig;
|
|
225
|
+
for (let j = 0; j < N_B; j++) {
|
|
226
|
+
let x = bx[j], y = by[j];
|
|
227
|
+
const ww = bwing[j];
|
|
228
|
+
if (ww > 0 && psi !== 0) {
|
|
229
|
+
const an = psi * ww, c = Math.cos(an), s = Math.sin(an), dx = x - SHX, dy = y - SHY, sc = 1 - 0.12 * ww * flapAmt * Math.sin(-psi / 1.25 * Math.PI);
|
|
230
|
+
x = SHX + (dx * c - dy * s) * sc; y = SHY + (dx * s + dy * c) * sc;
|
|
231
|
+
}
|
|
232
|
+
x *= sig; y *= sig;
|
|
233
|
+
const i = N_T + j;
|
|
234
|
+
out.x[i] = p0[0] + x * ca - y * sa;
|
|
235
|
+
out.y[i] = p0[1] + x * sa + y * ca + bob;
|
|
236
|
+
out.w[i] = bw[j] * wsc;
|
|
237
|
+
out.d[i] = 0;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function flightState(t, out) {
|
|
241
|
+
const sh = t < 2 ? sB0 : sHead(t);
|
|
242
|
+
const Lt = lerp(1500, sT - sR, seg(t, 3.35, 4.5, 'power2.inOut'));
|
|
243
|
+
const s0 = Math.min(Math.max(sh - Lt, 0), sR);
|
|
244
|
+
for (let j = 0; j < N_T; j++) {
|
|
245
|
+
pathAt(F, s0 + (sh - s0) * j / (N_T - 1), tmp);
|
|
246
|
+
out.x[j] = tmp[0]; out.y[j] = tmp[1]; out.w[j] = trailWidth(j);
|
|
247
|
+
const sx = s0 + (sh - s0) * j / (N_T - 1);
|
|
248
|
+
out.d[j] = Math.max(0.5 * (1 - sstep(0, 0.12, j / (N_T - 1))), dryAt(sx));
|
|
249
|
+
}
|
|
250
|
+
birdFigure(t, out, sh);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// --- flower
|
|
254
|
+
const PET_BUD = [-106, -98, -90, -82, -74].map(d => d * Math.PI / 180);
|
|
255
|
+
const PET_OPEN = [-234, -162, -90, -18, 54].map(d => d * Math.PI / 180);
|
|
256
|
+
const PET_LEN = [1.0, 1.06, 0.94, 1.04, 0.98];
|
|
257
|
+
const PET_ORDER = [2, 1, 3, 0, 4];
|
|
258
|
+
function sway(t) { return 0.04 * Math.sin(2 * Math.PI * 0.62 * (t - 5.7)) * sstep(5.6, 6.3, t); }
|
|
259
|
+
function stemInto(t, out) {
|
|
260
|
+
const g = seg(t, 4.6, 5.45, 'power3.out');
|
|
261
|
+
const sw = sway(t), dxTop = sw * 520;
|
|
262
|
+
const f0 = 0.36, df = 0.11, LL = 165, LW = 42;
|
|
263
|
+
const la = -142 * Math.PI / 180, lax = Math.cos(la), lay = Math.sin(la), lnx = -lay, lny = lax;
|
|
264
|
+
for (let j = 0; j < N_T; j++) {
|
|
265
|
+
const f = j / (N_T - 1);
|
|
266
|
+
pathAt(F, sR + (sT - sR) * f, tmp);
|
|
267
|
+
let x = tmp[0] + dxTop * f * f, y = tmp[1];
|
|
268
|
+
if (g > 0 && f > f0 && f < f0 + df) {
|
|
269
|
+
const v = (f - f0) / df, A = g * LL * Math.sin(Math.PI * v), B = g * LW * Math.sin(2 * Math.PI * v) * (1 + 0.15 * sw * 25);
|
|
270
|
+
x += A * lax + B * lnx; y += A * lay + B * lny;
|
|
271
|
+
}
|
|
272
|
+
out.x[j] = x; out.y[j] = y; out.w[j] = trailWidth(j);
|
|
273
|
+
if (g > 0 && f > f0 && f < f0 + df) { const v = (f - f0) / df; out.w[j] *= 1 + 0.35 * g * Math.sin(Math.PI * v); }
|
|
274
|
+
out.d[j] = dryAt(sR + (sT - sR) * f) * (f > f0 && f < f0 + df ? 1 - g : 1);
|
|
275
|
+
}
|
|
276
|
+
return [dxTop, sw];
|
|
277
|
+
}
|
|
278
|
+
function flowerFigure(t, out, dxTop, sw) {
|
|
279
|
+
const bA = seg(t, 5.25, 6.1, 'power3.out');
|
|
280
|
+
const sq = lerp(1, 0.64, bA), rot = -0.07 * bA + sw * 1.4;
|
|
281
|
+
const cr = Math.cos(rot), sr = Math.sin(rot);
|
|
282
|
+
const cx = T[0] + dxTop, cy = T[1];
|
|
283
|
+
const put = (i, px, py, w) => {
|
|
284
|
+
py *= sq; out.x[i] = cx + px * cr - py * sr; out.y[i] = cy + px * sr + py * cr; out.w[i] = w; out.d[i] = 0;
|
|
285
|
+
};
|
|
286
|
+
// stamen spiral
|
|
287
|
+
const rs = lerp(5, 32, bA);
|
|
288
|
+
for (let j = 0; j < N_SP; j++) {
|
|
289
|
+
const v = j / (N_SP - 1), r = rs * Math.pow(v, 0.85), an = -Math.PI / 2 + 2 * Math.PI * 1.65 * v;
|
|
290
|
+
put(N_T + j, r * Math.cos(an), r * Math.sin(an), (3 + 4.5 * v) * (1 - 0.94 * sstep(0.8, 1, v)));
|
|
291
|
+
}
|
|
292
|
+
for (let p = 0; p < 5; p++) {
|
|
293
|
+
const o = PET_ORDER.indexOf(p);
|
|
294
|
+
const bi = seg(t, 5.25 + 0.07 * o, 6.05 + 0.07 * o, 'back.out(1.7)');
|
|
295
|
+
const ba = seg(t, 5.25 + 0.07 * o, 6.0 + 0.07 * o, 'power3.out');
|
|
296
|
+
const a = lerp(PET_BUD[p], PET_OPEN[p], ba);
|
|
297
|
+
const om = lerp(0.15, 0.62, ba);
|
|
298
|
+
const L = lerp(250, 268 * PET_LEN[p], bi);
|
|
299
|
+
const breathe = 1 + 0.025 * Math.sin(2 * Math.PI * 0.9 * t + p) * sstep(6.0, 6.4, t);
|
|
300
|
+
for (let j = 0; j < N_PET; j++) {
|
|
301
|
+
const v = j / (N_PET - 1);
|
|
302
|
+
const ph = a + (v - 0.5) * 2 * om;
|
|
303
|
+
const notch = 1 - 0.1 * ba * Math.exp(-Math.pow((v - 0.5) / 0.035, 2));
|
|
304
|
+
const r = L * breathe * Math.pow(Math.sin(Math.PI * v), 0.6) * notch;
|
|
305
|
+
const w = 0.45 + 15 * Math.pow(Math.sin(Math.PI * v), 1.7) * (0.7 + 0.6 * v);
|
|
306
|
+
put(N_T + N_SP + p * N_PET + j, r * Math.cos(ph), r * Math.sin(ph), w);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function flowerState(t, out) {
|
|
311
|
+
const [dxTop, sw] = stemInto(t, out);
|
|
312
|
+
flowerFigure(t, out, dxTop, sw);
|
|
313
|
+
const mk2 = seg(t, 4.92, 5.5, 'power2.inOut');
|
|
314
|
+
if (mk2 < 1) {
|
|
315
|
+
birdFigure(t, SC, sT);
|
|
316
|
+
for (let j = 0; j < N_B; j++) {
|
|
317
|
+
const u = j / (N_B - 1), k = clamp((mk2 * 1.45 - u * 0.45) / 1.0, 0, 1), kk = k * k * (3 - 2 * k);
|
|
318
|
+
const i = N_T + j;
|
|
319
|
+
out.x[i] = lerp(SC.x[i], out.x[i], kk); out.y[i] = lerp(SC.y[i], out.y[i], kk); out.w[i] = lerp(SC.w[i], out.w[i], kk);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// --- chain snapshot for the stem being pulled into the water
|
|
325
|
+
const NCH = N_T + N_SP;
|
|
326
|
+
const chX = new Float32Array(NCH), chY = new Float32Array(NCH), chS = new Float32Array(NCH);
|
|
327
|
+
flowerState(SLIDE0, SA);
|
|
328
|
+
for (let j = 0; j < NCH; j++) { chX[j] = SA.x[j]; chY[j] = SA.y[j]; chS[j] = j ? chS[j - 1] + Math.hypot(chX[j] - chX[j - 1], chY[j] - chY[j - 1]) : 0; }
|
|
329
|
+
const LCH = chS[NCH - 1];
|
|
330
|
+
const COIL_K = 50, PSI_FEED = THS + LCH / COIL_K, RHO0 = 20;
|
|
331
|
+
const E_W = [R[0] - RHO0 * Math.cos(PSI_FEED), WATER - RHO0 * Q * Math.sin(PSI_FEED)];
|
|
332
|
+
const E = [E_W[0], 560];
|
|
333
|
+
function chainAt(s, o) {
|
|
334
|
+
s = clamp(s, 0, LCH); let lo = 0, hi = NCH - 1;
|
|
335
|
+
while (hi - lo > 1) { const m = (lo + hi) >> 1; if (chS[m] <= s) lo = m; else hi = m; }
|
|
336
|
+
const den = chS[hi] - chS[lo], k = den > 1e-9 ? (s - chS[lo]) / den : 0;
|
|
337
|
+
o[0] = lerp(chX[lo], chX[hi], k); o[1] = lerp(chY[lo], chY[hi], k); return o;
|
|
338
|
+
}
|
|
339
|
+
const ringStart = p => PSI_FEED + 2 * Math.PI * p;
|
|
340
|
+
const landPt = p => [E_W[0] + LAND[p][0], WATER + LAND[p][1]];
|
|
341
|
+
function ringR(p, t) { const tl = DET[p] + FD; return 58 + RMAX[p] * seg(t, tl, tl + 1.7, 'expo.out'); }
|
|
342
|
+
function ensoW(u) {
|
|
343
|
+
let w = 1.0 - 0.42 * Math.pow(u, 1.5) + 0.4 * Math.exp(-Math.pow(u / 0.028, 2)) + 0.05 * Math.sin(u * 17 + 1);
|
|
344
|
+
w *= Math.pow(sstep(1.0, 0.86, u), 0.7) * sstep(0, 0.012, u + 0.004);
|
|
345
|
+
return 54 * w;
|
|
346
|
+
}
|
|
347
|
+
const ensoD = u => clamp(sstep(0.5, 0.97, u) * 0.95, 0, 1);
|
|
348
|
+
|
|
349
|
+
function fallState(t, out) {
|
|
350
|
+
flowerState(Math.min(t, SLIDE0), out);
|
|
351
|
+
const c1 = seg(t, C1[0], C1[1], 'power3.inOut'), ks = seg(t, KS[0], KS[1], 'power3.inOut'), ku = seg(t, KU[0], KU[1], 'power3.inOut');
|
|
352
|
+
const q = lerp(Q, 1, ks);
|
|
353
|
+
const cX = (x) => x, polar = (i, Cx, Cy, rho, phi, w, d) => {
|
|
354
|
+
// apply close transform: converge, stand up, unwind
|
|
355
|
+
const Cx2 = lerp(lerp(Cx, E_W[0], c1), E[0], ks), Cy2 = lerp(lerp(Cy, E_W[1], c1), E[1], ks);
|
|
356
|
+
const u = i / (N - 1), th = theta(i);
|
|
357
|
+
const rE = RE * (1 + 0.016 * Math.sin(2 * th + 0.7) + 0.008 * Math.sin(5 * th)) + (u - 0.5) * 18;
|
|
358
|
+
const r2 = lerp(rho, rE, ku), ph2 = lerp(phi, th, seg(t, 8.5, 10.0, 'power2.inOut'));
|
|
359
|
+
out.x[i] = Cx2 + r2 * Math.cos(ph2); out.y[i] = Cy2 + r2 * q * Math.sin(ph2);
|
|
360
|
+
out.w[i] = lerp(w, ensoW(u), ku); out.d[i] = lerp(d, ensoD(u), ku);
|
|
361
|
+
};
|
|
362
|
+
// stem + stamen: pulled into the water, coiling as a spiral ripple
|
|
363
|
+
if (t >= SLIDE0) {
|
|
364
|
+
const dd = LCH * seg(t, SLIDE0, SLIDE1, 'power2.inOut');
|
|
365
|
+
const grow = 14 * seg(t, SLIDE0, 9.5, 'power1.out');
|
|
366
|
+
const o = [0, 0];
|
|
367
|
+
for (let j = 0; j < NCH; j++) {
|
|
368
|
+
const sg = chS[j];
|
|
369
|
+
if (sg >= dd && c1 === 0) { chainAt(sg - dd, o); out.x[j] = o[0]; out.y[j] = o[1]; out.w[j] = SA.w[j]; out.d[j] = SA.d[j]; }
|
|
370
|
+
else {
|
|
371
|
+
const depth = Math.max(dd - sg, 0), psi = THS + (LCH - depth) / COIL_K;
|
|
372
|
+
const rho0 = RHO0 + depth * 0.12 + grow * sstep(0, 40, depth);
|
|
373
|
+
const rho = lerp(rho0, RE - 40 + 80 * (j / NCH) * 0, c1) ;
|
|
374
|
+
const w = lerp(SA.w[j], 5.6 * (0.8 + 0.4 * vn(j * 0.05, 5)), sstep(0, 26, depth));
|
|
375
|
+
if (c1 === 0 && ks === 0 && ku === 0) {
|
|
376
|
+
out.x[j] = E_W[0] + rho0 * Math.cos(psi); out.y[j] = E_W[1] + rho0 * Q * Math.sin(psi); out.w[j] = w; out.d[j] = SA.d[j] * (1 - sstep(0, 26, depth));
|
|
377
|
+
} else polar(j, E_W[0], E_W[1], lerp(rho0, RE - 42, c1), psi, w, 0);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// petals
|
|
382
|
+
for (let p = 0; p < 5; p++) {
|
|
383
|
+
if (t < DET[p]) continue;
|
|
384
|
+
flowerState(DET[p], SB);
|
|
385
|
+
const i0 = N_T + N_SP + p * N_PET;
|
|
386
|
+
let mx = 0, my = 0;
|
|
387
|
+
for (let j = 0; j < N_PET; j++) { mx += SB.x[i0 + j]; my += SB.y[i0 + j]; }
|
|
388
|
+
mx /= N_PET; my /= N_PET;
|
|
389
|
+
const lp = landPt(p), tau = clamp((t - DET[p]) / FD, 0, 1);
|
|
390
|
+
const spin = [1.3, -1.6, 0.9, -1.1, 1.7][p] * ez('power1.out')(tau);
|
|
391
|
+
const flat = lerp(1, Q, ez('power2.in')(tau));
|
|
392
|
+
const flut = 1 - 0.35 * Math.sin(Math.PI * tau) * Math.abs(Math.sin(2 * Math.PI * 1.3 * tau));
|
|
393
|
+
const scl = lerp(1, 0.78, tau);
|
|
394
|
+
const ccx = lerp(mx, lp[0], ez('sine.inOut')(tau)) + 50 * Math.sin(2 * Math.PI * 0.9 * tau) * (1 - tau) * (p % 2 ? -1 : 1);
|
|
395
|
+
const ccy = lerp(my, lp[1], ez('power1.in')(tau));
|
|
396
|
+
const cs = Math.cos(spin), sn = Math.sin(spin);
|
|
397
|
+
const tl = DET[p] + FD, km = seg(t, tl, tl + 0.34, 'power2.out');
|
|
398
|
+
const rr = ringR(p, t);
|
|
399
|
+
const dC = [0, -16, -4, 10, 24, 38][p + 1];
|
|
400
|
+
for (let j = 0; j < N_PET; j++) {
|
|
401
|
+
const i = i0 + j, v = j / (N_PET - 1);
|
|
402
|
+
let rx = (SB.x[i] - mx) * scl, ry = (SB.y[i] - my) * scl;
|
|
403
|
+
let x = rx * cs - ry * sn, y = (rx * sn + ry * cs) * flat * flut;
|
|
404
|
+
x += ccx; y += ccy;
|
|
405
|
+
const phi = ringStart(p) + 2 * Math.PI * v;
|
|
406
|
+
const wr = 6.2 * Math.pow(Math.sin(Math.PI * v), 0.5) * (0.8 + 0.4 * vn(i * 0.06, 6));
|
|
407
|
+
if (c1 > 0 || ks > 0 || ku > 0) { polar(i, lp[0], lp[1], lerp(rr, RE + dC, c1), phi, wr, 0); continue; }
|
|
408
|
+
const xr = lp[0] + rr * Math.cos(phi), yr = lp[1] + rr * Q * Math.sin(phi);
|
|
409
|
+
out.x[i] = lerp(x, xr, km); out.y[i] = lerp(y, yr, km); out.w[i] = lerp(SB.w[i] * scl, wr, km); out.d[i] = 0;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function state(t, out) {
|
|
415
|
+
if (t < 4.5) flightState(t, out);
|
|
416
|
+
else if (t < DET[0]) flowerState(t, out);
|
|
417
|
+
else fallState(t, out);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// ---------- textures ----------
|
|
421
|
+
const PX0 = -700, PY0 = -360, PW = 3400, PH = 1840;
|
|
422
|
+
const paper = document.createElement('canvas'); paper.width = PW; paper.height = PH;
|
|
423
|
+
const grainTile = document.createElement('canvas'); grainTile.width = 512; grainTile.height = 512;
|
|
424
|
+
(function buildPaper() {
|
|
425
|
+
const p = paper.getContext('2d'), rnd = mulberry(20261020);
|
|
426
|
+
p.fillStyle = PAPER; p.fillRect(0, 0, PW, PH);
|
|
427
|
+
// low-frequency mottle
|
|
428
|
+
const mw = Math.ceil(PW / 10), mh = Math.ceil(PH / 10), m = document.createElement('canvas');
|
|
429
|
+
m.width = mw; m.height = mh; const mc = m.getContext('2d'), id = mc.createImageData(mw, mh);
|
|
430
|
+
for (let y = 0; y < mh; y++) for (let x = 0; x < mw; x++) {
|
|
431
|
+
let n = 0, a = 1, f = 0.045, tot = 0;
|
|
432
|
+
for (let o = 0; o < 4; o++) {
|
|
433
|
+
const X = x * f, Y = y * f, xi = Math.floor(X), yi = Math.floor(Y), fx = X - xi, fy = Y - yi;
|
|
434
|
+
const h = (i, j) => hash(i * 92821 + j * 68917 + o * 1013);
|
|
435
|
+
const ux = fx * fx * (3 - 2 * fx), uy = fy * fy * (3 - 2 * fy);
|
|
436
|
+
n += a * lerp(lerp(h(xi, yi), h(xi + 1, yi), ux), lerp(h(xi, yi + 1), h(xi + 1, yi + 1), ux), uy);
|
|
437
|
+
tot += a; a *= 0.5; f *= 2.1;
|
|
438
|
+
}
|
|
439
|
+
n /= tot;
|
|
440
|
+
const k = (y * mw + x) * 4, v = (n - 0.5);
|
|
441
|
+
if (v < 0) { id.data[k] = 150; id.data[k + 1] = 120; id.data[k + 2] = 80; id.data[k + 3] = Math.min(255, -v * 170); }
|
|
442
|
+
else { id.data[k] = 255; id.data[k + 1] = 252; id.data[k + 2] = 244; id.data[k + 3] = Math.min(255, v * 150); }
|
|
443
|
+
}
|
|
444
|
+
mc.putImageData(id, 0, 0);
|
|
445
|
+
p.imageSmoothingEnabled = true; p.imageSmoothingQuality = 'high';
|
|
446
|
+
p.globalAlpha = 0.26; p.drawImage(m, 0, 0, PW, PH); p.globalAlpha = 1;
|
|
447
|
+
// fibres
|
|
448
|
+
for (let i = 0; i < 7000; i++) {
|
|
449
|
+
const x = rnd() * PW, y = rnd() * PH, L = 6 + rnd() * (rnd() < 0.1 ? 140 : 40), a = rnd() * Math.PI * 2, bend = (rnd() - 0.5) * 18;
|
|
450
|
+
p.strokeStyle = rnd() < 0.7 ? `rgba(140,112,74,${0.05 + rnd() * 0.07})` : `rgba(255,253,246,${0.25 + rnd() * 0.3})`;
|
|
451
|
+
p.lineWidth = 0.5 + rnd() * 1.1; p.beginPath(); p.moveTo(x, y);
|
|
452
|
+
p.quadraticCurveTo(x + Math.cos(a) * L / 2 - Math.sin(a) * bend, y + Math.sin(a) * L / 2 + Math.cos(a) * bend, x + Math.cos(a) * L, y + Math.sin(a) * L);
|
|
453
|
+
p.stroke();
|
|
454
|
+
}
|
|
455
|
+
// grain tile (applied over ink too)
|
|
456
|
+
const g = grainTile.getContext('2d'), gd = g.createImageData(512, 512);
|
|
457
|
+
for (let i = 0; i < 512 * 512; i++) {
|
|
458
|
+
const r = rnd(), k = i * 4;
|
|
459
|
+
if (r < 0.5) { gd.data[k] = 70; gd.data[k + 1] = 55; gd.data[k + 2] = 38; gd.data[k + 3] = (0.5 - r) * 52; }
|
|
460
|
+
else { gd.data[k] = 255; gd.data[k + 1] = 251; gd.data[k + 2] = 242; gd.data[k + 3] = (r - 0.5) * 60; }
|
|
461
|
+
}
|
|
462
|
+
g.putImageData(gd, 0, 0);
|
|
463
|
+
})();
|
|
464
|
+
const grainPat = ctx.createPattern(grainTile, 'repeat');
|
|
465
|
+
const mottleTile = document.createElement('canvas'); mottleTile.width = 256; mottleTile.height = 256;
|
|
466
|
+
(function () {
|
|
467
|
+
const m = mottleTile.getContext('2d'), d = m.createImageData(256, 256);
|
|
468
|
+
for (let y = 0; y < 256; y++) for (let x = 0; x < 256; x++) {
|
|
469
|
+
let n = 0, a = 1, tot = 0;
|
|
470
|
+
for (let o = 0; o < 3; o++) {
|
|
471
|
+
const f = [8, 16, 32][o] / 256, X = x * f, Y = y * f, P = [8, 16, 32][o];
|
|
472
|
+
const xi = Math.floor(X), yi = Math.floor(Y), fx = X - xi, fy = Y - yi, ux = fx * fx * (3 - 2 * fx), uy = fy * fy * (3 - 2 * fy);
|
|
473
|
+
const h = (i, j) => hash(((i % P + P) % P) * 92821 + ((j % P + P) % P) * 68917 + o * 1013 + 5);
|
|
474
|
+
n += a * lerp(lerp(h(xi, yi), h(xi + 1, yi), ux), lerp(h(xi, yi + 1), h(xi + 1, yi + 1), ux), uy); tot += a; a *= 0.55;
|
|
475
|
+
}
|
|
476
|
+
n /= tot; const k = (y * 256 + x) * 4;
|
|
477
|
+
d.data[k] = d.data[k + 1] = d.data[k + 2] = 0; d.data[k + 3] = clamp((n - 0.3) * 2.2, 0, 1) * 255;
|
|
478
|
+
}
|
|
479
|
+
m.putImageData(d, 0, 0);
|
|
480
|
+
})();
|
|
481
|
+
const mottlePat = i2.createPattern(mottleTile, 'repeat');
|
|
482
|
+
function camMatrix(cam) { const cs = Math.cos(cam.rot) * cam.sc, sn = Math.sin(cam.rot) * cam.sc; return new DOMMatrix([cs, sn, -sn, cs, 960 - (cs * cam.cx - sn * cam.cy), 540 - (sn * cam.cx + cs * cam.cy)]); }
|
|
483
|
+
|
|
484
|
+
// ---------- seal ----------
|
|
485
|
+
const SEAL = 138;
|
|
486
|
+
const seal = document.createElement('canvas'); seal.width = 200; seal.height = 200;
|
|
487
|
+
let sealFontOk = false;
|
|
488
|
+
function buildSeal() {
|
|
489
|
+
const s = seal.getContext('2d'), rnd = mulberry(77);
|
|
490
|
+
s.setTransform(1, 0, 0, 1, 0, 0); s.globalAlpha = 1; s.globalCompositeOperation = 'source-over'; s.clearRect(0, 0, 200, 200);
|
|
491
|
+
sealFontOk = !document.fonts || document.fonts.check(SEAL_FONT, SEAL_CHAR);
|
|
492
|
+
s.translate(100, 100);
|
|
493
|
+
s.fillStyle = SEAL_RED;
|
|
494
|
+
s.beginPath();
|
|
495
|
+
const h = SEAL / 2;
|
|
496
|
+
const corners = [[-h, -h], [h, -h], [h, h], [-h, h]];
|
|
497
|
+
corners.forEach((c, i) => { const jx = (rnd() - 0.5) * 3, jy = (rnd() - 0.5) * 3; i ? s.lineTo(c[0] + jx, c[1] + jy) : s.moveTo(c[0] + jx, c[1] + jy); });
|
|
498
|
+
s.closePath(); s.fill();
|
|
499
|
+
s.globalCompositeOperation = 'destination-out';
|
|
500
|
+
s.strokeStyle = '#000'; s.lineWidth = 3.8; s.strokeRect(-h + 11, -h + 11, SEAL - 22, SEAL - 22);
|
|
501
|
+
s.fillStyle = '#000'; s.textAlign = 'center'; s.textBaseline = 'middle';
|
|
502
|
+
s.font = SEAL_FONT;
|
|
503
|
+
s.fillText(SEAL_CHAR, 0, 4);
|
|
504
|
+
for (let i = 0; i < 420; i++) {
|
|
505
|
+
const x = (rnd() - 0.5) * SEAL * 1.05, y = (rnd() - 0.5) * SEAL * 1.05, r = rnd() < 0.9 ? rnd() * 1.3 : 1 + rnd() * 2.6;
|
|
506
|
+
s.globalAlpha = 0.4 + rnd() * 0.6; s.beginPath(); s.arc(x, y, r, 0, Math.PI * 2); s.fill();
|
|
507
|
+
}
|
|
508
|
+
// edge wear
|
|
509
|
+
for (let i = 0; i < 90; i++) {
|
|
510
|
+
const side = Math.floor(rnd() * 4), u = (rnd() - 0.5) * SEAL, r = 1 + rnd() * 3;
|
|
511
|
+
const x = side === 0 ? -h : side === 1 ? h : u, y = side === 2 ? -h : side === 3 ? h : u;
|
|
512
|
+
s.globalAlpha = 0.8; s.beginPath(); s.arc(x, y, r, 0, Math.PI * 2); s.fill();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
buildSeal();
|
|
516
|
+
if (document.fonts) document.fonts.load(SEAL_FONT, SEAL_CHAR).then(buildSeal, () => {});
|
|
517
|
+
|
|
518
|
+
// ---------- camera ----------
|
|
519
|
+
function camera(t) {
|
|
520
|
+
const fx = T[0], fy = T[1];
|
|
521
|
+
const cx = track(t, [[0, 560], [2.0, 930, 'sine.inOut'], [3.0, 1120, 'sine.inOut'], [3.75, 1350, 'sine.inOut'], [4.6, 1495, 'power2.inOut'], [5.0, 1500, 'none'], [5.9, fx - 10, 'expo.out'], [7.0, fx, 'none'], [8.3, E_W[0] + 20, 'power2.inOut'], [9.8, E[0]], [10.0, E[0]], [12, E[0] + 8, 'none']]);
|
|
522
|
+
const cy = track(t, [[0, 600], [2.0, 520, 'sine.inOut'], [3.0, 480, 'sine.inOut'], [3.5, 700, 'sine.inOut'], [3.9, 680, 'sine.inOut'], [4.6, 468, 'power2.inOut'], [5.0, 472, 'none'], [5.9, fy + 50, 'expo.out'], [7.0, fy + 58, 'none'], [8.3, WATER - 70, 'power2.inOut'], [9.8, E[1], 'power2.inOut'], [10.0, E[1]], [12, E[1] - 4, 'none']]);
|
|
523
|
+
let sc = track(t, [[0, 1.16], [2.0, 1.02, 'sine.inOut'], [3.0, 1.0], [3.6, 0.94], [4.6, 1.07], [5.0, 1.08, 'none'], [5.9, 1.42, 'expo.out'], [7.0, 1.46, 'none'], [8.3, 1.28, 'power2.inOut'], [9.8, 1.0, 'power2.inOut'], [10.0, 1.0], [12, 1.03, 'sine.inOut']]);
|
|
524
|
+
const bump = t > SEAL_T ? 0.008 * Math.exp(-(t - SEAL_T) * 7) * Math.cos((t - SEAL_T) * 26) : 0;
|
|
525
|
+
sc *= 1 + bump;
|
|
526
|
+
const rot = 0.0035 * Math.sin(t * 0.45 + 0.4);
|
|
527
|
+
const dx = 5 * Math.sin(t * 0.37), dy = 4 * Math.sin(t * 0.29 + 1.1);
|
|
528
|
+
return { cx: cx + dx, cy: cy + dy, sc, rot };
|
|
529
|
+
}
|
|
530
|
+
function setCam(c, cam) {
|
|
531
|
+
const cs = Math.cos(cam.rot) * cam.sc, sn = Math.sin(cam.rot) * cam.sc;
|
|
532
|
+
// screen = R*S*(world - center) + (960,540)
|
|
533
|
+
c.setTransform(cs, sn, -sn, cs, 960 - (cs * cam.cx - sn * cam.cy), 540 - (sn * cam.cx + cs * cam.cy));
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// ---------- drawing ----------
|
|
537
|
+
const TONES = ['#101010', '#171716', '#1f1e1d', '#292726', '#353230', '#43403c'];
|
|
538
|
+
const TK = new Uint8Array(N);
|
|
539
|
+
function strokeLine(c, lo, hi, scale, wf, col, minW) {
|
|
540
|
+
c.lineCap = 'round'; c.lineJoin = 'round'; c.strokeStyle = col;
|
|
541
|
+
const toned = col === INK;
|
|
542
|
+
let runW = -1, runK = -1;
|
|
543
|
+
c.beginPath();
|
|
544
|
+
for (let i = lo; i < hi; i++) {
|
|
545
|
+
const raw = (S.w[i] + S.w[i + 1]) * 0.5;
|
|
546
|
+
if ((minW && raw < minW) || (!minW && raw * scale < 0.8)) { if (runW >= 0) { c.lineWidth = runW; c.stroke(); runW = -1; } continue; }
|
|
547
|
+
const w = Math.max(0.5 / scale, raw * wf);
|
|
548
|
+
const kk = toned ? TK[i] : 0;
|
|
549
|
+
if (runW < 0 || Math.abs(w - runW) > 0.35 / scale || kk !== runK) {
|
|
550
|
+
if (runW >= 0) { c.lineWidth = runW; c.stroke(); }
|
|
551
|
+
if (toned) c.strokeStyle = TONES[kk];
|
|
552
|
+
c.beginPath(); c.moveTo(S.x[i], S.y[i]); runW = w; runK = kk;
|
|
553
|
+
}
|
|
554
|
+
c.lineTo(S.x[i + 1], S.y[i + 1]);
|
|
555
|
+
}
|
|
556
|
+
if (runW >= 0) { c.lineWidth = runW; c.stroke(); }
|
|
557
|
+
}
|
|
558
|
+
function hairLines(c, lo, hi, scale) {
|
|
559
|
+
c.lineCap = 'round'; c.strokeStyle = INK; c.lineWidth = 0.75 / scale; c.globalAlpha = 0.32;
|
|
560
|
+
c.beginPath(); let open = false;
|
|
561
|
+
for (let i = lo; i < hi; i++) {
|
|
562
|
+
const raw = (S.w[i] + S.w[i + 1]) * 0.5;
|
|
563
|
+
if (raw * scale >= 0.8) { open = false; continue; }
|
|
564
|
+
if (!open) { c.moveTo(S.x[i], S.y[i]); open = true; }
|
|
565
|
+
c.lineTo(S.x[i + 1], S.y[i + 1]);
|
|
566
|
+
}
|
|
567
|
+
c.stroke(); c.globalAlpha = 1;
|
|
568
|
+
}
|
|
569
|
+
function feathers(c, lo, hi, scale) {
|
|
570
|
+
c.lineCap = 'round'; c.strokeStyle = INK; c.lineWidth = 0.7 / scale; c.globalAlpha = 0.5;
|
|
571
|
+
c.beginPath();
|
|
572
|
+
for (let i = lo + 1; i < hi; i += 2) {
|
|
573
|
+
const w = S.w[i]; if (w * scale < 6) continue;
|
|
574
|
+
const h = hash(i * 3 + 1); if (h > 0.32) continue;
|
|
575
|
+
let tx = S.x[i + 1] - S.x[i - 1], ty = S.y[i + 1] - S.y[i - 1]; const L = Math.hypot(tx, ty) || 1; tx /= L; ty /= L;
|
|
576
|
+
const side = hash(i * 7 + 2) < 0.5 ? -1 : 1, nx = -ty * side, ny = tx * side;
|
|
577
|
+
const ang = (hash(i * 11 + 4) - 0.5) * 1.1, ca = Math.cos(ang), sa = Math.sin(ang);
|
|
578
|
+
const dx = nx * ca - ny * sa, dy = nx * sa + ny * ca, len = (1.5 + hash(i * 5 + 3) * 6) / scale;
|
|
579
|
+
const bx0 = S.x[i] + nx * w * 0.46, by0 = S.y[i] + ny * w * 0.46;
|
|
580
|
+
c.moveTo(bx0, by0); c.lineTo(bx0 + dx * len, by0 + dy * len);
|
|
581
|
+
}
|
|
582
|
+
c.stroke(); c.globalAlpha = 1;
|
|
583
|
+
}
|
|
584
|
+
function dryCuts(c, lo, hi) {
|
|
585
|
+
c.globalCompositeOperation = 'destination-out';
|
|
586
|
+
c.lineCap = 'round';
|
|
587
|
+
c.strokeStyle = '#000';
|
|
588
|
+
const NBR = 12;
|
|
589
|
+
for (let b = 0; b < NBR; b++) {
|
|
590
|
+
const off = (b / (NBR - 1) - 0.5) * 0.92 + (hash(b * 31 + 5) - 0.5) * 0.05;
|
|
591
|
+
const edge = Math.pow(Math.abs(b / (NBR - 1) - 0.5) * 2, 2) * 0.3;
|
|
592
|
+
let open = false;
|
|
593
|
+
for (let i = lo; i < hi; i++) {
|
|
594
|
+
const d = S.d[i];
|
|
595
|
+
const nz = vn(i * 0.016 + b * 31.7, 9) * 0.75 + vn(i * 0.09 + b * 7.1, 11) * 0.25;
|
|
596
|
+
const cut = d >= 0.04 && nz < d * 0.78 + edge * d - 0.06;
|
|
597
|
+
if (!cut) { if (open) { c.stroke(); open = false; } continue; }
|
|
598
|
+
const x0 = S.x[i], y0 = S.y[i], x1 = S.x[i + 1], y1 = S.y[i + 1];
|
|
599
|
+
let nx = -(y1 - y0), ny = x1 - x0; const L = Math.hypot(nx, ny) || 1; nx /= L; ny /= L;
|
|
600
|
+
const w = S.w[i];
|
|
601
|
+
if (!open) { c.lineWidth = Math.max(0.7, w * (0.05 + 0.05 * d)); c.beginPath(); c.moveTo(x0 + nx * off * w, y0 + ny * off * w); open = true; }
|
|
602
|
+
c.lineTo(x1 + nx * off * w, y1 + ny * off * w);
|
|
603
|
+
}
|
|
604
|
+
if (open) c.stroke();
|
|
605
|
+
}
|
|
606
|
+
c.globalCompositeOperation = 'source-over';
|
|
607
|
+
}
|
|
608
|
+
function blot(c, x, y, r, a) {
|
|
609
|
+
const g = c.createRadialGradient(x, y, 0, x, y, r);
|
|
610
|
+
g.addColorStop(0, `rgba(28,28,28,${a})`); g.addColorStop(0.55, `rgba(28,28,28,${a * 0.45})`); g.addColorStop(1, 'rgba(28,28,28,0)');
|
|
611
|
+
c.fillStyle = g; c.beginPath(); c.arc(x, y, r, 0, Math.PI * 2); c.fill();
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
function draw(tr) {
|
|
615
|
+
const fr = Math.round(tr * 30), tq = remap(Math.floor(fr / 2) / 15); // drawing on twos
|
|
616
|
+
TRQ = Math.floor(fr / 2) / 15;
|
|
617
|
+
const t = remap(tr);
|
|
618
|
+
state(tq, S);
|
|
619
|
+
// boil
|
|
620
|
+
const seed = Math.floor(fr / 2);
|
|
621
|
+
for (let i = 0; i < N; i++) {
|
|
622
|
+
S.x[i] += (vn(i * 0.04 + seed * 13.1, 1) - 0.5) * 3.4;
|
|
623
|
+
S.y[i] += (vn(i * 0.04 + seed * 17.7, 2) - 0.5) * 3.4;
|
|
624
|
+
S.w[i] *= (0.95 + 0.1 * vn(i * 0.03 + seed * 7.3, 4)) * (0.95 + 0.1 * vn(i * 0.55, 12));
|
|
625
|
+
}
|
|
626
|
+
for (let i = 0; i < N; i++) {
|
|
627
|
+
const tone = 0.12 + 0.42 * vn(i * 0.011, 21) + 0.5 * S.d[i] - 0.3 * clamp((S.w[i] - 7) / 16, 0, 1);
|
|
628
|
+
TK[i] = clamp(Math.floor(tone * 6), 0, 5);
|
|
629
|
+
}
|
|
630
|
+
// draw-on range
|
|
631
|
+
let hi = N - 1, hiF = N - 1;
|
|
632
|
+
if (tq < 2.0) {
|
|
633
|
+
if (tq < 0.5) hiF = (N_T - 1) * lerp(0.8, 1, ez('power1.out')(clamp(tq / 0.5, 0, 1)));
|
|
634
|
+
else {
|
|
635
|
+
const p = ez('sine.inOut')(clamp((tq - 0.5) / 1.5, 0, 1));
|
|
636
|
+
let j = 0; while (j < N_B - 1 && birdCum[j + 1] < p) j++;
|
|
637
|
+
const k = (p - birdCum[j]) / Math.max(1e-6, birdCum[j + 1] - birdCum[j]);
|
|
638
|
+
hiF = N_T + j + clamp(k, 0, 1);
|
|
639
|
+
}
|
|
640
|
+
hi = Math.floor(hiF);
|
|
641
|
+
}
|
|
642
|
+
const cam = camera(t);
|
|
643
|
+
cam.sc *= 1 + 0.035 * sstep(1.5, HOLD0 + HOLD, tr) - 0.035 * sstep(HOLD0 + HOLD, HOLD0 + HOLD + 1.0, tr);
|
|
644
|
+
// paper
|
|
645
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
646
|
+
ctx.fillStyle = PAPER; ctx.fillRect(0, 0, SW, SH);
|
|
647
|
+
setCam(ctx, cam);
|
|
648
|
+
ctx.drawImage(paper, PX0, PY0);
|
|
649
|
+
// ink layer
|
|
650
|
+
ictx.setTransform(1, 0, 0, 1, 0, 0); ictx.clearRect(0, 0, SW, SH);
|
|
651
|
+
setCam(ictx, cam);
|
|
652
|
+
let hx = S.x[hi], hy = S.y[hi];
|
|
653
|
+
if (hi < N - 1) {
|
|
654
|
+
const k = hiF - hi; hx = lerp(S.x[hi], S.x[hi + 1], k); hy = lerp(S.y[hi], S.y[hi + 1], k);
|
|
655
|
+
S.x[hi + 1] = hx; S.y[hi + 1] = hy;
|
|
656
|
+
}
|
|
657
|
+
const top = Math.min(hi + 1, N - 1);
|
|
658
|
+
if (top > 0) {
|
|
659
|
+
strokeLine(ictx, 0, top, cam.sc, 1, INK);
|
|
660
|
+
hairLines(ictx, 0, top, cam.sc);
|
|
661
|
+
feathers(ictx, 0, top, cam.sc);
|
|
662
|
+
// ink spatter thrown off the heavy start of the enso
|
|
663
|
+
const sp = seg(tq, 9.85, 10.0, 'power2.out');
|
|
664
|
+
if (sp > 0) {
|
|
665
|
+
const th0 = THS, ex = E[0] + RE * Math.cos(th0) * 1.0, ey = E[1] + RE * Math.sin(th0);
|
|
666
|
+
ictx.fillStyle = INK;
|
|
667
|
+
for (let k = 0; k < 14; k++) {
|
|
668
|
+
const a = th0 + Math.PI + (hash(k * 13 + 1) - 0.5) * 2.2, d = 30 + hash(k * 7 + 3) * 70 * sp, r = (0.8 + hash(k * 5 + 9) * 4.2) * (k < 3 ? 1.6 : 1);
|
|
669
|
+
ictx.beginPath(); ictx.arc(ex + Math.cos(a) * d, ey + Math.sin(a) * d, r * (0.6 + 0.4 * sp), 0, Math.PI * 2); ictx.fill();
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
if (hi < N - 1) { ictx.fillStyle = INK; ictx.beginPath(); ictx.arc(hx, hy, Math.max(2.6, S.w[hi] * 0.66), 0, Math.PI * 2); ictx.fill(); }
|
|
673
|
+
dryCuts(ictx, 0, top);
|
|
674
|
+
// inner tone: wet ink pools darker at the edges, lighter in the belly of thick strokes
|
|
675
|
+
i2.setTransform(1, 0, 0, 1, 0, 0); i2.clearRect(0, 0, SW, SH); setCam(i2, cam);
|
|
676
|
+
strokeLine(i2, 0, top, cam.sc, 0.5, '#7a7068', 7);
|
|
677
|
+
i2.setTransform(1, 0, 0, 1, 0, 0); i2.globalCompositeOperation = 'destination-in';
|
|
678
|
+
mottlePat.setTransform(camMatrix(cam)); i2.fillStyle = mottlePat; i2.fillRect(0, 0, SW, SH); i2.globalCompositeOperation = 'source-over';
|
|
679
|
+
ictx.setTransform(1, 0, 0, 1, 0, 0);
|
|
680
|
+
ictx.globalCompositeOperation = 'source-atop'; ictx.globalAlpha = 0.42 + 0.22 * sstep(9.6, 10.0, tq) * (1 - seg(t, 10.0, 11.9, 'power1.out')); ictx.filter = 'blur(1.6px)';
|
|
681
|
+
ictx.drawImage(ink2, 0, 0);
|
|
682
|
+
ictx.filter = 'none'; ictx.globalAlpha = 1; ictx.globalCompositeOperation = 'source-over';
|
|
683
|
+
}
|
|
684
|
+
// diluted ink wash inside petals and leaf, sumi-e style; it dissolves into the water on landing
|
|
685
|
+
wctx.setTransform(1, 0, 0, 1, 0, 0); wctx.clearRect(0, 0, SW, SH);
|
|
686
|
+
let washAny = false;
|
|
687
|
+
if (tq > 4.7 && tq < 9.6) {
|
|
688
|
+
setCam(wctx, cam); wctx.fillStyle = INK;
|
|
689
|
+
const poly = (a, b, al) => {
|
|
690
|
+
if (al <= 0.004) return; washAny = true;
|
|
691
|
+
wctx.globalAlpha = al; wctx.beginPath(); wctx.moveTo(S.x[a], S.y[a]);
|
|
692
|
+
for (let i = a + 1; i <= b; i++) wctx.lineTo(S.x[i], S.y[i]);
|
|
693
|
+
wctx.closePath(); wctx.fill();
|
|
694
|
+
};
|
|
695
|
+
for (let q = 0; q < 5; q++) {
|
|
696
|
+
const o = PET_ORDER.indexOf(q), a = N_T + N_SP + q * N_PET;
|
|
697
|
+
let al = 0.14 * seg(tq, 5.45 + 0.07 * o, 6.1 + 0.07 * o, 'power2.out');
|
|
698
|
+
const tl = DET[q] + FD;
|
|
699
|
+
al *= 1 - 0.55 * seg(tq, DET[q], tl, 'none');
|
|
700
|
+
if (tq > tl) al *= 0.6 * (1 - seg(tq, tl, tl + 0.9, 'power1.out'));
|
|
701
|
+
poly(a, a + N_PET - 1, al);
|
|
702
|
+
}
|
|
703
|
+
const lf0 = Math.round(0.36 * (N_T - 1)), lf1 = Math.round(0.47 * (N_T - 1));
|
|
704
|
+
poly(lf0, lf1, 0.16 * seg(tq, 4.8, 5.6, 'power2.out') * (1 - seg(tq, SLIDE0, SLIDE0 + 0.45, 'none')));
|
|
705
|
+
wctx.globalAlpha = 1;
|
|
706
|
+
if (washAny) {
|
|
707
|
+
wctx.setTransform(1, 0, 0, 1, 0, 0); wctx.globalCompositeOperation = 'destination-out';
|
|
708
|
+
wctx.globalAlpha = 0.3; mottlePat.setTransform(camMatrix(cam)); wctx.fillStyle = mottlePat; wctx.fillRect(0, 0, SW, SH);
|
|
709
|
+
wctx.globalAlpha = 1; wctx.globalCompositeOperation = 'source-over';
|
|
710
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
711
|
+
ctx.filter = 'blur(7px)'; ctx.drawImage(washC, 0, 0); ctx.filter = 'blur(2px)'; ctx.globalAlpha = 0.6; ctx.drawImage(washC, 0, 0);
|
|
712
|
+
ctx.filter = 'none'; ctx.globalAlpha = 1;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
// composite ink: bleed halo, then body
|
|
716
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
717
|
+
ctx.globalAlpha = 0.07 + 0.07 * seg(t, 9.9, 12, 'power1.out'); ctx.filter = 'blur(14px)'; ctx.drawImage(ink, 0, 0);
|
|
718
|
+
ctx.globalAlpha = 0.2; ctx.filter = 'blur(3px)'; ctx.drawImage(ink, 0, 0);
|
|
719
|
+
ctx.filter = 'none'; ctx.globalAlpha = 0.96; ctx.drawImage(ink, 0, 0); ctx.globalAlpha = 1;
|
|
720
|
+
// bleed blots at the stroke ends
|
|
721
|
+
setCam(ctx, cam);
|
|
722
|
+
if (top > 0) {
|
|
723
|
+
blot(ctx, S.x[0], S.y[0], S.w[0] * 1.6 + 6, 0.24);
|
|
724
|
+
blot(ctx, hx, hy, S.w[hi] * 1.5 + 6, hi < N - 1 ? 0.32 : 0.16);
|
|
725
|
+
}
|
|
726
|
+
// seal
|
|
727
|
+
if (t > SEAL_T - 0.2) {
|
|
728
|
+
if (!sealFontOk) buildSeal();
|
|
729
|
+
const k = clamp((t - (SEAL_T - 0.2)) / 0.2, 0, 1), kin = ez('power2.in')(k);
|
|
730
|
+
const settle = t > SEAL_T ? 1 - 0.012 * Math.exp(-(t - SEAL_T) * 9) * Math.sin((t - SEAL_T) * 30) : 1;
|
|
731
|
+
const sc = lerp(1.22, 1, kin) * settle;
|
|
732
|
+
const sx = E[0] + 440, sy = E[1] + 330;
|
|
733
|
+
ctx.save(); ctx.translate(sx, sy); ctx.rotate(-0.045); ctx.scale(sc, sc);
|
|
734
|
+
ctx.globalAlpha = kin * 0.96; ctx.globalCompositeOperation = 'multiply';
|
|
735
|
+
ctx.drawImage(seal, -100, -100);
|
|
736
|
+
ctx.globalCompositeOperation = 'source-over';
|
|
737
|
+
if (t > SEAL_T) { const s2 = clamp((t - SEAL_T) / 0.6, 0, 1); ctx.globalAlpha = 0.14 * (1 - s2); ctx.filter = 'blur(6px)'; ctx.drawImage(seal, -100, -100); ctx.filter = 'none'; }
|
|
738
|
+
ctx.restore(); ctx.globalAlpha = 1;
|
|
739
|
+
}
|
|
740
|
+
// grain over everything, locked to the paper
|
|
741
|
+
const cs = Math.cos(cam.rot) * cam.sc, sn = Math.sin(cam.rot) * cam.sc;
|
|
742
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
743
|
+
grainPat.setTransform(new DOMMatrix([cs, sn, -sn, cs, 960 - (cs * cam.cx - sn * cam.cy), 540 - (sn * cam.cx + cs * cam.cy)]));
|
|
744
|
+
ctx.fillStyle = grainPat; ctx.fillRect(0, 0, SW, SH);
|
|
745
|
+
// light: warm window light from the top left, soft shade to the bottom right
|
|
746
|
+
ctx.globalCompositeOperation = 'multiply';
|
|
747
|
+
const sh = ctx.createLinearGradient(300, 0, 1800, 1080);
|
|
748
|
+
sh.addColorStop(0, 'rgba(255,255,255,0)'); sh.addColorStop(0.55, 'rgba(250,244,232,0)'); sh.addColorStop(1, 'rgba(232,220,198,0.24)');
|
|
749
|
+
ctx.fillStyle = sh; ctx.fillRect(0, 0, SW, SH);
|
|
750
|
+
const vg = ctx.createRadialGradient(960, 520, 520, 960, 540, 1180);
|
|
751
|
+
vg.addColorStop(0, 'rgba(255,255,255,0)'); vg.addColorStop(1, 'rgba(206,188,160,0.22)');
|
|
752
|
+
ctx.fillStyle = vg; ctx.fillRect(0, 0, SW, SH);
|
|
753
|
+
// a slow shaft of window light across the sheet
|
|
754
|
+
{
|
|
755
|
+
const ang = -0.42, ox = 760 + 140 * Math.sin(t * 0.21), ca = Math.cos(ang), sa = Math.sin(ang);
|
|
756
|
+
const g = ctx.createLinearGradient(ox - 700 * ca, 540 - 700 * sa, ox + 700 * ca, 540 + 700 * sa);
|
|
757
|
+
g.addColorStop(0, 'rgba(236,226,208,0.26)'); g.addColorStop(0.32, 'rgba(255,255,255,0)'); g.addColorStop(0.6, 'rgba(255,255,255,0)'); g.addColorStop(1, 'rgba(236,226,208,0.26)');
|
|
758
|
+
ctx.fillStyle = g; ctx.fillRect(0, 0, SW, SH);
|
|
759
|
+
}
|
|
760
|
+
ctx.globalCompositeOperation = 'screen';
|
|
761
|
+
const lx = 520 + 40 * Math.sin(t * 0.3), ly = 260;
|
|
762
|
+
const lg = ctx.createRadialGradient(lx, ly, 0, lx, ly, 1000);
|
|
763
|
+
lg.addColorStop(0, 'rgba(70,58,34,0.2)'); lg.addColorStop(1, 'rgba(0,0,0,0)');
|
|
764
|
+
ctx.fillStyle = lg; ctx.fillRect(0, 0, SW, SH);
|
|
765
|
+
ctx.globalCompositeOperation = 'source-over';
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
const p = { t: 0 };
|
|
769
|
+
const tl = gsap.timeline({ paused: true });
|
|
770
|
+
tl.to(p, { t: DUR, duration: DUR, ease: 'none', onUpdate: () => draw(p.t) }, 0);
|
|
771
|
+
window.__timelines = window.__timelines || {};
|
|
772
|
+
window.__timelines['main'] = tl;
|
|
773
|
+
draw(0);
|
|
774
|
+
})();
|
|
775
|
+
</script>
|
|
776
|
+
</body>
|
|
777
|
+
</html>
|