Kurz gesagt
Ein dickes Pappbuch über einen Gang durch den Wald. Jedes Blatt hat ein rundes Loch, etwas kleiner als das davor, und vom Umschlag aus sieht man bis zur letzten Seite.
Was Sie setzen
Tief in den Wald, ein Tunnelbuch aus zwanzig Pappblättern auf 150 mm im Quadrat. Jede rechte Seite ist eine Ebene eines gemalten Waldes (Eichen, Fingerhut, ein Rotkehlchen, ein Fuchs im Farn, ein Kauz, Birken), und jede hat ein rundes Fenster, etwas kleiner als das davor, alle um dieselbe Mitte. Die letzte Ebene ist ganz: eine Ricke und ihr Kitz an einem Teich auf der Lichtung. Vom Umschlag geht der Blick durch alle neunzehn Fenster bis zu den Rehen, und die Schnittkanten der Pappe stehen um den Tunnel wie die Stämme selbst. Auf der Rückseite jedes Blatts nennt eine Verszeile die Ebene gegenüber. Die Druckdatei führt alle Fenster auf der Stanzplatte.
Dieses Rezept beantwortet
- Wie mache ich ein Tunnelbuch, dessen Löcher zwanzig Seiten tief blicken lassen?
- Wie gebe ich dem Stanzformenbauer die Stanzlinie auf einer eigenen Platte im PDF?
Die kurze Antwort
// Leaf k (pages 2k − 1 and 2k) is cut with a circle of radius R1 · Q^(k − 1) round the
// same centre: 58 mm on the cover down to 12 mm on leaf 19. Leaf 20, the clearing, is
// whole, so from the cover the eye goes through nineteen windows to the far plane.
const [CX, CY, R1, Q] = [75, 66, 58, 0.9162];
const radius = (k) => R1 * Q ** (k - 1);
const leaves = Array.from({ length: 19 }, (_, i) => i + 1);
const dieCuts = {
shapes: leaves.map((k) => ({ id: `w${k}`, name: `${t({ en: 'Window', es: 'Ventana' })} ${k}`,
shape: 'circle', x: mm(CX - radius(k)), y: mm(CY - radius(k)),
width: mm(2 * radius(k)), height: mm(2 * radius(k)) })),
pages: leaves.map((k) => ({ pages: String(2 * k - 1), die: `w${k}` })), // recto of leaf k
corners: { radius: mm(4), edges: 'fore' },
};
Zutaten
- Funktionen
- Gestanzte LöcherStanzlinie im PDFAbgerundete Ecken und Bücher in Form3D-Buchbetrachter (Folio)ÜberschriftenformateBilder in SeitengestaltungenText, Linien und Kästen in SeitengestaltungenDokument-MetadatenAbsatzformateAnschnitt und SchnittmarkenPDFs in CMYK und GraustufenPDF-ExportAbbildungen und Tabellen als RessourcenSemantische FarbpaletteSeiten auf einem Canvas
- Nutzt außerdem
- Papier, Bindung, Tisch und Licht (Folio)ÜberschriftenattributeGestaltete AuftaktePapierfarbeIm PDF eingebettete SchriftenKapitel ohne Nummer
- Schrift
- Cormorant Garamond, Lora (SIL OFL 1.1)
- Dateien
plane01.jpgplane02.jpgplane03.jpgplane04.jpgplane05.jpgplane06.jpgplane07.jpgplane08.jpgplane09.jpgplane10.jpgplane11.jpgplane12.jpgplane13.jpgplane14.jpgplane15.jpgplane16.jpgplane17.jpgplane18.jpgplane19.jpgplane20.jpg- Plane 1 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 2 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 3 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 4 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 5 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 6 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 7 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 8 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 9 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 10 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 11 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 12 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 13 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 14 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 15 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 16 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 17 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 18 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 19 of the wood (Generated With Diffusion Models, eigener Text)
- Plane 20 of the wood (Generated With Diffusion Models, eigener Text)
Zubereitung
#1 · Neunzehn Fenster auf einer Achse
Der Code steht in der kurzen Antwort oben. Die Fenster entstehen in einer Schleife: Blatt k bekommt einen Kreis mit dem Radius R1 · Q^(k − 1) um dieselbe Mitte, und dieCuts.pages setzt ihn auf Seite 2k − 1, die Vorderseite dieses Blatts. Ein Loch schneidet beide Seiten seines Blatts, also hat die Rückseite dahinter dasselbe Fenster, gespiegelt. Q = 0,9162 führt in achtzehn Schritten von 58 mm auf 12 mm.
#2 · Ebenen im Passer zu ihren Fenstern
// The plane pictures were scaled so each painting's opening meets its window, centred on
// (CX, CY), over a softened copy of itself; the window's centre is flat, the die takes it.
const SHEET = { width: mm(TRIM + 2 * BLEED), height: mm(TRIM + 2 * BLEED) };
const painting = { kind: 'image', id: 'painting', resourceId: '{attr.picture}', fit: 'cover',
placement: at('page', 'top-left', -BLEED, -BLEED, SHEET) };
const full = (elements) => ({ enabled: true, minHeight: mm(TRIM - TOP), slot: { elements } });
const plate = { kind: 'box', id: 'plate', placement: at('page', 'top-left', 25, 129,
{ width: mm(100), height: mm(17) }), style: { backgroundColor: col('forest') } };
const line = (id, content, y, size, color, extra) => ({ kind: 'text', id, content,
fontFamily: DISPLAY, fontSize: pt(size), lineHeight: 1.1, color: col(color),
align: 'center', placement: at('page', 'top-left', 25, y, { width: mm(100) }), ...extra });
const headingStyles = [
{ id: 'cover', numbered: false, toc: false, advancedDesign: full([painting, plate,
line('title', '{title}', 131, 21, 'cream', { fontWeight: 600 }),
line('subtitle', '{subtitle}', 139.5, 10.5, 'moss', { italic: true })]) },
{ id: 'plane', numbered: false, breakBefore: { enabled: true, parity: 'odd' },
advancedDesign: full([painting]) },
];
Jedes Bild hat seine eigene neblige Lichtung, darum wurden die Bilder skaliert, bevor sie ins Buch kamen: Auf jedem wurde in Pixeln der Radius gemessen, bei dem Blätter den halben Ring bedecken, und das Bild so skaliert, dass dieser Radius auf das Fenster seines Blatts trifft. Vom Umschlag aus zeigt jede Ebene nur einen schmalen Blätterring um ihr Fenster, und die Ringe stapeln sich zum Tunnel. Die Mitte, die jede Stanzung wegnimmt, ist einfarbig und kostet in der Datei fast nichts.
#3 · Neunzehn Kreise auf der Platte Die
print: { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false,
dieLine: { output: 'page', ink: 'Die', width: pt(0.5) } },
Das PDF zieht jedes Fenster und jedes Blatt mit seinen am Vorderschnitt gerundeten Ecken auf einer Separation Die nach, die überdruckt und nie eingefärbt wird. Vierzig Seiten mit Bildern bleiben mit convertImages: false unter 1,5 MB.
#4 · Der Tunnel in der Hand
folio: {
tilt: 40, yaw: -30,
paper: { type: 'board', shade: '#f4ecd6' },
binding: { type: 'hardcover', cover: 'pages', coverMaterial: 'paper' },
surface: { type: 'oak' },
lighting: { environment: 'daylight', intensity: 1.1 },
},
Zwanzig Pappblätter ergeben einen dicken Block, und Folio stanzt jedes Fenster hindurch: Das geschlossene Buch zeigt den Tunnel, dessen Schnittwände in Stufen bis zur Lichtung hinabführen.
#5 · Zwanzig Ebenen auf einer flachen Seite
// `beneath` paints the page two on, which paints the page two on from it, and so on to
// the clearing: page 1 shows all twenty planes. Each canvas is painted once and reused.
const under = new Map();
const beneath = (i) => {
if (!under.has(i) && doc.pages[i]) {
const canvas = document.createElement('canvas');
under.set(i, canvas);
renderPageToCanvas(doc.pages[i], doc, canvas, { scale: 1, beneath });
}
return under.get(i);
};
beneath malt die übernächste Seite mit ihrem eigenen beneath: Das Fenster des Umschlags zeigt Seite 3, deren Fenster Seite 5, und so weiter bis Seite 39. Jede Seite wird einmal gemalt und wiederverwendet.
Das ganze Rezept
// ═══ Postext Cookbook · Nº 195 · A tunnel book twenty leaves deep ═══════════════════════
// https://postext.dev/en/cookbook/forest-tunnel-book
// Code: MIT · Text: original (CC BY 4.0) · Paintings: generated with diffusion models
// Fonts: Cormorant Garamond, Lora (SIL OFL 1.1) · Needs postext ≥ 1.84.0
//
// Twenty board leaves, each printed with one plane of a wood and cut with a round window a
// little smaller than the one before. From the cover you look down the whole tunnel, past
// oaks, foxgloves, an owl and a fox, to a doe and her fawn at a pool in the clearing.
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
import { createFolioFromDocument } from 'https://esm.sh/postext-folio';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'forest-tunnel-book';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a deep forest green behind the words, cream type
const palette = {
forest: '#1c2a1e', // the versos, and the plate under the cover title
cream: '#f4ecd6', // all the type
moss: '#a9b98a', // the subtitle and the colophon
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'moss (defaults)', value: { hex: palette.moss, model: 'hex' } },
];
// #endregion
const [TRIM, BLEED] = [150, 3]; // mm: a square board book, and its bleed
const [TOP, SIDE] = [128, 14]; // the words on each verso sit under its window
const [DISPLAY, TEXT] = ['Cormorant Garamond', 'Lora'];
const at = (to, edge, x = 0, y = 0, size) => ({ anchor: { to, edge },
offset: { x: mm(x), y: mm(y) }, ...(size && { size }) });
// #region answer: nineteen windows, each smaller than the last, all on one axis
// Leaf k (pages 2k − 1 and 2k) is cut with a circle of radius R1 · Q^(k − 1) round the
// same centre: 58 mm on the cover down to 12 mm on leaf 19. Leaf 20, the clearing, is
// whole, so from the cover the eye goes through nineteen windows to the far plane.
const [CX, CY, R1, Q] = [75, 66, 58, 0.9162];
const radius = (k) => R1 * Q ** (k - 1);
const leaves = Array.from({ length: 19 }, (_, i) => i + 1);
const dieCuts = {
shapes: leaves.map((k) => ({ id: `w${k}`, name: `${t({ en: 'Window', es: 'Ventana' })} ${k}`,
shape: 'circle', x: mm(CX - radius(k)), y: mm(CY - radius(k)),
width: mm(2 * radius(k)), height: mm(2 * radius(k)) })),
pages: leaves.map((k) => ({ pages: String(2 * k - 1), die: `w${k}` })), // recto of leaf k
Das zusammengesetzte script.js läuft unverändert: Fügen Sie es in das Modulskript einer beliebigen Seite ein, oder öffnen Sie das Rezept auf CodePen. Ordner des Rezepts auf GitHub ↗ (öffnet sich in einem neuen Tab)
Varianten
#Quadratische Fenster mit runden Ecken
Ein roundRect mit einem Eckradius von einem Drittel seiner halben Breite wirkt weicher, wie ausgeschnittenes Papier.
- shape: 'circle', x: mm(CX - radius(k)), y: mm(CY - radius(k)),
+ shape: 'roundRect', radius: mm(radius(k) / 3), x: mm(CX - radius(k)), y: mm(CY - radius(k)),#Alle Ecken runden
Ein Pappbuch für kleine Hände rundet alle vier Ecken jedes Blatts.
- corners: { radius: mm(4), edges: 'fore' },
+ corners: { radius: mm(8), edges: 'all' },Nachweise
- Rezept
- Ignacio Ferro
- Text
- The verse of the walk and the colophon · Postext Cookbook · CC BY 4.0
- Bilder
- Plane 1 of the wood · Generated With Diffusion Models · eigener Text
- Plane 2 of the wood · Generated With Diffusion Models · eigener Text
- Plane 3 of the wood · Generated With Diffusion Models · eigener Text
- Plane 4 of the wood · Generated With Diffusion Models · eigener Text
- Plane 5 of the wood · Generated With Diffusion Models · eigener Text
- Plane 6 of the wood · Generated With Diffusion Models · eigener Text
- Plane 7 of the wood · Generated With Diffusion Models · eigener Text
- Plane 8 of the wood · Generated With Diffusion Models · eigener Text
- Plane 9 of the wood · Generated With Diffusion Models · eigener Text
- Plane 10 of the wood · Generated With Diffusion Models · eigener Text
- Plane 11 of the wood · Generated With Diffusion Models · eigener Text
- Plane 12 of the wood · Generated With Diffusion Models · eigener Text
- Plane 13 of the wood · Generated With Diffusion Models · eigener Text
- Plane 14 of the wood · Generated With Diffusion Models · eigener Text
- Plane 15 of the wood · Generated With Diffusion Models · eigener Text
- Plane 16 of the wood · Generated With Diffusion Models · eigener Text
- Plane 17 of the wood · Generated With Diffusion Models · eigener Text
- Plane 18 of the wood · Generated With Diffusion Models · eigener Text
- Plane 19 of the wood · Generated With Diffusion Models · eigener Text
- Plane 20 of the wood · Generated With Diffusion Models · eigener Text
- Schriften
- Cormorant Garamond (SIL OFL 1.1) · Lora (SIL OFL 1.1)
- Code
- MIT, wie Postext
Diesen Text bearbeiten ↗ (öffnet sich in einem neuen Tab)Ordner des Rezepts auf GitHub ↗ (öffnet sich in einem neuen Tab)


