kasaframe 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/NOTICE +146 -0
- package/README.md +77 -2
- package/app/package.json +12 -0
- package/app/server/engine.ts +415 -0
- package/app/server/main.ts +205 -0
- package/app/web/env.d.ts +2 -0
- package/app/web/icons.ts +31 -0
- package/app/web/index.html +21 -0
- package/app/web/main.ts +1013 -0
- package/app/web/style.css +430 -0
- package/bin/hooks.mjs +51 -0
- package/bin/kf.mjs +14 -0
- package/docs/AGENTS.md +238 -0
- package/music/README.md +13 -0
- package/package.json +44 -4
- package/packages/adapters/package.json +36 -0
- package/packages/adapters/src/css.ts +11 -0
- package/packages/adapters/src/gsap.ts +26 -0
- package/packages/adapters/src/index.ts +9 -0
- package/packages/adapters/src/lottie.ts +22 -0
- package/packages/adapters/src/media.ts +59 -0
- package/packages/adapters/src/page.ts +229 -0
- package/packages/adapters/src/project.ts +214 -0
- package/packages/adapters/src/react.ts +36 -0
- package/packages/adapters/src/svelte.ts +22 -0
- package/packages/adapters/src/three.ts +18 -0
- package/packages/adapters/src/vue.ts +27 -0
- package/packages/check/package.json +19 -0
- package/packages/check/src/check.ts +273 -0
- package/packages/check/src/cli.ts +70 -0
- package/packages/check/src/image.ts +146 -0
- package/packages/check/src/index.ts +9 -0
- package/packages/check/src/ocr.swift +37 -0
- package/packages/check/src/probe.ts +328 -0
- package/packages/check/src/report.ts +44 -0
- package/packages/check/src/rules/assets.ts +42 -0
- package/packages/check/src/rules/beats.ts +212 -0
- package/packages/check/src/rules/camera.ts +217 -0
- package/packages/check/src/rules/captions.ts +49 -0
- package/packages/check/src/rules/flash.ts +235 -0
- package/packages/check/src/rules/frames.ts +135 -0
- package/packages/check/src/rules/layout.ts +257 -0
- package/packages/check/src/rules/page.ts +87 -0
- package/packages/check/src/rules/runs.ts +20 -0
- package/packages/check/src/rules/text.ts +326 -0
- package/packages/check/src/scan.ts +240 -0
- package/packages/check/src/serve.ts +67 -0
- package/packages/check/src/types.ts +80 -0
- package/packages/check/src/video.ts +137 -0
- package/packages/cli/package.json +29 -0
- package/packages/cli/src/blur.ts +68 -0
- package/packages/cli/src/browser.ts +203 -0
- package/packages/cli/src/command.ts +44 -0
- package/packages/cli/src/commands/app.ts +25 -0
- package/packages/cli/src/commands/beats.ts +36 -0
- package/packages/cli/src/commands/blender.ts +270 -0
- package/packages/cli/src/commands/check.ts +25 -0
- package/packages/cli/src/commands/doctor.ts +22 -0
- package/packages/cli/src/commands/gen.ts +173 -0
- package/packages/cli/src/commands/look.ts +39 -0
- package/packages/cli/src/commands/lyrics.ts +111 -0
- package/packages/cli/src/commands/make.ts +542 -0
- package/packages/cli/src/commands/new.ts +176 -0
- package/packages/cli/src/commands/preview.ts +43 -0
- package/packages/cli/src/commands/render.ts +216 -0
- package/packages/cli/src/commands/setup.ts +63 -0
- package/packages/cli/src/commands/sheet.ts +114 -0
- package/packages/cli/src/commands/skill.ts +43 -0
- package/packages/cli/src/commands/still.ts +40 -0
- package/packages/cli/src/commands/theme.ts +85 -0
- package/packages/cli/src/commands/transitions.ts +40 -0
- package/packages/cli/src/deps.ts +122 -0
- package/packages/cli/src/ffmpeg.ts +81 -0
- package/packages/cli/src/index.ts +8 -0
- package/packages/cli/src/kf.ts +53 -0
- package/packages/cli/src/lock.ts +72 -0
- package/packages/cli/src/out.ts +13 -0
- package/packages/cli/src/serve.ts +124 -0
- package/packages/clock/package.json +14 -0
- package/packages/clock/src/index.ts +25 -0
- package/packages/clock/src/install.ts +351 -0
- package/packages/clock/src/types.ts +45 -0
- package/packages/core/package.json +9 -0
- package/packages/core/src/beats.ts +283 -0
- package/packages/core/src/ease.ts +87 -0
- package/packages/core/src/frame.ts +99 -0
- package/packages/core/src/index.ts +27 -0
- package/packages/core/src/project.ts +146 -0
- package/packages/core/src/rand.ts +56 -0
- package/packages/core/src/spring.ts +52 -0
- package/packages/core/src/style.ts +100 -0
- package/packages/core/src/time.ts +88 -0
- package/packages/gen/PROVIDERS.md +55 -0
- package/packages/gen/package.json +9 -0
- package/packages/gen/src/generate.ts +204 -0
- package/packages/gen/src/image/og.ts +133 -0
- package/packages/gen/src/index.ts +18 -0
- package/packages/gen/src/keys.ts +60 -0
- package/packages/gen/src/media.ts +150 -0
- package/packages/gen/src/plan.ts +106 -0
- package/packages/gen/src/registry.ts +51 -0
- package/packages/gen/src/seam.ts +103 -0
- package/packages/gen/src/types.ts +86 -0
- package/packages/gen/src/video/fal.ts +140 -0
- package/packages/gen/src/video/h3.ts +107 -0
- package/packages/gen/src/video/http.ts +44 -0
- package/packages/gen/src/video/ltx.ts +60 -0
- package/packages/gen/src/video/minimax.ts +55 -0
- package/packages/gen/src/video/veo.ts +71 -0
- package/packages/jizura/package.json +16 -0
- package/packages/jizura/src/deny.ts +73 -0
- package/packages/jizura/src/index.ts +7 -0
- package/packages/jizura/src/install.ts +226 -0
- package/packages/jizura/src/layer.ts +282 -0
- package/packages/jizura/src/lyrics.ts +81 -0
- package/packages/jizura/src/pin.ts +5 -0
- package/packages/jizura/src/vite.ts +36 -0
- package/packages/motion/README.md +142 -0
- package/packages/motion/package.json +29 -0
- package/packages/motion/src/camera.ts +97 -0
- package/packages/motion/src/captions.ts +479 -0
- package/packages/motion/src/enter.ts +128 -0
- package/packages/motion/src/hangul.ts +129 -0
- package/packages/motion/src/impact.ts +100 -0
- package/packages/motion/src/index.ts +17 -0
- package/packages/motion/src/moves/brushWipe.ts +90 -0
- package/packages/motion/src/moves/cloneArray.ts +111 -0
- package/packages/motion/src/moves/curtains.ts +81 -0
- package/packages/motion/src/moves/echoStack.ts +70 -0
- package/packages/motion/src/moves/fit.ts +34 -0
- package/packages/motion/src/moves/flood.ts +61 -0
- package/packages/motion/src/moves/ghostStack.ts +79 -0
- package/packages/motion/src/moves/gridFloor.ts +100 -0
- package/packages/motion/src/moves/imageSwarm.ts +109 -0
- package/packages/motion/src/moves/index.ts +19 -0
- package/packages/motion/src/moves/irisBlades.ts +113 -0
- package/packages/motion/src/moves/karaokeLine.ts +94 -0
- package/packages/motion/src/moves/ledBoard.ts +94 -0
- package/packages/motion/src/moves/liquidTab.ts +72 -0
- package/packages/motion/src/moves/markerWrite.ts +63 -0
- package/packages/motion/src/moves/morphBox.ts +96 -0
- package/packages/motion/src/moves/neonSign.ts +77 -0
- package/packages/motion/src/moves/panelPop.ts +78 -0
- package/packages/motion/src/moves/paperTear.ts +75 -0
- package/packages/motion/src/moves/path.ts +64 -0
- package/packages/motion/src/moves/pathText.ts +107 -0
- package/packages/motion/src/moves/pointSphere.ts +109 -0
- package/packages/motion/src/moves/ransomLetters.ts +73 -0
- package/packages/motion/src/moves/shapeMorph.ts +143 -0
- package/packages/motion/src/moves/slamWords.ts +89 -0
- package/packages/motion/src/moves/sparkTrail.ts +114 -0
- package/packages/motion/src/moves/speedLines.ts +91 -0
- package/packages/motion/src/moves/splitFlap.ts +147 -0
- package/packages/motion/src/moves/stepWords.ts +117 -0
- package/packages/motion/src/moves/strikeOut.ts +98 -0
- package/packages/motion/src/moves/sunburst.ts +58 -0
- package/packages/motion/src/moves/tickerRows.ts +87 -0
- package/packages/motion/src/moves/tokenPicker.ts +114 -0
- package/packages/motion/src/moves/truchet.ts +85 -0
- package/packages/motion/src/moves/wordWall.ts +76 -0
- package/packages/motion/src/moves/worldRoll.ts +31 -0
- package/packages/motion/src/particles.ts +102 -0
- package/packages/motion/src/react/index.tsx +21 -0
- package/packages/motion/src/react/parts.tsx +431 -0
- package/packages/motion/src/react/time.tsx +97 -0
- package/packages/motion/src/text.ts +103 -0
- package/packages/motion/src/transition.ts +82 -0
- package/packages/motion/src/transition3d/cards.ts +65 -0
- package/packages/motion/src/transition3d/chain.ts +84 -0
- package/packages/motion/src/transition3d/dive.ts +181 -0
- package/packages/motion/src/transition3d/fold.ts +110 -0
- package/packages/motion/src/transition3d/gl.ts +219 -0
- package/packages/motion/src/transition3d/index.ts +228 -0
- package/packages/motion/src/transition3d/live.ts +70 -0
- package/packages/motion/src/transition3d/portal.ts +115 -0
- package/packages/motion/src/transition3d/react.tsx +29 -0
- package/packages/motion/src/transition3d/rig.ts +502 -0
- package/packages/motion/src/transition3d/shatter.ts +101 -0
- package/packages/motion/src/transition3d/whip.ts +65 -0
- package/packages/motion/src/transition3d/world.ts +683 -0
- package/packages/motion/src/transition3d/zoomOut.ts +114 -0
- package/packages/motion/src/transitions2d/catalog.ts +127 -0
- package/packages/motion/src/transitions2d/css.d.ts +2 -0
- package/packages/motion/src/transitions2d/cult-ui/LICENSE.md +9 -0
- package/packages/motion/src/transitions2d/cult-ui/RollingNumber.tsx +43 -0
- package/packages/motion/src/transitions2d/gl-transitions/LICENSE +25 -0
- package/packages/motion/src/transitions2d/gl-transitions/shaders.ts +1931 -0
- package/packages/motion/src/transitions2d/index.ts +2 -0
- package/packages/motion/src/transitions2d/kokonutui/LICENSE +21 -0
- package/packages/motion/src/transitions2d/kokonutui/MatrixText.css +16 -0
- package/packages/motion/src/transitions2d/kokonutui/MatrixText.tsx +94 -0
- package/packages/motion/src/transitions2d/magicui/HyperText.css +15 -0
- package/packages/motion/src/transitions2d/magicui/HyperText.tsx +115 -0
- package/packages/motion/src/transitions2d/magicui/LICENSE.md +21 -0
- package/packages/motion/src/transitions2d/magicui/MorphingText.css +25 -0
- package/packages/motion/src/transitions2d/magicui/MorphingText.tsx +130 -0
- package/packages/motion/src/transitions2d/magicui/WordRotate.tsx +42 -0
- package/packages/motion/src/transitions2d/react.ts +13 -0
- package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.css +39 -0
- package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.tsx +32 -0
- package/packages/motion/src/transitions2d/smoothui/LICENSE +21 -0
- package/packages/motion/src/transitions2d/smoothui/SharedAxisY.tsx +50 -0
- package/packages/motion/src/transitions2d/smoothui/TextMorph.tsx +90 -0
- package/packages/motion/src/transitions2d/smoothui/shaders.ts +223 -0
- package/packages/motion/src/transitions2d/unlumen/LICENSE +21 -0
- package/packages/motion/src/transitions2d/unlumen/ScrambleText.tsx +114 -0
- package/packages/motion/src/transitions2d/vengeance-ui/LICENSE +21 -0
- package/packages/motion/src/transitions2d/vengeance-ui/MorphText.css +69 -0
- package/packages/motion/src/transitions2d/vengeance-ui/MorphText.tsx +45 -0
- package/packages/motion/src/type.ts +131 -0
- package/packages/motion/src/ui.ts +172 -0
- package/packages/plan/package.json +15 -0
- package/packages/plan/src/brief.ts +254 -0
- package/packages/plan/src/captions.ts +75 -0
- package/packages/plan/src/detect.ts +93 -0
- package/packages/plan/src/index.ts +23 -0
- package/packages/plan/src/layout.ts +176 -0
- package/packages/plan/src/llm.ts +110 -0
- package/packages/plan/src/look.ts +220 -0
- package/packages/plan/src/plan.ts +125 -0
- package/packages/plan/src/request.ts +55 -0
- package/packages/plan/src/studio.ts +53 -0
- package/packages/plan/src/templates.ts +42 -0
- package/packages/plan/src/themes.ts +48 -0
- package/packages/plan/src/types.ts +106 -0
- package/packages/studio/package.json +12 -0
- package/packages/studio/src/index.ts +1 -0
- package/packages/studio/src/plugin.ts +236 -0
- package/packages/studio/src/ui/main.ts +503 -0
- package/packages/studio/src/ui/studio.css +165 -0
- package/packages/studio/src/ui/timeline.ts +317 -0
- package/packages/themes/kit/THEME-MAKE.md +68 -0
- package/packages/themes/kit/THEME.md +30 -0
- package/packages/themes/kit/briefs/og-intro-15s/brief.json +16 -0
- package/packages/themes/kit/briefs/og-intro-15s/facts.ts +29 -0
- package/packages/themes/kit/briefs/og-intro-15s/logo.svg +12 -0
- package/packages/themes/kit/effects.ts +5 -0
- package/packages/themes/kit/sample/index.html +11 -0
- package/packages/themes/kit/sample/main.ts +9 -0
- package/packages/themes/kit/sample/scenes/scene.ts +15 -0
- package/packages/themes/package.json +16 -0
- package/packages/themes/src/factory.ts +296 -0
- package/packages/themes/src/fx.ts +14 -0
- package/packages/themes/src/index.ts +105 -0
- package/packages/themes/src/stage3d.ts +177 -0
- package/packages/themes/src/types.ts +58 -0
- package/presets/kawaii-pastel.json +94 -0
- package/presets/neutral-dark.json +82 -0
- package/presets/og.json +98 -0
- package/skills/kasaframe/SKILL.md +32 -0
- package/templates/_shared/project/index.html +11 -0
- package/templates/_shared/project/lib/react.ts +22 -0
- package/templates/_shared/project/lib/stage.ts +272 -0
- package/templates/_shared/project/main.ts +9 -0
- package/templates/_shared/scenes/default.ts +18 -0
- package/templates/_shared/scenes/drop.ts +30 -0
- package/templates/_shared/scenes/end.ts +23 -0
- package/templates/_shared/scenes/hook.ts +16 -0
- package/templates/_shared/scenes/seam.ts +41 -0
- package/templates/_shared/scenes/step.ts +40 -0
- package/templates/ad/preview.png +0 -0
- package/templates/ad/template.json +132 -0
- package/templates/demo/preview.png +0 -0
- package/templates/demo/template.json +130 -0
- package/templates/explainer/preview.png +0 -0
- package/templates/explainer/template.json +142 -0
- package/templates/launch/preview.png +0 -0
- package/templates/launch/template.json +130 -0
- package/templates/mv/preview.png +0 -0
- package/templates/mv/scenes/default.ts +95 -0
- package/templates/mv/template.json +176 -0
- package/templates/promo/preview.png +0 -0
- package/templates/promo/template.json +144 -0
- package/templates/shorts/preview.png +0 -0
- package/templates/shorts/scenes/hook.ts +34 -0
- package/templates/shorts/template.json +127 -0
- package/templates/square/preview.png +0 -0
- package/templates/square/template.json +113 -0
- package/themes/debug-hud/THEME.md +39 -0
- package/themes/debug-hud/effects.ts +389 -0
- package/themes/debug-hud/sample/assets/og/logo.svg +12 -0
- package/themes/debug-hud/sample/beats.json +1 -0
- package/themes/debug-hud/sample/index.html +11 -0
- package/themes/debug-hud/sample/kf.json +59 -0
- package/themes/debug-hud/sample/lib/hudkit.ts +49 -0
- package/themes/debug-hud/sample/lib/og.ts +29 -0
- package/themes/debug-hud/sample/main.ts +9 -0
- package/themes/debug-hud/sample/scenes/end.ts +62 -0
- package/themes/debug-hud/sample/scenes/gather.ts +67 -0
- package/themes/debug-hud/sample/scenes/models.ts +70 -0
- package/themes/debug-hud/sample/scenes/price.ts +79 -0
- package/themes/debug-hud/sample/style.json +91 -0
- package/themes/debug-hud/still.png +0 -0
- package/themes/debug-hud/style.json +91 -0
- package/themes/debug-hud/theme.json +68 -0
- package/themes/og-measure/THEME.md +47 -0
- package/themes/og-measure/effects.ts +432 -0
- package/themes/og-measure/sample/assets/brand/og-logo-full.svg +12 -0
- package/themes/og-measure/sample/assets/brand/og-logo.svg +12 -0
- package/themes/og-measure/sample/assets/data/measure.json +353 -0
- package/themes/og-measure/sample/beats.json +1 -0
- package/themes/og-measure/sample/index.html +11 -0
- package/themes/og-measure/sample/kf.json +66 -0
- package/themes/og-measure/sample/lib/data.ts +62 -0
- package/themes/og-measure/sample/main.ts +9 -0
- package/themes/og-measure/sample/measure.ts +78 -0
- package/themes/og-measure/sample/scenes/end.ts +47 -0
- package/themes/og-measure/sample/scenes/gather.ts +51 -0
- package/themes/og-measure/sample/scenes/models.ts +34 -0
- package/themes/og-measure/sample/scenes/one.ts +39 -0
- package/themes/og-measure/sample/scenes/price.ts +56 -0
- package/themes/og-measure/sample/style.json +97 -0
- package/themes/og-measure/still.png +0 -0
- package/themes/og-measure/style.json +97 -0
- package/themes/og-measure/theme.json +79 -0
- package/themes/riso-zine/THEME.md +43 -0
- package/themes/riso-zine/effects.ts +321 -0
- package/themes/riso-zine/sample/assets/og/logo.svg +12 -0
- package/themes/riso-zine/sample/beats.json +1 -0
- package/themes/riso-zine/sample/index.html +11 -0
- package/themes/riso-zine/sample/kf.json +59 -0
- package/themes/riso-zine/sample/lib/og.ts +29 -0
- package/themes/riso-zine/sample/lib/shot.ts +86 -0
- package/themes/riso-zine/sample/lib/zine.ts +42 -0
- package/themes/riso-zine/sample/main.ts +9 -0
- package/themes/riso-zine/sample/scenes/end.ts +61 -0
- package/themes/riso-zine/sample/scenes/gather.ts +62 -0
- package/themes/riso-zine/sample/scenes/models.ts +52 -0
- package/themes/riso-zine/sample/scenes/price.ts +82 -0
- package/themes/riso-zine/sample/style.json +99 -0
- package/themes/riso-zine/still.png +0 -0
- package/themes/riso-zine/style.json +99 -0
- package/themes/riso-zine/theme.json +75 -0
- package/tools/beats/beats.py +372 -0
- package/tools/beats/requirements.txt +3 -0
- package/tools/lyrics/align.py +164 -0
- package/tools/lyrics/requirements.txt +9 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { rand, safeTime } from "@kasaframe/core";
|
|
2
|
+
import { div, mark } from "./fit.ts";
|
|
3
|
+
|
|
4
|
+
export interface PointSphereOpts {
|
|
5
|
+
/** 가운데(px) · 반지름(px) */
|
|
6
|
+
x?: number;
|
|
7
|
+
y?: number;
|
|
8
|
+
r?: number;
|
|
9
|
+
/** 점 개수 */
|
|
10
|
+
count?: number;
|
|
11
|
+
color?: string;
|
|
12
|
+
/** 도는 속도(라디안/초) */
|
|
13
|
+
spin?: number;
|
|
14
|
+
/** 앞으로 기운 각(라디안) */
|
|
15
|
+
tilt?: number;
|
|
16
|
+
/** 위도선을 따라 감기는 낱말들 — 앞쪽은 또렷하게, 뒤쪽은 흐리게 */
|
|
17
|
+
words?: string[];
|
|
18
|
+
/** 낱말 위도(-1 아래 … 1 위) */
|
|
19
|
+
lat?: number;
|
|
20
|
+
wordSize?: number;
|
|
21
|
+
wordColor?: string;
|
|
22
|
+
w?: number;
|
|
23
|
+
h?: number;
|
|
24
|
+
seed?: string | number;
|
|
25
|
+
scene?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 점 구와 위도선 글 — 피보나치 구 점들을 t 로 돌려 원근으로 찍고(앞일수록 크고 밝게), 위도선 위 낱말 상자가 같이 돌며 감긴다.
|
|
30
|
+
* (Livera 쇼릴 10.3–11초 · Nothing Went Foom 30.5–33초)
|
|
31
|
+
*/
|
|
32
|
+
export function pointSphere(el: HTMLElement, o: PointSphereOpts = {}): (t: number) => void {
|
|
33
|
+
const doc = el.ownerDocument;
|
|
34
|
+
const W = o.w ?? 1920;
|
|
35
|
+
const H = o.h ?? 1080;
|
|
36
|
+
const cx = o.x ?? W / 2;
|
|
37
|
+
const cy = o.y ?? H / 2;
|
|
38
|
+
const R = o.r ?? Math.min(W, H) * 0.36;
|
|
39
|
+
const n = o.count ?? 1400;
|
|
40
|
+
const color = o.color ?? "#f5c56b";
|
|
41
|
+
const seed = o.seed ?? "sphere";
|
|
42
|
+
const canvas = doc.createElement("canvas");
|
|
43
|
+
canvas.width = W;
|
|
44
|
+
canvas.height = H;
|
|
45
|
+
canvas.style.cssText = `position:absolute;left:0;top:0;width:${W}px;height:${H}px`;
|
|
46
|
+
el.append(canvas);
|
|
47
|
+
const g = canvas.getContext("2d")!;
|
|
48
|
+
const golden = Math.PI * (3 - Math.sqrt(5));
|
|
49
|
+
const pts = Array.from({ length: n }, (_, i) => {
|
|
50
|
+
const y = 1 - (2 * (i + 0.5)) / n;
|
|
51
|
+
const rr = Math.sqrt(1 - y * y);
|
|
52
|
+
const a = i * golden;
|
|
53
|
+
return { x: rr * Math.cos(a), y, z: rr * Math.sin(a), s: 0.6 + 0.8 * rand(seed, i) };
|
|
54
|
+
});
|
|
55
|
+
const words = o.words ?? [];
|
|
56
|
+
const lat = Math.max(-0.95, Math.min(0.95, o.lat ?? 0));
|
|
57
|
+
const ring = div(doc, "position:absolute;left:0;top:0;pointer-events:none");
|
|
58
|
+
const spans = words.map((wd) => {
|
|
59
|
+
const s = div(doc, `position:absolute;left:0;top:0;white-space:nowrap;font-family:var(--kf-font-display);font-weight:800;font-size:${o.wordSize ?? 54}px;letter-spacing:.06em;color:${o.wordColor ?? "#ffffff"};transform-origin:50% 50%`, wd);
|
|
60
|
+
ring.append(s);
|
|
61
|
+
return s;
|
|
62
|
+
});
|
|
63
|
+
el.append(ring);
|
|
64
|
+
const focal = R * 3.2;
|
|
65
|
+
const proj = (x: number, y: number, z: number) => {
|
|
66
|
+
const k = focal / (focal - z * R);
|
|
67
|
+
return { px: cx + x * R * k, py: cy - y * R * k, k };
|
|
68
|
+
};
|
|
69
|
+
return (t: number) => {
|
|
70
|
+
t = safeTime(t);
|
|
71
|
+
const spin = (o.spin ?? 0.45) * t;
|
|
72
|
+
const tilt = o.tilt ?? 0.35;
|
|
73
|
+
const cs = Math.cos(spin);
|
|
74
|
+
const ss = Math.sin(spin);
|
|
75
|
+
const ct = Math.cos(tilt);
|
|
76
|
+
const st = Math.sin(tilt);
|
|
77
|
+
const rot = (x: number, y: number, z: number) => {
|
|
78
|
+
const x1 = x * cs + z * ss;
|
|
79
|
+
const z1 = -x * ss + z * cs;
|
|
80
|
+
return { x: x1, y: y * ct - z1 * st, z: y * st + z1 * ct };
|
|
81
|
+
};
|
|
82
|
+
g.clearRect(0, 0, W, H);
|
|
83
|
+
g.fillStyle = color;
|
|
84
|
+
for (const p of pts) {
|
|
85
|
+
const q = rot(p.x, p.y, p.z);
|
|
86
|
+
const { px, py, k } = proj(q.x, q.y, q.z);
|
|
87
|
+
const front = (q.z + 1) / 2;
|
|
88
|
+
g.globalAlpha = 0.15 + 0.85 * front;
|
|
89
|
+
const size = (2.2 + 4.2 * front) * p.s * k;
|
|
90
|
+
g.fillRect(px - size / 2, py - size / 2, size, size);
|
|
91
|
+
}
|
|
92
|
+
g.globalAlpha = 1;
|
|
93
|
+
// 낱말 — 위도선 위에 고르게 놓고 구와 같이 돈다. 뒤로 돌아가면 흐려지고 작아진다
|
|
94
|
+
const rr = Math.sqrt(1 - lat * lat) * 1.08;
|
|
95
|
+
spans.forEach((s, i) => {
|
|
96
|
+
const a = (i / Math.max(1, spans.length)) * Math.PI * 2;
|
|
97
|
+
const q = rot(rr * Math.sin(a), lat, rr * Math.cos(a));
|
|
98
|
+
const { px, py, k } = proj(q.x, q.y, q.z);
|
|
99
|
+
const front = (q.z + 1) / 2;
|
|
100
|
+
const yaw = Math.atan2(q.x, q.z);
|
|
101
|
+
// 뒤로 돌아간 낱말은 숨긴다 — 흐리게 남기면 거울 글씨가 겹쳐 읽히지도 않고 대비만 낮다
|
|
102
|
+
s.style.display = front < 0.42 ? "none" : "block";
|
|
103
|
+
s.style.opacity = (0.35 + 0.65 * Math.min(1, (front - 0.42) / 0.3)).toFixed(3);
|
|
104
|
+
s.style.transform = `translate(${px.toFixed(1)}px, ${py.toFixed(1)}px) translate(-50%, -50%) perspective(900px) rotateY(${((yaw * 180) / Math.PI).toFixed(2)}deg) scale(${k.toFixed(3)})`;
|
|
105
|
+
s.style.zIndex = String(Math.round(front * 100));
|
|
106
|
+
});
|
|
107
|
+
mark("pointSphere", o.scene, true);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { clamp, ease, rand, safeTime } from "@kasaframe/core";
|
|
2
|
+
import { div, fitSize, lastIndex, mark } from "./fit.ts";
|
|
3
|
+
|
|
4
|
+
export interface RansomOpts {
|
|
5
|
+
text: string;
|
|
6
|
+
/** 글자가 차례로 붙기 시작하는 시각 */
|
|
7
|
+
at?: number;
|
|
8
|
+
/** 글자 모양을 다시 뽑는 시각(박). 없으면 초당 rate 번 */
|
|
9
|
+
hits?: number[];
|
|
10
|
+
rate?: number;
|
|
11
|
+
palette?: string[];
|
|
12
|
+
size?: number;
|
|
13
|
+
w?: number;
|
|
14
|
+
h?: number;
|
|
15
|
+
seed?: string | number;
|
|
16
|
+
scene?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const PALETTE = ["#FF6B2C", "#7CF0D6", "#FFD84D", "#B48CFF", "#FF5FA2", "#F2F3F5"];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 오려 붙인 글자 — 글자마다 색·크기·기울기·굵기·대소문자를 시드로 뽑고, 몇 글자는 색종이 조각 위에 앉는다. 박마다 다시 뽑아 표정이 바뀐다.
|
|
23
|
+
* (Where No Map Goes 5.5–6.3초 「WHeRE」)
|
|
24
|
+
*/
|
|
25
|
+
export function ransomLetters(el: HTMLElement, o: RansomOpts): (t: number) => void {
|
|
26
|
+
const doc = el.ownerDocument;
|
|
27
|
+
const W = o.w ?? 1920;
|
|
28
|
+
const H = o.h ?? 1080;
|
|
29
|
+
const pal = o.palette?.length ? o.palette : PALETTE;
|
|
30
|
+
const seed = o.seed ?? o.text;
|
|
31
|
+
const at = o.at ?? 0;
|
|
32
|
+
const px = o.size ?? fitSize(o.text, W, H, { share: 0.66, hShare: 0.42 });
|
|
33
|
+
const layer = div(doc, "position:absolute;inset:0;overflow:hidden;display:flex;align-items:center;justify-content:center");
|
|
34
|
+
const row = div(doc, `display:flex;align-items:center;white-space:nowrap;font-family:var(--kf-font-display);font-size:${px}px;line-height:1`);
|
|
35
|
+
layer.append(row);
|
|
36
|
+
el.append(layer);
|
|
37
|
+
const letters = [...o.text].map((c) => {
|
|
38
|
+
const box = div(doc, "position:relative;display:inline-block;padding:0 .04em;margin:0 .02em");
|
|
39
|
+
const paper = div(doc, "position:absolute;inset:-.06em -.02em;border-radius:.04em");
|
|
40
|
+
const glyph = div(doc, "position:relative", c === " " ? "\u00a0" : c);
|
|
41
|
+
box.append(paper, glyph);
|
|
42
|
+
row.append(box);
|
|
43
|
+
return { box, paper, glyph, c };
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return (t: number) => {
|
|
47
|
+
t = safeTime(t);
|
|
48
|
+
const roll = o.hits?.length ? Math.max(0, lastIndex(o.hits, t)) : Math.floor(Math.max(0, t) * (o.rate ?? 6));
|
|
49
|
+
let moving = false;
|
|
50
|
+
letters.forEach((l, i) => {
|
|
51
|
+
const local = t - at - i * 0.05;
|
|
52
|
+
const p = clamp(local / 0.18);
|
|
53
|
+
if (p < 1) moving = true;
|
|
54
|
+
const r = (k: number) => rand(seed, roll * 977 + i * 31 + k);
|
|
55
|
+
const color = pal[Math.floor(r(1) * pal.length)];
|
|
56
|
+
const onPaper = r(2) < 0.35;
|
|
57
|
+
const latin = /[a-z]/i.test(l.c);
|
|
58
|
+
l.glyph.textContent = latin ? (r(3) < 0.5 ? l.c.toUpperCase() : l.c.toLowerCase()) : l.c === " " ? "\u00a0" : l.c;
|
|
59
|
+
l.glyph.style.color = onPaper ? "#0E0F12" : color;
|
|
60
|
+
l.glyph.style.fontWeight = String(r(4) < 0.5 ? 900 : 560);
|
|
61
|
+
l.paper.style.background = onPaper ? color : "transparent";
|
|
62
|
+
l.paper.style.transform = `rotate(${((r(5) - 0.5) * 10).toFixed(2)}deg)`;
|
|
63
|
+
const s = (0.85 + 0.3 * r(6)) * ease.outBack(p);
|
|
64
|
+
const rot = (r(7) - 0.5) * 16;
|
|
65
|
+
const dy = (r(8) - 0.5) * px * 0.14;
|
|
66
|
+
l.box.style.opacity = p > 0 ? "1" : "0";
|
|
67
|
+
l.box.style.transform = `translateY(${dy.toFixed(1)}px) rotate(${rot.toFixed(2)}deg) scale(${s.toFixed(4)})`;
|
|
68
|
+
});
|
|
69
|
+
// 줄 전체도 조금씩 다가간다 — 글자 모양이 안 바뀌는 사이에도 멈추지 않게
|
|
70
|
+
row.style.transform = `scale(${(1 + 0.025 * t).toFixed(4)}) rotate(${(1.5 * Math.sin(t * 2.1)).toFixed(2)}deg)`;
|
|
71
|
+
mark("ransomLetters", o.scene, moving);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { safeTime } from "@kasaframe/core";
|
|
2
|
+
import { mark } from "./fit.ts";
|
|
3
|
+
import { springSteps } from "./liquidTab.ts";
|
|
4
|
+
|
|
5
|
+
export type MorphShape = "circle" | "triangle" | "square" | "diamond" | "star" | "hexagon" | "heart";
|
|
6
|
+
|
|
7
|
+
export interface ShapeMorphOpts {
|
|
8
|
+
/** 도형이 바뀌는 시각과 도형 — 보통 박마다 */
|
|
9
|
+
steps: { at: number; shape: MorphShape }[];
|
|
10
|
+
/** 가운데(px) · 반지름(px) */
|
|
11
|
+
x?: number;
|
|
12
|
+
y?: number;
|
|
13
|
+
r?: number;
|
|
14
|
+
color?: string;
|
|
15
|
+
/** 둘레를 도는 점 개수 — 같은 모양을 1.6배로 따라 그린다. 0 이면 없음 */
|
|
16
|
+
orbit?: number;
|
|
17
|
+
orbitScale?: number;
|
|
18
|
+
orbitDot?: number;
|
|
19
|
+
/** 둘레 점이 도는 속도(도/초) — 도형이 가만할 때도 화면이 멈추지 않게 */
|
|
20
|
+
spin?: number;
|
|
21
|
+
/** 꼭짓점 수 — 모든 도형을 같은 수로 다시 뽑아야 섞인다 */
|
|
22
|
+
points?: number;
|
|
23
|
+
stiffness?: number;
|
|
24
|
+
damping?: number;
|
|
25
|
+
w?: number;
|
|
26
|
+
h?: number;
|
|
27
|
+
scene?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const TAU = Math.PI * 2;
|
|
31
|
+
|
|
32
|
+
// 도형 윤곽을 가운데에서 본 각 → 반지름(단위 원 기준)으로 — 각이 같은 점끼리 섞으면 꼬이지 않고 변신한다
|
|
33
|
+
function polyRadius(verts: [number, number][], a: number): number {
|
|
34
|
+
const dx = Math.cos(a);
|
|
35
|
+
const dy = Math.sin(a);
|
|
36
|
+
let best = Infinity;
|
|
37
|
+
for (let i = 0; i < verts.length; i++) {
|
|
38
|
+
const [x1, y1] = verts[i];
|
|
39
|
+
const [x2, y2] = verts[(i + 1) % verts.length];
|
|
40
|
+
const ex = x2 - x1;
|
|
41
|
+
const ey = y2 - y1;
|
|
42
|
+
const den = dx * ey - dy * ex;
|
|
43
|
+
if (Math.abs(den) < 1e-9) continue;
|
|
44
|
+
const s = (x1 * ey - y1 * ex) / den;
|
|
45
|
+
const u = (x1 * dy - y1 * dx) / den;
|
|
46
|
+
if (s > 0 && u >= -1e-9 && u <= 1 + 1e-9) best = Math.min(best, s);
|
|
47
|
+
}
|
|
48
|
+
return Number.isFinite(best) ? best : 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 하트 곡선(x=16sin³s, y=13cos s−5cos2s−2cos3s−cos4s)을 64점으로 — 가운데를 조금 아래로 두어야 위 오목한 곳까지 한 번에 닿는다
|
|
52
|
+
const HEART: [number, number][] = Array.from({ length: 64 }, (_, k) => {
|
|
53
|
+
const s = (k / 64) * TAU;
|
|
54
|
+
const x = 16 * Math.sin(s) ** 3;
|
|
55
|
+
const y = -(13 * Math.cos(s) - 5 * Math.cos(2 * s) - 2 * Math.cos(3 * s) - Math.cos(4 * s));
|
|
56
|
+
return [x / 17, (y - 1) / 17];
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
function regular(n: number, rot = -Math.PI / 2, inner?: number): [number, number][] {
|
|
60
|
+
const out: [number, number][] = [];
|
|
61
|
+
const m = inner ? n * 2 : n;
|
|
62
|
+
for (let i = 0; i < m; i++) {
|
|
63
|
+
const r = inner && i % 2 ? inner : 1;
|
|
64
|
+
const a = rot + (i * TAU) / m;
|
|
65
|
+
out.push([r * Math.cos(a), r * Math.sin(a)]);
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function radius(shape: MorphShape, a: number): number {
|
|
71
|
+
switch (shape) {
|
|
72
|
+
case "circle":
|
|
73
|
+
return 1;
|
|
74
|
+
case "triangle":
|
|
75
|
+
return polyRadius(regular(3), a) * 1.15;
|
|
76
|
+
case "square":
|
|
77
|
+
return polyRadius(regular(4, -Math.PI / 4), a) * 1.05;
|
|
78
|
+
case "diamond":
|
|
79
|
+
return polyRadius(regular(4), a);
|
|
80
|
+
case "hexagon":
|
|
81
|
+
return polyRadius(regular(6), a);
|
|
82
|
+
case "star":
|
|
83
|
+
return polyRadius(regular(5, -Math.PI / 2, 0.45), a) * 1.1;
|
|
84
|
+
case "heart":
|
|
85
|
+
return polyRadius(HEART, a) * 1.05;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 도형 변신 — 원 → 삼각형 → 별 → 사각형 …, 모든 도형을 같은 수의 점으로(가운데에서 같은 각) 다시 뽑아 박마다 스프링으로 섞는다.
|
|
91
|
+
* 둘레의 점들도 같은 모양으로 1.6배 크게 따라 변하며 돈다. (Livera 15초 쇼릴 5.6–7.5초)
|
|
92
|
+
*/
|
|
93
|
+
export function shapeMorph(el: HTMLElement, o: ShapeMorphOpts): (t: number) => void {
|
|
94
|
+
const doc = el.ownerDocument;
|
|
95
|
+
const W = o.w ?? 1920;
|
|
96
|
+
const H = o.h ?? 1080;
|
|
97
|
+
const cx = o.x ?? W / 2;
|
|
98
|
+
const cy = o.y ?? H / 2;
|
|
99
|
+
const R = o.r ?? Math.min(W, H) * 0.24;
|
|
100
|
+
const n = o.points ?? 96;
|
|
101
|
+
const NS = "http://www.w3.org/2000/svg";
|
|
102
|
+
const svg = doc.createElementNS(NS, "svg");
|
|
103
|
+
svg.setAttribute("width", String(W));
|
|
104
|
+
svg.setAttribute("height", String(H));
|
|
105
|
+
svg.setAttribute("viewBox", `0 0 ${W} ${H}`);
|
|
106
|
+
svg.style.cssText = "position:absolute;left:0;top:0;overflow:visible";
|
|
107
|
+
const poly = doc.createElementNS(NS, "polygon");
|
|
108
|
+
poly.setAttribute("fill", o.color ?? "var(--kf-ink)");
|
|
109
|
+
svg.append(poly);
|
|
110
|
+
const orbitN = o.orbit ?? 18;
|
|
111
|
+
const dots = Array.from({ length: orbitN }, () => {
|
|
112
|
+
const c = doc.createElementNS(NS, "circle");
|
|
113
|
+
c.setAttribute("r", String(o.orbitDot ?? 7));
|
|
114
|
+
c.setAttribute("fill", o.color ?? "var(--kf-ink)");
|
|
115
|
+
svg.append(c);
|
|
116
|
+
return c;
|
|
117
|
+
});
|
|
118
|
+
el.append(svg);
|
|
119
|
+
const angles = Array.from({ length: n }, (_, i) => -Math.PI / 2 + (i * TAU) / n);
|
|
120
|
+
// 점마다 도형별 반지름 걸음 — 목표가 박마다 바뀌는 값이라 springSteps 그대로
|
|
121
|
+
const tracks = angles.map((a) => o.steps.map((s) => ({ at: s.at, to: radius(s.shape, a) })));
|
|
122
|
+
const sp = { stiffness: o.stiffness ?? 260, damping: o.damping ?? 18 };
|
|
123
|
+
const rAt = (rs: number[], a: number) => {
|
|
124
|
+
const u = ((((a + Math.PI / 2) / TAU) * n) % n + n) % n;
|
|
125
|
+
const i = Math.floor(u);
|
|
126
|
+
const f = u - i;
|
|
127
|
+
return rs[i] * (1 - f) + rs[(i + 1) % n] * f;
|
|
128
|
+
};
|
|
129
|
+
return (t: number) => {
|
|
130
|
+
t = safeTime(t);
|
|
131
|
+
const rs = tracks.map((tr) => springSteps(t, tr, sp));
|
|
132
|
+
poly.setAttribute("points", angles.map((a, i) => `${(cx + R * rs[i] * Math.cos(a)).toFixed(1)},${(cy + R * rs[i] * Math.sin(a)).toFixed(1)}`).join(" "));
|
|
133
|
+
const spin = ((o.spin ?? 40) * Math.PI) / 180;
|
|
134
|
+
const k = o.orbitScale ?? 1.6;
|
|
135
|
+
dots.forEach((d, j) => {
|
|
136
|
+
const a = -Math.PI / 2 + (j * TAU) / orbitN + spin * t;
|
|
137
|
+
const rr = R * k * rAt(rs, a);
|
|
138
|
+
d.setAttribute("cx", (cx + rr * Math.cos(a)).toFixed(1));
|
|
139
|
+
d.setAttribute("cy", (cy + rr * Math.sin(a)).toFixed(1));
|
|
140
|
+
});
|
|
141
|
+
mark("shapeMorph", o.scene, o.steps.some((s, i) => i > 0 && t >= s.at && t < s.at + 0.4));
|
|
142
|
+
};
|
|
143
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { clamp, ease, safeTime } from "@kasaframe/core";
|
|
2
|
+
import { div, fitSize, lastIndex, mark } from "./fit.ts";
|
|
3
|
+
|
|
4
|
+
export interface SlamWordsOpts {
|
|
5
|
+
words: string[];
|
|
6
|
+
/** 낱말마다 쾅 하는 시각(장면 초) — 보통 ctx.beats 의 박. words 보다 짧으면 남는 낱말은 안 나온다 */
|
|
7
|
+
hits: number[];
|
|
8
|
+
w?: number;
|
|
9
|
+
h?: number;
|
|
10
|
+
/** [바탕, 글] — 낱말마다 돌아가며 뒤집힌다 */
|
|
11
|
+
palettes?: [string, string][];
|
|
12
|
+
weight?: number;
|
|
13
|
+
scene?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const PALETTES: [string, string][] = [
|
|
17
|
+
["var(--kf-bg)", "var(--kf-ink)"],
|
|
18
|
+
["var(--kf-accent)", "var(--kf-on-accent)"],
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 박마다 낱말 하나가 화면을 꽉 채우며 쾅 — 1.22배에서 내려앉고, 글자는 바닥에서 꼬리를 끌며 차례로 솟고, 바탕색이 뒤집힌다.
|
|
23
|
+
* 다음 박까지는 다가가며 옆으로 흘러 멈추지 않는다. (mexicat 「I'm Upping My P(doom)」 59–60초의 훅)
|
|
24
|
+
*/
|
|
25
|
+
export function slamWords(el: HTMLElement, o: SlamWordsOpts): (t: number) => void {
|
|
26
|
+
const doc = el.ownerDocument;
|
|
27
|
+
const W = o.w ?? 1920;
|
|
28
|
+
const H = o.h ?? 1080;
|
|
29
|
+
const pals = o.palettes?.length ? o.palettes : PALETTES;
|
|
30
|
+
const layer = div(doc, "position:absolute;inset:0;overflow:hidden");
|
|
31
|
+
el.append(layer);
|
|
32
|
+
const words = o.words.slice(0, o.hits.length).map((text) => {
|
|
33
|
+
const px = fitSize(text, W, H, { share: 0.9, hShare: 0.72 });
|
|
34
|
+
const box = div(
|
|
35
|
+
doc,
|
|
36
|
+
`position:absolute;left:50%;top:50%;display:flex;white-space:nowrap;font-family:var(--kf-font-display);font-size:${px}px;` +
|
|
37
|
+
`font-weight:${o.weight ?? 900};line-height:.9;letter-spacing:-.04em;transform-origin:50% 50%`,
|
|
38
|
+
);
|
|
39
|
+
const letters = [...text].map((c) => {
|
|
40
|
+
const span = doc.createElement("span");
|
|
41
|
+
span.style.cssText = "position:relative;display:inline-block";
|
|
42
|
+
span.textContent = c === " " ? "\u00a0" : c;
|
|
43
|
+
// 솟는 글자 아래로 남는 세로 꼬리 — 글자색에서 투명으로
|
|
44
|
+
const tail = div(
|
|
45
|
+
doc,
|
|
46
|
+
"position:absolute;left:10%;right:10%;top:86%;height:1.2em;transform-origin:50% 0;" +
|
|
47
|
+
"background:repeating-linear-gradient(90deg,currentColor 0 .045em,transparent .045em .14em);" +
|
|
48
|
+
"-webkit-mask-image:linear-gradient(#000,transparent);mask-image:linear-gradient(#000,transparent)",
|
|
49
|
+
);
|
|
50
|
+
span.append(tail);
|
|
51
|
+
box.append(span);
|
|
52
|
+
return { span, tail };
|
|
53
|
+
});
|
|
54
|
+
layer.append(box);
|
|
55
|
+
return { box, letters, px };
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return (t: number) => {
|
|
59
|
+
t = safeTime(t);
|
|
60
|
+
const k = lastIndex(o.hits, t);
|
|
61
|
+
const [bg, ink] = pals[Math.max(0, k) % pals.length];
|
|
62
|
+
layer.style.background = bg;
|
|
63
|
+
words.forEach((wd, i) => {
|
|
64
|
+
if (i !== k) {
|
|
65
|
+
wd.box.style.display = "none";
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const local = t - o.hits[i];
|
|
69
|
+
wd.box.style.display = "flex";
|
|
70
|
+
wd.box.style.color = ink;
|
|
71
|
+
const land = ease.outCubic(clamp(local / 0.2));
|
|
72
|
+
const after = Math.max(0, local - 0.2);
|
|
73
|
+
// 박 사이에도 다가가며 옆으로 흘러야 0.1초 멈춤에 안 걸린다(짧은 낱말일수록 움직임이 작게 보인다)
|
|
74
|
+
const scale = (1.22 - 0.22 * land) * (1 + 0.16 * after);
|
|
75
|
+
const dx = (i % 2 ? -1 : 1) * W * 0.05 * after;
|
|
76
|
+
wd.box.style.transform = `translate(calc(-50% + ${dx.toFixed(1)}px),-50%) scale(${scale.toFixed(4)})`;
|
|
77
|
+
const each = Math.min(0.035, 0.12 / wd.letters.length);
|
|
78
|
+
wd.letters.forEach((l, j) => {
|
|
79
|
+
const p = clamp((local - j * each) / 0.16);
|
|
80
|
+
const e = ease.outCubic(p);
|
|
81
|
+
l.span.style.opacity = p > 0 ? "1" : "0";
|
|
82
|
+
l.span.style.transform = `translateY(${((1 - e) * wd.px * 0.7).toFixed(1)}px)`;
|
|
83
|
+
l.tail.style.transform = `scaleY(${(1 - e).toFixed(3)})`;
|
|
84
|
+
l.tail.style.opacity = (0.8 * (1 - e)).toFixed(3);
|
|
85
|
+
});
|
|
86
|
+
mark("slamWords", o.scene, local < 0.25);
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { clamp, rand, safeTime, toEase, type Ease, type EaseName } from "@kasaframe/core";
|
|
2
|
+
import { mark } from "./fit.ts";
|
|
3
|
+
import { curve, lengths, pointAt, type Pt } from "./path.ts";
|
|
4
|
+
|
|
5
|
+
export interface SparkTrailOpts {
|
|
6
|
+
/** 지나는 점들(무대 px). smooth 면 곡선으로 잇는다 */
|
|
7
|
+
points: Pt[];
|
|
8
|
+
smooth?: boolean;
|
|
9
|
+
at?: number;
|
|
10
|
+
dur?: number;
|
|
11
|
+
ease?: EaseName | Ease;
|
|
12
|
+
/** 선이 남는 길이(초). 없으면 끝까지 남는다 — 도화선처럼 타 들어가게 하려면 0.4 쯤 */
|
|
13
|
+
tail?: number;
|
|
14
|
+
color?: string;
|
|
15
|
+
width?: number;
|
|
16
|
+
sparks?: number;
|
|
17
|
+
w?: number;
|
|
18
|
+
h?: number;
|
|
19
|
+
seed?: string | number;
|
|
20
|
+
scene?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 불씨가 끄는 선 — 빛나는 점 하나가 불티를 흘리며 경로를 지나가고 그 뒤로 선이 남는다. 꼬리 쪽일수록 식어 어둡다.
|
|
25
|
+
* 다 그린 뒤에도 불씨가 끝에서 숨 쉬어 멈추지 않는다. (mexicat p(doom) 97·102·145초의 불씨)
|
|
26
|
+
*/
|
|
27
|
+
export function sparkTrail(el: HTMLElement, o: SparkTrailOpts): (t: number) => void {
|
|
28
|
+
const W = o.w ?? 1920;
|
|
29
|
+
const H = o.h ?? 1080;
|
|
30
|
+
const cv = el.ownerDocument.createElement("canvas");
|
|
31
|
+
cv.width = W;
|
|
32
|
+
cv.height = H;
|
|
33
|
+
cv.style.cssText = "position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none";
|
|
34
|
+
el.append(cv);
|
|
35
|
+
const g = cv.getContext("2d")!;
|
|
36
|
+
const pts = o.smooth === false ? o.points : curve(o.points);
|
|
37
|
+
const cum = lengths(pts);
|
|
38
|
+
const L = cum[cum.length - 1] || 1;
|
|
39
|
+
const at = o.at ?? 0;
|
|
40
|
+
const dur = o.dur ?? 1.2;
|
|
41
|
+
const ez = toEase(o.ease ?? "inOutCubic");
|
|
42
|
+
// 스타일 색은 장면이 처음 그려질 때 읽는다 — build 때는 아직 변수가 안 걸렸을 수 있다
|
|
43
|
+
let color = o.color ?? "";
|
|
44
|
+
const lw = o.width ?? 9;
|
|
45
|
+
const nSparks = o.sparks ?? 70;
|
|
46
|
+
const seed = o.seed ?? "spark";
|
|
47
|
+
const sAt = (u: number) => L * ez(clamp((u - at) / dur));
|
|
48
|
+
|
|
49
|
+
return (t: number) => {
|
|
50
|
+
t = safeTime(t);
|
|
51
|
+
g.clearRect(0, 0, W, H);
|
|
52
|
+
if (t < at) return;
|
|
53
|
+
if (!color) color = getComputedStyle(el.ownerDocument.documentElement).getPropertyValue("--kf-accent").trim() || "#ff6b2c";
|
|
54
|
+
const head = sAt(t);
|
|
55
|
+
const from = o.tail !== undefined ? Math.max(0, sAt(t - o.tail)) : 0;
|
|
56
|
+
g.lineCap = "round";
|
|
57
|
+
g.lineJoin = "round";
|
|
58
|
+
g.strokeStyle = color;
|
|
59
|
+
g.shadowColor = color;
|
|
60
|
+
g.shadowBlur = lw * 2.5;
|
|
61
|
+
// 꼬리에서 머리로 갈수록 밝게 — 조각마다 투명도를 올린다
|
|
62
|
+
const chunks = 48;
|
|
63
|
+
for (let c = 0; c < chunks; c++) {
|
|
64
|
+
const a = from + ((head - from) * c) / chunks;
|
|
65
|
+
const b = from + ((head - from) * (c + 1)) / chunks;
|
|
66
|
+
if (b <= a) continue;
|
|
67
|
+
const f = (c + 1) / chunks;
|
|
68
|
+
g.globalAlpha = 0.25 + 0.75 * f * f;
|
|
69
|
+
g.lineWidth = lw * (0.7 + 0.3 * f);
|
|
70
|
+
g.beginPath();
|
|
71
|
+
const p0 = pointAt(pts, cum, a);
|
|
72
|
+
g.moveTo(p0.x, p0.y);
|
|
73
|
+
for (let i = 0; i < pts.length; i++) if (cum[i] > a && cum[i] < b) g.lineTo(pts[i][0], pts[i][1]);
|
|
74
|
+
const p1 = pointAt(pts, cum, b);
|
|
75
|
+
g.lineTo(p1.x, p1.y);
|
|
76
|
+
g.stroke();
|
|
77
|
+
}
|
|
78
|
+
g.shadowBlur = 0;
|
|
79
|
+
// 불티 — 머리가 지나간 자리에서 태어나 0.45초 동안 튀며 식는다
|
|
80
|
+
for (let i = 0; i < nSparks; i++) {
|
|
81
|
+
const born = at + (dur * i) / nSparks;
|
|
82
|
+
const age = t - born;
|
|
83
|
+
if (age < 0 || age > 0.45) continue;
|
|
84
|
+
const p = pointAt(pts, cum, sAt(born));
|
|
85
|
+
const ang = p.angle + Math.PI + (rand(seed, i) - 0.5) * 2.2;
|
|
86
|
+
const v = 120 + 260 * rand(seed, i + 500);
|
|
87
|
+
const x = p.x + Math.cos(ang) * v * age;
|
|
88
|
+
const y = p.y + Math.sin(ang) * v * age + 260 * age * age;
|
|
89
|
+
g.globalAlpha = (1 - age / 0.45) * 0.9;
|
|
90
|
+
g.fillStyle = i % 3 ? color : "#fff4e0";
|
|
91
|
+
g.beginPath();
|
|
92
|
+
g.arc(x, y, 1.6 + 2.2 * rand(seed, i + 900), 0, Math.PI * 2);
|
|
93
|
+
g.fill();
|
|
94
|
+
}
|
|
95
|
+
// 머리 — 번진 빛 + 흰 속. 다 그린 뒤에도 숨 쉰다
|
|
96
|
+
const hp = pointAt(pts, cum, head);
|
|
97
|
+
const breath = 1 + 0.18 * Math.sin(t * 9);
|
|
98
|
+
const r = lw * 6 * breath;
|
|
99
|
+
const grad = g.createRadialGradient(hp.x, hp.y, 0, hp.x, hp.y, r);
|
|
100
|
+
grad.addColorStop(0, "rgba(255,244,224,1)");
|
|
101
|
+
grad.addColorStop(0.25, color);
|
|
102
|
+
grad.addColorStop(1, "rgba(0,0,0,0)");
|
|
103
|
+
g.globalAlpha = 1;
|
|
104
|
+
g.fillStyle = grad;
|
|
105
|
+
g.beginPath();
|
|
106
|
+
g.arc(hp.x, hp.y, r, 0, Math.PI * 2);
|
|
107
|
+
g.fill();
|
|
108
|
+
g.fillStyle = "#fff";
|
|
109
|
+
g.beginPath();
|
|
110
|
+
g.arc(hp.x, hp.y, lw * 0.9, 0, Math.PI * 2);
|
|
111
|
+
g.fill();
|
|
112
|
+
mark("sparkTrail", o.scene, t < at + dur);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { rand, safeTime } from "@kasaframe/core";
|
|
2
|
+
import { mark } from "./fit.ts";
|
|
3
|
+
|
|
4
|
+
export interface SpeedLinesOpts {
|
|
5
|
+
/** radial 가운데로 모이는 집중선 · horizontal 옆으로 흐르는 속도선 */
|
|
6
|
+
kind?: "radial" | "horizontal";
|
|
7
|
+
count?: number;
|
|
8
|
+
color?: string;
|
|
9
|
+
/** 비워 두는 가운데 반지름(화면 짧은 변의 몫) — radial */
|
|
10
|
+
inner?: number;
|
|
11
|
+
/** 손그림처럼 끓는 횟수(초당) — 12 면 만화 결 */
|
|
12
|
+
boil?: number;
|
|
13
|
+
/** 가장 굵은 선(px) */
|
|
14
|
+
width?: number;
|
|
15
|
+
/** horizontal 의 흐름 속도(px/초) — 음수면 오른쪽으로 */
|
|
16
|
+
speed?: number;
|
|
17
|
+
x?: number;
|
|
18
|
+
y?: number;
|
|
19
|
+
seed?: string | number;
|
|
20
|
+
w?: number;
|
|
21
|
+
h?: number;
|
|
22
|
+
scene?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 집중선·속도선 — 선마다 각도·길이·굵기를 시드로 뽑고 초당 12번 새로 뽑아 끓는다(손그림 결). 선은 바깥이 굵고 안쪽이 뾰족한 쐐기.
|
|
27
|
+
* (Where No Map Goes 33–38초 · Update Me 32.4초)
|
|
28
|
+
*/
|
|
29
|
+
export function speedLines(el: HTMLElement, o: SpeedLinesOpts = {}): (t: number) => void {
|
|
30
|
+
const doc = el.ownerDocument;
|
|
31
|
+
const W = o.w ?? 1920;
|
|
32
|
+
const H = o.h ?? 1080;
|
|
33
|
+
const canvas = doc.createElement("canvas");
|
|
34
|
+
canvas.width = W;
|
|
35
|
+
canvas.height = H;
|
|
36
|
+
canvas.style.cssText = `position:absolute;left:0;top:0;width:${W}px;height:${H}px;pointer-events:none`;
|
|
37
|
+
el.append(canvas);
|
|
38
|
+
const g = canvas.getContext("2d")!;
|
|
39
|
+
const kind = o.kind ?? "radial";
|
|
40
|
+
const n = o.count ?? (kind === "radial" ? 110 : 46);
|
|
41
|
+
const seed = o.seed ?? "speed";
|
|
42
|
+
const boil = o.boil ?? 12;
|
|
43
|
+
const cx = o.x ?? W / 2;
|
|
44
|
+
const cy = o.y ?? H / 2;
|
|
45
|
+
const maxW = o.width ?? 16;
|
|
46
|
+
const color = o.color ?? "#ffffff";
|
|
47
|
+
return (t: number) => {
|
|
48
|
+
t = safeTime(t);
|
|
49
|
+
const f = Math.floor(t * boil);
|
|
50
|
+
g.clearRect(0, 0, W, H);
|
|
51
|
+
g.fillStyle = color;
|
|
52
|
+
if (kind === "radial") {
|
|
53
|
+
const outer = Math.hypot(W, H) * 0.6;
|
|
54
|
+
const inner = Math.min(W, H) * (o.inner ?? 0.3);
|
|
55
|
+
for (let i = 0; i < n; i++) {
|
|
56
|
+
const r = (k: number) => rand(seed, f * 9973 + i * 7 + k);
|
|
57
|
+
const a = r(0) * Math.PI * 2;
|
|
58
|
+
const rin = inner * (0.75 + 0.7 * r(1));
|
|
59
|
+
const half = (maxW * (0.25 + r(2))) / 2 / outer;
|
|
60
|
+
g.globalAlpha = 0.55 + 0.45 * r(3);
|
|
61
|
+
g.beginPath();
|
|
62
|
+
g.moveTo(cx + rin * Math.cos(a), cy + rin * Math.sin(a));
|
|
63
|
+
g.lineTo(cx + outer * Math.cos(a + half), cy + outer * Math.sin(a + half));
|
|
64
|
+
g.lineTo(cx + outer * Math.cos(a - half), cy + outer * Math.sin(a - half));
|
|
65
|
+
g.closePath();
|
|
66
|
+
g.fill();
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
const speed = o.speed ?? 2600;
|
|
70
|
+
for (let i = 0; i < n; i++) {
|
|
71
|
+
const r = (k: number) => rand(seed, i * 11 + k);
|
|
72
|
+
const len = W * (0.12 + 0.4 * r(0));
|
|
73
|
+
const y = H * r(1);
|
|
74
|
+
const thick = maxW * (0.15 + 0.85 * r(2));
|
|
75
|
+
// 흐름은 끊김 없이(t 에 비례), 굵기·밝기만 끓인다
|
|
76
|
+
const span = W + len;
|
|
77
|
+
const x = ((((r(3) * span - t * speed * (0.7 + 0.6 * r(4))) % span) + span) % span) - len;
|
|
78
|
+
const jitter = rand(seed, f * 977 + i);
|
|
79
|
+
g.globalAlpha = 0.35 + 0.55 * jitter;
|
|
80
|
+
g.beginPath();
|
|
81
|
+
g.moveTo(x, y);
|
|
82
|
+
g.lineTo(x + len, y - thick / 2);
|
|
83
|
+
g.lineTo(x + len, y + thick / 2);
|
|
84
|
+
g.closePath();
|
|
85
|
+
g.fill();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
g.globalAlpha = 1;
|
|
89
|
+
mark("speedLines", o.scene, true);
|
|
90
|
+
};
|
|
91
|
+
}
|