@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,602 @@
|
|
|
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="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@500;600;700&display=swap" />
|
|
7
|
+
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
|
|
8
|
+
<style>
|
|
9
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
10
|
+
html, body { width: 1920px; height: 1080px; overflow: hidden; background: #BFE3E0; }
|
|
11
|
+
#root { position: relative; width: 1920px; height: 1080px; overflow: hidden; font-family: "Inter", sans-serif; }
|
|
12
|
+
#cv { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; }
|
|
13
|
+
#labels { position: absolute; left: 112px; top: 88px; color: #2D4B53; }
|
|
14
|
+
.mwrap { position: relative; height: 168px; width: 420px; overflow: visible; }
|
|
15
|
+
.month { position: absolute; left: -6px; top: 0; font-size: 156px; line-height: 168px; font-weight: 700; letter-spacing: -0.035em; will-change: transform, opacity; }
|
|
16
|
+
#count { margin-top: 8px; font-size: 44px; line-height: 56px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
17
|
+
#count span { font-weight: 500; opacity: 0.62; }
|
|
18
|
+
</style>
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<div id="root" data-composition-id="main" data-start="0" data-duration="17.5" data-width="1920" data-height="1080">
|
|
22
|
+
<canvas id="cv" class="clip" width="1920" height="1080" data-start="0" data-duration="17.5" data-track-index="0"></canvas>
|
|
23
|
+
<div id="labels" class="clip" data-start="0" data-duration="17.5" data-track-index="1">
|
|
24
|
+
<div class="mwrap"><div class="month" id="mA"></div><div class="month" id="mB"></div></div>
|
|
25
|
+
<div id="count"></div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
<script>
|
|
29
|
+
/*
|
|
30
|
+
A city that grows. 17.5 s, 1920x1080, does not loop.
|
|
31
|
+
An isometric pastel island city drawn on one canvas, plus two labels (month + count).
|
|
32
|
+
Beat map:
|
|
33
|
+
0.0 - 6.0 island tiles drop in from the centre, roads draw out, beach ring forms; camera pulls back and orbits
|
|
34
|
+
0.5 - 8.75 one month every 0.75 s (Jan to Dec): the count rolls up, buildings are born, towers add floors
|
|
35
|
+
9.0 - 10.6 dusk: sea and land shift to peach and blue-lilac, labels turn cream
|
|
36
|
+
10.0 - 11.5 windows, lamps and car lights switch on in a wave from the core; labels leave at 10.25 s
|
|
37
|
+
11.5 - 17.5 night deepens while the camera pushes in slowly; cars, boats and ripples keep moving
|
|
38
|
+
Change the words: MONTHS, VALS and COUNT_LABEL (SAMPLE DATA, just below).
|
|
39
|
+
Change the colours: the hex constants in the "colour" block (GRASS, SAND, ROAD, CORAL, BLD, TREE...),
|
|
40
|
+
the sea gradient in draw(), and the label colours c0 / c1 in labels().
|
|
41
|
+
Deterministic: one seeded PRNG (mulberry32). Never add unseeded random numbers or clock reads.
|
|
42
|
+
*/
|
|
43
|
+
(() => {
|
|
44
|
+
// SAMPLE DATA: change these. 12 labels, 12 values, one word after the number.
|
|
45
|
+
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
46
|
+
const VALS = [1200, 2100, 3400, 5000, 7200, 10100, 13800, 18500, 24300, 31000, 39000, 48000];
|
|
47
|
+
const COUNT_LABEL = 'followers';
|
|
48
|
+
|
|
49
|
+
const W = 1920, H = 1080, DUR = 17.5;
|
|
50
|
+
const cv = document.getElementById('cv');
|
|
51
|
+
const ctx = cv.getContext('2d');
|
|
52
|
+
const sh = document.createElement('canvas'); sh.width = W / 2; sh.height = H / 2; const sctx = sh.getContext('2d');
|
|
53
|
+
const gl = document.createElement('canvas'); gl.width = W / 2; gl.height = H / 2; const gctx = gl.getContext('2d');
|
|
54
|
+
const half = c => { c.setTransform(1, 0, 0, 1, 0, 0); c.clearRect(0, 0, W / 2, H / 2); c.setTransform(0.5, 0, 0, 0.5, 0, 0); };
|
|
55
|
+
|
|
56
|
+
// ---------- seeded PRNG ----------
|
|
57
|
+
function mulberry32(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; }; }
|
|
58
|
+
const R = mulberry32(20261020);
|
|
59
|
+
|
|
60
|
+
// ---------- easing ----------
|
|
61
|
+
const clamp = (v, a = 0, b = 1) => Math.min(b, Math.max(a, v));
|
|
62
|
+
const lerp = (a, b, k) => a + (b - a) * k;
|
|
63
|
+
const eOut3 = k => 1 - Math.pow(1 - k, 3);
|
|
64
|
+
const eExpo = k => k >= 1 ? 1 : 1 - Math.pow(2, -10 * k);
|
|
65
|
+
const eInOut = k => -(Math.cos(Math.PI * k) - 1) / 2;
|
|
66
|
+
const eBack = (k, s = 1.9) => { const c3 = s + 1; return 1 + c3 * Math.pow(k - 1, 3) + s * Math.pow(k - 1, 2); };
|
|
67
|
+
const mix3 = (a, b, k) => [lerp(a[0], b[0], k), lerp(a[1], b[1], k), lerp(a[2], b[2], k)];
|
|
68
|
+
|
|
69
|
+
// ---------- colour ----------
|
|
70
|
+
const hex = h => [parseInt(h.slice(1, 3), 16), parseInt(h.slice(3, 5), 16), parseInt(h.slice(5, 7), 16)];
|
|
71
|
+
const TINT_D = hex('#6F6A93'), TINT_N = hex('#2C2F6E');
|
|
72
|
+
let DK = 0; // dusk amount 0..1
|
|
73
|
+
let TINT = TINT_D;
|
|
74
|
+
function shade(c, f) { // f: 1 = lit. cool lilac-tinted shade
|
|
75
|
+
const m = (1 - f) * 0.55;
|
|
76
|
+
const o = [c[0] * f * (1 - m) + TINT[0] * m, c[1] * f * (1 - m) + TINT[1] * m, c[2] * f * (1 - m) + TINT[2] * m];
|
|
77
|
+
const w = DK * clamp((f - 0.8) / 0.2) * 0.42;
|
|
78
|
+
return w > 0 ? mix3(o, [255, 196, 164], w) : o;
|
|
79
|
+
}
|
|
80
|
+
const DUSKM = [0.60, 0.65, 0.80];
|
|
81
|
+
function dk(c) { return [c[0] * lerp(1, DUSKM[0], DK), c[1] * lerp(1, DUSKM[1], DK), c[2] * lerp(1, DUSKM[2], DK)]; }
|
|
82
|
+
function css(c, a = 1) { const d = dk(c); return a >= 1 ? `rgb(${d[0] | 0},${d[1] | 0},${d[2] | 0})` : `rgba(${d[0] | 0},${d[1] | 0},${d[2] | 0},${a})`; }
|
|
83
|
+
const GRASS = hex('#CDE6B8'), SAND = hex('#F3E3C3'), EARTH = hex('#E6D3AE'), ROCK = hex('#C9B28E'), ROAD = hex('#F4EFE6');
|
|
84
|
+
const CORAL = hex('#F27D72');
|
|
85
|
+
const BLD = ['#F7EFDF', '#ECDDC2', '#DDD3EB', '#E9E1F2', '#F4E8E0', '#E4D8C6'].map(hex);
|
|
86
|
+
const HOUSE_ROOF = ['#C9BEDB', '#D8C6AE', '#BFB6D3'].map(hex);
|
|
87
|
+
const GLASS = hex('#A8BED3');
|
|
88
|
+
const TREE = hex('#A9D497'), TREE_HI = hex('#CDEBB8'), TREE_DK = hex('#88BC85');
|
|
89
|
+
const LIT = [255, 226, 160];
|
|
90
|
+
const WL = -0.5; // water level
|
|
91
|
+
|
|
92
|
+
// ---------- world ----------
|
|
93
|
+
const N = 31, C = 15, RU = 15.6, RV = 11.4;
|
|
94
|
+
const noise = [];
|
|
95
|
+
for (let i = 0; i < N; i++) { noise[i] = []; for (let j = 0; j < N; j++) noise[i][j] = R(); }
|
|
96
|
+
const sn = (i, j) => { let s = 0, c = 0; for (let a = -1; a <= 1; a++) for (let b = -1; b <= 1; b++) { const x = i + a, y = j + b; if (x >= 0 && y >= 0 && x < N && y < N) { s += noise[x][y]; c++; } } return s / c; };
|
|
97
|
+
const dist = (i, j) => { const u = i - j, v = i + j - 2 * C; return Math.sqrt((u / RU) ** 2 + (v / RV) ** 2) + (sn(i, j) - 0.5) * 0.22; };
|
|
98
|
+
const land = [], D = [];
|
|
99
|
+
for (let i = 0; i < N; i++) { land[i] = []; D[i] = []; for (let j = 0; j < N; j++) { D[i][j] = dist(i, j); land[i][j] = D[i][j] < 1; } }
|
|
100
|
+
// remove lonely spurs so the coast reads clean
|
|
101
|
+
for (let pass = 0; pass < 2; pass++) for (let i = 1; i < N - 1; i++) for (let j = 1; j < N - 1; j++) {
|
|
102
|
+
const n = [land[i + 1][j], land[i - 1][j], land[i][j + 1], land[i][j - 1]].filter(Boolean).length;
|
|
103
|
+
if (land[i][j] && n <= 1) land[i][j] = false; if (!land[i][j] && n >= 3) land[i][j] = true;
|
|
104
|
+
}
|
|
105
|
+
const isLand = (i, j) => i >= 0 && j >= 0 && i < N && j < N && land[i][j];
|
|
106
|
+
const beach = (i, j) => isLand(i, j) && (!isLand(i + 1, j) || !isLand(i - 1, j) || !isLand(i, j + 1) || !isLand(i, j - 1));
|
|
107
|
+
const isRoadLine = (i, j) => (i % 4 === 3) || (j % 4 === 3);
|
|
108
|
+
const isRoad = (i, j) => isLand(i, j) && !beach(i, j) && isRoadLine(i, j);
|
|
109
|
+
const landT = (i, j) => 0.05 + 6.0 * Math.pow(Math.max(0, D[i][j]), 1.45);
|
|
110
|
+
|
|
111
|
+
const MONTH_T = []; for (let m = 0; m < 12; m++) MONTH_T.push(0.5 + 0.75 * m);
|
|
112
|
+
const snapMonth = t => { for (const mt of MONTH_T) if (mt >= t) return mt; return MONTH_T[11]; };
|
|
113
|
+
|
|
114
|
+
const tiles = [];
|
|
115
|
+
for (let i = 0; i < N; i++) for (let j = 0; j < N; j++) if (land[i][j]) tiles.push({ i, j, x: i - C, z: j - C, t0: landT(i, j), beach: beach(i, j),
|
|
116
|
+
open: [[i - 1, j], [i + 1, j], [i, j - 1], [i, j + 1]].map(([a, b2]) => !isLand(a, b2) || (!beach(i, j) && beach(a, b2))) });
|
|
117
|
+
|
|
118
|
+
// roads: strips drawn outward from the centre cross
|
|
119
|
+
const roadT = {};
|
|
120
|
+
const roadStrips = [];
|
|
121
|
+
for (const q of tiles) {
|
|
122
|
+
const { i, j } = q;
|
|
123
|
+
if (!isRoad(i, j)) continue;
|
|
124
|
+
if (i % 4 === 3) { const tt = Math.max(0.5 + Math.abs(i - C) * 0.10 + Math.abs(j - C) * 0.12, q.t0 + 0.15); roadStrips.push({ i, j, axis: 'j', t0: tt, sgn: Math.sign(j - C) }); roadT[i + ',' + j] = Math.min(roadT[i + ',' + j] ?? 99, tt); }
|
|
125
|
+
if (j % 4 === 3) { const tt = Math.max(0.5 + Math.abs(j - C) * 0.10 + Math.abs(i - C) * 0.12, q.t0 + 0.15); roadStrips.push({ i, j, axis: 'i', t0: tt, sgn: Math.sign(i - C) }); roadT[i + ',' + j] = Math.min(roadT[i + ',' + j] ?? 99, tt); }
|
|
126
|
+
}
|
|
127
|
+
const nearRoadT = (i, j) => { let m = 99; for (const [a, b] of [[1, 0], [-1, 0], [0, 1], [0, -1]]) { const k = (i + a) + ',' + (j + b); if (roadT[k] !== undefined) m = Math.min(m, roadT[k]); } return m === 99 ? 0 : m; };
|
|
128
|
+
|
|
129
|
+
// buildings + trees + lamps
|
|
130
|
+
const FH = 0.36;
|
|
131
|
+
const buildings = [], trees = [], lamps = [];
|
|
132
|
+
for (const q of tiles) {
|
|
133
|
+
const { i, j } = q;
|
|
134
|
+
if (q.beach || isRoad(i, j)) {
|
|
135
|
+
if (q.beach && !isRoad(i, j) && R() < 0.3) trees.push({ x: i - C + (R() - 0.5) * 0.5, z: j - C + (R() - 0.5) * 0.5, s: 0.7 + R() * 0.35, t0: q.t0 + 0.5 + R() * 0.8, y: -0.36 });
|
|
136
|
+
if (isRoad(i, j) && i % 4 === 3 && j % 4 === 3) lamps.push({ x: i - C - 0.4, z: j - C + 0.4, t0: (roadT[i + ',' + j] || 0) + 0.3, tl: 9.75 + D[i][j] * 0.5 });
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const r = D[i][j];
|
|
140
|
+
if (R() < 0.13 + r * 0.12) { // park
|
|
141
|
+
const n = 2 + Math.floor(R() * 3);
|
|
142
|
+
for (let k = 0; k < n; k++) trees.push({ x: i - C + (R() - 0.5) * 0.62, z: j - C + (R() - 0.5) * 0.62, s: 0.62 + R() * 0.4, t0: snapMonth(q.t0 + 0.35) + 0.1 + k * 0.08 + R() * 0.2 });
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const F = Math.max(1, Math.round(1 + 11.5 * Math.pow(Math.max(0, 1 - r), 2.3) + R() * 2.2));
|
|
146
|
+
const house = F <= 2 && r > 0.45;
|
|
147
|
+
const ins = house ? 0.17 + R() * 0.05 : 0.1 + R() * 0.07;
|
|
148
|
+
const tb = snapMonth(Math.max(q.t0 + 0.3, nearRoadT(i, j) + 0.15)) + R() * 0.32;
|
|
149
|
+
const floors = [];
|
|
150
|
+
const FF = house ? 1 : F;
|
|
151
|
+
for (let k = 0; k < FF; k++) {
|
|
152
|
+
if (k < 3) floors.push(tb + k * 0.1);
|
|
153
|
+
else { const raw = tb + 0.3 + (k - 2) / Math.max(1, FF - 2) * Math.max(0.2, 8.6 - tb - 0.3); floors.push(Math.min(8.9, snapMonth(raw) + (k % 3) * 0.06 + R() * 0.12)); }
|
|
154
|
+
}
|
|
155
|
+
const b = { x0: i - C - 0.5 + ins, x1: i - C + 0.5 - ins, z0: j - C - 0.5 + ins, z1: j - C + 0.5 - ins, cx: i - C, cz: j - C, r,
|
|
156
|
+
col: BLD[Math.floor(R() * BLD.length)], roof: null, floors, F: FF, tb, house, ridgeX: R() < 0.5,
|
|
157
|
+
hroof: HOUSE_ROOF[Math.floor(R() * HOUSE_ROOF.length)], split: FF >= 7 ? FF - 2 - Math.floor(R() * 2) : FF,
|
|
158
|
+
tank: FF >= 4 && R() < 0.65, win: [] };
|
|
159
|
+
for (let k = 0; k < FF; k++) for (let w = 0; w < 4; w++) b.win.push(R() < 0.8 ? 10.0 + r * 1.0 + k * 0.02 + R() * 0.5 : 99);
|
|
160
|
+
buildings.push(b);
|
|
161
|
+
}
|
|
162
|
+
{ // coral accent: a few tall roofs + a few houses
|
|
163
|
+
let n = 0; for (const b of buildings) { if (!b.house && b.F >= 4 && n < 6 && R() < 0.22) { b.roof = CORAL; n++; } }
|
|
164
|
+
let h = 0; for (const b of buildings) { if (b.house && h < 5 && R() < 0.3) { b.hroof = CORAL; h++; } }
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// cars on road lines
|
|
168
|
+
const cars = [], lines = [];
|
|
169
|
+
for (let a = 3; a < N; a += 4) {
|
|
170
|
+
let lo = 99, hi = -99; for (let j = 0; j < N; j++) if (isRoad(a, j)) { lo = Math.min(lo, j); hi = Math.max(hi, j); }
|
|
171
|
+
if (hi - lo > 4) lines.push({ axis: 'j', fixed: a, lo, hi });
|
|
172
|
+
lo = 99; hi = -99; for (let i = 0; i < N; i++) if (isRoad(i, a)) { lo = Math.min(lo, i); hi = Math.max(hi, i); }
|
|
173
|
+
if (hi - lo > 4) lines.push({ axis: 'i', fixed: a, lo, hi });
|
|
174
|
+
}
|
|
175
|
+
const CARC = ['#FFFBF3', '#DCD2EA', '#EBDCC0', '#BFD0E0', '#FFFBF3'].map(hex);
|
|
176
|
+
for (const L of lines) {
|
|
177
|
+
const n = Math.max(1, Math.round((L.hi - L.lo) / 4.5));
|
|
178
|
+
for (let k = 0; k < n; k++) cars.push({ L, dir: R() < 0.5 ? 1 : -1, sp: 1.2 + R() * 0.9, off: R() * 40, col: CARC[Math.floor(R() * CARC.length)] });
|
|
179
|
+
}
|
|
180
|
+
if (cars.length > 3) cars[3].col = CORAL;
|
|
181
|
+
|
|
182
|
+
// sea life: boats, glints, clouds
|
|
183
|
+
const boats = [{ s: 1.42, a0: 2.2, w: 0.05 }, { s: 1.62, a0: 4.1, w: -0.04 }, { s: 1.33, a0: 0.4, w: 0.045 }, { s: 1.8, a0: 5.4, w: 0.035 }];
|
|
184
|
+
const glints = []; for (let k = 0; k < 90; k++) glints.push({ s: 1.12 + R() * 1.2, a: R() * Math.PI * 2, ph: R() * 6.28, w: 1.2 + R() * 1.6, l: 5 + R() * 9 });
|
|
185
|
+
const PUFFS = [[0, -0.1, 0.95], [-0.8, 0.12, 0.7], [0.85, 0.14, 0.74], [-0.38, -0.42, 0.66], [0.42, -0.46, 0.6], [-1.45, 0.34, 0.48], [1.5, 0.36, 0.5], [0.05, 0.3, 0.8], [-1.05, -0.12, 0.5], [1.12, -0.1, 0.46], [-0.6, 0.42, 0.55], [0.7, 0.44, 0.55], [-1.95, 0.5, 0.3], [2.0, 0.5, 0.32]];
|
|
186
|
+
const clouds = [
|
|
187
|
+
{ sx: -260, sy: -40, sz: 3.0, dir: -1, par: 1.0 }, { sx: 330, sy: 70, sz: 3.4, dir: 1, par: 1.25 },
|
|
188
|
+
{ sx: -40, sy: 300, sz: 2.4, dir: 1, par: 1.5 }, { sx: 120, sy: -330, sz: 2.2, dir: -1, par: 0.8 },
|
|
189
|
+
{ x: -7, z: 3, y: 5.5, sz: 1.5, v: [0.5, -0.2] }, { x: 3, z: -7, y: 6.2, sz: 1.3, v: [0.45, -0.15] }, { x: 7, z: 6, y: 5.2, sz: 1.4, v: [0.4, -0.2] }];
|
|
190
|
+
|
|
191
|
+
// ---------- camera ----------
|
|
192
|
+
let K = 60, cs = 1, snn = 0, OX = 960, OY = 600;
|
|
193
|
+
function camera(t) {
|
|
194
|
+
const a = lerp(-16, 10, eInOut(clamp(t / 12))) * Math.PI / 180;
|
|
195
|
+
cs = Math.cos(a); snn = Math.sin(a);
|
|
196
|
+
const k1 = eInOut(clamp(t / 8.8)), k2 = eInOut(clamp((t - 8.8) / 3.2));
|
|
197
|
+
K = lerp(128, 55, Math.pow(k1, 0.85)) + 6 * k2;
|
|
198
|
+
OX = 1000 + lerp(0, -10, k1); OY = lerp(560, 636, k1) - 16 * k2;
|
|
199
|
+
}
|
|
200
|
+
function P(x, y, z) { const xr = x * cs - z * snn, zr = x * snn + z * cs; return [OX + (xr - zr) * 0.866 * K, OY + (xr + zr) * 0.5 * K - y * K * 0.82]; }
|
|
201
|
+
const depth = (x, z) => (x * cs - z * snn) + (x * snn + z * cs);
|
|
202
|
+
const uvxz = (u, v) => [(u + v) / 2, (v - u) / 2];
|
|
203
|
+
|
|
204
|
+
function path(c, pts) { c.beginPath(); c.moveTo(pts[0][0], pts[0][1]); for (let k = 1; k < pts.length; k++) c.lineTo(pts[k][0], pts[k][1]); c.closePath(); }
|
|
205
|
+
function poly(c, pts, fill) { path(c, pts); c.fillStyle = fill; c.fill(); }
|
|
206
|
+
const sideF = (nx, nz) => { const xr = nx * cs - nz * snn, zr = nx * snn + nz * cs; return { vis: xr + zr > 0.02, f: 0.86 - 0.13 * ((xr - zr) / 1.4142) }; };
|
|
207
|
+
function vgrad(pb, pt, cb, ct, a = 1) { const g = ctx.createLinearGradient(pb[0], pb[1], pt[0], pt[1]); g.addColorStop(0, css(cb, a)); g.addColorStop(1, css(ct, a)); return g; }
|
|
208
|
+
|
|
209
|
+
// box with gradient sides (ambient occlusion at the base, light toward the top)
|
|
210
|
+
function box(x0, x1, z0, z1, y0, y1, col, topCol, alpha = 1, ao = 0.86) {
|
|
211
|
+
const faces = [
|
|
212
|
+
{ n: [-1, 0], a: [x0, z1], b: [x0, z0] }, { n: [1, 0], a: [x1, z0], b: [x1, z1] },
|
|
213
|
+
{ n: [0, -1], a: [x0, z0], b: [x1, z0] }, { n: [0, 1], a: [x1, z1], b: [x0, z1] }];
|
|
214
|
+
const vis = [];
|
|
215
|
+
for (const fc of faces) {
|
|
216
|
+
const s = sideF(fc.n[0], fc.n[1]); if (!s.vis) continue;
|
|
217
|
+
const pts = [P(fc.a[0], y0, fc.a[1]), P(fc.b[0], y0, fc.b[1]), P(fc.b[0], y1, fc.b[1]), P(fc.a[0], y1, fc.a[1])];
|
|
218
|
+
const mb = [(pts[0][0] + pts[1][0]) / 2, (pts[0][1] + pts[1][1]) / 2], mt = [(pts[2][0] + pts[3][0]) / 2, (pts[2][1] + pts[3][1]) / 2];
|
|
219
|
+
poly(ctx, pts, vgrad(mb, mt, shade(col, s.f * ao), shade(col, Math.min(1.03, s.f * 1.05)), alpha));
|
|
220
|
+
vis.push({ ...fc, f: s.f });
|
|
221
|
+
}
|
|
222
|
+
poly(ctx, [P(x0, y1, z0), P(x1, y1, z0), P(x1, y1, z1), P(x0, y1, z1)], css(shade(topCol || col, 1), alpha));
|
|
223
|
+
return vis;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function hull(pts) {
|
|
227
|
+
pts = pts.slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
228
|
+
const cr = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
|
|
229
|
+
const lo = [], up = [];
|
|
230
|
+
for (const p of pts) { while (lo.length >= 2 && cr(lo[lo.length - 2], lo[lo.length - 1], p) <= 0) lo.pop(); lo.push(p); }
|
|
231
|
+
for (let k = pts.length - 1; k >= 0; k--) { const p = pts[k]; while (up.length >= 2 && cr(up[up.length - 2], up[up.length - 1], p) <= 0) up.pop(); up.push(p); }
|
|
232
|
+
up.pop(); lo.pop(); return lo.concat(up);
|
|
233
|
+
}
|
|
234
|
+
function shadowVec(h) { const vx = h * 0.62, vz = h * 0.05; return [vx * cs + vz * snn, -vx * snn + vz * cs]; }
|
|
235
|
+
|
|
236
|
+
function cloudPos(c, t) { return [c.x + c.v[0] * t, c.z + c.v[1] * t]; }
|
|
237
|
+
function drawCloud(c, t) {
|
|
238
|
+
if (!c.dir) return;
|
|
239
|
+
const e = Math.pow(clamp(t / 1.6), 1.6), e2 = eOut3(clamp(t / 1.6));
|
|
240
|
+
if (e >= 1) return;
|
|
241
|
+
const p = [W / 2 + c.sx * (1 + e2 * 0.6) + c.dir * e * 1500 * c.par, H / 2 + c.sy * (1 + e2 * 0.6) - e * 120 * c.par], s = c.sz * 64 * (1 + e2 * 0.5 * c.par);
|
|
242
|
+
const c2 = gctx; half(c2);
|
|
243
|
+
c2.fillStyle = 'rgb(214,214,236)';
|
|
244
|
+
for (const [ox, oy, r] of PUFFS) { c2.beginPath(); c2.arc(p[0] + ox * s, p[1] + oy * s + s * 0.12, r * s * 0.62, 0, Math.PI * 2); c2.fill(); }
|
|
245
|
+
const gg = c2.createLinearGradient(0, p[1] - s, 0, p[1] + s * 0.6);
|
|
246
|
+
gg.addColorStop(0, '#ffffff'); gg.addColorStop(0.65, '#fdfcff'); gg.addColorStop(1, '#e9e7f4');
|
|
247
|
+
c2.fillStyle = gg;
|
|
248
|
+
for (const [ox, oy, r] of PUFFS) { c2.beginPath(); c2.arc(p[0] + ox * s - s * 0.06, p[1] + oy * s - s * 0.03, r * s * 0.56, 0, Math.PI * 2); c2.fill(); }
|
|
249
|
+
// flat cloud base
|
|
250
|
+
c2.globalCompositeOperation = 'destination-out'; c2.fillRect(p[0] - 4 * s, p[1] + s * 0.62, 8 * s, 3 * s); c2.globalCompositeOperation = 'source-over';
|
|
251
|
+
ctx.save(); ctx.filter = `blur(${(3 + e * 10).toFixed(1)}px)`; ctx.globalAlpha = 0.97; ctx.drawImage(gctx.canvas, 0, 0, W, H); ctx.restore();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ---------- draw ----------
|
|
255
|
+
function draw(t) {
|
|
256
|
+
camera(Math.min(t, 11));
|
|
257
|
+
// from 11.5 s a slow push: 3.15 % per second about the frame centre
|
|
258
|
+
const zs = Math.pow(1.0315, Math.max(0, t - 11.5));
|
|
259
|
+
OX = 960 + (OX - 960) * zs; OY = 540 + (OY - 540) * zs; K *= zs;
|
|
260
|
+
DK = eInOut(clamp((t - 9.0) / 1.6));
|
|
261
|
+
TINT = mix3(TINT_D, TINT_N, DK);
|
|
262
|
+
// sea: day teal -> sunset peach/lilac
|
|
263
|
+
const g = ctx.createLinearGradient(0, 0, 0, H);
|
|
264
|
+
g.addColorStop(0, `rgb(${mix3([210, 238, 233], [244, 182, 160], DK).map(v => v | 0)})`);
|
|
265
|
+
g.addColorStop(0.5, `rgb(${mix3([192, 228, 224], [150, 140, 196], DK).map(v => v | 0)})`);
|
|
266
|
+
g.addColorStop(1, `rgb(${mix3([172, 214, 214], [80, 90, 150], DK).map(v => v | 0)})`);
|
|
267
|
+
ctx.fillStyle = g; ctx.fillRect(0, 0, W, H);
|
|
268
|
+
// ripples follow the island outline
|
|
269
|
+
ctx.lineWidth = 2;
|
|
270
|
+
for (let k = 0; k < 4; k++) {
|
|
271
|
+
const ph = ((t * 0.07 + k / 4) % 1);
|
|
272
|
+
const s = 1.08 + ph * 0.9;
|
|
273
|
+
ctx.beginPath();
|
|
274
|
+
for (let a = 0; a <= 72; a++) { const th = a / 72 * Math.PI * 2; const [x, z] = uvxz(s * RU * Math.cos(th), s * RV * Math.sin(th)); const p = P(x, WL, z); a ? ctx.lineTo(p[0], p[1]) : ctx.moveTo(p[0], p[1]); }
|
|
275
|
+
ctx.strokeStyle = `rgba(255,255,255,${(0.30 * Math.sin(ph * Math.PI) * (1 - DK * 0.5)).toFixed(3)})`; ctx.stroke();
|
|
276
|
+
}
|
|
277
|
+
// glints
|
|
278
|
+
ctx.lineCap = 'round';
|
|
279
|
+
for (const gl_ of glints) {
|
|
280
|
+
const a = Math.pow(0.5 + 0.5 * Math.sin(t * gl_.w + gl_.ph), 6);
|
|
281
|
+
if (a < 0.03) continue;
|
|
282
|
+
const [x, z] = uvxz(gl_.s * RU * Math.cos(gl_.a), gl_.s * RV * Math.sin(gl_.a));
|
|
283
|
+
const p = P(x, WL, z);
|
|
284
|
+
ctx.strokeStyle = DK > 0.5 ? `rgba(255,226,200,${(a * 0.8).toFixed(3)})` : `rgba(255,255,255,${(a * 0.8).toFixed(3)})`;
|
|
285
|
+
ctx.lineWidth = 2.5; ctx.beginPath(); ctx.moveTo(p[0] - gl_.l, p[1]); ctx.lineTo(p[0] + gl_.l, p[1]); ctx.stroke();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// shallow-water halo
|
|
289
|
+
half(sctx); sctx.fillStyle = '#fff';
|
|
290
|
+
for (const q of tiles) { const p = clamp((t - q.t0) / 0.6); if (p <= 0) continue; sctx.globalAlpha = p; const e = 0.5 + 0.9 * p;
|
|
291
|
+
poly(sctx, [P(q.x - e, WL, q.z - e), P(q.x + e, WL, q.z - e), P(q.x + e, WL, q.z + e), P(q.x - e, WL, q.z + e)], '#fff'); }
|
|
292
|
+
sctx.globalAlpha = 1;
|
|
293
|
+
ctx.save(); ctx.filter = 'blur(18px)'; ctx.globalAlpha = 0.4 - DK * 0.3; ctx.drawImage(sh, 0, 0, W, H); ctx.restore();
|
|
294
|
+
// island drop shadow in the water
|
|
295
|
+
half(sctx);
|
|
296
|
+
for (const q of tiles) { const p = clamp((t - q.t0) / 0.4); if (p <= 0) continue; const [dx, dz] = shadowVec(0.6 * p); sctx.globalAlpha = p;
|
|
297
|
+
poly(sctx, [P(q.x - 0.5 + dx, WL, q.z - 0.5 + dz), P(q.x + 0.5 + dx, WL, q.z - 0.5 + dz), P(q.x + 0.5 + dx, WL, q.z + 0.5 + dz), P(q.x - 0.5 + dx, WL, q.z + 0.5 + dz)], '#2a3d5a'); }
|
|
298
|
+
sctx.globalAlpha = 1;
|
|
299
|
+
ctx.save(); ctx.filter = 'blur(10px)'; ctx.globalAlpha = 0.22; ctx.globalCompositeOperation = 'multiply'; ctx.drawImage(sh, 0, 0, W, H); ctx.restore();
|
|
300
|
+
|
|
301
|
+
// boats
|
|
302
|
+
for (const bt of boats) drawBoat(bt, t);
|
|
303
|
+
|
|
304
|
+
// ground tiles with strata sides
|
|
305
|
+
const ts = tiles.filter(q => t > q.t0).sort((a, b) => depth(a.x, a.z) - depth(b.x, b.z));
|
|
306
|
+
for (const q of ts) {
|
|
307
|
+
const p = clamp((t - q.t0) / 0.42), e = eBack(p, 1.3);
|
|
308
|
+
const dy = (1 - e) * 1.4 + (q.beach ? -0.36 : 0);
|
|
309
|
+
const al = 1;
|
|
310
|
+
const vr = (noise[q.i][q.j] - 0.5) * 3.5;
|
|
311
|
+
const top = q.beach ? SAND : GRASS;
|
|
312
|
+
const tc = [top[0] + vr, top[1] + vr * 0.8, top[2] + vr];
|
|
313
|
+
const x0 = q.x - 0.5, x1 = q.x + 0.5, z0 = q.z - 0.5, z1 = q.z + 0.5, yt = dy, yb = WL - 0.04 + (1 - e) * 1.4;
|
|
314
|
+
const faces = [{ n: [-1, 0], a: [x0, z1], b: [x0, z0], o: q.open[0] }, { n: [1, 0], a: [x1, z0], b: [x1, z1], o: q.open[1] }, { n: [0, -1], a: [x0, z0], b: [x1, z0], o: q.open[2] }, { n: [0, 1], a: [x1, z1], b: [x0, z1], o: q.open[3] }];
|
|
315
|
+
for (const fc of faces) {
|
|
316
|
+
const s = sideF(fc.n[0], fc.n[1]); if (!s.vis || (!fc.o && p >= 1)) continue;
|
|
317
|
+
const pts = [P(fc.a[0], yb, fc.a[1]), P(fc.b[0], yb, fc.b[1]), P(fc.b[0], yt, fc.b[1]), P(fc.a[0], yt, fc.a[1])];
|
|
318
|
+
const mb = [(pts[0][0] + pts[1][0]) / 2, (pts[0][1] + pts[1][1]) / 2], mt = [(pts[2][0] + pts[3][0]) / 2, (pts[2][1] + pts[3][1]) / 2];
|
|
319
|
+
const gg = ctx.createLinearGradient(mb[0], mb[1], mt[0], mt[1]);
|
|
320
|
+
gg.addColorStop(0, css(shade(ROCK, s.f * 0.92), al)); gg.addColorStop(0.62, css(shade(EARTH, s.f), al));
|
|
321
|
+
gg.addColorStop(0.8, css(shade(EARTH, s.f * 1.04), al)); gg.addColorStop(0.81, css(shade(top, s.f * 0.97), al)); gg.addColorStop(1, css(shade(top, s.f * 0.97), al));
|
|
322
|
+
poly(ctx, pts, gg);
|
|
323
|
+
if (fc.o && p >= 1) { // foam line at the waterline
|
|
324
|
+
const fa = 0.55 + 0.25 * Math.sin(t * 2.4 + q.i * 0.9 + q.j * 0.6);
|
|
325
|
+
ctx.strokeStyle = `rgba(255,255,255,${(fa * (1 - DK * 0.35)).toFixed(3)})`; ctx.lineWidth = Math.max(2, K * 0.05);
|
|
326
|
+
ctx.beginPath(); ctx.moveTo(pts[0][0], pts[0][1] + 1); ctx.lineTo(pts[1][0], pts[1][1] + 1); ctx.stroke();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
{ const e2 = 0.006; poly(ctx, [P(x0 - e2, yt, z0 - e2), P(x1 + e2, yt, z0 - e2), P(x1 + e2, yt, z1 + e2), P(x0 - e2, yt, z1 + e2)], css(shade(tc, 1), al)); }
|
|
330
|
+
}
|
|
331
|
+
// roads
|
|
332
|
+
for (const r of roadStrips) {
|
|
333
|
+
const p = clamp((t - r.t0) / 0.14); if (p <= 0) continue;
|
|
334
|
+
const x = r.i - C, z = r.j - C, w = 0.3;
|
|
335
|
+
let a0, a1; const along = r.axis === 'j' ? z : x;
|
|
336
|
+
if (r.sgn > 0) { a0 = along - 0.5; a1 = along - 0.5 + p; } else if (r.sgn < 0) { a1 = along + 0.5; a0 = along + 0.5 - p; } else { a0 = along - 0.5 * p; a1 = along + 0.5 * p; }
|
|
337
|
+
const pts = r.axis === 'j' ? [P(x - w, 0.004, a0), P(x + w, 0.004, a0), P(x + w, 0.004, a1), P(x - w, 0.004, a1)]
|
|
338
|
+
: [P(a0, 0.004, z - w), P(a1, 0.004, z - w), P(a1, 0.004, z + w), P(a0, 0.004, z + w)];
|
|
339
|
+
poly(ctx, pts, css(ROAD));
|
|
340
|
+
// dashed centre line
|
|
341
|
+
if (!(r.i % 4 === 3 && r.j % 4 === 3)) {
|
|
342
|
+
const m0 = Math.max(a0, along - 0.18), m1 = Math.min(a1, along + 0.18);
|
|
343
|
+
if (m1 > m0) { const d = r.axis === 'j' ? [P(x - 0.025, 0.006, m0), P(x + 0.025, 0.006, m0), P(x + 0.025, 0.006, m1), P(x - 0.025, 0.006, m1)] : [P(m0, 0.006, z - 0.025), P(m1, 0.006, z - 0.025), P(m1, 0.006, z + 0.025), P(m0, 0.006, z + 0.025)];
|
|
344
|
+
poly(ctx, d, css([226, 216, 200])); }
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// object shadows (half res)
|
|
349
|
+
half(sctx); sctx.fillStyle = '#000';
|
|
350
|
+
const objs = [];
|
|
351
|
+
for (const b of buildings) {
|
|
352
|
+
if (t < b.tb) continue;
|
|
353
|
+
let h = 0; for (const ft of b.floors) { const p = clamp((t - ft) / 0.32); if (p > 0) h += FH * eBack(p); }
|
|
354
|
+
if (h <= 0.001) continue;
|
|
355
|
+
b.h = h; const hh = b.house ? h + 0.2 : h;
|
|
356
|
+
const [dx, dz] = shadowVec(hh * 1.1 + 0.15);
|
|
357
|
+
const pts = []; for (const [x, z] of [[b.x0, b.z0], [b.x1, b.z0], [b.x1, b.z1], [b.x0, b.z1]]) { pts.push(P(x, 0, z)); pts.push(P(x + dx, 0, z + dz)); }
|
|
358
|
+
sctx.globalAlpha = 1; poly(sctx, hull(pts), '#000');
|
|
359
|
+
objs.push({ k: 0, o: b, d: depth(b.cx, b.cz) });
|
|
360
|
+
}
|
|
361
|
+
for (const tr of trees) {
|
|
362
|
+
const p = clamp((t - tr.t0) / 0.45); if (p <= 0) continue;
|
|
363
|
+
tr.p = p;
|
|
364
|
+
const [dx, dz] = shadowVec(0.4 * tr.s); const c = P(tr.x + dx, 0, tr.z + dz);
|
|
365
|
+
sctx.globalAlpha = p; sctx.beginPath(); sctx.ellipse(c[0], c[1], 0.26 * tr.s * K, 0.15 * tr.s * K, 0, 0, Math.PI * 2); sctx.fill();
|
|
366
|
+
objs.push({ k: 1, o: tr, d: depth(tr.x, tr.z) });
|
|
367
|
+
}
|
|
368
|
+
for (const car of cars) {
|
|
369
|
+
const L = car.L, len = L.hi - L.lo;
|
|
370
|
+
const s = ((car.off + car.dir * car.sp * t) % len + len) % len, pos = L.lo + s;
|
|
371
|
+
const ti = L.axis === 'j' ? L.fixed : Math.round(pos), tj = L.axis === 'j' ? Math.round(pos) : L.fixed;
|
|
372
|
+
const rt = roadT[ti + ',' + tj]; if (rt === undefined || t < rt + 0.5) continue;
|
|
373
|
+
const a = clamp((t - rt - 0.5) / 0.4) * clamp(Math.min(s, len - s) / 0.6); if (a <= 0.01) continue;
|
|
374
|
+
const lane = 0.14 * car.dir;
|
|
375
|
+
const x = L.axis === 'j' ? L.fixed - C + lane : pos - C, z = L.axis === 'j' ? pos - C : L.fixed - C - lane;
|
|
376
|
+
objs.push({ k: 2, o: car, x, z, a, d: depth(x, z) });
|
|
377
|
+
}
|
|
378
|
+
for (const lp of lamps) { if (t < lp.t0) continue; objs.push({ k: 3, o: lp, d: depth(lp.x, lp.z) }); }
|
|
379
|
+
for (const c of clouds) { // cloud shadows drift over the city
|
|
380
|
+
if (c.dir) continue;
|
|
381
|
+
const [x, z] = cloudPos(c, t); const [dx, dz] = shadowVec(c.y * 0.5); const p = P(x + dx, 0, z + dz);
|
|
382
|
+
sctx.globalAlpha = 0.3 * clamp((t - 3) / 1.5); sctx.beginPath(); sctx.ellipse(p[0], p[1], c.sz * K * 1.5, c.sz * K * 0.8, 0, 0, Math.PI * 2); sctx.fill();
|
|
383
|
+
}
|
|
384
|
+
sctx.globalAlpha = 1;
|
|
385
|
+
ctx.save(); ctx.filter = 'blur(5px)'; ctx.globalAlpha = 0.26 - DK * 0.08; ctx.globalCompositeOperation = 'multiply';
|
|
386
|
+
ctx.drawImage(sh, 0, 0, W, H); ctx.restore();
|
|
387
|
+
|
|
388
|
+
half(gctx);
|
|
389
|
+
objs.sort((a, b) => a.d - b.d);
|
|
390
|
+
for (const ob of objs) {
|
|
391
|
+
if (ob.k === 0) (ob.o.house ? drawHouse : drawBuilding)(ob.o, t);
|
|
392
|
+
else if (ob.k === 1) drawTree(ob.o, t);
|
|
393
|
+
else if (ob.k === 2) drawCar(ob, t);
|
|
394
|
+
else drawLamp(ob.o, t);
|
|
395
|
+
}
|
|
396
|
+
// sunlight wash (top-left warm) -> sunset grade
|
|
397
|
+
ctx.save(); ctx.globalCompositeOperation = 'soft-light';
|
|
398
|
+
const sl = ctx.createLinearGradient(0, 0, W, H);
|
|
399
|
+
sl.addColorStop(0, `rgba(255,${lerp(248, 170, DK) | 0},${lerp(232, 130, DK) | 0},${lerp(0.4, 0.6, DK).toFixed(3)})`);
|
|
400
|
+
sl.addColorStop(0.55, 'rgba(255,255,255,0)');
|
|
401
|
+
sl.addColorStop(1, `rgba(${lerp(90, 30, DK) | 0},${lerp(110, 50, DK) | 0},${lerp(170, 140, DK) | 0},${lerp(0.25, 0.65, DK).toFixed(3)})`);
|
|
402
|
+
ctx.fillStyle = sl; ctx.fillRect(0, 0, W, H); ctx.restore();
|
|
403
|
+
const nd = eInOut(clamp((t - 11.2) / 5.2));
|
|
404
|
+
if (nd > 0) { ctx.save(); ctx.globalCompositeOperation = 'multiply'; ctx.fillStyle = `rgba(58,40,112,${(0.66 * nd).toFixed(3)})`; ctx.fillRect(0, 0, W, H); ctx.restore(); }
|
|
405
|
+
// window + lamp glow
|
|
406
|
+
if (DK > 0) {
|
|
407
|
+
ctx.save(); ctx.globalCompositeOperation = 'screen';
|
|
408
|
+
ctx.filter = 'blur(12px)'; ctx.globalAlpha = 0.85; ctx.drawImage(gl, 0, 0, W, H);
|
|
409
|
+
ctx.filter = 'blur(3px)'; ctx.globalAlpha = 0.55; ctx.drawImage(gl, 0, 0, W, H); ctx.restore();
|
|
410
|
+
}
|
|
411
|
+
// clouds float above everything
|
|
412
|
+
for (const c of clouds) drawCloud(c, t);
|
|
413
|
+
// soft vignette
|
|
414
|
+
const vg = ctx.createRadialGradient(W / 2, H / 2, H * 0.42, W / 2, H / 2, H * 1.05);
|
|
415
|
+
vg.addColorStop(0, 'rgba(60,70,120,0)'); vg.addColorStop(1, `rgba(60,70,120,${(0.12 + DK * 0.16).toFixed(3)})`);
|
|
416
|
+
ctx.fillStyle = vg; ctx.fillRect(0, 0, W, H);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function windowsOn(b, fc, k0, k1, t, fi, glassBase) {
|
|
420
|
+
const A = fc.a, B = fc.b;
|
|
421
|
+
const pt = (u, y) => P(A[0] + (B[0] - A[0]) * u, y, A[1] + (B[1] - A[1]) * u);
|
|
422
|
+
for (let k = k0; k < k1; k++) {
|
|
423
|
+
const y0 = k * FH;
|
|
424
|
+
for (let w = 0; w < 2; w++) {
|
|
425
|
+
const u0 = 0.15 + w * 0.39, u1 = u0 + 0.27;
|
|
426
|
+
const q = [pt(u0, y0 + 0.1), pt(u1, y0 + 0.1), pt(u1, y0 + 0.27), pt(u0, y0 + 0.27)];
|
|
427
|
+
const lt = b.win[k * 4 + (fi % 2) * 2 + w] ?? 99;
|
|
428
|
+
let lp = clamp((t - lt) / 0.22);
|
|
429
|
+
if (lp > 0 && t > 11) { const hsh = (lt * 9301.7) % 1; if (hsh < 0.3) lp *= 0.72 + 0.28 * (0.5 + 0.5 * Math.sin(t * (2 + hsh * 9) + hsh * 40)); }
|
|
430
|
+
const glass = shade(mix3(b.col, GLASS, 0.5), fc.f * glassBase);
|
|
431
|
+
if (lp > 0) {
|
|
432
|
+
const d = dk(glass), c = mix3(d, LIT, lp);
|
|
433
|
+
poly(ctx, q, `rgb(${c[0] | 0},${c[1] | 0},${c[2] | 0})`);
|
|
434
|
+
gctx.globalAlpha = lp; poly(gctx, q, 'rgb(255,186,118)');
|
|
435
|
+
} else {
|
|
436
|
+
poly(ctx, q, css(glass));
|
|
437
|
+
// sky reflection sliver
|
|
438
|
+
poly(ctx, [q[2], q[3], pt(u0, y0 + 0.21), pt(u0 + 0.08, y0 + 0.27)].slice(0, 3), css(mix3(glass, [255, 255, 255], 0.35)));
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function drawBuilding(b, t) {
|
|
445
|
+
const h = b.h, splitH = Math.min(h, b.split * FH);
|
|
446
|
+
const roofCol = b.roof || [Math.min(255, b.col[0] + 7), Math.min(255, b.col[1] + 7), Math.min(255, b.col[2] + 7)];
|
|
447
|
+
const visLo = box(b.x0, b.x1, b.z0, b.z1, 0, splitH, b.col, h > splitH + 0.001 ? shade(b.col, 0.97) : roofCol);
|
|
448
|
+
const nLo = Math.floor(splitH / FH + 0.02);
|
|
449
|
+
visLo.forEach((fc, fi) => windowsOn(b, fc, 0, nLo, t, fi, 0.84));
|
|
450
|
+
let topH = splitH, x0 = b.x0, x1 = b.x1, z0 = b.z0, z1 = b.z1;
|
|
451
|
+
if (h > splitH + 0.001) {
|
|
452
|
+
const s = 0.09; x0 += s; x1 -= s; z0 += s; z1 -= s;
|
|
453
|
+
const visUp = box(x0, x1, z0, z1, splitH, h, b.col, roofCol);
|
|
454
|
+
const nUp = Math.floor(h / FH + 0.02);
|
|
455
|
+
visUp.forEach((fc, fi) => windowsOn(b, fc, b.split, nUp, t, fi, 0.84));
|
|
456
|
+
topH = h;
|
|
457
|
+
}
|
|
458
|
+
const ii = 0.06;
|
|
459
|
+
poly(ctx, [P(x0 + ii, topH, z0 + ii), P(x1 - ii, topH, z0 + ii), P(x1 - ii, topH, z1 - ii), P(x0 + ii, topH, z1 - ii)], css(shade(roofCol, 0.92)));
|
|
460
|
+
if (b.tank) {
|
|
461
|
+
const last = b.floors[b.floors.length - 1];
|
|
462
|
+
const p = clamp((t - last - 0.2) / 0.3);
|
|
463
|
+
if (p > 0) { const cx = (x0 + x1) / 2 + 0.05, cz = (z0 + z1) / 2 + 0.05, s = 0.11; box(cx - s, cx + s, cz - s, cz + s, topH, topH + 0.15 * eBack(p), hex('#ECE7F2'), null, p); }
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function drawHouse(b, t) {
|
|
468
|
+
const hw = b.h * 0.95;
|
|
469
|
+
const vis = box(b.x0, b.x1, b.z0, b.z1, 0, hw, b.col, b.col);
|
|
470
|
+
vis.forEach((fc, fi) => windowsOn(b, fc, 0, hw > FH * 0.9 ? 1 : 0, t, fi, 0.84));
|
|
471
|
+
const rp = clamp((t - b.floors[0] - 0.12) / 0.35); if (rp <= 0) return;
|
|
472
|
+
const rh = 0.22 * eBack(rp, 2.4), o = 0.05, ry = hw + rh;
|
|
473
|
+
const rc = b.hroof;
|
|
474
|
+
let A, Bq, tri;
|
|
475
|
+
if (b.ridgeX) {
|
|
476
|
+
const zm = (b.z0 + b.z1) / 2;
|
|
477
|
+
A = { pts: [P(b.x0 - o, hw, b.z0 - o), P(b.x1 + o, hw, b.z0 - o), P(b.x1 + o, ry, zm), P(b.x0 - o, ry, zm)], n: [0, -1] };
|
|
478
|
+
Bq = { pts: [P(b.x0 - o, hw, b.z1 + o), P(b.x1 + o, hw, b.z1 + o), P(b.x1 + o, ry, zm), P(b.x0 - o, ry, zm)], n: [0, 1] };
|
|
479
|
+
tri = [{ pts: [P(b.x0, hw, b.z0), P(b.x0, hw, b.z1), P(b.x0, ry, zm)], n: [-1, 0] }, { pts: [P(b.x1, hw, b.z0), P(b.x1, hw, b.z1), P(b.x1, ry, zm)], n: [1, 0] }];
|
|
480
|
+
} else {
|
|
481
|
+
const xm = (b.x0 + b.x1) / 2;
|
|
482
|
+
A = { pts: [P(b.x0 - o, hw, b.z0 - o), P(b.x0 - o, hw, b.z1 + o), P(xm, ry, b.z1 + o), P(xm, ry, b.z0 - o)], n: [-1, 0] };
|
|
483
|
+
Bq = { pts: [P(b.x1 + o, hw, b.z0 - o), P(b.x1 + o, hw, b.z1 + o), P(xm, ry, b.z1 + o), P(xm, ry, b.z0 - o)], n: [1, 0] };
|
|
484
|
+
tri = [{ pts: [P(b.x0, hw, b.z0), P(b.x1, hw, b.z0), P(xm, ry, b.z0)], n: [0, -1] }, { pts: [P(b.x0, hw, b.z1), P(b.x1, hw, b.z1), P(xm, ry, b.z1)], n: [0, 1] }];
|
|
485
|
+
}
|
|
486
|
+
const sA = sideF(A.n[0], A.n[1]), sB = sideF(Bq.n[0], Bq.n[1]);
|
|
487
|
+
const slopes = [[A, sA], [Bq, sB]].sort((m, n) => (m[1].vis ? 1 : 0) - (n[1].vis ? 1 : 0));
|
|
488
|
+
const al = clamp(rp * 3);
|
|
489
|
+
poly(ctx, slopes[0][0].pts, css(shade(rc, slopes[0][1].vis ? lerp(1, slopes[0][1].f, 0.6) : 0.8), al));
|
|
490
|
+
for (const tr of tri) { const s = sideF(tr.n[0], tr.n[1]); if (s.vis) poly(ctx, tr.pts, css(shade(b.col, s.f * 1.02), al)); }
|
|
491
|
+
poly(ctx, slopes[1][0].pts, css(shade(rc, slopes[1][1].vis ? lerp(1.04, slopes[1][1].f, 0.5) : 0.8), al));
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function drawTree(tr, t) {
|
|
495
|
+
const p = tr.p, e = eBack(p, 2.2);
|
|
496
|
+
const sc = lerp(0.6, 1, e);
|
|
497
|
+
const wob = Math.sin(p * Math.PI * 2) * (1 - p) * 0.24;
|
|
498
|
+
const sway = Math.sin(t * 1.6 + tr.x * 0.7 + tr.z) * 0.012 * K;
|
|
499
|
+
const sx = sc * (1 + wob), sy = sc * (1 - wob), s = tr.s;
|
|
500
|
+
const ty = tr.y || 0, base = P(tr.x, ty, tr.z), top = P(tr.x, ty + 0.42 * s * sy, tr.z);
|
|
501
|
+
ctx.globalAlpha = clamp(p * 3);
|
|
502
|
+
ctx.strokeStyle = css(hex('#B59C84')); ctx.lineWidth = Math.max(2, 0.05 * K); ctx.lineCap = 'round';
|
|
503
|
+
ctx.beginPath(); ctx.moveTo(base[0], base[1]); ctx.lineTo(top[0] + sway * 0.5, top[1]); ctx.stroke();
|
|
504
|
+
const r = 0.2 * s * K, cx = top[0] + sway, cy = top[1] - r * sy * 0.7;
|
|
505
|
+
ctx.fillStyle = css(TREE_DK); ctx.beginPath(); ctx.ellipse(cx, cy, r * sx, r * sy, 0, 0, Math.PI * 2); ctx.fill();
|
|
506
|
+
ctx.fillStyle = css(TREE); ctx.beginPath(); ctx.ellipse(cx - r * 0.12 * sx, cy - r * 0.12 * sy, r * 0.86 * sx, r * 0.84 * sy, 0, 0, Math.PI * 2); ctx.fill();
|
|
507
|
+
ctx.fillStyle = css(TREE_HI); ctx.beginPath(); ctx.ellipse(cx - r * 0.34 * sx, cy - r * 0.36 * sy, r * 0.38 * sx, r * 0.32 * sy, 0, 0, Math.PI * 2); ctx.fill();
|
|
508
|
+
ctx.globalAlpha = 1;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function drawCar(ob, t) {
|
|
512
|
+
const car = ob.o, along = car.L.axis === 'j';
|
|
513
|
+
const hl = 0.22, hw = 0.115;
|
|
514
|
+
const bump = Math.abs(Math.sin(t * 9 + car.off)) * 0.006;
|
|
515
|
+
const X0 = along ? ob.x - hw : ob.x - hl, X1 = along ? ob.x + hw : ob.x + hl, Z0 = along ? ob.z - hl : ob.z - hw, Z1 = along ? ob.z + hl : ob.z + hw;
|
|
516
|
+
box(X0, X1, Z0, Z1, 0.015, 0.13 + bump, car.col, null, ob.a, 0.92);
|
|
517
|
+
const cl = 0.11, d = car.dir;
|
|
518
|
+
const off = along ? [0, -d * 0.03] : [-d * 0.03, 0];
|
|
519
|
+
const cx0 = along ? ob.x - hw * 0.82 : ob.x - cl + off[0], cx1 = along ? ob.x + hw * 0.82 : ob.x + cl + off[0];
|
|
520
|
+
const cz0 = along ? ob.z - cl + off[1] : ob.z - hw * 0.82, cz1 = along ? ob.z + cl + off[1] : ob.z + hw * 0.82;
|
|
521
|
+
box(cx0, cx1, cz0, cz1, 0.13 + bump, 0.22 + bump, mix3(car.col, GLASS, 0.45), car.col, ob.a, 0.95);
|
|
522
|
+
if (DK > 0.2) {
|
|
523
|
+
const fx = along ? ob.x : ob.x + d * hl, fz = along ? ob.z + d * hl : ob.z;
|
|
524
|
+
const p = P(fx, 0.07, fz);
|
|
525
|
+
gctx.globalAlpha = (DK - 0.2) * ob.a; gctx.fillStyle = 'rgb(255,220,160)'; gctx.beginPath(); gctx.arc(p[0], p[1], 0.11 * K, 0, Math.PI * 2); gctx.fill();
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function drawLamp(lp, t) {
|
|
530
|
+
const a = clamp((t - lp.t0) / 0.3);
|
|
531
|
+
const b = P(lp.x, 0, lp.z), tp = P(lp.x, 0.42 * lerp(0.7, 1, eBack(a)), lp.z);
|
|
532
|
+
ctx.globalAlpha = a; ctx.strokeStyle = css([150, 146, 170]); ctx.lineWidth = Math.max(1.5, 0.035 * K);
|
|
533
|
+
ctx.beginPath(); ctx.moveTo(b[0], b[1]); ctx.lineTo(tp[0], tp[1]); ctx.stroke();
|
|
534
|
+
const on = clamp((t - lp.tl) / 0.2);
|
|
535
|
+
const hc = mix3(dk([236, 232, 244]), [255, 232, 180], on);
|
|
536
|
+
ctx.fillStyle = `rgb(${hc[0] | 0},${hc[1] | 0},${hc[2] | 0})`; ctx.beginPath(); ctx.arc(tp[0], tp[1], Math.max(2.5, 0.055 * K), 0, Math.PI * 2); ctx.fill();
|
|
537
|
+
ctx.globalAlpha = 1;
|
|
538
|
+
if (on > 0) { gctx.globalAlpha = on; gctx.fillStyle = 'rgb(255,200,130)'; gctx.beginPath(); gctx.arc(tp[0], tp[1], 0.16 * K, 0, Math.PI * 2); gctx.fill();
|
|
539
|
+
gctx.globalAlpha = on * 0.35; gctx.beginPath(); gctx.ellipse(b[0], b[1], 0.4 * K, 0.22 * K, 0, 0, Math.PI * 2); gctx.fill(); }
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function drawBoat(bt, t) {
|
|
543
|
+
const vis = clamp((t - 1.6) / 0.6); if (vis <= 0) return;
|
|
544
|
+
const th = bt.a0 + bt.w * t;
|
|
545
|
+
const [x, z] = uvxz(bt.s * RU * Math.cos(th), bt.s * RV * Math.sin(th));
|
|
546
|
+
const [x2, z2] = uvxz(bt.s * RU * Math.cos(th + 0.01 * Math.sign(bt.w)), bt.s * RV * Math.sin(th + 0.01 * Math.sign(bt.w)));
|
|
547
|
+
let hx = x2 - x, hz = z2 - z; const l = Math.hypot(hx, hz); hx /= l; hz /= l;
|
|
548
|
+
const px = -hz, pz = hx;
|
|
549
|
+
const bob = Math.sin(t * 2.2 + bt.a0) * 0.02;
|
|
550
|
+
const y = WL + 0.02 + bob;
|
|
551
|
+
// wake
|
|
552
|
+
ctx.lineWidth = 2; ctx.strokeStyle = `rgba(255,255,255,${(0.55 * vis).toFixed(3)})`;
|
|
553
|
+
for (const sgn of [-1, 1]) { const a = P(x - hx * 0.3, WL, z - hz * 0.3), b2 = P(x - hx * 1.6 + px * sgn * 0.45, WL, z - hz * 1.6 + pz * sgn * 0.45); ctx.beginPath(); ctx.moveTo(a[0], a[1]); ctx.lineTo(b2[0], b2[1]); ctx.stroke(); }
|
|
554
|
+
const hl = 0.36, hw = 0.12;
|
|
555
|
+
const hull_ = [P(x + hx * hl, y, z + hz * hl), P(x + px * hw, y, z + pz * hw), P(x - hx * hl * 0.8 + px * hw, y, z - hz * hl * 0.8 + pz * hw), P(x - hx * hl * 0.8 - px * hw, y, z - hz * hl * 0.8 - pz * hw), P(x - px * hw, y, z - pz * hw)];
|
|
556
|
+
ctx.globalAlpha = vis;
|
|
557
|
+
const hull2 = hull_.map(p => [p[0], p[1] - 0.09 * K]);
|
|
558
|
+
poly(ctx, hull([...hull_, ...hull2]), css(shade([250, 246, 238], 0.8)));
|
|
559
|
+
poly(ctx, hull2, css([252, 249, 242]));
|
|
560
|
+
const m0 = P(x, y + 0.11, z), m1 = P(x, y + 0.75, z), sb = P(x - hx * 0.3, y + 0.13, z - hz * 0.3), sf = P(x + hx * 0.26, y + 0.13, z + hz * 0.26);
|
|
561
|
+
poly(ctx, [m1, sb, m0], css([255, 255, 255]));
|
|
562
|
+
poly(ctx, [m1, sf, m0], css(shade([255, 252, 246], 0.9)));
|
|
563
|
+
ctx.globalAlpha = 1;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// ---------- labels ----------
|
|
567
|
+
const mA = document.getElementById('mA'), mB = document.getElementById('mB'), cnt = document.getElementById('count'), lab = document.getElementById('labels');
|
|
568
|
+
let lastM = -2, lastCount = '';
|
|
569
|
+
function labels(t) {
|
|
570
|
+
let m = -1; for (let k = 0; k < 12; k++) if (t >= MONTH_T[k]) m = k;
|
|
571
|
+
const q = m >= 0 ? t - MONTH_T[m] : 0;
|
|
572
|
+
if (m !== lastM) { mA.textContent = m >= 0 ? MONTHS[m] : ''; mB.textContent = m > 0 ? MONTHS[m - 1] : ''; lastM = m; }
|
|
573
|
+
const ein = eExpo(clamp(q / 0.4));
|
|
574
|
+
mA.style.transform = `translateY(${((1 - ein) * 44).toFixed(2)}px)`; mA.style.opacity = clamp(q / 0.16).toFixed(3);
|
|
575
|
+
const qo = clamp(q / 0.2);
|
|
576
|
+
mB.style.transform = `translateY(${(-36 * qo * qo).toFixed(2)}px)`; mB.style.opacity = (m > 0 ? 1 - qo : 0).toFixed(3);
|
|
577
|
+
const v = m < 0 ? 0 : lerp(m > 0 ? VALS[m - 1] : 0, VALS[m], eOut3(clamp(q / 0.6)));
|
|
578
|
+
const s = Math.round(v / 10) * 10;
|
|
579
|
+
const str = m < 0 ? '' : s.toLocaleString('en-US');
|
|
580
|
+
if (str !== lastCount) { cnt.innerHTML = m < 0 ? '' : str + ' <span>' + COUNT_LABEL + '</span>'; lastCount = str; }
|
|
581
|
+
cnt.style.opacity = clamp((t - 0.6) / 0.3).toFixed(3);
|
|
582
|
+
cnt.style.transform = `translateY(${((1 - eExpo(clamp((t - 0.6) / 0.45))) * 24).toFixed(2)}px)`;
|
|
583
|
+
const dk = eInOut(clamp((t - 9.0) / 1.6));
|
|
584
|
+
const c0 = [45, 75, 83], c1 = [250, 244, 232];
|
|
585
|
+
lab.style.color = `rgb(${lerp(c0[0], c1[0], dk) | 0},${lerp(c0[1], c1[1], dk) | 0},${lerp(c0[2], c1[2], dk) | 0})`;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
const proxy = { t: 0 };
|
|
589
|
+
const render = () => {
|
|
590
|
+
draw(proxy.t); labels(Math.min(proxy.t, 11));
|
|
591
|
+
const lf = clamp((proxy.t - 10.25) / 0.45);
|
|
592
|
+
lab.style.opacity = (1 - lf * lf).toFixed(3); lab.style.transform = `translateY(${(-24 * lf * lf).toFixed(2)}px)`;
|
|
593
|
+
};
|
|
594
|
+
const tl = gsap.timeline({ paused: true });
|
|
595
|
+
tl.to(proxy, { t: DUR, duration: DUR, ease: 'none', onUpdate: render }, 0);
|
|
596
|
+
window.__timelines = window.__timelines || {};
|
|
597
|
+
window.__timelines['main'] = tl;
|
|
598
|
+
render();
|
|
599
|
+
})();
|
|
600
|
+
</script>
|
|
601
|
+
</body>
|
|
602
|
+
</html>
|