kasaframe 0.0.0-stage → 0.1.3

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.
Files changed (442) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +148 -0
  3. package/README.md +92 -2
  4. package/app/package.json +12 -0
  5. package/app/server/engine.ts +533 -0
  6. package/app/server/main.ts +209 -0
  7. package/app/web/env.d.ts +2 -0
  8. package/app/web/icons.ts +31 -0
  9. package/app/web/index.html +21 -0
  10. package/app/web/main.ts +1195 -0
  11. package/app/web/style.css +463 -0
  12. package/bin/hooks.mjs +64 -0
  13. package/bin/kf.mjs +32 -0
  14. package/docs/AGENTS.md +286 -0
  15. package/music/README.md +37 -0
  16. package/package.json +44 -4
  17. package/packages/adapters/package.json +36 -0
  18. package/packages/adapters/src/css.ts +11 -0
  19. package/packages/adapters/src/gsap.ts +26 -0
  20. package/packages/adapters/src/index.ts +9 -0
  21. package/packages/adapters/src/lottie.ts +22 -0
  22. package/packages/adapters/src/media.ts +59 -0
  23. package/packages/adapters/src/page.ts +229 -0
  24. package/packages/adapters/src/project.ts +214 -0
  25. package/packages/adapters/src/react.ts +36 -0
  26. package/packages/adapters/src/svelte.ts +22 -0
  27. package/packages/adapters/src/three.ts +18 -0
  28. package/packages/adapters/src/vue.ts +27 -0
  29. package/packages/check/package.json +19 -0
  30. package/packages/check/src/check.ts +280 -0
  31. package/packages/check/src/cli.ts +70 -0
  32. package/packages/check/src/image.ts +146 -0
  33. package/packages/check/src/index.ts +9 -0
  34. package/packages/check/src/ocr.swift +37 -0
  35. package/packages/check/src/probe.ts +328 -0
  36. package/packages/check/src/report.ts +44 -0
  37. package/packages/check/src/rules/assets.ts +45 -0
  38. package/packages/check/src/rules/beats.ts +212 -0
  39. package/packages/check/src/rules/camera.ts +217 -0
  40. package/packages/check/src/rules/captions.ts +49 -0
  41. package/packages/check/src/rules/flash.ts +235 -0
  42. package/packages/check/src/rules/frames.ts +136 -0
  43. package/packages/check/src/rules/layout.ts +281 -0
  44. package/packages/check/src/rules/page.ts +87 -0
  45. package/packages/check/src/rules/runs.ts +20 -0
  46. package/packages/check/src/rules/text.ts +326 -0
  47. package/packages/check/src/scan.ts +240 -0
  48. package/packages/check/src/serve.ts +67 -0
  49. package/packages/check/src/types.ts +80 -0
  50. package/packages/check/src/video.ts +137 -0
  51. package/packages/cli/package.json +30 -0
  52. package/packages/cli/src/blur.ts +80 -0
  53. package/packages/cli/src/browser.ts +203 -0
  54. package/packages/cli/src/command.ts +44 -0
  55. package/packages/cli/src/commands/app.ts +25 -0
  56. package/packages/cli/src/commands/beats.ts +36 -0
  57. package/packages/cli/src/commands/bench.ts +123 -0
  58. package/packages/cli/src/commands/blender.ts +293 -0
  59. package/packages/cli/src/commands/check.ts +25 -0
  60. package/packages/cli/src/commands/direct.ts +210 -0
  61. package/packages/cli/src/commands/doctor.ts +30 -0
  62. package/packages/cli/src/commands/gen.ts +173 -0
  63. package/packages/cli/src/commands/look.ts +46 -0
  64. package/packages/cli/src/commands/lyrics.ts +157 -0
  65. package/packages/cli/src/commands/make.ts +1121 -0
  66. package/packages/cli/src/commands/music.ts +78 -0
  67. package/packages/cli/src/commands/narrate.ts +238 -0
  68. package/packages/cli/src/commands/new.ts +185 -0
  69. package/packages/cli/src/commands/preview.ts +43 -0
  70. package/packages/cli/src/commands/render.ts +250 -0
  71. package/packages/cli/src/commands/series.ts +110 -0
  72. package/packages/cli/src/commands/setup.ts +102 -0
  73. package/packages/cli/src/commands/sheet.ts +114 -0
  74. package/packages/cli/src/commands/skill.ts +43 -0
  75. package/packages/cli/src/commands/still.ts +40 -0
  76. package/packages/cli/src/commands/theme.ts +172 -0
  77. package/packages/cli/src/commands/transitions.ts +40 -0
  78. package/packages/cli/src/deps.ts +122 -0
  79. package/packages/cli/src/ffmpeg.ts +81 -0
  80. package/packages/cli/src/index.ts +8 -0
  81. package/packages/cli/src/kf.ts +64 -0
  82. package/packages/cli/src/lock.ts +72 -0
  83. package/packages/cli/src/mix.ts +131 -0
  84. package/packages/cli/src/out.ts +13 -0
  85. package/packages/cli/src/pool.ts +34 -0
  86. package/packages/cli/src/segments.ts +402 -0
  87. package/packages/cli/src/serve.ts +124 -0
  88. package/packages/clock/package.json +14 -0
  89. package/packages/clock/src/index.ts +25 -0
  90. package/packages/clock/src/install.ts +351 -0
  91. package/packages/clock/src/types.ts +45 -0
  92. package/packages/core/package.json +9 -0
  93. package/packages/core/src/beats.ts +283 -0
  94. package/packages/core/src/ease.ts +87 -0
  95. package/packages/core/src/frame.ts +99 -0
  96. package/packages/core/src/index.ts +27 -0
  97. package/packages/core/src/project.ts +157 -0
  98. package/packages/core/src/rand.ts +56 -0
  99. package/packages/core/src/spring.ts +52 -0
  100. package/packages/core/src/style.ts +100 -0
  101. package/packages/core/src/time.ts +88 -0
  102. package/packages/director/package.json +23 -0
  103. package/packages/director/src/assemble.ts +361 -0
  104. package/packages/director/src/brief.ts +122 -0
  105. package/packages/director/src/catalog.ts +49 -0
  106. package/packages/director/src/content.ts +343 -0
  107. package/packages/director/src/fallback.ts +58 -0
  108. package/packages/director/src/index.ts +13 -0
  109. package/packages/director/src/pattern.ts +90 -0
  110. package/packages/director/src/patterns/fill/cells.ts +115 -0
  111. package/packages/director/src/patterns/formula/stack.ts +93 -0
  112. package/packages/director/src/patterns/util.ts +58 -0
  113. package/packages/director/src/scene.ts +62 -0
  114. package/packages/director/src/select.ts +163 -0
  115. package/packages/director/src/transitions.ts +115 -0
  116. package/packages/gen/PROVIDERS.md +90 -0
  117. package/packages/gen/package.json +9 -0
  118. package/packages/gen/src/ask.ts +132 -0
  119. package/packages/gen/src/audio.ts +91 -0
  120. package/packages/gen/src/blender.ts +54 -0
  121. package/packages/gen/src/capabilities.ts +151 -0
  122. package/packages/gen/src/generate.ts +206 -0
  123. package/packages/gen/src/image/codex.ts +117 -0
  124. package/packages/gen/src/image/og.ts +133 -0
  125. package/packages/gen/src/index.ts +26 -0
  126. package/packages/gen/src/keys.ts +86 -0
  127. package/packages/gen/src/media.ts +150 -0
  128. package/packages/gen/src/music/elevenlabs.ts +41 -0
  129. package/packages/gen/src/music/index.ts +120 -0
  130. package/packages/gen/src/music/library.ts +73 -0
  131. package/packages/gen/src/music/lyria.ts +52 -0
  132. package/packages/gen/src/music/types.ts +28 -0
  133. package/packages/gen/src/plan.ts +106 -0
  134. package/packages/gen/src/registry.ts +54 -0
  135. package/packages/gen/src/seam.ts +103 -0
  136. package/packages/gen/src/tts/dashscope.ts +64 -0
  137. package/packages/gen/src/tts/elevenlabs.ts +84 -0
  138. package/packages/gen/src/tts/gemini.ts +73 -0
  139. package/packages/gen/src/tts/index.ts +241 -0
  140. package/packages/gen/src/tts/local.ts +42 -0
  141. package/packages/gen/src/tts/types.ts +44 -0
  142. package/packages/gen/src/types.ts +90 -0
  143. package/packages/gen/src/video/fal.ts +140 -0
  144. package/packages/gen/src/video/h3.ts +112 -0
  145. package/packages/gen/src/video/http.ts +44 -0
  146. package/packages/gen/src/video/ltx.ts +60 -0
  147. package/packages/gen/src/video/minimax.ts +55 -0
  148. package/packages/gen/src/video/veo.ts +71 -0
  149. package/packages/jizura/package.json +16 -0
  150. package/packages/jizura/src/deny.ts +73 -0
  151. package/packages/jizura/src/index.ts +7 -0
  152. package/packages/jizura/src/install.ts +269 -0
  153. package/packages/jizura/src/layer.ts +325 -0
  154. package/packages/jizura/src/lyrics.ts +81 -0
  155. package/packages/jizura/src/pin.ts +8 -0
  156. package/packages/jizura/src/vendor.ts +140 -0
  157. package/packages/jizura/src/vite.ts +63 -0
  158. package/packages/jizura/vendor/JIZURA_LICENSE.txt +21 -0
  159. package/packages/jizura/vendor/NOTICE +43 -0
  160. package/packages/jizura/vendor/engine.json +47 -0
  161. package/packages/jizura/vendor/fonts/BlackHanSans-Regular.woff2 +0 -0
  162. package/packages/jizura/vendor/fonts/DotGothic16-Regular.woff2 +0 -0
  163. package/packages/jizura/vendor/fonts/GowunBatang-Bold.woff2 +0 -0
  164. package/packages/jizura/vendor/fonts/IBMPlexMono-Medium.ttf +0 -0
  165. package/packages/jizura/vendor/fonts/IBMPlexMono-SemiBold.ttf +0 -0
  166. package/packages/jizura/vendor/fonts/NotoSansKR-VF.woff2 +0 -0
  167. package/packages/jizura/vendor/fonts/NotoSerifKR-VF.woff2 +0 -0
  168. package/packages/jizura/vendor/fonts/OFL-blackhansans.txt +93 -0
  169. package/packages/jizura/vendor/fonts/OFL-dotgothic16.txt +93 -0
  170. package/packages/jizura/vendor/fonts/OFL-gowunbatang.txt +94 -0
  171. package/packages/jizura/vendor/fonts/OFL-ibmplexmono.txt +93 -0
  172. package/packages/jizura/vendor/fonts/OFL-notosanskr.txt +93 -0
  173. package/packages/jizura/vendor/fonts/OFL-notoserifkr.txt +94 -0
  174. package/packages/jizura/vendor/fonts/fonts.json +52 -0
  175. package/packages/jizura/vendor/jizura_engine.js +35024 -0
  176. package/packages/motion/README.md +153 -0
  177. package/packages/motion/package.json +30 -0
  178. package/packages/motion/src/camera.ts +97 -0
  179. package/packages/motion/src/captions.ts +487 -0
  180. package/packages/motion/src/enter.ts +128 -0
  181. package/packages/motion/src/hangul.ts +129 -0
  182. package/packages/motion/src/impact.ts +100 -0
  183. package/packages/motion/src/index.ts +17 -0
  184. package/packages/motion/src/moves/brushWipe.ts +103 -0
  185. package/packages/motion/src/moves/cloneArray.ts +111 -0
  186. package/packages/motion/src/moves/curtains.ts +81 -0
  187. package/packages/motion/src/moves/dress.ts +191 -0
  188. package/packages/motion/src/moves/echoStack.ts +70 -0
  189. package/packages/motion/src/moves/fit.ts +70 -0
  190. package/packages/motion/src/moves/flood.ts +61 -0
  191. package/packages/motion/src/moves/ghostStack.ts +88 -0
  192. package/packages/motion/src/moves/gridFloor.ts +100 -0
  193. package/packages/motion/src/moves/imageSwarm.ts +113 -0
  194. package/packages/motion/src/moves/index.ts +38 -0
  195. package/packages/motion/src/moves/irisBlades.ts +113 -0
  196. package/packages/motion/src/moves/karaokeLine.ts +108 -0
  197. package/packages/motion/src/moves/ledBoard.ts +94 -0
  198. package/packages/motion/src/moves/liquidTab.ts +72 -0
  199. package/packages/motion/src/moves/markerWrite.ts +63 -0
  200. package/packages/motion/src/moves/menu.ts +138 -0
  201. package/packages/motion/src/moves/morphBox.ts +96 -0
  202. package/packages/motion/src/moves/neonSign.ts +78 -0
  203. package/packages/motion/src/moves/panelPop.ts +78 -0
  204. package/packages/motion/src/moves/paperTear.ts +75 -0
  205. package/packages/motion/src/moves/path.ts +64 -0
  206. package/packages/motion/src/moves/pathText.ts +107 -0
  207. package/packages/motion/src/moves/pointSphere.ts +109 -0
  208. package/packages/motion/src/moves/ransomLetters.ts +73 -0
  209. package/packages/motion/src/moves/shapeMorph.ts +143 -0
  210. package/packages/motion/src/moves/slamWords.ts +96 -0
  211. package/packages/motion/src/moves/sparkTrail.ts +130 -0
  212. package/packages/motion/src/moves/speedLines.ts +91 -0
  213. package/packages/motion/src/moves/splitFlap.ts +149 -0
  214. package/packages/motion/src/moves/stepWords.ts +128 -0
  215. package/packages/motion/src/moves/strikeOut.ts +98 -0
  216. package/packages/motion/src/moves/sunburst.ts +58 -0
  217. package/packages/motion/src/moves/tickerRows.ts +91 -0
  218. package/packages/motion/src/moves/tokenPicker.ts +115 -0
  219. package/packages/motion/src/moves/truchet.ts +85 -0
  220. package/packages/motion/src/moves/wordWall.ts +78 -0
  221. package/packages/motion/src/moves/worldRoll.ts +32 -0
  222. package/packages/motion/src/particles.ts +102 -0
  223. package/packages/motion/src/react/index.tsx +21 -0
  224. package/packages/motion/src/react/parts.tsx +431 -0
  225. package/packages/motion/src/react/time.tsx +97 -0
  226. package/packages/motion/src/text.ts +103 -0
  227. package/packages/motion/src/transition.ts +82 -0
  228. package/packages/motion/src/transition3d/cards.ts +65 -0
  229. package/packages/motion/src/transition3d/chain.ts +84 -0
  230. package/packages/motion/src/transition3d/dive.ts +181 -0
  231. package/packages/motion/src/transition3d/fold.ts +110 -0
  232. package/packages/motion/src/transition3d/gl.ts +219 -0
  233. package/packages/motion/src/transition3d/index.ts +235 -0
  234. package/packages/motion/src/transition3d/live.ts +70 -0
  235. package/packages/motion/src/transition3d/portal.ts +115 -0
  236. package/packages/motion/src/transition3d/react.tsx +29 -0
  237. package/packages/motion/src/transition3d/rig.ts +600 -0
  238. package/packages/motion/src/transition3d/shatter.ts +104 -0
  239. package/packages/motion/src/transition3d/space.ts +173 -0
  240. package/packages/motion/src/transition3d/whip.ts +78 -0
  241. package/packages/motion/src/transition3d/world.ts +737 -0
  242. package/packages/motion/src/transition3d/zoomOut.ts +114 -0
  243. package/packages/motion/src/transitions2d/catalog.ts +127 -0
  244. package/packages/motion/src/transitions2d/css.d.ts +2 -0
  245. package/packages/motion/src/transitions2d/cult-ui/LICENSE.md +9 -0
  246. package/packages/motion/src/transitions2d/cult-ui/RollingNumber.tsx +43 -0
  247. package/packages/motion/src/transitions2d/gl-transitions/LICENSE +25 -0
  248. package/packages/motion/src/transitions2d/gl-transitions/shaders.ts +1931 -0
  249. package/packages/motion/src/transitions2d/index.ts +2 -0
  250. package/packages/motion/src/transitions2d/kokonutui/LICENSE +21 -0
  251. package/packages/motion/src/transitions2d/kokonutui/MatrixText.css +16 -0
  252. package/packages/motion/src/transitions2d/kokonutui/MatrixText.tsx +94 -0
  253. package/packages/motion/src/transitions2d/magicui/HyperText.css +15 -0
  254. package/packages/motion/src/transitions2d/magicui/HyperText.tsx +115 -0
  255. package/packages/motion/src/transitions2d/magicui/LICENSE.md +21 -0
  256. package/packages/motion/src/transitions2d/magicui/MorphingText.css +25 -0
  257. package/packages/motion/src/transitions2d/magicui/MorphingText.tsx +130 -0
  258. package/packages/motion/src/transitions2d/magicui/WordRotate.tsx +42 -0
  259. package/packages/motion/src/transitions2d/react.ts +13 -0
  260. package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.css +39 -0
  261. package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.tsx +32 -0
  262. package/packages/motion/src/transitions2d/smoothui/LICENSE +21 -0
  263. package/packages/motion/src/transitions2d/smoothui/SharedAxisY.tsx +50 -0
  264. package/packages/motion/src/transitions2d/smoothui/TextMorph.tsx +90 -0
  265. package/packages/motion/src/transitions2d/smoothui/shaders.ts +223 -0
  266. package/packages/motion/src/transitions2d/unlumen/LICENSE +21 -0
  267. package/packages/motion/src/transitions2d/unlumen/ScrambleText.tsx +114 -0
  268. package/packages/motion/src/transitions2d/vengeance-ui/LICENSE +21 -0
  269. package/packages/motion/src/transitions2d/vengeance-ui/MorphText.css +69 -0
  270. package/packages/motion/src/transitions2d/vengeance-ui/MorphText.tsx +45 -0
  271. package/packages/motion/src/type.ts +131 -0
  272. package/packages/motion/src/ui.ts +172 -0
  273. package/packages/patterns/package.json +15 -0
  274. package/packages/patterns/src/bars/rank.ts +119 -0
  275. package/packages/patterns/src/before-after/shrink.ts +127 -0
  276. package/packages/patterns/src/before-after/strike.ts +125 -0
  277. package/packages/patterns/src/code/terminal.ts +133 -0
  278. package/packages/patterns/src/compare/bars.ts +142 -0
  279. package/packages/patterns/src/compare/duel.ts +103 -0
  280. package/packages/patterns/src/end/lockup.ts +85 -0
  281. package/packages/patterns/src/end/slam.ts +91 -0
  282. package/packages/patterns/src/flow/graph.ts +250 -0
  283. package/packages/patterns/src/hook-number/counter.ts +101 -0
  284. package/packages/patterns/src/hook-number/roll.ts +179 -0
  285. package/packages/patterns/src/hook-number/slam.ts +91 -0
  286. package/packages/patterns/src/index.ts +38 -0
  287. package/packages/patterns/src/kit.ts +449 -0
  288. package/packages/patterns/src/limit/gauge.ts +117 -0
  289. package/packages/patterns/src/list/cards.ts +131 -0
  290. package/packages/patterns/src/list/cycle.ts +22 -0
  291. package/packages/patterns/src/media/panels.ts +100 -0
  292. package/packages/patterns/src/objects.ts +234 -0
  293. package/packages/patterns/src/quote/karaoke.ts +126 -0
  294. package/packages/patterns/src/quote/slam.ts +22 -0
  295. package/packages/patterns/src/screen/focus.ts +85 -0
  296. package/packages/patterns/src/steps/path.ts +137 -0
  297. package/packages/patterns/src/steps/stack.ts +111 -0
  298. package/packages/patterns/src/term-reveal/chips.ts +92 -0
  299. package/packages/patterns/src/term-reveal/expand.ts +127 -0
  300. package/packages/patterns/src/timeline/axis.ts +144 -0
  301. package/packages/patterns/src/title/mask.ts +85 -0
  302. package/packages/patterns/src/title/slam.ts +23 -0
  303. package/packages/patterns/src/toggle-sim/switch.ts +92 -0
  304. package/packages/patterns/src/trend/columns.ts +108 -0
  305. package/packages/patterns/src/trend/draw.ts +140 -0
  306. package/packages/patterns/src/types.ts +67 -0
  307. package/packages/patterns/src/words/moves.ts +42 -0
  308. package/packages/patterns/src/words/slam.ts +4 -0
  309. package/packages/plan/package.json +15 -0
  310. package/packages/plan/src/asks.ts +256 -0
  311. package/packages/plan/src/brief.ts +383 -0
  312. package/packages/plan/src/captions.ts +78 -0
  313. package/packages/plan/src/detect.ts +93 -0
  314. package/packages/plan/src/index.ts +27 -0
  315. package/packages/plan/src/layout.ts +176 -0
  316. package/packages/plan/src/llm.ts +172 -0
  317. package/packages/plan/src/look.ts +222 -0
  318. package/packages/plan/src/plan.ts +179 -0
  319. package/packages/plan/src/request.ts +55 -0
  320. package/packages/plan/src/series.ts +76 -0
  321. package/packages/plan/src/studio.ts +53 -0
  322. package/packages/plan/src/templates.ts +42 -0
  323. package/packages/plan/src/themes.ts +48 -0
  324. package/packages/plan/src/types.ts +157 -0
  325. package/packages/studio/package.json +12 -0
  326. package/packages/studio/src/index.ts +1 -0
  327. package/packages/studio/src/plugin.ts +236 -0
  328. package/packages/studio/src/ui/main.ts +503 -0
  329. package/packages/studio/src/ui/studio.css +165 -0
  330. package/packages/studio/src/ui/timeline.ts +317 -0
  331. package/packages/themes/kit/THEME-MAKE.md +68 -0
  332. package/packages/themes/kit/THEME.md +30 -0
  333. package/packages/themes/kit/briefs/og-intro-15s/brief.json +16 -0
  334. package/packages/themes/kit/briefs/og-intro-15s/facts.ts +29 -0
  335. package/packages/themes/kit/briefs/og-intro-15s/logo.svg +12 -0
  336. package/packages/themes/kit/effects.ts +5 -0
  337. package/packages/themes/kit/sample/index.html +11 -0
  338. package/packages/themes/kit/sample/main.ts +9 -0
  339. package/packages/themes/kit/sample/scenes/scene.ts +15 -0
  340. package/packages/themes/package.json +19 -0
  341. package/packages/themes/src/factory.ts +296 -0
  342. package/packages/themes/src/fx.ts +14 -0
  343. package/packages/themes/src/index.ts +114 -0
  344. package/packages/themes/src/slotkit.ts +79 -0
  345. package/packages/themes/src/slots.ts +46 -0
  346. package/packages/themes/src/stage3d.ts +197 -0
  347. package/packages/themes/src/types.ts +58 -0
  348. package/presets/kawaii-pastel.json +94 -0
  349. package/presets/neutral-dark.json +82 -0
  350. package/presets/og.json +98 -0
  351. package/series/og-shorts.json +14 -0
  352. package/skills/kasaframe/SKILL.md +33 -0
  353. package/templates/_shared/project/index.html +11 -0
  354. package/templates/_shared/project/lib/react.ts +22 -0
  355. package/templates/_shared/project/lib/stage.ts +292 -0
  356. package/templates/_shared/project/main.ts +9 -0
  357. package/templates/_shared/scenes/default.ts +21 -0
  358. package/templates/_shared/scenes/drop.ts +33 -0
  359. package/templates/_shared/scenes/end.ts +26 -0
  360. package/templates/_shared/scenes/hook.ts +18 -0
  361. package/templates/_shared/scenes/seam.ts +41 -0
  362. package/templates/_shared/scenes/step.ts +49 -0
  363. package/templates/ad/preview.png +0 -0
  364. package/templates/ad/template.json +151 -0
  365. package/templates/demo/preview.png +0 -0
  366. package/templates/demo/template.json +141 -0
  367. package/templates/explainer/preview.png +0 -0
  368. package/templates/explainer/template.json +193 -0
  369. package/templates/launch/preview.png +0 -0
  370. package/templates/launch/template.json +163 -0
  371. package/templates/mv/preview.png +0 -0
  372. package/templates/mv/scenes/default.ts +98 -0
  373. package/templates/mv/template.json +178 -0
  374. package/templates/promo/preview.png +0 -0
  375. package/templates/promo/template.json +185 -0
  376. package/templates/shorts/preview.png +0 -0
  377. package/templates/shorts/scenes/hook.ts +37 -0
  378. package/templates/shorts/template.json +196 -0
  379. package/templates/square/preview.png +0 -0
  380. package/templates/square/template.json +133 -0
  381. package/themes/debug-hud/THEME.md +39 -0
  382. package/themes/debug-hud/effects.ts +389 -0
  383. package/themes/debug-hud/sample/assets/og/logo.svg +12 -0
  384. package/themes/debug-hud/sample/beats.json +1 -0
  385. package/themes/debug-hud/sample/index.html +11 -0
  386. package/themes/debug-hud/sample/kf.json +59 -0
  387. package/themes/debug-hud/sample/lib/hudkit.ts +49 -0
  388. package/themes/debug-hud/sample/lib/og.ts +29 -0
  389. package/themes/debug-hud/sample/main.ts +9 -0
  390. package/themes/debug-hud/sample/scenes/end.ts +62 -0
  391. package/themes/debug-hud/sample/scenes/gather.ts +67 -0
  392. package/themes/debug-hud/sample/scenes/models.ts +70 -0
  393. package/themes/debug-hud/sample/scenes/price.ts +79 -0
  394. package/themes/debug-hud/sample/style.json +91 -0
  395. package/themes/debug-hud/slots.ts +99 -0
  396. package/themes/debug-hud/still.png +0 -0
  397. package/themes/debug-hud/style.json +91 -0
  398. package/themes/debug-hud/theme.json +68 -0
  399. package/themes/og-measure/THEME.md +47 -0
  400. package/themes/og-measure/effects.ts +432 -0
  401. package/themes/og-measure/sample/assets/brand/og-logo-full.svg +12 -0
  402. package/themes/og-measure/sample/assets/brand/og-logo.svg +12 -0
  403. package/themes/og-measure/sample/assets/data/measure.json +353 -0
  404. package/themes/og-measure/sample/beats.json +1 -0
  405. package/themes/og-measure/sample/index.html +11 -0
  406. package/themes/og-measure/sample/kf.json +66 -0
  407. package/themes/og-measure/sample/lib/data.ts +62 -0
  408. package/themes/og-measure/sample/main.ts +9 -0
  409. package/themes/og-measure/sample/measure.ts +78 -0
  410. package/themes/og-measure/sample/scenes/end.ts +47 -0
  411. package/themes/og-measure/sample/scenes/gather.ts +51 -0
  412. package/themes/og-measure/sample/scenes/models.ts +34 -0
  413. package/themes/og-measure/sample/scenes/one.ts +39 -0
  414. package/themes/og-measure/sample/scenes/price.ts +56 -0
  415. package/themes/og-measure/sample/style.json +97 -0
  416. package/themes/og-measure/slots.ts +88 -0
  417. package/themes/og-measure/still.png +0 -0
  418. package/themes/og-measure/style.json +97 -0
  419. package/themes/og-measure/theme.json +79 -0
  420. package/themes/riso-zine/THEME.md +43 -0
  421. package/themes/riso-zine/effects.ts +321 -0
  422. package/themes/riso-zine/sample/assets/og/logo.svg +12 -0
  423. package/themes/riso-zine/sample/beats.json +1 -0
  424. package/themes/riso-zine/sample/index.html +11 -0
  425. package/themes/riso-zine/sample/kf.json +59 -0
  426. package/themes/riso-zine/sample/lib/og.ts +29 -0
  427. package/themes/riso-zine/sample/lib/shot.ts +86 -0
  428. package/themes/riso-zine/sample/lib/zine.ts +42 -0
  429. package/themes/riso-zine/sample/main.ts +9 -0
  430. package/themes/riso-zine/sample/scenes/end.ts +61 -0
  431. package/themes/riso-zine/sample/scenes/gather.ts +62 -0
  432. package/themes/riso-zine/sample/scenes/models.ts +52 -0
  433. package/themes/riso-zine/sample/scenes/price.ts +82 -0
  434. package/themes/riso-zine/sample/style.json +99 -0
  435. package/themes/riso-zine/slots.ts +81 -0
  436. package/themes/riso-zine/still.png +0 -0
  437. package/themes/riso-zine/style.json +99 -0
  438. package/themes/riso-zine/theme.json +75 -0
  439. package/tools/beats/beats.py +372 -0
  440. package/tools/beats/requirements.txt +3 -0
  441. package/tools/lyrics/align.py +164 -0
  442. package/tools/lyrics/requirements.txt +9 -0
