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

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

絵と穴の位置がそろった、いないいないばあのボードブック

dieCutsで次の絵のだまし所に合わせた4つの抜き穴、さらに小さな穴へ続く表紙の窓、角丸、抜き型の線。

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

1ページ(全14ページ)

  • 英語の見本:日本語版はまだありません
  • 仕上がり160 × 160 mm
  • 1段
  • Andika 24/31
  • Fredoka
  • Nunito
  • 14ページ
  • レベル
  • Postext 1.84.0
  • 組版時間9 ms
  • コード187行

かんたんな説明

小さな子のための厚紙の絵本。ページの穴から次の絵が少しだけ見え、文で当てっこをして、ページをめくると本当は何だったかがわかります。

できあがり

Peek-a-boo! Who’s in the Garden?(スペイン語版は『¡Cucú!』)。160ミリ角、14ページのボードブックで、四隅を丸く抜いています。どの絵にも穴があり、その穴は次の絵の、目をだます部分にぴったり重なります。眠っている猫のしま模様の脇腹はトラに見え、羊の毛は雲に、ちょうちんは月に見えます。表紙の窓は奥の穴より大きいので、最初のひと目で2ページ奥までのぞけます。左のページの文が当てっこをさせ、めくると答えが出ます。印刷所に渡すPDFには、抜き型の線が専用の版に載ります。

このレシピが答える質問

  • 本のページに穴を抜いて、それぞれの穴から次の絵の一部が見えるようにするには?
  • 抜き型の線をPDFの専用の版に載せて抜き型屋に渡すには?

手短な答え

script.js · 43〜61行コード全体で見る
// Each painting is cut where the next one's telling part lies: the cat's striped flank, the
// sheep's wool, the lantern's glow. The cover's window is wider than the hedge's hole and
// holds it, so from the cover you see the hedge, and through the hedge the cat. A hole cuts
// both sides of its leaf, mirrored on the verso, and the words there run round it.
const circle = (id, name, cx, cy, d) => ({ id, name, shape: 'circle', x: mm(cx - d / 2),
  y: mm(cy - d / 2), width: mm(d), height: mm(d), wrap: { gap: mm(4) } });
const dieCuts = {
  shapes: [
    circle('window', t({ en: 'Cover window', es: 'Ventana de la cubierta' }), 112, 68, 60),
    circle('hedge', t({ en: 'Gap in the hedge', es: 'Hueco del seto' }), 112, 60, 36),
    { id: 'knot', name: t({ en: 'Knothole', es: 'Nudo de la valla' }), shape: 'ellipse',
      x: mm(102), y: mm(48), width: mm(32), height: mm(40), wrap: { gap: mm(4) } },
    circle('peephole', t({ en: 'Barn-door peephole', es: 'Mirilla del granero' }), 91, 29, 20),
  ],
  // By position in the book: page 1 is the cover, 3 the hedge, 7 the fence, 11 the door.
  pages: [{ pages: '1', die: 'window' }, { pages: '3', die: 'hedge' },
    { pages: '7', die: 'knot' }, { pages: '11', die: 'peephole' }],
  corners: { radius: mm(9), edges: 'all' }, // board books are rounded on all four corners
};

材料

種類
Andika, Fredoka, Nunito (SIL OFL 1.1)
素材
  • cat.jpg
  • cover.jpg
  • door.jpg
  • fence.jpg
  • hedge.jpg
  • lantern.jpg
  • sheep.jpg
  • Cover painting: a cottage garden, a hedge, hollyhocks and a robin (Generated With Diffusion Models, オリジナル)
  • Page 3: the hedge (Generated With Diffusion Models, オリジナル)
  • Page 5: the ginger cat asleep (Generated With Diffusion Models, オリジナル)
  • Page 7: the wooden fence (Generated With Diffusion Models, オリジナル)
  • Page 9: the sheep (Generated With Diffusion Models, オリジナル)
  • Page 11: the barn door (Generated With Diffusion Models, オリジナル)
  • Page 13: Grandpa and his lantern at dusk (Generated With Diffusion Models, オリジナル)

