انتقل إلى المحتوى الرئيسي
الوصفة رقم 195

دليل الوصفات · الفصل 10 · الإخراج والدمج

كتاب نفق بعمق عشرين ورقة

تسع عشرة نافذة مستديرة مقصوصة بـ dieCuts، كلٌّ أصغر من سابقتها على محور واحد: من الغلاف ترى عبر عشرين طبقة حتى غزال عند البركة.

في هذه الصفحة
المُخرَج
Canvas · PDF · عناصر تحكم حية
المستوى
متقدم
Postext
اختُبرت مع Postext 1.84.0
تتطلب ≥ 1.84.0 · postext-pdf ≥ 1.84.0
الترخيص
حُدّثت في 13 نوفمبر 2026
الشيفرة MIT · النص CC BY 4.0
  • نموذج باللغة الإنجليزية: لا توجد طبعة عربية بعد
  • مقاس القص 150 × 150 مم
  • عمود واحد
  • Cormorant Garamond 14/17
  • Lora
  • 40 صفحة
  • المستوى
  • Postext 1.84.0
  • أُخرجت في 6 ms
  • أسطر الشيفرة: 166

باختصار

كتاب سميك من الورق المقوّى عن نزهة في غابة. في كل ورقة ثقب مستدير أصغر قليلًا من الذي قبله، فترى من الغلاف حتى الصفحة الأخيرة.

ما الذي ستنضده

Into the Wood (وبالإسبانية Al fondo del bosque)، كتاب نفق من عشرين ورقة مقوّاة على مربع طوله 150 مم. كل صفحة يمنى طبقة من غابة مرسومة (سنديان، وقفّاز الثعلب، وأبو الحناء، وثعلب بين السراخس، وبومة، وبتولا)، وفي كلٍّ منها نافذة مستديرة أصغر قليلًا من سابقتها، وكلها حول المركز نفسه. والطبقة الأخيرة كاملة: ظبية وصغيرها عند بركة في الفسحة. من الغلاف يعبر النظر النوافذ التسع عشرة حتى الظباء، وتحيط حواف الورق المقصوص بالنفق كأنها الجذوع نفسها. وعلى ظهر كل ورقة بيت يسمّي الطبقة المقابلة. ويحمل ملف المطبعة كل النوافذ على لوح القص.

تجيب هذه الوصفة عن

  • كيف أصنع كتاب نفق تكشف فتحاته عشرين صفحة في العمق؟
  • كيف أسلّم صانع القالب خط القص على لوح خاص به في ملف PDF؟

الجواب المختصر

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' },
};

المكونات

الخطوط
Cormorant Garamond, Lora (SIL OFL 1.1)
الأصول
  • plane01.jpg
  • plane02.jpg
  • plane03.jpg
  • plane04.jpg
  • plane05.jpg
  • plane06.jpg
  • plane07.jpg
  • plane08.jpg
  • plane09.jpg
  • plane10.jpg
  • plane11.jpg
  • plane12.jpg
  • plane13.jpg
  • plane14.jpg
  • plane15.jpg
  • plane16.jpg
  • plane17.jpg
  • plane18.jpg
  • plane19.jpg
  • plane20.jpg
  • 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, أصلي)

طريقة التحضير

#1 · تسع عشرة نافذة على محور واحد

الشيفرة هي الجواب المختصر أعلاه. تُبنى النوافذ في حلقة تكرار: تأخذ الورقة k دائرة نصف قطرها R1 · Q^(k − 1) حول المركز نفسه، وتضعها dieCuts.pages في الصفحة 2k − 1، أي وجه تلك الورقة. والثقب يقصّ وجهي الورقة، فللظهر خلفه النافذة نفسها معكوسة. وتنقل Q = 0.9162 نصف القطر من 58 مم إلى 12 مم في ثماني عشرة خطوة.

#2 · طبقات مطابقة لنوافذها

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]) },
];

لكل لوحة فسحتها الضبابية، لذا غُيّر حجم الصور قبل دخولها الكتاب: قيس في كلٍّ منها بالبكسل نصف القطر الذي تغطي عنده الأوراق نصف الحلقة، ثم صُغّرت اللوحة حتى يلتقي هذا النصف قطر بنافذة ورقتها. ومن الغلاف لا تُظهر كل طبقة إلا حلقة رفيعة من الأوراق حول نافذتها، فتتراكب الحلقات نفقًا. والمركز الذي يأخذه كل قص لون واحد، فلا يكاد يزيد حجم الملف.

#3 · تسع عشرة دائرة على لوح Die

script.js · الأسطر 83–84في الشيفرة الكاملة
  print: { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false,
    dieLine: { output: 'page', ink: 'Die', width: pt(0.5) } },

يرسم ملف PDF كل نافذة، وكل ورقة بزاويتيها المستديرتين عند الحافة الأمامية، على فصل لوني Die بطباعة فوقية لا يُحبَّر أبدًا. وتبقى أربعون صفحة من اللوحات دون 1.5 ميغابايت مع convertImages: false.

#4 · النفق في اليد

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 · عشرون طبقة على صفحة مسطحة

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. وتُرسم كل صفحة مرة واحدة ثم يعاد استعمالها.

الوصفة كاملة

Sandbox
// ═══ 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

يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)

تنويعات

#نوافذ مربعة مستديرة الزوايا

roundRect بنصف قطر زاوية يساوي ثلث نصف عرضه يعطي مظهرًا ألين، كالورق المقصوص.

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

#اجعل كل الزوايا مستديرة

كتاب الورق المقوّى للأيدي الصغيرة يستدير زواياه الأربع في كل ورقة.

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

الحقوق

الوصفة
Ignacio Ferro
النص
  • 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 (SIL OFL 1.1) · Lora (SIL OFL 1.1)
الشيفرة
MIT، مثل Postext
SandboxPDF