@@ -0,0 +1,129 @@
1
+ /** 두벌식 자판 기준 한글 조합. 타자 움직임이 키 하나마다 화면에 보일 글자를 만든다 */
2
+
3
+ const S_BASE = 0xac00;
4
+ const S_END = 0xd7a3;
5
+ const V_COUNT = 21;
6
+ const T_COUNT = 28;
7
+
8
+ export const INITIALS = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ";
9
+ export const VOWELS = "ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ";
10
+ /** 0 번은 받침 없음 */
11
+ export const FINALS = " ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ";
12
+
13
+ /** 두 키로 치는 겹모음 */
14
+ const VOWEL_PARTS: Record<string, [string, string]> = {
15
+ ㅘ: ["ㅗ", "ㅏ"],
16
+ ㅙ: ["ㅗ", "ㅐ"],
17
+ ㅚ: ["ㅗ", "ㅣ"],
18
+ ㅝ: ["ㅜ", "ㅓ"],
19
+ ㅞ: ["ㅜ", "ㅔ"],
20
+ ㅟ: ["ㅜ", "ㅣ"],
21
+ ㅢ: ["ㅡ", "ㅣ"],
22
+ };
23
+
24
+ /** 두 키로 치는 겹받침 */
25
+ const FINAL_PARTS: Record<string, [string, string]> = {
26
+ ㄳ: ["ㄱ", "ㅅ"],
27
+ ㄵ: ["ㄴ", "ㅈ"],
28
+ ㄶ: ["ㄴ", "ㅎ"],
29
+ ㄺ: ["ㄹ", "ㄱ"],
30
+ ㄻ: ["ㄹ", "ㅁ"],
31
+ ㄼ: ["ㄹ", "ㅂ"],
32
+ ㄽ: ["ㄹ", "ㅅ"],
33
+ ㄾ: ["ㄹ", "ㅌ"],
34
+ ㄿ: ["ㄹ", "ㅍ"],
35
+ ㅀ: ["ㄹ", "ㅎ"],
36
+ ㅄ: ["ㅂ", "ㅅ"],
37
+ };
38
+
39
+ const COMBINE_FINAL: Record<string, string> = Object.fromEntries(
40
+ Object.entries(FINAL_PARTS).map(([whole, [a, b]]) => [a + b, whole]),
41
+ );
42
+
43
+ export interface Syllable {
44
+ /** 초성·중성·종성 호환 자모. 받침 없으면 final 은 "" */
45
+ initial: string;
46
+ vowel: string;
47
+ final: string;
48
+ }
49
+
50
+ export const isSyllable = (ch: string): boolean => {
51
+ const c = ch.codePointAt(0) ?? 0;
52
+ return ch.length === 1 && c >= S_BASE && c <= S_END;
53
+ };
54
+
55
+ export function decompose(ch: string): Syllable | null {
56
+ if (!isSyllable(ch)) return null;
57
+ const s = ch.charCodeAt(0) - S_BASE;
58
+ const t = s % T_COUNT;
59
+ const v = ((s - t) / T_COUNT) % V_COUNT;
60
+ const l = Math.floor(s / (V_COUNT * T_COUNT));
61
+ return { initial: INITIALS[l], vowel: VOWELS[v], final: t === 0 ? "" : FINALS[t] };
62
+ }
63
+
64
+ /** 모르는 자모가 오면 null — 호출하는 쪽이 원래 글자를 그대로 쓴다(undefined 가 화면에 새지 않게) */
65
+ export function compose(initial: string, vowel: string, final = ""): string | null {
66
+ const l = INITIALS.indexOf(initial);
67
+ const v = VOWELS.indexOf(vowel);
68
+ const t = final === "" ? 0 : FINALS.indexOf(final);
69
+ if (l < 0 || v < 0 || t < 0 || (final !== "" && t === 0)) return null;
70
+ return String.fromCharCode(S_BASE + (l * V_COUNT + v) * T_COUNT + t);
71
+ }
72
+
73
+ /** ㄸ·ㅃ·ㅉ 는 받침이 될 수 없다 */
74
+ export const canBeFinal = (consonant: string): boolean => consonant !== " " && FINALS.includes(consonant);
75
+
76
+ /** 받침 + 다음 초성이 겹받침이 되는가 — 두벌식 입력기의 도깨비불 */
77
+ export const joinFinal = (final: string, next: string): string | null => COMBINE_FINAL[final + next] ?? null;
78
+
79
+ /** 한 음절을 칠 때 키마다 보이는 모양. 「닭」→ ㄷ, 다, 달, 닭 */
80
+ export function syllableSteps(ch: string): string[] {
81
+ const d = decompose(ch);
82
+ if (!d) return [ch];
83
+ const steps: string[] = [d.initial];
84
+ const vp = VOWEL_PARTS[d.vowel];
85
+ if (vp) steps.push(compose(d.initial, vp[0]) ?? ch);
86
+ steps.push(compose(d.initial, d.vowel) ?? ch);
87
+ if (d.final) {
88
+ const fp = FINAL_PARTS[d.final];
89
+ if (fp) steps.push(compose(d.initial, d.vowel, fp[0]) ?? ch);
90
+ steps.push(ch);
91
+ }
92
+ return steps;
93
+ }
94
+
95
+ /**
96
+ * 글 전체를 칠 때 키마다 보이는 화면 글. 0 번은 빈 글, 마지막은 원문 그대로.
97
+ * ime 면 다음 음절 초성이 앞 음절 받침으로 먼저 붙었다가(가 → 간 → 가나) 모음이 오면 떨어진다 — 실제 입력기가 그렇다.
98
+ */
99
+ export function typingFrames(text: string, opts: { ime?: boolean } = {}): string[] {
100
+ const ime = opts.ime ?? true;
101
+ const chars = Array.from(text);
102
+ const frames: string[] = [""];
103
+ let done = "";
104
+ for (let i = 0; i < chars.length; i++) {
105
+ const ch = chars[i];
106
+ const steps = syllableSteps(ch);
107
+ const prev = i > 0 ? decompose(chars[i - 1]) : null;
108
+ const cur = decompose(ch);
109
+ for (let k = 0; k < steps.length; k++) {
110
+ if (k === 0 && ime && prev && cur) {
111
+ const carry = carryForm(prev, cur.initial);
112
+ if (carry) {
113
+ frames.push(done.slice(0, done.length - chars[i - 1].length) + carry);
114
+ continue;
115
+ }
116
+ }
117
+ frames.push(done + steps[k]);
118
+ }
119
+ done += ch;
120
+ }
121
+ if (frames[frames.length - 1] !== text) frames.push(text);
122
+ return frames;
123
+ }
124
+
125
+ function carryForm(prev: Syllable, consonant: string): string | null {
126
+ if (prev.final === "") return canBeFinal(consonant) ? compose(prev.initial, prev.vowel, consonant) : null;
127
+ const joined = joinFinal(prev.final, consonant);
128
+ return joined ? compose(prev.initial, prev.vowel, joined) : null;
129
+ }
@@ -0,0 +1,100 @@
1
+ import { clamp, emit, noise1, progress, toEase, type Beats, type MotionRules, type PulseOpts, type Style, safeTime } from "@kasaframe/core";
2
+
3
+ interface Tagged {
4
+ source?: string;
5
+ scene?: string;
6
+ emit?: boolean;
7
+ }
8
+
9
+ export interface ShakeOpts extends Tagged {
10
+ at: number;
11
+ dur?: number;
12
+ /** 최대 흔들림(px). rules 가 있으면 rules.shake.maxPx 를 넘지 않는다 */
13
+ px?: number;
14
+ /** 초당 흔들림 */
15
+ freq?: number;
16
+ seed?: number | string;
17
+ rules?: MotionRules;
18
+ }
19
+
20
+ /** 감쇠하는 흔들림. 잡음은 시드 고정이라 탭마다 같은 궤적 */
21
+ export function shake(t: number, opts: ShakeOpts): Style {
22
+ t = safeTime(t);
23
+ const dur = opts.dur ?? 0.45;
24
+ const local = t - opts.at;
25
+ if (local < 0 || local >= dur) return {};
26
+ const max = opts.rules ? Math.min(opts.px ?? opts.rules.shake.maxPx, opts.rules.shake.maxPx) : (opts.px ?? 12);
27
+ const amp = max * (1 - local / dur) ** 2;
28
+ const f = opts.freq ?? 26;
29
+ const seed = opts.seed ?? opts.source ?? "shake";
30
+ const x = noise1(`${seed}x`, local * f) * amp;
31
+ const y = noise1(`${seed}y`, local * f) * amp * 0.7;
32
+ if (opts.emit !== false) emit({ kind: "shake", source: opts.source ?? "shake", scene: opts.scene, value: amp });
33
+ return { x, y, rotate: noise1(`${seed}r`, local * f * 0.6) * amp * 0.04 };
34
+ }
35
+
36
+ export interface DropBurstOpts extends Tagged {
37
+ /** 드롭 시각. beats·drop 을 주면 거기서 잰 시각을 쓴다 — 드롭 아닌 곳에서 터지지 않게 */
38
+ at?: number;
39
+ beats?: Beats;
40
+ drop?: number;
41
+ px?: number;
42
+ rules?: MotionRules;
43
+ seed?: number | string;
44
+ }
45
+
46
+ export interface DropBurstState {
47
+ /** 흰 섬광 덮개의 불투명도 0..1 */
48
+ flash: number;
49
+ /** 충격파 고리 — 지름 배율과 불투명도 */
50
+ ring: { scale: number; opacity: number };
51
+ /** 화면 전체(카메라 틀)에 줄 흔들림 */
52
+ shake: Style;
53
+ /** 내용에 줄 한 번 튐 */
54
+ punch: Style;
55
+ p: number;
56
+ }
57
+
58
+ export function dropBurst(t: number, opts: DropBurstOpts): DropBurstState {
59
+ t = safeTime(t);
60
+ const at = opts.beats && opts.drop !== undefined ? opts.beats.drop(opts.drop) : opts.at;
61
+ if (at === undefined || !Number.isFinite(at)) throw new Error("dropBurst: at 이나 beats·drop 을 준다");
62
+ const source = opts.source ?? "dropBurst";
63
+ const local = t - at;
64
+ const p = progress(t, at, 0.9);
65
+ const flash = local < 0 ? 0 : local < 0.04 ? 1 : clamp(1 - (local - 0.04) / 0.22) ** 2;
66
+ if (opts.emit !== false) emit({ kind: "flash", source, scene: opts.scene, value: flash });
67
+ const rp = toEase("outCubic")(progress(t, at, 0.7));
68
+ const ring = local < 0 ? { scale: 0, opacity: 0 } : { scale: 0.2 + 2.6 * rp, opacity: (1 - rp) * 0.9 };
69
+ const kick = local < 0 ? 0 : Math.exp(-local / 0.12) * Math.cos(local * 28);
70
+ return {
71
+ flash,
72
+ ring,
73
+ shake: shake(t, { at, px: opts.px, rules: opts.rules, seed: opts.seed ?? source, source, scene: opts.scene, emit: opts.emit }),
74
+ punch: local < 0 || local > 0.8 ? {} : { scale: 1 + 0.08 * kick },
75
+ p,
76
+ };
77
+ }
78
+
79
+ export interface BeatPulseOpts extends PulseOpts {
80
+ beats: Beats;
81
+ /** 박에서 커지는 정도 */
82
+ amount?: number;
83
+ rules?: MotionRules;
84
+ }
85
+
86
+ /** 박 펄스 — style.json 의 beatPulse 를 따른다. 기본(drops-only)이면 드롭 구간 밖에선 늘 그대로 */
87
+ export function beatPulse(t: number, opts: BeatPulseOpts): Style & { v: number } {
88
+ t = safeTime(t);
89
+ const rule = opts.rules?.beatPulse ?? "drops-only";
90
+ if (rule === "off") return { v: 0 };
91
+ const v = opts.beats.pulse(t, {
92
+ every: opts.every ?? (rule === "downbeats" ? "downbeat" : "beat"),
93
+ decay: opts.decay,
94
+ within: opts.within ?? (rule === "drops-only" ? "drops" : "all"),
95
+ source: opts.source ?? "beatPulse",
96
+ scene: opts.scene,
97
+ emit: opts.emit,
98
+ });
99
+ return { v, scale: 1 + (opts.amount ?? 0.05) * v };
100
+ }
@@ -0,0 +1,17 @@
1
+ export { compose, decompose, isSyllable, syllableSteps, typingFrames } from "./hangul.ts";
2
+ export { typeText, typeLines, typeDuration } from "./type.ts";
3
+ export type { TypeOpts, TypeState } from "./type.ts";
4
+ export { enter, exit, inOut, stagger, MOVES } from "./enter.ts";
5
+ export type { MoveName, MoveOpts, Side, StaggerOpts } from "./enter.ts";
6
+ export { counter, sweep, words, letters } from "./text.ts";
7
+ export type { CounterOpts, SweepOpts, WordState } from "./text.ts";
8
+ export { transition, TRANSITIONS } from "./transition.ts";
9
+ export type { TransitionName, TransitionOpts, TransitionState } from "./transition.ts";
10
+ export { shake, dropBurst, beatPulse } from "./impact.ts";
11
+ export type { ShakeOpts, DropBurstOpts, DropBurstState, BeatPulseOpts } from "./impact.ts";
12
+ export { camera, breathe, flyPath } from "./camera.ts";
13
+ export type { CameraOpts, BreatheOpts, FlyKey, Vec3 } from "./camera.ts";
14
+ export { sparkles, burst } from "./particles.ts";
15
+ export type { Particle, SparkleOpts, BurstOpts } from "./particles.ts";
16
+ export { cursor, grow, draw, codeReveal, terminal, safeText } from "./ui.ts";
17
+ export type { CursorKey, CursorState, CodeState, TermStep, TermLine, TermState } from "./ui.ts";
@@ -0,0 +1,103 @@
1
+ import { clamp, ease, noise1, rand, safeTime } from "@kasaframe/core";
2
+ import { mark } from "./fit.ts";
3
+
4
+ export interface BrushWipeOpts {
5
+ /** 덮기 시작 시각 — at + dur/2 에 화면이 다 덮인다(그때 장면을 바꾼다) */
6
+ at: number;
7
+ dur?: number;
8
+ /** 붓 획(띠) 수 */
9
+ strokes?: number;
10
+ color?: string;
11
+ /** 띠 기울기(도) */
12
+ angle?: number;
13
+ seed?: string | number;
14
+ w?: number;
15
+ h?: number;
16
+ scene?: string;
17
+ }
18
+
19
+ /**
20
+ * 붓 획 덮기 — 굵은 붓 띠 몇 줄이 번갈아(홀짝 반대 방향) 화면을 덮고, 같은 방향으로 꼬리가 빠지며 걷힌다. 머리·꼬리는 시드 잡음으로
21
+ * 거칠고 띠 안엔 마른 붓 줄무늬. 다 덮인 at + dur/2 에 뒤 장면을 바꾼다. (OtherReality p(doom) 38.3–38.8초)
22
+ */
23
+ export function brushWipe(el: HTMLElement, o: BrushWipeOpts): (t: number) => void {
24
+ const doc = el.ownerDocument;
25
+ const W = o.w ?? 1920;
26
+ const H = o.h ?? 1080;
27
+ const canvas = doc.createElement("canvas");
28
+ canvas.width = W;
29
+ canvas.height = H;
30
+ canvas.style.cssText = `position:absolute;left:0;top:0;width:${W}px;height:${H}px;pointer-events:none;z-index:50`;
31
+ el.append(canvas);
32
+ const g = canvas.getContext("2d")!;
33
+ const n = o.strokes ?? 5;
34
+ const dur = o.dur ?? 0.8;
35
+ const seed = o.seed ?? "brush";
36
+ const color = o.color ?? "#5b3fd9";
37
+ const D = Math.hypot(W, H) * 1.08;
38
+ const bandH = (D / n) * 1.18;
39
+ const L = D * 1.2;
40
+ const cover = dur * 0.36;
41
+ const lag = (dur * 0.5 - cover) / Math.max(1, n - 1);
42
+ const angle = ((o.angle ?? -7) * Math.PI) / 180;
43
+ return (t: number) => {
44
+ t = safeTime(t);
45
+ g.clearRect(0, 0, W, H);
46
+ if (t < o.at || t > o.at + dur + 0.05) {
47
+ mark("brushWipe", o.scene, false);
48
+ return;
49
+ }
50
+ g.save();
51
+ g.translate(W / 2, H / 2);
52
+ g.rotate(angle);
53
+ for (let j = 0; j < n; j++) {
54
+ const head = ease.inOutCubic(clamp((t - o.at - j * lag) / cover));
55
+ const tail = ease.inOutCubic(clamp((t - o.at - dur * 0.5 - j * lag) / cover));
56
+ if (head <= 0 || tail >= 1) continue;
57
+ const dir = j % 2 ? -1 : 1;
58
+ const yc = -D / 2 + (j + 0.5) * (D / n);
59
+ const steps = 24;
60
+ const edge = (p: number, side: number, k: number) => {
61
+ // 붓 끝의 들쭉날쭉 — 띠 높이를 따라 잡음, 끝 근처 털은 더 길게
62
+ const yy = k / steps;
63
+ const jag = (noise1(`${seed}:${j}:${side}`, yy * 6) - 0.5) * 70 + (rand(seed, j * 1000 + side * 100 + k) - 0.5) * 26;
64
+ return dir * (-L / 2 + L * p) + dir * jag * (p > 0 && p < 1 ? 1 : 0);
65
+ };
66
+ g.fillStyle = color;
67
+ g.globalAlpha = 1;
68
+ g.beginPath();
69
+ for (let k = 0; k <= steps; k++) g.lineTo(edge(head, 0, k), yc - bandH / 2 + (bandH * k) / steps);
70
+ for (let k = steps; k >= 0; k--) g.lineTo(edge(tail, 1, k), yc - bandH / 2 + (bandH * k) / steps);
71
+ g.closePath();
72
+ g.fill();
73
+ // 마른 붓 줄무늬 — 띠 안에서 밝은 결 몇 줄
74
+ // 결은 옅게 — 진하면 띠가 지나는 동안 칸마다 밝음·어둠이 오가 섬광 검사(frame.flash)에 걸린다
75
+ g.globalAlpha = 0.07;
76
+ g.fillStyle = "#ffffff";
77
+ const a = Math.min(edge(head, 0, 12), edge(tail, 1, 12));
78
+ const b = Math.max(edge(head, 0, 12), edge(tail, 1, 12));
79
+ for (let s = 0; s < 9; s++) {
80
+ const r = (k: number) => rand(seed, j * 97 + s * 7 + k);
81
+ const y = yc - bandH / 2 + bandH * (0.08 + 0.84 * r(0));
82
+ const x0 = a + (b - a) * r(1) * 0.4;
83
+ const x1 = b - (b - a) * r(2) * 0.4;
84
+ g.fillRect(Math.min(x0, x1), y, Math.abs(x1 - x0), 2 + 5 * r(3));
85
+ }
86
+ }
87
+ // 다 덮인 동안 광택 한 줄이 띠를 따라 휙 지난다 — 한 색으로 덮인 화면이 0.1초 넘게 서 있으면 멈춤(frame.freeze)으로 잡힌다
88
+ const sp = clamp((t - o.at - dur * 0.22) / (dur * 0.56));
89
+ if (sp > 0 && sp < 1) {
90
+ const x = -D / 2 + D * sp;
91
+ const gr = g.createLinearGradient(x - D * 0.12, 0, x + D * 0.12, 0);
92
+ gr.addColorStop(0, "rgba(255,255,255,0)");
93
+ gr.addColorStop(0.5, "rgba(255,255,255,.14)");
94
+ gr.addColorStop(1, "rgba(255,255,255,0)");
95
+ g.globalAlpha = 1;
96
+ g.fillStyle = gr;
97
+ g.fillRect(x - D * 0.12, -D / 2, D * 0.24, D);
98
+ }
99
+ g.restore();
100
+ g.globalAlpha = 1;
101
+ mark("brushWipe", o.scene, true);
102
+ };
103
+ }
@@ -0,0 +1,111 @@
1
+ import { rand, safeTime } from "@kasaframe/core";
2
+ import { div, lastIndex, mark } from "./fit.ts";
3
+ import { springSteps } from "./liquidTab.ts";
4
+
5
+ export interface CloneArrayOpts {
6
+ /** 수가 두 배가 되는 시각들 — 처음엔 하나, 박마다 1→2→4→8… */
7
+ hits: number[];
8
+ /** 하나를 짓는다(복제마다 한 번씩, i 는 복제 번호). (t) => void 를 돌려주면 장면 초로 칠한다 */
9
+ build: (el: HTMLElement, i: number) => ((t: number) => void) | void;
10
+ /** 하나의 원래 크기(px) — 처음 한 개일 때 이 크기 */
11
+ item: { w: number; h: number };
12
+ /** 최대 개수 — 넘으면 더 늘지 않는다 */
13
+ max?: number;
14
+ /** 바깥 복제가 작아지고 흐려지는 정도(0–1) */
15
+ falloff?: number;
16
+ /** 화면에서 쓰는 몫 */
17
+ share?: number;
18
+ x?: number;
19
+ y?: number;
20
+ stiffness?: number;
21
+ damping?: number;
22
+ w?: number;
23
+ h?: number;
24
+ scene?: string;
25
+ }
26
+
27
+ /**
28
+ * 복제가 줄지어 늘어난다 — 박마다 수가 두 배, 새 복제는 부모 자리에서 튀어나와 격자의 바깥 칸으로 스프링을 타고 간다.
29
+ * 칸은 가운데에서 가까운 차례로 채워 바깥일수록 작고 흐리다. (Escape Velocity 115.5–116.5초 · mexicat 1→2→4→8)
30
+ */
31
+ export function cloneArray(el: HTMLElement, o: CloneArrayOpts): (t: number) => void {
32
+ const doc = el.ownerDocument;
33
+ const W = o.w ?? 1920;
34
+ const H = o.h ?? 1080;
35
+ const cx = o.x ?? W / 2;
36
+ const cy = o.y ?? H / 2;
37
+ const max = o.max ?? 64;
38
+ const share = o.share ?? 0.9;
39
+ const fall = o.falloff ?? 0.45;
40
+ const counts = [1];
41
+ for (const _ of o.hits) counts.push(Math.min(max, counts[counts.length - 1] * 2));
42
+ // 개수마다 격자 — 가로를 더 넓게, 칸은 가운데에서 가까운 차례
43
+ const layouts = counts.map((n) => {
44
+ let cols = 1;
45
+ while (cols * Math.ceil(n / cols) < n || (cols / Math.ceil(n / cols)) * (o.item.w / o.item.h) < W / H) {
46
+ if (cols >= n) break;
47
+ cols++;
48
+ }
49
+ const rows = Math.ceil(n / cols);
50
+ const cell = Math.min((W * share) / cols / o.item.w, (H * share) / rows / o.item.h, 1);
51
+ const slots: { x: number; y: number; d: number }[] = [];
52
+ for (let r = 0; r < rows; r++)
53
+ for (let c = 0; c < cols; c++) {
54
+ const x = cx + (c - (cols - 1) / 2) * o.item.w * cell;
55
+ const y = cy + (r - (rows - 1) / 2) * o.item.h * cell;
56
+ slots.push({ x, y, d: Math.hypot((x - cx) / W, (y - cy) / H) });
57
+ }
58
+ slots.sort((a, b) => a.d - b.d || a.x - b.x || a.y - b.y);
59
+ const far = Math.max(1e-6, slots[n - 1].d);
60
+ return { cell, slots: slots.slice(0, n).map((s) => ({ ...s, k: s.d / far })) };
61
+ });
62
+ const total = counts[counts.length - 1];
63
+ const sp = { stiffness: o.stiffness ?? 240, damping: o.damping ?? 20 };
64
+ const clones = Array.from({ length: total }, (_, i) => {
65
+ const box = div(doc, `position:absolute;left:0;top:0;width:${o.item.w}px;height:${o.item.h}px;transform-origin:50% 50%;will-change:transform`);
66
+ const inner = div(doc, "position:absolute;inset:0");
67
+ box.append(inner);
68
+ el.append(box);
69
+ const paint = o.build(inner, i) ?? null;
70
+ // 몇 번째 박에 태어나나 — 그 박 전 개수의 자리(i - 전 개수)가 부모
71
+ const born = counts.findIndex((n) => n > i);
72
+ const parent = born > 0 ? i - counts[born - 1] : 0;
73
+ return { box, paint, born, parent, phase: rand("clone", i) * 6.28 };
74
+ });
75
+ type Key = "x" | "y" | "s" | "a";
76
+ const valAt = (i: number, key: Key, lv: number): number => {
77
+ const L = layouts[lv];
78
+ const s = L.slots[i];
79
+ if (key === "x") return s.x;
80
+ if (key === "y") return s.y;
81
+ if (key === "s") return L.cell * (1 - fall * s.k * 0.6);
82
+ return 1 - fall * s.k;
83
+ };
84
+ const track = (i: number, key: Key) => {
85
+ const c = clones[i];
86
+ const steps = [];
87
+ for (let lv = Math.max(1, c.born); lv < layouts.length; lv++) steps.push({ at: o.hits[lv - 1], to: valAt(i, key, lv) });
88
+ // 태어날 때는 부모의 그 박 직전 자리에서 출발
89
+ return { steps, from: valAt(c.born > 0 ? c.parent : i, key, Math.max(0, c.born - 1)) };
90
+ };
91
+ const tracks = clones.map((_, i) => ({ x: track(i, "x"), y: track(i, "y"), s: track(i, "s"), a: track(i, "a") }));
92
+ return (t: number) => {
93
+ t = safeTime(t);
94
+ const lv = lastIndex(o.hits, t) + 1;
95
+ clones.forEach((c, i) => {
96
+ if (c.born > lv) {
97
+ c.box.style.visibility = "hidden";
98
+ return;
99
+ }
100
+ c.box.style.visibility = "visible";
101
+ const v = (k: Key) => springSteps(t, tracks[i][k].steps, { from: tracks[i][k].from, ...sp });
102
+ // 자리 잡은 복제도 조금씩 숨 쉰다 — 같은 꼴이 여럿이면 가만할 때 화면이 굳어 보인다
103
+ const bob = Math.sin(t * 3.1 + c.phase) * 4 * v("s");
104
+ c.box.style.opacity = Math.max(0, Math.min(1, v("a"))).toFixed(3);
105
+ c.box.style.transform = `translate(${(v("x") - o.item.w / 2).toFixed(1)}px, ${(v("y") - o.item.h / 2 + bob).toFixed(1)}px) scale(${Math.max(0.01, v("s")).toFixed(4)})`;
106
+ c.box.style.zIndex = String(total - i);
107
+ if (c.paint) c.paint(t);
108
+ });
109
+ mark("cloneArray", o.scene, lv > 0 && t < o.hits[lv - 1] + 0.4);
110
+ };
111
+ }
@@ -0,0 +1,81 @@
1
+ import { safeTime } from "@kasaframe/core";
2
+ import { div, mark } from "./fit.ts";
3
+ import { springSteps } from "./liquidTab.ts";
4
+
5
+ export interface CurtainsOpts {
6
+ /** 열림 정도(0 닫힘 … 1 열림)가 바뀌는 시각 */
7
+ steps: { at: number; open: number }[];
8
+ color?: string;
9
+ /** 주름 하나 너비(px) */
10
+ fold?: number;
11
+ /** 위 가림막(물결 테두리) — false 면 없음 */
12
+ valance?: boolean;
13
+ trim?: string;
14
+ stiffness?: number;
15
+ damping?: number;
16
+ w?: number;
17
+ h?: number;
18
+ scene?: string;
19
+ }
20
+
21
+ /**
22
+ * 무대 막 — 두 폭이 바깥으로 모이며(주름이 좁아진다) 열리고, 안쪽 가장자리는 묶인 자리(높이 62%)에서 잘록하게 휜다.
23
+ * 주름은 늘 조금 흔들린다. 처음·끝을 감싸는 데. (Heibel 1·155초 · Retro Pixel 1·157초)
24
+ */
25
+ export function curtains(el: HTMLElement, o: CurtainsOpts): (t: number) => void {
26
+ const doc = el.ownerDocument;
27
+ const W = o.w ?? 1920;
28
+ const H = o.h ?? 1080;
29
+ const color = o.color ?? "#b3122a";
30
+ const fold = o.fold ?? 70;
31
+ const trim = o.trim ?? "#e2b54a";
32
+ const hw = W / 2 + 40;
33
+ const sp = { stiffness: o.stiffness ?? 90, damping: o.damping ?? 16 };
34
+ // 주름 — 어두운 골과 밝은 등성이를 되풀이, 위는 더 어둡게
35
+ const velvet =
36
+ `linear-gradient(180deg, rgba(0,0,0,.45) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 80%, rgba(0,0,0,.35) 100%),` +
37
+ `repeating-linear-gradient(90deg, color-mix(in srgb, ${color} 55%, black) 0px, ${color} ${fold * 0.3}px, color-mix(in srgb, ${color} 75%, white) ${fold * 0.5}px, ${color} ${fold * 0.7}px, color-mix(in srgb, ${color} 55%, black) ${fold}px)`;
38
+ const halves = ([-1, 1] as const).map((side) => {
39
+ const part = div(
40
+ doc,
41
+ `position:absolute;top:0;${side < 0 ? "left" : "right"}:0;width:${hw}px;height:${H}px;background:${velvet};` +
42
+ `border-bottom:14px solid ${trim};box-sizing:border-box;transform-origin:${side < 0 ? "0%" : "100%"} 0%;z-index:60`,
43
+ );
44
+ el.append(part);
45
+ return { side, part };
46
+ });
47
+ if (o.valance !== false) {
48
+ const vh = H * 0.11;
49
+ const scallop = vh * 0.9;
50
+ const top = div(
51
+ doc,
52
+ `position:absolute;left:0;top:0;width:${W}px;height:${vh + scallop / 2}px;z-index:61;` +
53
+ `background:linear-gradient(180deg, color-mix(in srgb, ${color} 60%, black), ${color});` +
54
+ `-webkit-mask:radial-gradient(${scallop / 2}px at 50% ${vh}px, #000 98%, transparent) 0 0/${scallop}px 100%, linear-gradient(#000,#000) 0 0/100% ${vh}px no-repeat;` +
55
+ `mask:radial-gradient(${scallop / 2}px at 50% ${vh}px, #000 98%, transparent) 0 0/${scallop}px 100%, linear-gradient(#000,#000) 0 0/100% ${vh}px no-repeat`,
56
+ );
57
+ el.append(top);
58
+ }
59
+ const pts = 28;
60
+ return (t: number) => {
61
+ t = safeTime(t);
62
+ const p = Math.max(0, Math.min(1.05, springSteps(t, o.steps.map((s) => ({ at: s.at, to: s.open })), { from: o.steps[0]?.open ?? 0, ...sp })));
63
+ for (const { side, part } of halves) {
64
+ const sway = Math.sin(t * 1.7 + side) * 0.6;
65
+ // 열수록 폭이 모여 좁아진다 — 너비는 그대로 두고 scaleX 로 접어야 주름도 같이 좁아진다
66
+ const gather = 1 - 0.8 * p;
67
+ part.style.transform = `scaleX(${gather.toFixed(4)}) skewX(${(sway * (1 - p * 0.5)).toFixed(3)}deg)`;
68
+ const inner = side < 0 ? hw : 0;
69
+ const outer = side < 0 ? 0 : hw;
70
+ const edge: string[] = [];
71
+ for (let k = 0; k <= pts; k++) {
72
+ const y = (k / pts) * H;
73
+ const tie = Math.exp(-(((y / H - 0.62) / 0.3) ** 2));
74
+ // 안쪽 가장자리를 바깥으로 당긴다 — 묶인 높이에서 가장 많이
75
+ edge.push(`${(inner + side * hw * 0.55 * p * tie).toFixed(1)}px ${y.toFixed(1)}px`);
76
+ }
77
+ part.style.clipPath = `polygon(${outer}px 0px, ${edge.join(", ")}, ${outer}px ${H}px)`;
78
+ }
79
+ mark("curtains", o.scene, o.steps.some((s) => t >= s.at && t < s.at + 0.6));
80
+ };
81
+ }