Коротко
Толстая картонная книга о прогулке по лесу. В каждом листе круглое отверстие чуть меньше предыдущего, и с обложки видно до последней страницы.
Что получится
Into the Wood — книга-туннель из двадцати картонных листов в квадрате 150 мм. Каждая правая полоса — один план нарисованного леса (дубы, наперстянки, малиновка, лиса в папоротнике, сова, берёзы), и в каждой вырезано круглое окно чуть меньше предыдущего, все с общим центром. Последний план цельный: олениха с оленёнком у пруда на поляне. С обложки взгляд проходит сквозь все девятнадцать окон до оленей, а срезы картона стоят вокруг туннеля, как стволы. На обороте каждого листа строка стихов называет план напротив. Файл для печати содержит все окна на форме вырубки.
Рецепт отвечает на вопросы
- Как сделать книгу-тоннель с отверстиями на двадцать страниц в глубину?
- Как отправить изготовителю штампа контур вырубки отдельной формой в PDF?
Короткий ответ
// 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' },
};
Ингредиенты
- Возможности
- Вырубные отверстияКонтур вырубки в PDFСкруглённые углы и фигурные книгиТрёхмерный просмотр книги (Folio)Стили заголовковИллюстрации в дизайне страницыТекст, линейки и рамки в дизайне страницыМетаданные документаСтили абзацевВылет и метки обрезаPDF в CMYK и в оттенках серогоЭкспорт в PDFРисунки и таблицы как ресурсыСемантическая палитраСтраницы на холсте
- Также применяет
- Бумага, переплёт, стол и свет (Folio)Атрибуты заголовковОформленные начальные полосыЦвет бумагиШрифты, встроенные в PDFГлавы без номера
- Шрифты
- Cormorant Garamond, Lora (SIL OFL 1.1)
- Материалы
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, оригинал)
- 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 · Планы в приводке с окнами
// 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
print: { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false,
dieLine: { output: 'page', ink: 'Die', width: pt(0.5) } },
PDF обводит каждое окно и каждый лист со скруглёнными наружными углами на отдельной форме Die, которая накладывается поверх красок (оверпринт) и сама краской не печатается. Сорок страниц живописи укладываются в 1,5 МБ при convertImages: false.
#4 · Туннель в руках
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 · Двадцать планов на плоской странице
// `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. Каждая страница рисуется один раз и используется снова, и плоская обложка показывает тот же туннель, что и книга.
Рецепт целиком
// ═══ 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 работает как есть: вставьте его в модульный скрипт любой страницы или откройте рецепт на 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)
Изменить описание рецепта ↗ (открывается в новой вкладке)Папка рецепта на GitHub ↗ (открывается в новой вкладке)


