@toonstrip/core 0.1.0 → 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.
Files changed (2) hide show
  1. package/README.md +71 -0
  2. package/package.json +16 -2
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @toonstrip/core
2
+
3
+ The framework-agnostic rendering engine: draws a single `Panel` (from
4
+ `@toonstrip/schema`) onto a `CanvasRenderingContext2D` — figures, poses,
5
+ speech/thought/caption balloons, backdrops, camera framing, and strip layout.
6
+ No DOM dependency; runs in Node via `@napi-rs/canvas` or in a browser.
7
+
8
+ Part of [toonstrip](https://github.com/dkdev24/toonstrip), a
9
+ framework-embeddable comic-strip renderer. Most consumers want
10
+ `@toonstrip/element` (a ready-made `<comic-strip>` custom element) rather
11
+ than calling this package directly — reach for `core` when you're rendering
12
+ outside the DOM (a Node script, a build-time static fallback) or building
13
+ your own embed.
14
+
15
+ ## Install
16
+
17
+ ```
18
+ npm install @toonstrip/core @toonstrip/schema
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ import { createCanvas, loadImage } from "@napi-rs/canvas";
25
+ import { layoutStrip, renderPanel, type Cast } from "@toonstrip/core";
26
+ import { loadCastManifest } from "@toonstrip/pack-comic-chat";
27
+ import type { Panel } from "@toonstrip/schema";
28
+
29
+ const manifest = loadCastManifest();
30
+ const dan = manifest.cast.dan;
31
+ const pastoral = manifest.backdrops.find((b) => b.id === "pastoral")!;
32
+
33
+ const cast: Cast = {
34
+ manifest: { version: 1, cast: { dan }, backdrops: [pastoral] },
35
+ sheets: new Map([["dan", await loadImage(dan.sheet)]]),
36
+ backdrops: new Map([["pastoral", await loadImage(pastoral.file)]]),
37
+ };
38
+
39
+ const panel: Panel = {
40
+ backdrop: "pastoral",
41
+ camera: "medium",
42
+ bodies: [{ character: "dan", emotion: { angle: 0, intensity: 0.5 } }],
43
+ speakers: [{ speaker: "dan", balloon: "speech", text: "Rendered from a Node script." }],
44
+ };
45
+
46
+ const { panelWidth, panelHeight } = layoutStrip(900);
47
+ const canvas = createCanvas(panelWidth, panelHeight);
48
+ const ctx = canvas.getContext("2d") as unknown as CanvasRenderingContext2D;
49
+ renderPanel(ctx, panel, cast, panelWidth, panelHeight);
50
+ ```
51
+
52
+ A `Cast` is a resolved asset pack: the `CastManifest` (character/backdrop
53
+ metadata) plus loaded `sheets`/`backdrops` images, keyed by id. Building one
54
+ from a pack package or from files fetched over the network is the caller's
55
+ job — `@toonstrip/pack-comic-chat` and `@toonstrip/element`'s `load-pack.ts`
56
+ are the two existing examples.
57
+
58
+ ## What's exported
59
+
60
+ - `renderPanel(ctx, panel, cast, width, height, options?)` — draws one panel
61
+ - `layoutStrip(containerWidth)` — column count + per-panel size for a strip
62
+ at a given container width (drives responsive relayout)
63
+ - `selectFigures`, `figureFor`, pose-selection helpers — for a caller that
64
+ needs to advance pose cycles without drawing (e.g. a virtualized strip)
65
+ - Balloon measurement/drawing primitives (`measureBalloon`, `drawBalloon`,
66
+ `layoutBalloons`) if you're composing a custom render path
67
+ - `Cast`, `Figure`, `PoseCycle` and the rest of the type surface
68
+
69
+ ## License
70
+
71
+ MIT
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@toonstrip/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
+ "description": "Framework-agnostic canvas rendering engine for toonstrip comic strips.",
4
5
  "license": "MIT",
5
6
  "type": "module",
6
7
  "main": "./dist/index.js",
@@ -26,5 +27,18 @@
26
27
  },
27
28
  "publishConfig": {
28
29
  "access": "public"
29
- }
30
+ },
31
+ "keywords": [
32
+ "toonstrip",
33
+ "comic",
34
+ "canvas",
35
+ "rendering"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/dkdev24/toonstrip.git",
40
+ "directory": "packages/core"
41
+ },
42
+ "homepage": "https://github.com/dkdev24/toonstrip#readme",
43
+ "bugs": "https://github.com/dkdev24/toonstrip/issues"
30
44
  }