作り方

#1 · 次の絵が正体を見せる場所に穴を

コードは上の手短な答えです。形は仕上がりの左上の角から置き、dieCuts.pagesで抜くページを、本の最初のページから数えて指定します。穴は、それを抜くページではなく、穴からのぞく絵の上で測ります。生け垣、柵、扉はどこに穴があってもよいテクスチャーですが、猫とちょうちんはそうはいきません。

#2 · 穴と位置をそろえた絵

script.js · 65〜84行コード全体で見る
// Each painting hangs from the trim and runs BLEED past it on every side, so the holes hit it
// in the same place on screen and in print. A picture's section drops the foot margin, so its
// design reaches the foot of the page; the words on the verso behind it, in the same section,
// start TOP down.
const SHEET = { width: mm(TRIM + 2 * BLEED), height: mm(TRIM + 2 * BLEED) }; // trim + 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 flush = { margins: { top: mm(TOP), bottom: mm(0), left: mm(INNER), right: mm(OUTER) } };
const title = { kind: 'text', id: 'title', content: '{titleText}', fontFamily: DISPLAY,
  fontWeight: 600, fontSize: pt(40), lineHeight: 1, color: col('accent'), align: 'left',
  placement: at('page', 'top-left', 62, 8, { width: mm(88) }) };
const headingStyles = [
  { id: 'cover', numbered: false, toc: false, ...flush, advancedDesign: full([painting, title]) },
  { id: 'picture', numbered: false, ...flush, breakBefore: { enabled: true, parity: 'odd' },
    advancedDesign: full([painting]) },
  // The back cover: the board printed dusk blue (the section's palette), the type in cream.
  { id: 'back', numbered: false, toc: false, breakBefore: { enabled: true, parity: 'even' },
    color: col('cream'), palette: { paper: palette.dusk } },
];

穴の位置は仕上がり線からのミリで決まるので、どの絵も仕上がり線から下げ、四辺とも塗り足し分はみ出させます。画面でも印刷でも同じ位置です。絵のスタイルは下マージンだけをなくします。デザインはページの下端まで届き、絵の裏の左ページの文字は44ミリの上マージンを保って、小さな穴の上端より下から始まります。

#3 · 専用の版に載る抜き型の線

script.js · 96〜99行コード全体で見る
  // The die line is stroked on a Separation plate of its own ('Die'), overprinting, that the
  // press never inks. PDF/X-4 on coated stock: the board is printed on coated paper.
  print: { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false,
    dieLine: { output: 'page', ink: 'Die', width: pt(0.5) } },

PDFは各ページを丸ごと印刷し、穴と角丸の丁の輪郭を、オーバープリントでインキを載せないDieの分版に描きます。convertImages: falseで絵はsRGBタグ付きのRGB JPEGのまま残り(PDF/X-4で認められています)、ファイルは小さく収まります。

#4 · 手に取った本

script.js · 122〜128行コード全体で見る
  folio: {
    tilt: 50, yaw: -32,
    paper: { type: 'board', shade: '#fbf5e8' },
    binding: { type: 'hardcover', cover: 'pages', coverMaterial: 'paper' },
    surface: { type: 'oak' },
    lighting: { environment: 'daylight', intensity: 1.05 },
  },

Folioは各丁に穴を抜き、切り口の壁ごと下のページを見せるので、段になった窓が奥行きとして読めます。厚紙は硬くめくれ、角丸はすべての丁で抜かれます。

#5 · 平らなページでものぞける

