跳到主要内容
食谱编号147

排版食谱 · 第11章 · 漫画与连环画

跨页大图、插格和破格

两页漫画里的一场暴风雨:出血的满版大图上叠一个插格,一层三边出血,一只海鸥飞出格子边框,还有一格只有旁白。

本页内容
类型
漫画
输出
Canvas · PDF
难度
中级
Postext
已用Postext 1.65.0测试
需要≥ 1.25.0 · postext-pdf ≥ 1.25.0
许可证
更新于2026年10月10日
代码MIT · 文本CC BY 4.0
  • 成品尺寸168 × 259 mm
  • 1栏
  • ZCOOL KuaiLe 10/14
  • 2页
  • 难度
  • Postext 1.65.0
  • 排版用时156 ms
  • 116行代码

简单来说

两页讲暴风雨的漫画:第一页是一整幅大画,上面叠着一个小格子画着女孩;第二页里一只海鸥飞出了画框。

成品一览

《珀斯科夫灯塔》里暴风雨的两页。第一页是满版大图:一幅暴风雨中的灯塔铺满整页,四边都出血,右下角叠着一个带框的小格子,画着窗前的玛雅。第二页开头是一道三边出血的巨浪;下面,一只海鸥从守塔人那一格飞出,越过边框;旁边一个没有画面的窄格,在藏青底色上放了两个旁白框。开本是美式漫画书的 168 × 259 mm,出血 3 mm,有十种语言的版本。

这道食谱解答

  • 怎样让一格出血到页边外,或让人物冲出格框?

简短回答

script.js · 第44–64行在完整代码中
// In the Markdown, the panel attributes do the work:
//   :::page{split="*" bleed}                 one panel, every edge bled off the page
//   ::panel{art=sp-maya-face inset="56 64 38 30"}   over the panel before it: x y w h in %
//   ::panel{art=sp-wave bleed="top start end"}      only the edges that touch the trim
//   ::panel{art=sp-tomas pop=sp-tomas-pop}   a transparent layer drawn over the border
//   ::panel{bg=night}                        no picture: captions on a palette colour
// A bleeding panel runs to the bleed box, 3 mm past the trim, and loses its border on those
// sides. The pop layer is cropped and placed exactly like the panel's picture, then drawn
// after the border without the panel's clip, so whatever it holds outside the cell shows.
const comics = {
  gutter: { horizontal: mm(4), vertical: mm(3) },
  panel: { borderWidth: pt(1.2), borderColor: col('ink'), background: col('paper') },
  lettering: { fontFamily: LETTERING, fontSize: pt(8.5), color: col('ink'), inset: mm(2) },
  balloonStyles: [
    { id: 'speech', stroke: col('ink') },
    { id: 'caption', fill: col('lamp'), stroke: col('ink') },
    { id: 'inner', fill: col('paper'), stroke: col('ink') },
    { id: 'sfx', fontFamily: SFX, color: col('accent'), haloColor: col('ink'), halo: pt(2) },
  ],
  runningHeads: true, // a comic page has no running head unless asked: here, its folio
};

用料

类型
Comic Neue, Bangers, Zen Antique, Dela Gothic One, ZCOOL KuaiLe, ZCOOL QingKe HuangYou, Playpen Sans Arabic, Lalezar(SIL OFL 1.1)
素材
  • sp-maya-face.jpg
  • sp-splash.jpg
  • sp-tomas-pop.png
  • sp-tomas.jpg
  • sp-wave.jpg
  • Panel picture: the lighthouse in the storm (splash) (Generated With Diffusion Models, 原创)
  • Panel picture: Maya at the window (inset) (Generated With Diffusion Models, 原创)
  • Panel picture: the wave on the rocks (Generated With Diffusion Models, 原创)
  • Panel picture: the keeper on the gallery (Generated With Diffusion Models, 原创)
  • Panel picture: the gull flying over the border (transparent layer) (Generated With Diffusion Models, 原创)

做法

#1 · 让满版大图四边出血

代码就是上面的简短回答。split="*" 让整个画框只有一个格子,页面上的 bleed 让碰到画框的每一格都延伸到出血框,超出裁切线 3 mm,这几边不画边框(分割页面)。第2页上,巨浪那一格的 bleed="top start end" 只让这三边出血,底边仍和下面的格子保持格间距。start 和 end 跟随阅读方向,所以从右往左读的日文版和阿拉伯文版出血的边也一样。

#2 · 在大图上叠一个插格

