@zinejs/core 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,11 +47,12 @@ new Zine(container, {
47
47
  source, // ImageSource | PdfSource (required)
48
48
  direction: 'ltr', // 'ltr' | 'rtl'
49
49
  spreadMode: 'cover', // 'double' | 'single' | 'cover' (lone first page) | 'book' (lone first & last)
50
+ curl: 'cone', // WebGL2 only: 'cone' | 'roll' | 'leaf' | 'flick' | 'simple'
50
51
  frontCover: 'front.jpg', // optional image prepended as a lone front cover
51
52
  backCover: 'back.jpg', // optional image appended as a lone back cover
52
53
  pages: { 4: 'ad.jpg' }, // optional: replace source pages with images (0-based; -1 = last)
53
54
  startPage: 0,
54
- flipDuration: 800, // ms
55
+ flipDuration: 800, // ms (spread timing; a lone page stretches it and eases out)
55
56
  singlePageThreshold: 640, // px: below this, show one page at a time
56
57
  clickToFlip: 'edge', // 'edge' | 'half' | 'off'
57
58
  zoom: { enabled: true, max: 4, wheel: true, doubleClick: [1, 2, 4] },
@@ -59,6 +60,7 @@ new Zine(container, {
59
60
  });
60
61
  ```
61
62
 
63
+ See the [root README](../../README.md#curl-models) for what each curl model does.
62
64
  ## Methods & events
63
65
 
64
66
  ```js
@@ -0,0 +1,17 @@
1
+ import { type PageMesh } from './mesh';
2
+ import type { CurlAnchor } from './types';
3
+ /**
4
+ * Natural conical page curl — the Xerox PARC / iBooks model.
5
+ *
6
+ * The leaf wraps an imaginary right circular cone whose apex rides the spine and
7
+ * whose opening angle θ breathes over the turn (Hong, Card & Chen, 2004). A corner
8
+ * grab yields a diagonal cone; a mid-edge grab blends toward a cylinder so the
9
+ * free edge lifts as one. The curled sheet then rotates about the spine and settles
10
+ * flat on the far side. Arc length from the apex is preserved, so the paper never
11
+ * stretches — the motion reads as stiff, premium stock rather than cloth.
12
+ *
13
+ * On a full-width lone page (`anchor.fill`) the hinge is the container edge with no
14
+ * facing half to land on: the cone softens, the flop is delayed so the peel stays
15
+ * over the page longer, and the renderer dissolves the sheet as it finishes.
16
+ */
17
+ export declare function deformCone(mesh: PageMesh, W: number, H: number, t: number, anchor: CurlAnchor): void;
@@ -0,0 +1,20 @@
1
+ import { type PageMesh } from './mesh';
2
+ import type { CurlAnchor } from './types';
3
+ /**
4
+ * Inertial follow-through page flick.
5
+ *
6
+ * The leaf is a cantilever clamped at the spine and driven through a rotation
7
+ * ρ(t) = πt. Paper inertia (the Euler force, ∝ −ρ̈) bends the sheet opposite the
8
+ * angular acceleration with a first-mode-like profile — zero curvature at the
9
+ * clamped spine, maximal at the free edge. Under an eased turn the acceleration
10
+ * changes sign at mid-flight, so the free edge trails while the turn winds up,
11
+ * swings through vertical, then overtakes and settles as the turn slows: the
12
+ * follow-through/overlapping-action principle, grounded in base-rotated
13
+ * cantilever dynamics. Tangent angles are integrated along the width, so the
14
+ * sheet never stretches, and the curvature direction reversing over the turn is
15
+ * what none of the wrap-style curls do.
16
+ *
17
+ * Rows far from the grabbed corner lag slightly more than the driven row, so a
18
+ * corner grab pulls a soft living diagonal across the sheet.
19
+ */
20
+ export declare function deformFlick(mesh: PageMesh, W: number, H: number, t: number, anchor: CurlAnchor): void;
@@ -0,0 +1,19 @@
1
+ import { type PageMesh } from './mesh';
2
+ import type { CurlAnchor } from './types';
3
+ /**
4
+ * Traveling smooth-curvature leaf curl.
5
+ *
6
+ * Inspired by rolling-cylinder page curls and modern developable-surface book
7
+ * simulations, but with a compact raised-cosine curvature wave instead of a
8
+ * constant-radius cylinder. The sheet has three regions:
9
+ *
10
+ * 1. untouched paper before the wave,
11
+ * 2. an isometric bend whose curvature smoothly rises and falls,
12
+ * 3. a flat, reflected flap after the wave.
13
+ *
14
+ * The wave travels from the free edge to just beyond the spine while its width grows
15
+ * and collapses. Integrating a unit tangent preserves material length exactly; straight
16
+ * ruling lines preserve distance along the curl axis. Curvature reaches zero at both
17
+ * seams, eliminating the hard crease shared by circular/fold models.
18
+ */
19
+ export declare function deformLeaf(mesh: PageMesh, W: number, H: number, t: number, anchor: CurlAnchor): void;
@@ -5,11 +5,3 @@ import { type PageMesh } from './mesh';
5
5
  * cylinder bend; GPU-rendered here with the shared perspective so it reads like the CSS fold.
6
6
  */
7
7
  export declare function deformSimple(mesh: PageMesh, W: number, H: number, t: number): void;
8
- /**
9
- * Bent page flip: the single-page (fill) form for spine curls whose spread shape assumes a
10
- * centered spine or a neighbour (roll). The leaf rotates about its spine edge (0→π) like the
11
- * flat turn, but the sheet also curves into a shallow arc that peaks mid-flip and flattens at
12
- * both ends, so the paper visibly bends as it turns instead of staying rigid. Reduces to the
13
- * flat turn when the bend is zero; arc length across the width is preserved.
14
- */
15
- export declare function deformBentFlip(mesh: PageMesh, W: number, H: number, t: number): void;
@@ -7,16 +7,19 @@ import type { PageMesh } from './mesh';
7
7
  /** Where a corner-anchored curl folds from: y in [0,1], 0 = top edge, 1 = bottom edge. */
8
8
  export interface CurlAnchor {
9
9
  y: number;
10
+ /**
11
+ * Full-width lone page (single-page mode). The leaf hinges at the container edge and
12
+ * has no facing half to land on — deforms may soften and delay the flop so the curl
13
+ * reads naturally before the renderer dissolves the sheet.
14
+ */
15
+ fill?: boolean;
10
16
  }
11
17
  export type CurlDeform = (mesh: PageMesh, W: number, H: number, t: number, anchor: CurlAnchor) => void;
12
18
  export interface CurlModel {
13
19
  readonly deform: CurlDeform;
14
- /** Single-page (fill) variant for curls whose spread form assumes a centered spine or a
15
- * neighbouring page. Used in fill mode when present; otherwise `deform` is used as-is. */
16
- readonly deformFill?: CurlDeform;
17
20
  /** True when the fold originates at a corner (`anchor.y`) rather than the whole edge. */
18
21
  readonly anchored: boolean;
19
22
  }
20
- export type CurlType = 'roll' | 'simple' | 'fold' | 'peel';
23
+ export type CurlType = 'roll' | 'cone' | 'leaf' | 'flick' | 'simple';
21
24
  export declare const CURL_TYPES: CurlType[];
22
25
  export declare const DEFAULT_CURL: CurlType;