本文へスキップ
レシピ番号195

レシピ集 · 第10章 · 出力と組み込み

20枚の奥行きをもつトンネルブック

dieCutsで19の丸窓を同じ軸に、ひとつずつ小さく抜き、表紙から20枚の森の層を通して、池のほとりのシカまで見通します。

このページの内容
レベル
上級
Postext
Postext 1.84.0で検証済み
1.84.0以上が必要 · postext-pdf ≥ 1.84.0
ライセンス
2026年11月13日更新
コードMIT · 本文CC BY 4.0

1ページ(全40ページ)

  • 英語の見本:日本語版はまだありません
  • 仕上がり150 × 150 mm
  • 1段
  • Cormorant Garamond 14/17
  • Lora
  • 40ページ
  • レベル
  • Postext 1.84.0
  • 組版時間6 ms
  • コード166行

かんたんな説明

森の散歩をえがいた厚いボードブック。どの丁にも前より少し小さな丸い穴があり、表紙から最後のページまで見通せます。

できあがり

Into the Wood(スペイン語版は『Al fondo del bosque』)。150ミリ角、20枚のボードでできたトンネルブックです。右ページはそれぞれ描かれた森の一層で(オーク、ジギタリス、コマドリ、シダの中のキツネ、フクロウ、シラカバ)、どれも前より少し小さな丸窓を同じ中心に抜いてあります。最後の層だけは抜かず、空き地の池にいる母ジカと子ジカです。表紙からのぞくと19の窓を通ってシカまで目が届き、ボードの切り口が木の幹のようにトンネルを囲みます。各丁の裏には、向かいの層を名指す一行の詩があります。印刷所に渡すPDFには、すべての窓が抜き型の版に載ります。

このレシピが答える質問

  • 穴から二十ページ奥まで見えるトンネルブックを作るには?
  • 抜き型の線を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 · 同じ軸にそろえた19の窓

コードは上の手短な答えです。窓はループで作ります。k枚目の丁には同じ中心で半径R1 · Q^(k − 1)の円が与えられ、dieCuts.pagesがそれを2k − 1ページ、つまりその丁の表に置きます。穴は丁の両面を抜くので、裏にも同じ窓が左右反転して開きます。Q = 0.9162で、半径は18段階で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版の19の円

script.js · 83〜84行コード全体で見る
  print: { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false,
    dieLine: { output: 'page', ink: 'Die', width: pt(0.5) } },

PDFは各窓と、小口側の角を丸めた各丁の輪郭を、オーバープリントでインキを載せないDieの分版に描きます。convertImages: falseで、40ページの絵でも1.5メガバイトに収まります。

#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 },
  },

20枚のボードは厚いかたまりになり、Folioはそのすべてに窓を抜きます。閉じた本にはトンネルが現れ、切り口の壁が段になって空き地まで下りていきます。

#5 · 平らなページで20層

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は2ページ先のページを、それ自身の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はそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)

アレンジ

#角の丸い四角の窓

roundRectで角の半径を半幅の3分の1にすると、切り絵のようなやわらかい感じになります。

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