inset="56 64 38 30" 把玛雅那一格放在前一格的 56%、64% 处,宽 38%,高 30%。插格不占格子:它叠在大图上,有自己的边框,阅读时紧跟在大图之后。它的画面按自己的安全区裁切到自己的框里,这里保留的是玛雅的脸。

插格:玛雅的脸在自己的框里,叠在大图右下角,配着她的内心独白。

#3 · 让海鸥飞出边框

script.js · 第111–197行在完整代码中
// From the art manifest; fractions of each picture, the same in every language. The gull's
// layer is a transparent PNG the size of the keeper's picture, so it shares its crop.
const face = (x, y, width, height) => ({ x, y, width, height });
const ART = {
  'sp-splash': { width: 708, height: 1000, safeArea: face(0.26, 0.14, 0.6, 0.48),
    anchors: [{ id: 'sfx', x: 0.82, y: 0.4 }], avoid: [face(0.28, 0.15, 0.17, 0.35)] },
  'sp-maya-face': { width: 1000, height: 1000, safeArea: face(0.33, 0.26, 0.35, 0.34),
    anchors: [{ id: 'maya', x: 0.52, y: 0.48, face: face(0.37, 0.27, 0.29, 0.31) }] },
  'sp-wave': { width: 1400, height: 600, safeArea: face(0.4, 0.12, 0.53, 0.6),
    anchors: [{ id: 'sfx', x: 0.6, y: 0.35 }], avoid: [face(0.82, 0.02, 0.06, 0.3)] },
  'sp-tomas': { width: 1000, height: 1000, safeArea: face(0.22, 0.13, 0.6, 0.49),
    anchors: [{ id: 'tomas', x: 0.63, y: 0.345, head: { x: 0.67, y: 0.24 },
      face: face(0.56, 0.17, 0.24, 0.25) }], avoid: [face(0.32, 0.13, 0.15, 0.33)] },
  'sp-tomas-pop': { width: 1000, height: 1000 },
};
const ALT = {
  'sp-splash': t({ en: 'The red-and-white lighthouse in a night storm, waves exploding on the '
      + 'rocks, its beam cutting through the rain, lightning behind.',
    es: 'El faro rojo y blanco en una noche de tormenta: las olas revientan en las rocas, el haz '
      + 'corta la lluvia y detrás cae un rayo.',
    ca: 'El far vermell i blanc en una nit de tempesta: les onades esclaten a les roques, el feix '
      + 'talla la pluja i al darrere cau un llamp.',
    zh: '暴风雨之夜,红白相间的灯塔,浪头在礁石上炸开,光束穿过雨幕,后面是闪电。',
    ar: 'المنارة الحمراء والبيضاء في ليلة عاصفة، والموج يتفجّر على الصخور، وشعاعها يشقّ المطر، '
      + 'وخلفها برق.',
    ja: '嵐の夜の赤と白の灯台。岩に波が砕け、光の帯が雨を切り裂き、後ろで稲妻が光る。',
    pt: 'O farol vermelho e branco numa noite de tempestade: as ondas arrebentam nas pedras, o '
      + 'facho corta a chuva e, atrás, cai um raio.',
    fr: 'Le phare rouge et blanc par une nuit de tempête : les vagues explosent sur les rochers, '
      + 'le faisceau fend la pluie et, derrière, un éclair.',
    de: 'Der rot-weiße Leuchtturm in einer Sturmnacht: Wellen explodieren an den Felsen, sein '
      + 'Strahl schneidet durch den Regen, dahinter ein Blitz.',
    it: 'Il faro bianco e rosso in una notte di tempesta: le onde si infrangono sugli '
      + 'scogli, il fascio di luce taglia la pioggia e, dietro, cade un fulmine.' }),
  'sp-maya-face': t({ en: 'Maya’s face behind a rain-streaked window, hood up, lit by the lamp.',
    es: 'La cara de Maya tras una ventana surcada de lluvia, con la capucha puesta y la luz de la '
      + 'lámpara.',
    ca: 'La cara de la Maya darrere una finestra plena de pluja, amb la caputxa posada i la llum '
      + 'del llum.',
    zh: '玛雅戴着兜帽,脸贴在满是雨痕的窗后,被灯光照亮。',
    ar: 'وجه مايا خلف نافذة يسيل عليها المطر، والقلنسوة على رأسها، ونور المصباح عليها.',
    ja: '雨の筋が流れる窓の向こうに、フードをかぶったマヤの顔。ランプの光に照らされている。',
    pt: 'O rosto de Maya atrás de uma janela riscada de chuva, de capuz, à luz da lamparina.',
    fr: 'Le visage de Maya derrière une vitre striée de pluie, capuche sur la tête, à la lueur de '
      + 'la lampe.',
    de: 'Mayas Gesicht hinter einem regenüberströmten Fenster, die Kapuze auf, vom Licht der '
      + 'Lampe beleuchtet.',
    it: 'Il volto di Maya dietro una finestra rigata di pioggia, col cappuccio alzato, '
      + 'alla luce della lampada.' }),
  'sp-wave': t({ en: 'A huge wave bursts over black rocks below the lighthouse at night.',
    es: 'Una ola enorme revienta sobre las rocas negras al pie del faro, de noche.',
    ca: 'Una onada enorme esclata sobre les roques negres al peu del far, de nit.',
    zh: '夜里,一道巨浪在灯塔下的黑色礁石上炸开。',
    ar: 'موجة هائلة تتفجّر ليلًا فوق الصخور السوداء تحت المنارة.',
    ja: '夜、灯台の下の黒い岩に巨大な波が砕け散る。',
    pt: 'Uma onda enorme arrebenta nas pedras negras ao pé do farol, à noite.',
    fr: 'Une vague énorme se brise sur les rochers noirs au pied du phare, la nuit.',
    de: 'Eine gewaltige Welle bricht nachts über die schwarzen Felsen unter dem Leuchtturm.',
    it: 'Un’onda enorme si abbatte sugli scogli neri ai piedi del faro, di notte.' }),
  'sp-tomas': t({ en: 'The keeper in an oilskin on the lantern gallery holds up a storm lantern, '
      + 'his beard whipping in the wind.',
    es: 'El farero, con impermeable de hule en la galería, levanta un farol; el viento le agita '
      + 'la barba.',
    ca: 'El faroner, amb impermeable d’hule a la galeria, aixeca un fanal; el vent li remena la '
      + 'barba.',
    zh: '守塔人穿着油布雨衣站在灯室回廊上,高举一盏防风灯,胡子被风吹得乱飞。',
    ar: 'الحارس بمعطفه المشمّع على شرفة الفانوس يرفع مصباح العاصفة، والريح تعبث بلحيته.',
    ja: '油合羽の灯台守が回廊でカンテラを掲げる。ひげが風にあおられている。',
    pt: 'O faroleiro, de capa impermeável na galeria, ergue um lampião; o vento agita a barba '
      + 'dele.',
    fr: 'Le gardien, en ciré sur la galerie du phare, brandit une lanterne ; le vent lui fouette '
      + 'la barbe.',
    de: 'Der Wärter in Ölzeug hebt auf der Galerie der Laterne eine Sturmlaterne; der Wind '
      + 'peitscht ihm den Bart.',
    it: 'Il guardiano del faro, in cerata sul ballatoio, solleva una lanterna; il vento '
      + 'gli sferza la barba.' }),
  'sp-tomas-pop': t({ en: 'A herring gull flies out across the panel’s left border.',
    es: 'Una gaviota sale volando por el borde izquierdo de la viñeta.',
    ca: 'Una gavina surt volant per la vora esquerra de la vinyeta.',
    zh: '一只银鸥飞出格子的左边框。',
    ar: 'نورس فضي يطير خارجًا عبر الحافة اليسرى للإطار.',
    ja: 'セグロカモメがコマの左の枠を越えて飛んでいく。',
    pt: 'Uma gaivota sai voando pela borda esquerda do quadro.',
    fr: 'Une mouette s’envole par-dessus le bord gauche de la case.',
    de: 'Eine Silbermöwe fliegt über den linken Rand des Panels hinaus.',
    it: 'Un gabbiano esce in volo oltre il bordo sinistro della vignetta.' }),
};