script.js · 242〜252行コード全体で見る
// renderPageToCanvas cuts the holes; `beneath` hands it the pages under them, painted here
// at a lower scale (the composite stretches them to the page), each with its own holes.
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がページを番号で返し、それぞれ自分の穴ごと描かれるので、表紙から生け垣が、生け垣の穴から猫が見えます。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 193 · A peek-a-boo board book with holes in register ════════
// https://postext.dev/en/cookbook/peek-a-boo-board-book
// Code: MIT · Text: original (CC BY 4.0) · Paintings: generated with diffusion models
// Fonts: Andika, Fredoka, Nunito (SIL OFL 1.1) · Needs postext ≥ 1.84.0
//
// A fourteen-page board book for toddlers: on every other recto a hole is cut through the
// painting, and what shows through it is a scrap of the next picture. The words on the left
// make a guess from the scrap; the turned page shows what it really is. The leaves have
// rounded corners, the holes step down from the cover, and the PDF carries the die line.
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 = 'peek-a-boo-board-book';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a cream board, a robin red for the title and the guesses, a dusk blue
const palette = {
  ink: '#2a2420', // text: a warm near-black
  accent: '#b8432c', // the cover title and the guesses: the robin's breast
  paper: '#fbf5e8', // the board the words are printed on
  dusk: '#253a63', // the back cover, the blue of the last painting's sky
  cream: '#fff9ec', // type on the cover and the back
  muted: '#7a6f64', // 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: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
// #endregion
const [TRIM, BLEED] = [160, 3]; // mm: a square board book, and its bleed
const [TOP, FOOT, INNER, OUTER] = [44, 16, 18, 16]; // the words sit low, under the holes' tops
const [TEXT, DISPLAY, LABEL] = ['Andika', 'Fredoka', 'Nunito'];
const LEAD = 31; // pt: 24 pt type on a generous leading, for reading aloud
const at = (to, edge, x = 0, y = 0, size) => ({ anchor: { to, edge },
  offset: { x: mm(x), y: mm(y) }, ...(size && { size }) });

// #region answer: the dies, and the pages they cut
// Each painting is cut where the next one's telling part lies: the cat's striped flank, the
// sheep's wool, the lantern's glow. The cover's window is wider than the hedge's hole and
// holds it, so from the cover you see the hedge, and through the hedge the cat. A hole cuts
// both sides of its leaf, mirrored on the verso, and the words there run round it.
const circle = (id, name, cx, cy, d) => ({ id, name, shape: 'circle', x: mm(cx - d / 2),
  y: mm(cy - d / 2), width: mm(d), height: mm(d), wrap: { gap: mm(4) } });

組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)

アレンジ

#小口側の角だけ丸める

絵本では背から遠い2つの角を丸め、背側は直角のままにします。

-  corners: { radius: mm(9), edges: 'all' }, // board books are rounded on all four corners
+  corners: { radius: mm(6), edges: 'fore' },

#丁ごと形に抜く

viewBox単位の輪郭で各丁を抜きます。左ページでは左右反転し、角丸より優先されます。

   corners: { radius: mm(9), edges: 'all' }, // board books are rounded on all four corners
+  outline: { d: 'M0 0.35 L0.5 0 L1 0.35 L1 1 L0 1 Z', viewBox: [1, 1] }, // a house

クレジット

レシピ
Ignacio Ferro
本文
  • The words of the board book · Postext Cookbook · CC BY 4.0
画像
  • Cover painting: a cottage garden, a hedge, hollyhocks and a robin · Generated With Diffusion Models · オリジナル
  • Page 3: the hedge · Generated With Diffusion Models · オリジナル
  • Page 5: the ginger cat asleep · Generated With Diffusion Models · オリジナル
  • Page 7: the wooden fence · Generated With Diffusion Models · オリジナル
  • Page 9: the sheep · Generated With Diffusion Models · オリジナル
  • Page 11: the barn door · Generated With Diffusion Models · オリジナル
  • Page 13: Grandpa and his lantern at dusk · Generated With Diffusion Models · オリジナル
フォント
Andika (SIL OFL 1.1) · Fredoka (SIL OFL 1.1) · Nunito (SIL OFL 1.1)
SandboxPDF