@dopaminefx/effect-comic 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/comic-fonts.d.ts +18 -0
- package/dist/comic-fonts.d.ts.map +1 -0
- package/dist/comic-fonts.js +16 -0
- package/dist/comic-fonts.js.map +1 -0
- package/dist/comic-params.d.ts +77 -0
- package/dist/comic-params.d.ts.map +1 -0
- package/dist/comic-params.js +31 -0
- package/dist/comic-params.js.map +1 -0
- package/dist/comic-renderer.d.ts +32 -0
- package/dist/comic-renderer.d.ts.map +1 -0
- package/dist/comic-renderer.js +299 -0
- package/dist/comic-renderer.js.map +1 -0
- package/dist/comic-shader.d.ts +30 -0
- package/dist/comic-shader.d.ts.map +1 -0
- package/dist/comic-shader.js +238 -0
- package/dist/comic-shader.js.map +1 -0
- package/dist/comic-tempo.d.ts +24 -0
- package/dist/comic-tempo.d.ts.map +1 -0
- package/dist/comic-tempo.js +45 -0
- package/dist/comic-tempo.js.map +1 -0
- package/dist/comic.dope.json +842 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
- package/src/comic-fonts.ts +23 -0
- package/src/comic-params.ts +95 -0
- package/src/comic-renderer.ts +336 -0
- package/src/comic-shader.ts +247 -0
- package/src/comic-tempo.ts +46 -0
- package/src/comic.dope.json +842 -0
- package/src/index.ts +80 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comic Impact (the "BAM! POW!"→affirmation success effect) — the DATA-DRIVEN
|
|
3
|
+
* panel factory shim.
|
|
4
|
+
*
|
|
5
|
+
* Everything that isn't the shader or the Canvas2D draw is DATA in
|
|
6
|
+
* comic.dope.json, interpreted by the shared backbone:
|
|
7
|
+
* - the mood→params mapping + the OKLCH golden-angle palette (the loader),
|
|
8
|
+
* - the per-frame slam logic (`tempo.frame` — amp + the presence/flash
|
|
9
|
+
* extras, delta-0 with the old hand frame() hook),
|
|
10
|
+
* - the shadow height (`render.shadowHeightFrac`), the dpr-scaled Ben-Day cell
|
|
11
|
+
* + style-fattened ink (`render.pass`), the panel wiring (`render.panel`),
|
|
12
|
+
* the no-snap clock (`render.config.stepping: "none"`), and
|
|
13
|
+
* `tempo.reducedMotion`,
|
|
14
|
+
* - the uniform `binding` contract (the `u<Name>` list + exceptions),
|
|
15
|
+
* - the affirmation `content.pool` + the mood→face/curve `typography` table.
|
|
16
|
+
*
|
|
17
|
+
* The genuinely code-shaped parts that stay JS are the GLSL (comic-shader.ts —
|
|
18
|
+
* the single source the MSL + Kotlin shaders are generated from), the Canvas2D
|
|
19
|
+
* panel draw (comic-renderer.ts — the jagged starburst + the per-letter
|
|
20
|
+
* display-face lettering, which is NOT datafied), and the per-fire word pick +
|
|
21
|
+
* typography compose (the `composeParams` hook).
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { drawComicFrame, ensureComicFonts } from "./comic-renderer.js";
|
|
25
|
+
import { type ComicRenderParams, type ComicWord } from "./comic-params.js";
|
|
26
|
+
import { COMIC_FRAGMENT_SRC, COMIC_VERTEX_SRC } from "./comic-shader.js";
|
|
27
|
+
import {
|
|
28
|
+
parseDope,
|
|
29
|
+
pickFromList,
|
|
30
|
+
registerDopePanelEffect,
|
|
31
|
+
resolveTypography,
|
|
32
|
+
type DopeTypography,
|
|
33
|
+
} from "@dopaminefx/core";
|
|
34
|
+
import doc from "./comic.dope.json";
|
|
35
|
+
|
|
36
|
+
export type { ComicRenderParams, ComicWord } from "./comic-params.js";
|
|
37
|
+
|
|
38
|
+
// Re-export the bundled comic-face preloader from the effect's own chunk, so a
|
|
39
|
+
// host that imports this effect can await its lettering without pulling the barrel.
|
|
40
|
+
export { ensureComicFonts } from "./comic-renderer.js";
|
|
41
|
+
|
|
42
|
+
const DOPE = parseDope(doc as object);
|
|
43
|
+
const CONTENT = (DOPE.content ?? {}) as { pool?: readonly string[] };
|
|
44
|
+
const TYPO = DOPE.typography as unknown as DopeTypography;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Compose the non-numeric Comic params on top of the loader bag: the per-fire
|
|
48
|
+
* WORD (seed-picked from `content.pool`) + the mood/whimsy/intensity TYPOGRAPHY
|
|
49
|
+
* (face + the curve fields). Code-shaped on web (the seeded pick + the CSS font
|
|
50
|
+
* stack); the native generated factories fold the same typography in via the
|
|
51
|
+
* loader and pick the word inside the panel draw.
|
|
52
|
+
*/
|
|
53
|
+
function composeComic(
|
|
54
|
+
numeric: Record<string, unknown>,
|
|
55
|
+
feeling: { mood: string; intensity: number; whimsy: number; seed: number },
|
|
56
|
+
): Record<string, unknown> {
|
|
57
|
+
const pool = CONTENT.pool ?? ["DONE!"];
|
|
58
|
+
return {
|
|
59
|
+
...numeric,
|
|
60
|
+
word: pickFromList(pool, feeling.seed) as ComicWord,
|
|
61
|
+
...resolveTypography(TYPO, feeling.mood, feeling.intensity, feeling.whimsy),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Registers the EffectFactory AND the bundled "comic" program (so loadEffect()
|
|
66
|
+
// can bind a host-authored comic variant — different words/font/curves — with no
|
|
67
|
+
// code; composeParams adds the word + typography from the resolved doc).
|
|
68
|
+
export const comic = registerDopePanelEffect(
|
|
69
|
+
DOPE,
|
|
70
|
+
{ vertex: COMIC_VERTEX_SRC, fragment: COMIC_FRAGMENT_SRC },
|
|
71
|
+
drawComicFrame,
|
|
72
|
+
{ composeParams: composeComic },
|
|
73
|
+
) as unknown as import("@dopaminefx/core").EffectFactory<ComicRenderParams>;
|
|
74
|
+
|
|
75
|
+
// Begin loading the bundled display faces as soon as the effect is imported so
|
|
76
|
+
// they're usually ready by the time the user fires (comic-renderer side-effects
|
|
77
|
+
// this too; calling again is a no-op).
|
|
78
|
+
void ensureComicFonts();
|
|
79
|
+
|
|
80
|
+
export default comic;
|