pop=sp-tomas-pop 给守塔人那一格加第二张图:一张和他的画一样大小的透明 PNG,上面只有海鸥。Postext 用和这格画面完全相同的方式裁切、摆放它,然后在边框之后、不受格子裁剪地画出来,于是海鸥伸出格子的部分就飞过了边框和页边(分格与画面)。focus="45% 50%" 在安全区允许的范围内把取景往左移,让海鸥横跨左边框,而不是整只落在页边上。

#4 · 留一个没有画面的格子

script.js · 第19–31行在完整代码中
const palette = {
  ink: '#141b24', // panel borders and lettering
  night: '#1d2a3a', // the ground of the text-only panel
  lamp: '#f2c14e', // the captions: the colour of the lantern
  accent: '#e9f0f5', // sound effects: surf white, outlined in ink
  muted: '#5c6672', // folios
  paper: '#fbfaf7',
};
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: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];

没有 art 的 ::panel 是一个空格子,带着格子样式的边框;bg=night 用调色板里的颜色填满它。它的两个旁白框 at=top 和 at=bottom 分别贴着上下边,是暴风雨之后的一个停顿。

完整食谱

沙盒
// ═══ Postext Cookbook · Nº 147 · A splash page, an inset and a broken border ═══════
// https://postext.dev/en/cookbook/splash-inset-broken-border
// Code: MIT · Text: original (CC BY 4.0) · Pictures: generated with diffusion models
// Fonts: Comic Neue, Bangers and the faces of five editions (OFL) · Needs postext ≥ 1.25.0
//
// Two pages of a storm: a splash page that bleeds off all four edges with a small inset panel
// laid over it, then a page whose top tier bleeds off three edges, whose second panel lets a
// gull fly out over its border, and whose last panel holds only captions on a night-blue ground.
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage, loadVerticalAlternates,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'zh'; // @lang: 'en' | 'es' | 'ca' | 'zh' | 'ar' | 'ja' | 'pt' | 'fr' | 'de' | 'it'
const RECIPE = 'splash-inset-broken-border';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: storm blue, lamplight and the white of the surf
const palette = {
  ink: '#141b24', // panel borders and lettering
  night: '#1d2a3a', // the ground of the text-only panel
  lamp: '#f2c14e', // the captions: the colour of the lantern
  accent: '#e9f0f5', // sound effects: surf white, outlined in ink
  muted: '#5c6672', // folios
  paper: '#fbfaf7',
};
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: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
// #endregion

