# Ένα βιβλίο-τούνελ είκοσι φύλλων σε βάθος

> Δεκαεννέα στρογγυλά παράθυρα dieCuts, όλο και μικρότερα σε έναν άξονα: από το εξώφυλλο βλέπετε μέσα από είκοσι ζωγραφιστά πλάνα δάσους ένα ελάφι σε λιμνούλα.

- Έκδοση HTML: https://postext.dev/el/cookbook/forest-tunnel-book
- Συνταγή Αρ. 195 · Έξοδος και ενσωμάτωση · Επίπεδο 3 (Προχωρημένο) · Έξοδοι: Canvas, PDF, Ζωντανά χειριστήρια
- Είδη: Μονόφυλλα και εφήμερα έντυπα
- Απαιτεί postext ≥ 1.84.0, postext-pdf ≥ 1.84.0 · δοκιμασμένη με 1.84.0, postext-pdf 1.84.0 στις 2026-11-13
- Σελίδες: [1](https://postext.dev/cookbook/forest-tunnel-book/en/p01.webp?v=bc45895d), [2](https://postext.dev/cookbook/forest-tunnel-book/en/p02.webp?v=bc45895d), [3](https://postext.dev/cookbook/forest-tunnel-book/en/p03.webp?v=bc45895d), [4](https://postext.dev/cookbook/forest-tunnel-book/en/p04.webp?v=bc45895d), [11](https://postext.dev/cookbook/forest-tunnel-book/en/p11.webp?v=bc45895d), [19](https://postext.dev/cookbook/forest-tunnel-book/en/p19.webp?v=bc45895d), [21](https://postext.dev/cookbook/forest-tunnel-book/en/p21.webp?v=bc45895d), [29](https://postext.dev/cookbook/forest-tunnel-book/en/p29.webp?v=bc45895d), [37](https://postext.dev/cookbook/forest-tunnel-book/en/p37.webp?v=bc45895d), [39](https://postext.dev/cookbook/forest-tunnel-book/en/p39.webp?v=bc45895d), [40](https://postext.dev/cookbook/forest-tunnel-book/en/p40.webp?v=bc45895d)
- PDF: https://postext.dev/cookbook/forest-tunnel-book/en/forest-tunnel-book.pdf?v=bc45895d
- Άνοιγμα στο Sandbox: https://postext.dev/el/sandbox#recipe=forest-tunnel-book&lang=en (.postext: https://postext.dev/cookbook/forest-tunnel-book/en/forest-tunnel-book.postext)
- Τελευταία ενημέρωση: 2026-11-13
- Άλλες γλώσσες: [en](https://postext.dev/en/cookbook/forest-tunnel-book.md), [es](https://postext.dev/es/cookbook/forest-tunnel-book.md), [ca](https://postext.dev/ca/cookbook/forest-tunnel-book.md), [de](https://postext.dev/de/cookbook/forest-tunnel-book.md), [fr](https://postext.dev/fr/cookbook/forest-tunnel-book.md), [it](https://postext.dev/it/cookbook/forest-tunnel-book.md), [pt](https://postext.dev/pt/cookbook/forest-tunnel-book.md), [zh](https://postext.dev/zh/cookbook/forest-tunnel-book.md), [ja](https://postext.dev/ja/cookbook/forest-tunnel-book.md), [ar](https://postext.dev/ar/cookbook/forest-tunnel-book.md)

## Με λίγα λόγια

Ένα χοντρό βιβλίο από χαρτόνι για έναν περίπατο στο δάσος. Κάθε φύλλο έχει μια στρογγυλή τρύπα λίγο μικρότερη από την προηγούμενη, έτσι από το εξώφυλλο βλέπετε ως την τελευταία σελίδα.

## Τι θα στοιχειοθετήσετε

*Into the Wood*, ένα βιβλίο-τούνελ με είκοσι φύλλα από χαρτόνι σε τετράγωνο 150 mm. Κάθε δεξιά σελίδα είναι ένα επίπεδο ενός ζωγραφισμένου δάσους (βελανιδιές, δακτυλίτιδες, ένας κοκκινολαίμης, μια αλεπού στις φτέρες, μια κουκουβάγια, σημύδες), και καθεμία έχει κομμένο ένα στρογγυλό παράθυρο λίγο μικρότερο από το προηγούμενο, όλα με το ίδιο κέντρο. Το τελευταίο επίπεδο είναι ολόκληρο: μια ελαφίνα και το ελαφάκι της σε μια λιμνούλα μέσα σε ένα ξέφωτο. Από το εξώφυλλο το μάτι περνά μέσα από και τα δεκαεννέα παράθυρα ως τα ελάφια, και οι κομμένες άκρες του χαρτονιού στέκονται γύρω από το τούνελ σαν τους ίδιους τους κορμούς. Στην πίσω πλευρά κάθε φύλλου ένας στίχος ονομάζει το επίπεδο απέναντί του. Το αρχείο για το τυπογραφείο φέρει κάθε παράθυρο στον τσίγκο του κοπτικού.

**Αυτή η συνταγή απαντά:**

- Πώς φτιάχνω βιβλίο-τούνελ, με τρύπες σε κάθε φύλλο που δείχνουν την τελευταία σελίδα από το εξώφυλλο;
- Πώς στέλνω στον κατασκευαστή του κοπτικού μια γραμμή κοπτικού σε δικό της τσίγκο στο PDF;

## Η σύντομη απάντηση

```js
// script.js, γραμμές 38–50
// 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' },
};
```

## Υλικά

**Διδάσκει**

- [Οπές κοπής (die-cut)](https://postext.dev/el/docs/special-inks-die-cuts.md#κοπές): Τα dieCuts.shapes και dieCuts.pages (ή ένας περιέκτης :::diecut) ανοίγουν μια τρύπα σε μια σελίδα και στο φύλλο της· το κείμενο και στις δύο όψεις τρέχει γύρω της.
- [Γραμμή κοπτικού στο PDF](https://postext.dev/el/docs/special-inks-die-cuts.md#η-γραμμή-κοπτικού-στο-pdf): Το print.dieLine χαράζει κάθε τρύπα και κάθε άκρη με σχήμα σε δικό του τσίγκο Separation που τυπώνεται πάνω από τα άλλα και δεν μελανώνεται ποτέ, για τον κατασκευαστή της μήτρας κοπής.

**Χρησιμοποιεί επίσης**

- [Στρογγυλεμένες γωνίες και βιβλία με σχήμα](https://postext.dev/el/docs/special-inks-die-cuts.md#στρογγυλεμένες-γωνίες-και-βιβλία-με-σχήμα)
- [Τρισδιάστατη προβολή βιβλίου (Folio)](https://postext.dev/el/docs/configuration-html-folio-epub.md#ένα-τρισδιάστατο-βιβλίο-postext-folio)
- [Στιλ επικεφαλίδων](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων)
- [Εικόνες στις σχεδιάσεις σελίδας](https://postext.dev/el/docs/configuration-headers-footers.md#στοιχεία-εικόνας)
- [Κείμενο, γραμμές και πλαίσια στις σχεδιάσεις σελίδας](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα)
- [Μεταδεδομένα εγγράφου](https://postext.dev/el/docs/document-format.md#μεταδεδομένα-frontmatter)
- [Στιλ παραγράφων](https://postext.dev/el/docs/configuration-styles.md#στιλ-παραγράφων)
- [Περιθώριο αιμορραγίας και σημάδια κοπής](https://postext.dev/el/docs/configuration-page-layout.md#γραμμές-κοπής)
- [PDF σε CMYK και σε τόνους του γκρι](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#δημιουργία-pdf-διαμόρφωση)
- [Εξαγωγή PDF](https://postext.dev/el/docs/configuration-pdf-output.md#παραγωγή-pdf)
- [Εικόνες και πίνακες ως πόροι](https://postext.dev/el/docs/document-format-resources.md#πόροι)
- [Σημασιολογική χρωματική παλέτα](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#παλέτα-χρωμάτων)
- [Σελίδες σε καμβά](https://postext.dev/el/docs/configuration-programmatic-usage.md#απόδοση-σελίδας-σε-bitmap)
- [Χαρτί, βιβλιοδεσία, γραφείο και φως (Folio)](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#προβολή-folio-διαμόρφωση)
- [Ιδιότητες επικεφαλίδων](https://postext.dev/el/docs/document-format.md#χαρακτηριστικά-επικεφαλίδων)
- [Σχεδιασμένες εναρκτήριες σελίδες](https://postext.dev/el/docs/configuration-headings.md#πλάτος-και-προηγμένη-σχεδίαση)
- [Χρώμα χαρτιού](https://postext.dev/el/docs/configuration-page-layout.md#σελίδα)
- [Γραμματοσειρές ενσωματωμένες στο PDF](https://postext.dev/el/docs/configuration-pdf-output.md#γιατί-πάροχος-γραμματοσειρών)
- [Κεφάλαια χωρίς αρίθμηση](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων)

**Η διαμόρφωση με μια ματιά**

- [`bodyText`](https://postext.dev/el/docs/configuration-text.md#κυρίως-κείμενο), [`colorPalette`](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#παλέτα-χρωμάτων), [`dieCuts`](https://postext.dev/el/docs/special-inks-die-cuts.md#κοπές), [`folio`](https://postext.dev/el/docs/configuration-html-folio-epub.md#εμφάνιση), [`footer`](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα), [`header`](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα), [`headingStyles`](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων), [`headings`](https://postext.dev/el/docs/configuration-headings.md#επικεφαλίδες), [`layout`](https://postext.dev/el/docs/configuration-page-layout.md#διάταξη), [`locale`](https://postext.dev/el/docs/configuration-language.md#συλλαβισμός), [`page`](https://postext.dev/el/docs/configuration-page-layout.md#σελίδα), [`paragraphStyles`](https://postext.dev/el/docs/configuration-styles.md#στιλ-παραγράφων), [`print`](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#παραγωγή-για-εκτύπωση-διαμόρφωση)

**API**

- [`buildDocumentWithFonts`](https://postext.dev/el/docs/configuration-programmatic-usage.md#φόρτωση-γραμματοσειρών-πριν-από-τη-σελιδοποίηση), [`createFolioFromDocument`](https://postext.dev/el/docs/configuration-html-folio-epub.md#ένα-τρισδιάστατο-βιβλίο-postext-folio), [`decompressWoff2`](https://postext.dev/el/docs/configuration-pdf-output.md#πάροχος-γραμματοσειρών-για-τον-browser-fontsource--woff2), [`registerResourceImage`](https://postext.dev/el/docs/architecture.md#η-επιφάνεια-του-api), [`renderPageToCanvas`](https://postext.dev/el/docs/configuration-programmatic-usage.md#απόδοση-σελίδας-σε-bitmap), [`renderToPdf`](https://postext.dev/el/docs/configuration-pdf-output.md#παραγωγή-pdf)

**Γραμματοσειρές**

- Cormorant Garamond (OFL-1.1), Lora (OFL-1.1)

## Προετοιμασία

### 1 · Δεκαεννέα παράθυρα σε έναν άξονα

Ο κώδικας είναι [η σύντομη απάντηση](https://postext.dev/el/cookbook/forest-tunnel-book.md#η-σύντομη-απάντηση) παραπάνω. Τα παράθυρα φτιάχνονται σε έναν βρόχο: το φύλλο k παίρνει έναν κύκλο ακτίνας R1 · Q^(k − 1) γύρω από το ίδιο κέντρο, και το `dieCuts.pages` τον βάζει στη σελίδα 2k − 1, τη δεξιά σελίδα αυτού του φύλλου. Μια τρύπα κόβει και τις δύο πλευρές του φύλλου της, έτσι η αριστερή σελίδα πίσω της έχει το ίδιο παράθυρο, κατοπτρισμένο. Το Q = 0,9162 κατεβάζει τα 58 mm στα 12 mm σε δεκαοκτώ βήματα, και το τελευταίο παράθυρο είναι ίσα ίσα αρκετά φαρδύ για τα ελάφια.

### 2 · Επίπεδα σε σύμπτωση με τα παράθυρά τους

```js
// script.js, γραμμές 54–71
// 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]) },
];
```

Κάθε πίνακας έχει το δικό του θολό άνοιγμα, γι' αυτό οι εικόνες κλιμακώθηκαν πριν μπουν στο βιβλίο: σε καθεμία μετρήθηκε σε pixel η ακτίνα όπου τα φύλλα καλύπτουν το μισό δαχτυλίδι, και ο πίνακας κλιμακώθηκε ώσπου αυτή η ακτίνα να συναντήσει το παράθυρο του φύλλου, στο κέντρο του παραθύρου. Από το εξώφυλλο, κάθε επίπεδο δείχνει μόνο ένα λεπτό δαχτυλίδι από τα φύλλα του γύρω από το παράθυρό του, και τα δαχτυλίδια στοιβάζονται σε ένα τούνελ. Το κέντρο που αφαιρεί κάθε κοπή (die-cut) είναι επίπεδο, γι' αυτό δεν κοστίζει σχεδόν τίποτα στο αρχείο.

### 3 · Δεκαεννέα κύκλοι στον τσίγκο Die

```js
// script.js, γραμμές 83–84
  print: { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false,
    dieLine: { output: 'page', ink: 'Die', width: pt(0.5) } },
```

Το PDF χαράζει κάθε παράθυρο, και κάθε φύλλο με τις στρογγυλεμένες γωνίες της εξωτερικής του άκρης, σε έναν τσίγκο `Die` που τυπώνεται με υπερεκτύπωση και δεν μελανώνεται ποτέ. Σαράντα σελίδες με πίνακες μένουν κάτω από 1,5 MB με `convertImages: false`.

### 4 · Το τούνελ στο χέρι

```js
// script.js, γραμμές 99–105
  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 },
  },
```

Είκοσι φύλλα από χαρτόνι φτιάχνουν ένα χοντρό μπλοκ, και το Folio κόβει κάθε παράθυρο μέσα από αυτό: το κλειστό βιβλίο δείχνει το τούνελ με τα τοιχώματα της κοπής να κατεβαίνουν σκαλί σκαλί ως το ξέφωτο.

### 5 · Είκοσι επίπεδα σε μια επίπεδη σελίδα

```js
// script.js, γραμμές 250–260
// `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` ζωγραφίζει τη σελίδα που βρίσκεται δύο θέσεις πιο πέρα με το δικό της `beneath`, έτσι το παράθυρο του εξωφύλλου δείχνει τη σελίδα 3, το παράθυρο της οποίας δείχνει τη σελίδα 5, και ούτω καθεξής ως τη σελίδα 39. Κάθε σελίδα ζωγραφίζεται μία φορά και ξαναχρησιμοποιείται, και το επίπεδο εξώφυλλο δείχνει το ίδιο τούνελ με το βιβλίο.

## Η πλήρης συνταγή

Ένα αρχείο, συντεθειμένο από τον φάκελο της συνταγής με το δείγμα κειμένου και το κοινό κιτ του Συνταγολογίου ενσωματωμένα· φτιάχνει τη δική του σελίδα. Για να το εκτελέσετε, βάλτε το σε ένα `<script type="module">` σε μια κενή σελίδα, ή επικολλήστε το στο πάνελ JS ενός νέου CodePen (ως module). Εισάγει το postext από το esm.sh, οπότε δεν χρειάζεται εγκατάσταση ούτε build.

- Φάκελος πηγής: https://github.com/drnachio/postext/tree/main/cookbook/forest-tunnel-book

### script.js

```js
// ═══ 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
  corners: { radius: mm(4), edges: 'fore' },
};
// #endregion

// #region planes: each recto a painted plane, the verso behind it a line of the walk
// 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]) },
];
// #endregion

const config = {
  locale: t({ en: 'en-gb', es: 'es' }),
  colorPalette,
  page: { sizePreset: 'custom', width: mm(TRIM), height: mm(TRIM), dpi: 150,
    backgroundColor: col('forest'), cutLines: { enabled: false, bleed: mm(BLEED) },
    margins: { top: mm(TOP), bottom: mm(0), left: mm(SIDE), right: mm(SIDE) } },
  layout: { layoutType: 'single' },
  dieCuts,
  // #region die-line: nineteen circles on the Die plate, one per recto
  print: { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false,
    dieLine: { output: 'page', ink: 'Die', width: pt(0.5) } },
  // #endregion
  bodyText: { fontFamily: DISPLAY, fontSize: pt(14), lineHeight: pt(17), italic: true,
    color: col('cream'), italicColor: col('cream'), textAlign: 'center', firstLineIndent: pt(0),
    hyphenation: { enabled: false }, optimalLineBreaking: true, avoidRunts: true },
  headings: { fontFamily: DISPLAY, color: col('cream'), levels: [
    { level: 1, fontSize: pt(14), lineHeight: pt(17), marginTop: pt(0), marginBottom: pt(0) },
  ] },
  headingStyles,
  paragraphStyles: [{ id: 'colophon', fontFamily: TEXT, fontSize: pt(9), lineHeight: pt(12.5),
    italic: false, color: col('moss'), textAlign: 'center', firstLineIndent: pt(0),
    marginBottom: pt(4) }],
  header: { elements: [] }, // a picture book carries no running heads
  footer: { elements: [] }, // and no folios
  // #region folio: twenty board leaves, seen low enough for the windows to show their walls
  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 },
  },
  // #endregion
};

// ─── 2 · Content ────────────────────────────────────────────────────────────
// Each plane is a heading with a picture; the line after it is printed on its verso.
const markdown = String.raw`---
title: "Into the Wood"
subtitle: "A tunnel book in twenty planes"
---

# Into the Wood {style="cover" picture="plane01"}

Past the old oaks, the foxgloves lean out to see who comes.

# Foxgloves {style="plane" picture="plane02"}

Red toadstools sit out on the roots in the moss.

# Toadstools {style="plane" picture="plane03"}

A robin on the bramble sings that it saw you first.

# The robin {style="plane" picture="plane04"}

Bluebells lie under the trees like a low blue mist.

# Bluebells {style="plane" picture="plane05"}

A fox looks out of the bracken, and is gone.

# The fox {style="plane" picture="plane06"}

Holly, with its red berries and its sharp green leaves.

# Holly {style="plane" picture="plane07"}

The birches stand pale, like candles nobody has lit.

# Birches {style="plane" picture="plane08"}

An owl in the oak opens one eye, and shuts it again.

# The owl {style="plane" picture="plane09"}

The ferns grow wide, and the light comes in.

# Ferns {style="plane" picture="plane10"}

Old stones wear coats of green velvet moss.

# Mossy stones {style="plane" picture="plane11"}

A squirrel runs up a trunk and scolds you from the top.

# The squirrel {style="plane" picture="plane12"}

Two rabbits sit up and agree that you are harmless.

# Rabbits {style="plane" picture="plane13"}

The far trunks go grey and soft in the mist.

# Grey trunks {style="plane" picture="plane14"}

The path goes on, and the moss is soft underfoot.

# The path {style="plane" picture="plane15"}

The sun comes down through the leaves in long bright bars.

# Sunlight {style="plane" picture="plane16"}

The mist turns to gold all round you.

# Golden mist {style="plane" picture="plane17"}

The last branches open like a door.

# The last branches {style="plane" picture="plane18"}

Foxgloves again, standing tall in the sun.

# Foxgloves in the sun {style="plane" picture="plane19"}

And there, at the pool in the clearing, the deer.

# The clearing {style="plane" picture="plane20"}

:::paragraphs{style="colophon"}
Twenty painted planes of a wood, each with a smaller window than the last: from the cover you look through them all to the clearing.

Words: Postext Cookbook, CC BY 4.0. Paintings generated with diffusion models.
:::
`; // content.<lang>.md, inlined by the Cookbook

const PLANES = t({
  en: ['Two old oaks and ferns', 'Foxgloves', 'Red toadstools in the moss',
    'A robin on a bramble', 'Bluebells', 'A fox in autumn bracken', 'Holly with red berries',
    'Pale birches', 'A tawny owl on an oak branch', 'Wide ferns in the light',
    'Mossy stones', 'A red squirrel on a trunk', 'Two rabbits', 'Grey trunks in the mist',
    'The path through moss', 'Sunbeams through the leaves', 'Golden mist',
    'The last branches', 'Foxgloves in the sun', 'A doe and her fawn drinking at a pool'],
  es: ['Dos robles viejos y helechos', 'Dedaleras', 'Setas rojas en el musgo',
    'Un petirrojo en una zarza', 'Campanillas', 'Un zorro entre helechos de otoño',
    'Acebo con bayas rojas', 'Abedules pálidos', 'Un cárabo en una rama de roble',
    'Helechos a la luz', 'Piedras con musgo', 'Una ardilla roja en un tronco', 'Dos conejos',
    'Troncos grises en la niebla', 'El sendero entre el musgo', 'Rayos de sol entre las hojas',
    'Niebla dorada', 'Las últimas ramas', 'Dedaleras al sol',
    'Una cierva y su cervatillo bebiendo en una charca'],
});
const id = (k) => `plane${String(k).padStart(2, '0')}`;
const resources = PLANES.map((alt, i) => ({ id: id(i + 1), typeId: 'figure', kind: 'bitmap',
  createdAt: 0, updatedAt: 0, altText: alt,
  bitmap: { fileId: `${id(i + 1)}.jpg`, format: 'jpeg', width: 760, height: 760 } }));
const FILES = { plane01: asset('plane01.jpg'), plane02: asset('plane02.jpg'),
  plane03: asset('plane03.jpg'), plane04: asset('plane04.jpg'), plane05: asset('plane05.jpg'),
  plane06: asset('plane06.jpg'), plane07: asset('plane07.jpg'), plane08: asset('plane08.jpg'),
  plane09: asset('plane09.jpg'), plane10: asset('plane10.jpg'), plane11: asset('plane11.jpg'),
  plane12: asset('plane12.jpg'), plane13: asset('plane13.jpg'), plane14: asset('plane14.jpg'),
  plane15: asset('plane15.jpg'), plane16: asset('plane16.jpg'), plane17: asset('plane17.jpg'),
  plane18: asset('plane18.jpg'), plane19: asset('plane19.jpg'), plane20: asset('plane20.jpg') };

// ─── 3 · Fonts ──────────────────────────────────────────────────────────────
const FONTS = { 'Cormorant Garamond': ['500i', '600'], Lora: ['400'] };

// ─── 4 · Build & show ───────────────────────────────────────────────────────
await Promise.all(Object.entries(FILES).map(([key, url]) => loadImage(`${key}.jpg`, url)));
// The press file first, with bleed and marks; the screen's trimmed pages last.
const cut = { ...config.page.cutLines, enabled: true };
const pressConfig = { ...config, page: { ...config.page, cutLines: cut } };
const press = await buildDocumentWithFonts({ markdown, resources }, pressConfig, kitFonts(FONTS));
const doc = await buildDocumentWithFonts({ markdown, resources }, config, kitFonts(FONTS));

// #region folio-stage: the book closed on the desk, the tunnel straight ahead
const stage = document.createElement('section');
stage.id = 'folio';
stage.ariaLabel = t({ en: 'The tunnel book in 3D', es: 'El libro túnel en 3D' });
stage.style.cssText = 'height: min(78vh, 720px); margin: 0 auto; max-width: 1280px';
document.body.append(stage);
createFolioFromDocument(stage, doc, { at: 0,
  appearance: { textureBaseUrl: 'https://postext.dev/folio/textures' } });
// #endregion

// #region see-through: every recto looks down the rest of the tunnel
// `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);
};
// #endregion
showPages(doc, { title: t({ en: 'Into the Wood · a tunnel book',
  es: 'Al fondo del bosque · un libro túnel' }), beneath });
document.getElementById('pages').before(stage);
offerPdf(() => renderToPdf(press, { fontProvider: fontsourceProvider, resourceBytes: imageBytes,
  profileBaseUrl: 'https://postext.dev/icc/' }), `${RECIPE}.pdf`);

// ─── Kit ── helpers shared by every Cookbook recipe · postext.dev/cookbook ─────

// ─── Kit · core v1 ── the same in every recipe · postext.dev/cookbook
function mm(value) { return { value, unit: 'mm' }; }
function pt(value) { return { value, unit: 'pt' }; }
function em(value) { return { value, unit: 'em' }; }
/** The sample language's string: t({ en: 'Figure', es: 'Figura' }). */
function t(strings) { return strings[LANG] ?? Object.values(strings)[0]; }
/** A file in this recipe's assets folder, served from the Postext repo by jsDelivr. */
function asset(file) { return `https://cdn.jsdelivr.net/gh/drnachio/postext@main/cookbook/${RECIPE}/assets/${file}`; }

// ─── Kit · fonts v3 ── the same in every recipe · postext.dev/cookbook
// Postext loads the faces a config asks for before layout and asks the kit
// for Fontsource's files, the ones the PDF embeds too.

/** buildDocumentWithFonts' options: the resolver, and FONTS' faces loaded
 *  with the config's. FONTS = { 'Family Name': ['400', '400i', '700'] }. */
function kitFonts(FONTS = {}) {
  const faces = Object.entries(FONTS).flatMap(([family, specs]) => specs.map((spec) =>
    ({ family, weight: parseInt(spec, 10), style: spec.endsWith('i') ? 'italic' : 'normal' })));
  return { resolve: fontsourceResolver, faces };
}

/** A face's files with their ranges: latin, then latin-ext and greek when
 *  `text` needs them (kitSubsetsFor). Null for a face Fontsource lacks. */
async function fontsourceResolver(family, weight, style, { text = '' } = {}) {
  const id = fontsourceId(family);
  const meta = await fontsourceMeta(family);
  if (meta && !(await fontsourceWeights(family, style)).includes(weight)) return null;
  kitStatus('Loading fonts…');
  const at = await fontsourceAt(id);
  return ['latin', ...kitSubsetsFor(text, meta)].map((subset) => ({
    source: `${at}files/${id}-${subset}-${weight}-${style}.woff2`,
    unicodeRange: kitRanges()[subset],
  }));
}

/** Each file's unicode-range (a function: the kit runs after the pen's code). */
function kitRanges() {
  return {
    latin: 'U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,'
      + 'U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD',
    'latin-ext': 'U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,'
      + 'U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF',
    greek: 'U+0370-03FF',
  };
}

/** For the cjk, arabic and comics blocks: loads `faces` (as FONTS) for the
 *  sample `text`; `optional` skips a face Fontsource lacks. Files are added in
 *  the order asked, the last winning a shared character. Resolves to the count. */
async function loadFonts(faces, text = '', { optional = false } = {}) {
  kitStatus('Loading fonts…');
  const ranges = kitRanges();
  const jobs = [];
  for (const [family, specs] of Object.entries(faces)) {
    const id = fontsourceId(family);
    const todo = [...new Set(specs)].map((spec) => [parseInt(spec, 10), spec.endsWith('i') ? 'italic' : 'normal'])
      .filter(([weight, style]) => !hasFace(family, weight, style)); // before any await
    const at = fontsourceAt(id);
    const meta = optional || /[^\0-ÿ]/u.test(text) ? await fontsourceMeta(family) : null;
    const subsets = ['latin', ...kitSubsetsFor(text, meta)];
    for (const [weight, style] of todo) {
      if (optional && !(meta && (await fontsourceWeights(family, style)).includes(weight))) continue;
      for (const subset of subsets) {
        const url = `${await at}files/${id}-${subset}-${weight}-${style}.woff2`;
        const face = new FontFace(family, `url(${url}) format('woff2')`,
          { weight: String(weight), style, unicodeRange: ranges[subset] });
        jobs.push(face.load().catch(() => {
          if (subset === 'latin' && !optional) throw new Error(`Fontsource has no ${family} ${weight} ${style}`);
        }));
      }
    }
  }
  const ready = await Promise.all(jobs).catch((error) => { kitFail(error); throw error; });
  return ready.filter((face) => face && document.fonts.add(face)).length;
}

/** A loaded FontFace covers this face (fonts.check() says yes to any family). */
function hasFace(family, weight, style) {
  for (const face of document.fonts) {
    if (face.status !== 'loaded' || face.style !== style) continue;
    if (face.family.replace(/^["']|["']$/g, '') !== family) continue;
    const [low, high = low] = face.weight.split(' ').map(Number);
    if (weight >= low && weight <= high) return true;
  }
  return false;
}

/** The files beyond latin `text` needs that `meta`'s family ships. */
function kitSubsetsFor(text, meta) {
  return [[/[Ā-˿ᴀ-ᶿḀ-ỿ†ℓⱠ-Ɀ꜠-ꟿ]/u, 'latin-ext'], [/[Ͱ-Ͽ]/u, 'greek']]
    .filter(([re, x]) => re.test(text) && meta?.subsets?.includes(x)).map(([, x]) => x);
}

/** Fontsource's id for a family: 'Source Serif 4' → 'source-serif-4'. */
function fontsourceId(family) { return family.toLowerCase().replace(/\s+/g, '-'); }

/** A package's folder at the one version @5 names now (#766). */
function fontsourceAt(id, u = `https://cdn.jsdelivr.net/npm/@fontsource/${id}@`) {
  return (fontsourceAt.c ??= {})[id] ??= fetch(u + '5/package.json').then((r) => r.json())
    .then((p) => p.version || 5, () => 5).then((v) => `${u}${v}/`);
}

/** The family's Fontsource metadata (weights, styles, subsets), or null. */
function fontsourceMeta(family, id = fontsourceId(family)) {
  return (fontsourceMeta.c ??= {})[id] ??= fetch(`https://api.fontsource.org/v1/fonts/${id}`)
    .then((res) => (res.ok ? res.json() : null), () => null);
}

/** The weights the package ships in `style`: the API pairs none (no Libre
 *  Caslon 700 italic file), so italics are read from latin-italic.css. */
function fontsourceWeights(family, style, id = fontsourceId(family)) {
  return (fontsourceWeights.c ??= {})[id + style] ??= fontsourceMeta(family).then(async (m) => {
    if (!m?.styles.includes(style)) return m ? [] : [400, 700];
    const css = style === 'italic' ? await fetch(`${await fontsourceAt(id)}latin-italic.css`).then((r) => (r.ok ? r.text() : ''), () => '') : '';
    const w = [...css.matchAll(/weight: (\d+)/g)].map((x) => +x[1]);
    return w.length ? w : m.weights;
  });
}

// ─── Kit · viewer v2 ── the same in every recipe · postext.dev/cookbook
/** The pages as spreads on a dark desk, page 1 alone, then verso | recto,
 *  each painted when it scrolls near. Other options go to renderPageToCanvas. */
function showPages(docs, { title, width = 460, ...render } = {}) {
  const root = viewer(title);
  const pages = [docs].flat().flatMap((doc) =>
    doc.pages.map((page) => ({ doc, page, n: (doc.pageIndexOffset ?? 0) + page.index })));
  const spreads = [];
  let verso = null;
  for (const p of pages) {
    if (p.n % 2 === 1) { if (verso) spreads.push([verso, null]); verso = p; }
    else { spreads.push([verso, p]); verso = null; }
  }
  if (verso) spreads.push([verso, null]);
  const density = Math.min(window.devicePixelRatio || 1, 2);
  showPages.painter?.disconnect();
  const painter = new IntersectionObserver((entries) => {
    for (const { isIntersecting, target } of entries) {
      if (!isIntersecting) continue;
      painter.unobserve(target);
      const { doc, page } = target.postext;
      renderPageToCanvas(page, doc, target, { ...render, scale: (width * density) / page.width });
    }
  }, { rootMargin: '800px' });
  showPages.painter = painter;
  root.replaceChildren(...spreads.map((pair) => {
    const spread = document.createElement('div');
    spread.className = 'pt-spread';
    for (const p of pair) {
      const figure = document.createElement('figure');
      if (p) {
        const label = p.page.pageLabel || String(p.n + 1);
        const canvas = document.createElement('canvas');
        canvas.postext = p;
        canvas.style.aspectRatio = `${p.page.width} / ${p.page.height}`;
        canvas.setAttribute('role', 'img');
        canvas.setAttribute('aria-label', `Page ${label}`);
        const folio = document.createElement('figcaption');
        folio.textContent = label;
        figure.append(canvas, folio);
        painter.observe(canvas);
      } else figure.className = 'pt-blank';
      spread.append(figure);
    }
    return spread;
  }));
  kitStatus(`${pages.length} ${pages.length === 1 ? 'page' : 'pages'}`);
  document.documentElement.dataset.postext = 'ready';
  return pages.length;
}

/** The desk, the bar and the error reporting, created once. */
function viewer(title) {
  if (!document.getElementById('pt-kit')) {
    document.head.insertAdjacentHTML('beforeend', `<style id="pt-kit">
      :root { color-scheme: dark; }
      body { margin: 0; background: #0e1014; color: #b9bcc4; font: 13px/1.45 system-ui, sans-serif; }
      #pt-bar { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center;
        gap: 6px 16px; padding: 10px 16px; background: rgb(14 16 20 / .92); backdrop-filter: blur(6px);
        border-bottom: 1px solid #23262d; }
      #pt-bar strong { color: #f4f1ea; font-weight: 600; }
      #pt-actions { display: flex; gap: 12px; margin-left: auto; }
      #pt-actions a, #pt-actions button { color: #d8a21a; font: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
      #pages { display: grid; justify-items: center; gap: 48px; padding: 32px 16px 72px; }
      .pt-spread { display: flex; }
      .pt-spread figure { margin: 0; width: min(460px, 44vw); }
      .pt-spread canvas { display: block; width: 100%; background: #fff;
        box-shadow: 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); }
      .pt-spread figure:first-child canvas { box-shadow: inset -14px 0 14px -14px rgb(0 0 0 / .18), 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); }
      .pt-spread figcaption { margin-top: 10px; text-align: center; font: 600 10px/1 system-ui, sans-serif;
        letter-spacing: .18em; text-transform: uppercase; color: #6c7079; }
      .pt-blank { visibility: hidden; }
      @media (max-width: 760px) {
        .pt-spread { flex-direction: column; gap: 32px; }
        .pt-spread figure { width: min(460px, 92vw); }
        .pt-blank { display: none; }
      }
    </style>`);
    document.body.insertAdjacentHTML('afterbegin',
      '<header id="pt-bar"><strong id="pt-title"></strong><span id="pt-status" role="status"></span><span id="pt-actions"></span></header>');
    document.getElementById('pt-title').textContent = document.title || 'Postext';
    addEventListener('error', (event) => kitFail(event.error ?? event.message));
    addEventListener('unhandledrejection', (event) => kitFail(event.reason));
  }
  if (title) document.getElementById('pt-title').textContent = title;
  return document.getElementById('pages')
    ?? document.body.appendChild(Object.assign(document.createElement('main'), { id: 'pages' }));
}

function kitStatus(text) {
  viewer();
  document.getElementById('pt-status').textContent = text;
}

function kitFail(error) {
  document.documentElement.dataset.postext = 'error';
  kitStatus(`Error: ${error?.message ?? error}`);
}

// ─── Kit · pdf v3 ── the same in every recipe that exports a PDF
/** The Fontsource files the screen used, as TrueType, with their range and
 *  place: the nearest weight the family ships in that style, upright with no italic;
 *  latin, then what its letters need (kitSubsetsFor). */
async function fontsourceProvider(family, weight, style, request) {
  const id = fontsourceId(family);
  const meta = await fontsourceMeta(family);
  const s = style === 'italic' && meta && !meta.styles.includes('italic') ? 'normal' : style;
  const shipped = meta ? await fontsourceWeights(family, s) : [];
  const weights = shipped.length ? shipped : [400, 700];
  const w = weights.reduce((a, b) => (Math.abs(b - weight) < Math.abs(a - weight) ? b : a));
  const text = String.fromCodePoint(...(request?.codePoints ?? []));
  const files = await Promise.all(['latin', ...kitSubsetsFor(text, meta)].map(async (subset, order) => {
    const res = await fetch(`${await fontsourceAt(id)}files/${id}-${subset}-${w}-${s}.woff2`);
    if (!res.ok) throw new Error(`Fontsource has no ${family} ${w} ${s} ${subset}`);
    return Object.assign(await decompressWoff2(new Uint8Array(await res.arrayBuffer())),
      { unicodeRange: kitRanges()[subset], order });
  }));
  return files.length === 1 ? files[0] : files;
}

/** A "Build the PDF" button; then "Open the PDF" (a new tab: CodePen's frame
 *  shows no PDFs) and a download link. */
function offerPdf(makePdf, filename) {
  viewer();
  const button = Object.assign(document.createElement('button'), { type: 'button', textContent: 'Build the PDF' });
  button.dataset.postextPdf = filename;
  button.addEventListener('click', async () => {
    button.disabled = true;
    button.textContent = 'Building the PDF…';
    try {
      const bytes = await makePdf();
      const url = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }));
      const size = `${Math.max(1, Math.round(bytes.length / 1024))} KB`;
      button.replaceWith(
        Object.assign(document.createElement('a'), { href: url, target: '_blank', rel: 'noopener', textContent: 'Open the PDF ↗' }),
        Object.assign(document.createElement('a'), { href: url, download: filename, textContent: `Download ${filename} · ${size}` }));
    } catch (error) {
      button.disabled = false;
      button.textContent = 'Build the PDF';
      kitFail(error);
    }
  });
  document.getElementById('pt-actions').append(button);
}

// ─── Kit · images v3 ── recipes with pictures · postext.dev/cookbook
/** Registers a photo or PNG for the canvas and keeps its bytes for the PDF.
 *  fetch → ImageBitmap never taints the canvas (a plain cross-origin <img> would). */
async function loadImage(fileId, url) {
  const res = await fetch(url);
  if (!res.ok) throw new Error(`Image not found (${res.status}): ${url}`);
  const bytes = new Uint8Array(await res.arrayBuffer());
  registerResourceImage(fileId, await createImageBitmap(new Blob([bytes])));
  (loadImage.bytes ??= new Map()).set(fileId, bytes);
}

/** Registers SVG markup as a vector image, its fonts inside (inlineSvgFonts, ≥ 1.25).
 *  `options` go to registerResourceImage: { singleInk: true } tints it on the canvas. */
async function loadSvg(fileId, svg, options) {
  if (typeof inlineSvgFonts === 'function') svg = await inlineSvgFonts(svg, svgFaces);
  const img = new Image();
  img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
  await img.decode();
  registerResourceImage(fileId, img, options);
  (loadImage.bytes ??= new Map()).set(fileId, new TextEncoder().encode(svg));
}

/** A face's Fontsource files: nearest weight; latin + what the SVG sets. */
async function svgFaces(family, weight, style, { codePoints = [] } = {}) {
  const [id, m] = [fontsourceId(family), await fontsourceMeta(family)];
  const w = m?.weights.reduce((a, b) => (Math.abs(b - weight) < Math.abs(a - weight) ? b : a)) ?? weight;
  const s = m?.styles.includes(style) === false ? 'normal' : style;
  return Promise.all(['latin', ...kitSubsetsFor(String.fromCodePoint(...codePoints), m)].map(async (x) => new Uint8Array(
    await (await fetch(`${await fontsourceAt(id)}files/${id}-${x}-${w}-${s}.woff2`)).arrayBuffer())));
}

/** renderToPdf({ resourceBytes: imageBytes }) */
function imageBytes(fileId) { return loadImage.bytes?.get(fileId); }

/** renderToHtml({ resourceImageUrl: imageUrl }) */
function imageUrl(fileId) {
  const bytes = imageBytes(fileId);
  if (!bytes) return undefined;
  imageUrl.urls ??= new Map();
  if (!imageUrl.urls.has(fileId)) {
    const type = /\.svg$/i.test(fileId) ? 'image/svg+xml' : /\.png$/i.test(fileId) ? 'image/png' : 'image/jpeg';
    imageUrl.urls.set(fileId, URL.createObjectURL(new Blob([bytes], { type })));
  }
  return imageUrl.urls.get(fileId);
}

// ─── /Kit ───────────────────────────────────────────────────────────────────────
```

## Παραλλαγές

### Τετράγωνα παράθυρα με στρογγυλεμένες γωνίες

Ένα `roundRect` με ακτίνα γωνίας το ένα τρίτο του μισού πλάτους του δίνει μια πιο μαλακή όψη, σαν κομμένο χαρτί.

```diff
-    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)),
```

### Στρογγυλέψτε κάθε γωνία

Ένα βιβλίο από χαρτόνι για μικρά χέρια στρογγυλεύει και τις τέσσερις γωνίες κάθε φύλλου.

```diff
-  corners: { radius: mm(4), edges: 'fore' },
+  corners: { radius: mm(8), edges: 'all' },
```

## Ευχαριστίες

- Συνταγή: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Κείμενο: The verse of the walk and the colophon: Postext Cookbook, CC-BY-4.0
- Εικόνες: Plane 1 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 2 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 3 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 4 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 5 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 6 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 7 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 8 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 9 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 10 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 11 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 12 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 13 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 14 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 15 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 16 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 17 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 18 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 19 of the wood: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plane 20 of the wood: Generated With Diffusion Models, πρωτότυπο
- Γραμματοσειρές: Cormorant Garamond (OFL-1.1), Lora (OFL-1.1)
- Κώδικας: MIT · Δείγμα περιεχομένου: CC-BY-4.0

## Σχετικές συνταγές

- [Αρ. 193 · Ένα βιβλίο κουκού-τζα από χαρτόνι με τρύπες σε σύμπτωση](https://postext.dev/el/cookbook/peek-a-boo-board-book.md): Τέσσερις τρύπες κοπής με dieCuts στη λεπτομέρεια που δείχνει η επόμενη εικόνα, παράθυρο που στενεύει σε μικρότερη τρύπα, στρογγυλές γωνίες, γραμμή κοπτικού. · Επίπεδο 2 (Μεσαίο) · Μονόφυλλα και εφήμερα έντυπα
- [Αρ. 100 · Ένα σελιδοποιημένο βιβλίο πάνω στο γραφείο, σε 3D](https://postext.dev/el/cookbook/folio-book-on-a-desk.md): Το createFolioFromDocument του postext-folio ανοίγει σελιδοποιημένο κεφάλαιο ως πανόδετο βιβλίο σε γραφείο από καρυδιά, με όψη από το config.folio. · Επίπεδο 2 (Μεσαίο) · Πεζογραφία, θέατρο και λογοτεχνικός λόγος
- [Αρ. 191 · Μενού αρτοποιείου με λευκό μελάνι σε χαρτί kraft](https://postext.dev/el/cookbook/white-ink-kraft-menu.md): Αδιαφανές λευκό ως μελάνι spot σε kraft: λευκά γράμματα στο καφέ χαρτόνι, λευκή κάρτα κάτω από καφέ γράμματα, και λευκό με αφαίρεση από πράσινο πεδίο. · Επίπεδο 3 (Προχωρημένο) · Μονόφυλλα και εφήμερα έντυπα
