@zinejs/core 0.2.0 → 0.4.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 +5 -1
- package/dist/geometry/curls/cone.d.ts +17 -0
- package/dist/geometry/curls/flick.d.ts +20 -0
- package/dist/geometry/curls/leaf.d.ts +19 -0
- package/dist/geometry/curls/silk.d.ts +27 -0
- package/dist/geometry/curls/simple.d.ts +0 -8
- package/dist/geometry/curls/types.d.ts +7 -4
- package/dist/index.js +172 -150
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +13 -7
- package/dist/index.umd.cjs.map +1 -1
- package/dist/types-CcPVyhOJ.js +13 -0
- package/dist/types-CcPVyhOJ.js.map +1 -0
- package/dist/{webglRenderer-m-lr412M.js → webglRenderer-BK-ArG1G.js} +192 -93
- package/dist/webglRenderer-BK-ArG1G.js.map +1 -0
- package/dist/zine.d.ts +1 -1
- package/options.schema.json +4 -4
- package/package.json +1 -1
- package/dist/geometry/curls/fold.d.ts +0 -9
- package/dist/geometry/curls/peel.d.ts +0 -9
- package/dist/types-Bz64qLvE.js +0 -11
- package/dist/types-Bz64qLvE.js.map +0 -1
- package/dist/webglRenderer-m-lr412M.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ Framework-agnostic flipbook engine: turn images or PDFs into a page-flipping boo
|
|
|
10
10
|
npm install @zinejs/core
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
Also ships a **UMD** build at `dist/index.umd.cjs` (global `ZineJS`) for CDN / `<script>` hosts. The ESM build code-splits the CSS and WebGL2 renderers; the UMD build inlines both so a single script is enough.
|
|
14
|
+
|
|
13
15
|
## Image book
|
|
14
16
|
|
|
15
17
|
```js
|
|
@@ -47,11 +49,12 @@ new Zine(container, {
|
|
|
47
49
|
source, // ImageSource | PdfSource (required)
|
|
48
50
|
direction: 'ltr', // 'ltr' | 'rtl'
|
|
49
51
|
spreadMode: 'cover', // 'double' | 'single' | 'cover' (lone first page) | 'book' (lone first & last)
|
|
52
|
+
curl: 'cone', // WebGL2 only: 'cone' | 'roll' | 'leaf' | 'flick' | 'silk' | 'simple'
|
|
50
53
|
frontCover: 'front.jpg', // optional image prepended as a lone front cover
|
|
51
54
|
backCover: 'back.jpg', // optional image appended as a lone back cover
|
|
52
55
|
pages: { 4: 'ad.jpg' }, // optional: replace source pages with images (0-based; -1 = last)
|
|
53
56
|
startPage: 0,
|
|
54
|
-
flipDuration: 800, // ms
|
|
57
|
+
flipDuration: 800, // ms (spread timing; a lone page stretches it and eases out)
|
|
55
58
|
singlePageThreshold: 640, // px: below this, show one page at a time
|
|
56
59
|
clickToFlip: 'edge', // 'edge' | 'half' | 'off'
|
|
57
60
|
zoom: { enabled: true, max: 4, wheel: true, doubleClick: [1, 2, 4] },
|
|
@@ -59,6 +62,7 @@ new Zine(container, {
|
|
|
59
62
|
});
|
|
60
63
|
```
|
|
61
64
|
|
|
65
|
+
See the [root README](../../README.md#curl-models) for what each curl model does.
|
|
62
66
|
## Methods & events
|
|
63
67
|
|
|
64
68
|
```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;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type PageMesh } from './mesh';
|
|
2
|
+
import type { CurlAnchor } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Silk — hand-turned S-curve page.
|
|
5
|
+
*
|
|
6
|
+
* This is not a traveling contact wave (`leaf`), not a cone wrap (`cone`), not a
|
|
7
|
+
* cylinder roll (`roll`), and not a single-mode inertial cantilever (`flick`).
|
|
8
|
+
*
|
|
9
|
+
* Real paper turned by hand takes an S-shaped cross-section: a main bend through
|
|
10
|
+
* the near half and a reverse bend through the far half (the flap over the
|
|
11
|
+
* fingers). The sheet is a developable strip clamped at the spine and driven
|
|
12
|
+
* through a base rotation ρ(t) = πt. Along the width the tangent is:
|
|
13
|
+
*
|
|
14
|
+
* θ(u) = ρ + env·S·sin(2πu) + peel(t)·u²
|
|
15
|
+
*
|
|
16
|
+
* where:
|
|
17
|
+
* - sin(2πu) is a full-period S (zero net at spine and free edge, opposite
|
|
18
|
+
* bends in the two halves) — a true inflection that none of the other
|
|
19
|
+
* models produce mid-turn,
|
|
20
|
+
* - u² is an early peel lead that lifts the free edge first, then releases.
|
|
21
|
+
*
|
|
22
|
+
* env = sin(πt) holds the S through the middle and forces exact flat rests.
|
|
23
|
+
* Rows far from the tap lag so a corner grab draws a living diagonal.
|
|
24
|
+
* Arc length is integrated with the unit tangent (trapezoid per grid cell), so
|
|
25
|
+
* the paper never stretches.
|
|
26
|
+
*/
|
|
27
|
+
export declare function deformSilk(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' | '
|
|
23
|
+
export type CurlType = 'roll' | 'cone' | 'leaf' | 'flick' | 'silk' | 'simple';
|
|
21
24
|
export declare const CURL_TYPES: CurlType[];
|
|
22
25
|
export declare const DEFAULT_CURL: CurlType;
|