Pular para o conteúdo principal
Receita número 195

Receitas · Capítulo 10 · Saída e integração

Um livro túnel com vinte folhas de fundo

Dezenove janelas redondas cortadas com dieCuts, cada uma menor que a anterior num mesmo eixo: da capa se vê através de vinte planos até um cervo.

Nesta página
Nível
Avançado
Postext
Testada com o Postext 1.84.0
Requer ≥ 1.84.0 · postext-pdf ≥ 1.84.0
Licença
Atualizada em 13 de nov. de 2026
Código MIT · Texto CC BY 4.0
  • Amostra em inglês: ainda sem edição em português
  • Refile 150 × 150 mm
  • 1 coluna
  • Cormorant Garamond 14/17
  • Lora
  • 40 páginas
  • Nível
  • Postext 1.84.0
  • Diagramado em 6 ms
  • 166 linhas de código

Em poucas palavras

Um livro grosso de papelão sobre um passeio no bosque. Cada folha tem um furo redondo um pouco menor que o anterior, e da capa se vê até a última página.

O que você vai compor

No fundo do bosque, um livro túnel de vinte folhas de papelão num quadrado de 150 mm. Cada página ímpar é um plano de um bosque pintado (carvalhos, dedaleiras, um pisco, uma raposa entre as samambaias, uma coruja, bétulas), e cada uma tem uma janela redonda um pouco menor que a anterior, todas no mesmo centro. O último plano é inteiro: uma corça e seu filhote num lago da clareira. Da capa, o olhar atravessa as dezenove janelas até os cervos, e as bordas do papelão cortado cercam o túnel como os próprios troncos. No verso de cada folha, um verso nomeia o plano em frente. O PDF da gráfica leva todas as janelas na chapa de faca.

Esta receita responde a

  • Como faço um livro túnel cujos furos deixam ver vinte páginas de profundidade?
  • Como entrego a quem faz a faca a linha de faca numa chapa própria do PDF?

A resposta curta

script.js · linhas 38–50no código completo
// 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' },
};

Ingredientes

Tipografia
Cormorant Garamond, Lora (SIL OFL 1.1)
Materiais
  • 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, original)
  • Plane 2 of the wood (Generated With Diffusion Models, original)
  • Plane 3 of the wood (Generated With Diffusion Models, original)
  • Plane 4 of the wood (Generated With Diffusion Models, original)
  • Plane 5 of the wood (Generated With Diffusion Models, original)
  • Plane 6 of the wood (Generated With Diffusion Models, original)
  • Plane 7 of the wood (Generated With Diffusion Models, original)
  • Plane 8 of the wood (Generated With Diffusion Models, original)
  • Plane 9 of the wood (Generated With Diffusion Models, original)
  • Plane 10 of the wood (Generated With Diffusion Models, original)
  • Plane 11 of the wood (Generated With Diffusion Models, original)
  • Plane 12 of the wood (Generated With Diffusion Models, original)
  • Plane 13 of the wood (Generated With Diffusion Models, original)
  • Plane 14 of the wood (Generated With Diffusion Models, original)
  • Plane 15 of the wood (Generated With Diffusion Models, original)
  • Plane 16 of the wood (Generated With Diffusion Models, original)
  • Plane 17 of the wood (Generated With Diffusion Models, original)
  • Plane 18 of the wood (Generated With Diffusion Models, original)
  • Plane 19 of the wood (Generated With Diffusion Models, original)
  • Plane 20 of the wood (Generated With Diffusion Models, original)

Preparo

#1 · Dezenove janelas num eixo

O código é a resposta curta acima. As janelas saem de um laço: a folha k recebe um círculo de raio R1 · Q^(k − 1) em volta do mesmo centro, e dieCuts.pages o coloca na página 2k − 1, a frente dessa folha. Um furo corta as duas faces, então o verso atrás tem a mesma janela, espelhada. Q = 0,9162 leva de 58 mm a 12 mm em dezoito passos.

#2 · Planos em registro com as janelas

script.js · linhas 54–71no código completo
// 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]) },
];

Cada pintura tem sua própria clareira de névoa, então as imagens foram redimensionadas antes de entrar no livro: em cada uma se mediu em pixels o raio onde as folhas cobrem metade do anel, e a pintura foi redimensionada até esse raio encontrar a janela da sua folha. Da capa, cada plano mostra só um anel fino de folhas em volta da janela, e os anéis se empilham num túnel. O centro que cada faca leva embora é liso, e quase não pesa no arquivo.

#3 · Dezenove círculos na chapa Die

script.js · linhas 83–84no código completo
  print: { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false,
    dieLine: { output: 'page', ink: 'Die', width: pt(0.5) } },

O PDF traça cada janela, e cada folha com os cantos arredondados do lado do corte, numa separação Die em sobreimpressão que nunca é entintada. Quarenta páginas de pinturas ficam abaixo de 1,5 MB com convertImages: false.

#4 · O túnel na mão

script.js · linhas 99–105no código completo
  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 },
  },

Vinte folhas de papelão fazem um bloco grosso, e o Folio corta cada janela através dele: o livro fechado mostra o túnel, com as paredes do corte descendo em degraus até a clareira.

#5 · Vinte planos numa página plana

script.js · linhas 250–260no código completo
// `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 pinta a página duas adiante com seu próprio beneath: a janela da capa mostra a página 3, cuja janela mostra a 5, e assim até a 39. Cada página é pintada uma vez e reutilizada.

A receita completa

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

O script.js montado funciona como está: cole-o como script de módulo em qualquer página ou abra a receita no CodePen. Pasta da receita no GitHub ↗ (abre em uma nova aba)

Variações

#Janelas quadradas de cantos redondos

Um roundRect com raio de canto de um terço da sua meia-largura dá um ar mais suave, de papel recortado.

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

#Arredonde todos os cantos

Um livro de papelão para mãos pequenas arredonda os quatro cantos de cada folha.

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

Créditos

Texto
  • The verse of the walk and the colophon · Postext Cookbook · CC BY 4.0
Imagens
  • Plane 1 of the wood · Generated With Diffusion Models · original
  • Plane 2 of the wood · Generated With Diffusion Models · original
  • Plane 3 of the wood · Generated With Diffusion Models · original
  • Plane 4 of the wood · Generated With Diffusion Models · original
  • Plane 5 of the wood · Generated With Diffusion Models · original
  • Plane 6 of the wood · Generated With Diffusion Models · original
  • Plane 7 of the wood · Generated With Diffusion Models · original
  • Plane 8 of the wood · Generated With Diffusion Models · original
  • Plane 9 of the wood · Generated With Diffusion Models · original
  • Plane 10 of the wood · Generated With Diffusion Models · original
  • Plane 11 of the wood · Generated With Diffusion Models · original
  • Plane 12 of the wood · Generated With Diffusion Models · original
  • Plane 13 of the wood · Generated With Diffusion Models · original
  • Plane 14 of the wood · Generated With Diffusion Models · original
  • Plane 15 of the wood · Generated With Diffusion Models · original
  • Plane 16 of the wood · Generated With Diffusion Models · original
  • Plane 17 of the wood · Generated With Diffusion Models · original
  • Plane 18 of the wood · Generated With Diffusion Models · original
  • Plane 19 of the wood · Generated With Diffusion Models · original
  • Plane 20 of the wood · Generated With Diffusion Models · original
Fontes
Cormorant Garamond (SIL OFL 1.1) · Lora (SIL OFL 1.1)
SandboxPDF