// #region editions: six editions, each lettered in faces for its script
const [LETTERING, SFX] = t({
  en: ['Comic Neue', 'Bangers'], es: ['Comic Neue', 'Bangers'], ca: ['Comic Neue', 'Bangers'],
  ja: ['Zen Antique', 'Dela Gothic One'], zh: ['ZCOOL KuaiLe', 'ZCOOL QingKe HuangYou'],
  ar: ['Playpen Sans Arabic', 'Lalezar'], pt: ['Comic Neue', 'Bangers'],
  fr: ['Comic Neue', 'Bangers'], de: ['Comic Neue', 'Bangers'], it: ['Comic Neue', 'Bangers'],
});
// #endregion

// #region answer: a bleed, an inset and a pop-out, written on the panels themselves
// In the Markdown, the panel attributes do the work:
//   :::page{split="*" bleed}                 one panel, every edge bled off the page
//   ::panel{art=sp-maya-face inset="56 64 38 30"}   over the panel before it: x y w h in %
//   ::panel{art=sp-wave bleed="top start end"}      only the edges that touch the trim
//   ::panel{art=sp-tomas pop=sp-tomas-pop}   a transparent layer drawn over the border

组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)

变化

#下面一层也出血

-::panel{art=sp-tomas pop=sp-tomas-pop focus="45% 50%"}
+::panel{art=sp-tomas pop=sp-tomas-pop focus="45% 50%" bleed="bottom start"}

#给插格加白框

命名的格子样式只改一个格子,在格子上用 style= 选用。

   panel: { borderWidth: pt(1.2), borderColor: col('ink'), background: col('paper') },
+  panelStyles: [{ id: 'framed', borderWidth: pt(3), borderColor: col('paper') }],

常见问题

  • 破格用的图层必须和这一格画面的像素尺寸完全一样:Postext 用同一个窗口裁切它,小一号的抠图会落到别的位置。
  • 出血需要设置 page.bleed;没有它,出血的格子只到裁切线为止。
  • 靠近出血边的拟声词可能伸进出血区,越过裁切线,被裁刀切掉。日文的“ザッバーン”是五个字高的竖行,所以固定得比拉丁字母的拟声词低,放在 60% 44%。

致谢

文本
原创文字, CC BY 4.0
图片
  • Panel picture: the lighthouse in the storm (splash) · Generated With Diffusion Models · 原创
  • Panel picture: Maya at the window (inset) · Generated With Diffusion Models · 原创
  • Panel picture: the wave on the rocks · Generated With Diffusion Models · 原创
  • Panel picture: the keeper on the gallery · Generated With Diffusion Models · 原创
  • Panel picture: the gull flying over the border (transparent layer) · Generated With Diffusion Models · 原创
字体
Comic Neue (SIL OFL 1.1) · Bangers (SIL OFL 1.1) · Zen Antique (SIL OFL 1.1) · Dela Gothic One (SIL OFL 1.1) · ZCOOL KuaiLe (SIL OFL 1.1) · ZCOOL QingKe HuangYou (SIL OFL 1.1) · Playpen Sans Arabic (SIL OFL 1.1) · Lalezar (SIL OFL 1.1)
沙盒PDF