简单来说
一份仿20世纪30年代的地方报纸,每张照片都是一段无声短片。纸上它们是静止的图片;在3D查看器里,它们一起动起来,一遍又一遍,像童话里的报纸。
成品一览
《The Wexcombe Lantern》是一份虚构的海滨周报,这一期出版于1933年6月,版面是280 × 430 mm的小报,分四栏,栏间有线:窄体报头,一篇头条配一张横跨三栏的图片,另一篇配两栏宽的图片,还有潮汐表、分类小广告和一个体育版。每张图片都是一段五秒的黑白影片。印刷版里,以及查看器下方的平面页面里,每张都是它的首帧。在Folio里,它是一份印在浅色新闻纸上的对折报纸,打开的版面上的图片同时动起来,而且一直动:市长在讲话,女飞行员在挥手,渔夫在笑,守门员扑出去又站起来。页面本身什么也不画;版式就是一份普通的报纸,其余交给这些片段。
这道食谱解答
- 怎样让一页上的几段无声循环视频同时播放,并在每次翻到这一页时重新开始?
- 怎样在3D阅读器里把报纸显示成对折的纸张,并把财经版印在鲑鱼色纸上?
简短回答
// A video resource prints its poster (the first frame) on the flat page. In Folio, and in the
// HTML viewer, the poster comes alive: autoplay starts it muted when its page is on show, loop
// keeps it going, and exclusive: false lets it run alongside the other clips instead of
// pausing them, as one exclusive player at a time would.
const videoStyle = {
playMark: { enabled: false }, // a press photograph, not a play button
qr: { enabled: false }, // the clips live on the page, not behind a link
linkPoster: false,
player: { autoplay: true, loop: true, muted: true, exclusive: false, controls: false },
};
const clip = (id, url, [w, h], placement, caption, altText) => ({ id, typeId: 'picture',
kind: 'video', createdAt: 0, updatedAt: 0, caption, altText, placement,
video: { source: 'file', fileId: `${id}-loop.mp4`, url, // url: where the clip plays from
format: 'mp4', width: w, height: h, duration: 5,
poster: { fileId: `${id}-poster.jpg`, format: 'jpeg', width: w, height: h } } });
用料
- 功能
- 同时播放的视频三栏及以上作为资源的视频视频封面:播放标记和二维码跨多栏的浮动体报纸开本对折的报纸(Folio)3D书本查看器(Folio)纸张、装订、台面与光照(Folio)设计过的章首页标题样式标题属性页面设计中的文字、线条和框书眉与页码栏间线标注框框内或正文中的分栏段落样式来源与出处行
- 类型
- Libre Caslon Text, Oswald, Courier Prime(SIL OFL 1.1)
- 素材
actress-loop.mp4actress-poster.jpgaviator-loop.mp4aviator-poster.jpgclock-loop.mp4clock-poster.jpgfisherman-loop.mp4fisherman-poster.jpgkeeper-loop.mp4keeper-poster.jpgmayor-loop.mp4mayor-poster.jpg- Mrs Edith Rowe speaks at the opening of the Harbour line: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg (Generated With Diffusion Models, CC BY 4.0)
- The first frame of the mayor loop, its printed picture (Generated With Diffusion Models, CC BY 4.0)
- The Guildhall clock tower: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg (Generated With Diffusion Models, CC BY 4.0)
- The first frame of the clock loop, its printed picture (Generated With Diffusion Models, CC BY 4.0)
- Skipper Jacob Hosking with the cod: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg (Generated With Diffusion Models, CC BY 4.0)
- The first frame of the fisherman loop, its printed picture (Generated With Diffusion Models, CC BY 4.0)
- Miss Constance Lacey in the cockpit: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg (Generated With Diffusion Models, CC BY 4.0)
- The first frame of the aviator loop, its printed picture (Generated With Diffusion Models, CC BY 4.0)
- Miss Rosalind Avery on the stage: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg (Generated With Diffusion Models, CC BY 4.0)
- The first frame of the actress loop, its printed picture (Generated With Diffusion Models, CC BY 4.0)
- Tom Rundle in goal: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg (Generated With Diffusion Models, CC BY 4.0)
- The first frame of the keeper loop, its printed picture (Generated With Diffusion Models, CC BY 4.0)
做法
#1 · 把每张图片做成和其他片段一起循环的视频
代码就是上面的简短回答。视频资源把海报帧当作图片印出,所以这些片段可以代替照片,也像照片一样带题注。三个播放器选项让页面动起来:autoplay在片段所在的页面显示时开始播放(总是静音,这是浏览器的要求),loop让它从头再放,exclusive: false让它和其他片段同时播放。视频默认是独占的:一段开始播放,其他正在播放的都会暂停,这适合讲课视频,却不适合一整版会动的照片。播放标记和二维码都关掉了,所以纸上的片段看起来就是新闻照片。
#2 · 给每段循环视频在网格上安排位置
const resources = [
clip('mayor', asset('mayor-loop.mp4'), [640, 480],
{ position: 'top', span: 'column', columns: 3 },
'**Mrs Edith Rowe** speaks from the platform at the foot of Quay Hill before cutting '
+ 'the ribbon.',
'A woman in a dark coat and small hat speaks at a draped podium, one hand raised.'),
clip('clock', asset('clock-loop.mp4'), [480, 640],
{ position: 'top', span: 'column', columns: 2 },
'**Twelve o’clock** on the Guildhall tower, for the first time since 1924.',
'A stone clock tower against clouds, pigeons on its ledge.'),
clip('fisherman', asset('fisherman-loop.mp4'), [640, 480],
{ position: 'auto', span: 'column', columns: 2 },
'**Skipper Jacob Hosking** and the 82-pound cod on the quay.',
'An old fisherman in an oilskin laughs, holding up a huge cod.'),
clip('aviator', asset('aviator-loop.mp4'), [640, 480],
{ position: 'top', span: 'column', columns: 2 },
'**Miss Constance Lacey** waves from the cockpit on Wexcombe Common.',
'A young woman in a flying helmet waves from the open cockpit of a biplane.'),
clip('actress', asset('actress-loop.mp4'), [480, 640],
{ position: 'top', span: 'column', columns: 2 },
'**Miss Rosalind Avery** as Hester Lane, on the garden steps in Act III.',
'An actress in a long gown on a garden stage set, one arm outstretched.'),
clip('keeper', asset('keeper-loop.mp4'), [640, 480],
{ position: 'top', span: 'column', columns: 3 },
'**Tom Rundle** at Gannet Park, before the penalty he saved.',
'A goalkeeper in a flat cap crouches on his line in front of a packed terrace.'),
];
版式是layoutType: 'multiple'加columnCount: 4。浮动体的columns决定它占几栏:市长和守门员各占三栏,女飞行员、钟楼、渔夫和女演员各占两栏。跨几栏的浮动体会占据一组顶端齐平的空栏的顶部,或者占据引用它的那一栏及其后各空栏的底部,所以::resource行放在哪里,决定了它落在哪个空位。市长的片段在第一段之后引用,于是第1栏留给正文,图片排在第2到第4栏上方。
#3 · 排报头和各版的版名
const nameplate = { enabled: true, slot: { elements: [
depth(10), // the masthead is ten grid lines deep; the rules and the dateline hang from it
{ kind: 'rule', id: 'foot', thickness: pt(2.5), color: col('ink'),
placement: { ...at('#depth', 'align-bottom', 0, -1.5), size: { width: 'fill' } } },
...[['left', '{attr.issue}'], ['center', '{publishDate}'], ['right', '{attr.price}']].map(
([align, content]) => text(`date-${align}`, content, { ...typed(9, { fontWeight: 700 }),
align }, { ...at('#foot', 'above', 0, -1.6), size: { width: 'fill' } })),
rule('thin', '#date-left', 0.6, 1.8),
text('name', '{titleText}', { ...oswald(66, 700, { textTransform: 'uppercase',
letterSpacing: pt(1.5) }), lineHeight: 1, align: 'center' },
{ ...at('#thin', 'above', 0, -2), size: { width: 'fill' } }),
// Two ears over the name: the paper's age on the left, the weather on the right.
text('since', '{attr.since}', { ...caps(8, 600, 'flag'), align: 'left' },
{ ...at('container', 'top-left', 0, 1), size: { width: mm(90) } }),
text('weather', 'Weather: {attr.weather}', { ...typed(8.5, { italic: true }), align: 'right' },
{ ...at('container', 'top-right', 0, 1), size: { width: mm(110) } }),
] } };
头版的一级标题就是报名,由一个设计槽位画出:上方两个报眼,报名用Oswald大写字母,日期行夹在一细一粗两条线之间。内页以3 pt横条上的红色栏目旗标开头(pages区域),除第一页外,每页顶部都有页码行。
#4 · 在Folio里打开报纸
const stage = Object.assign(document.createElement('section'),
{ id: 'folio', ariaLabel: 'The newspaper in 3D' });
stage.style.cssText = 'height: min(82vh, 820px); margin: 0 auto; max-width: 1280px';
document.getElementById('pages').before(stage);
createFolioFromDocument(stage, doc, {
// Folio plays each clip from its video.url, muted, while its page is on show.
appearance: { textureBaseUrl: 'https://postext.dev/folio/textures' },
onChange: ({ pages }) => kitStatus(`${doc.pages.length} pages · open at `
+ pages.map((i) => doc.pages[i].pageLabel || i + 1).join('–')),
});
config.folio把报纸放在日光下的橡木桌上:45 g/m²的新闻纸,能透出下一页;binding.type: 'folded'表示纸张对折一次,一张套一张,没有订书钉,也没有书脊,报纸就是这样叠起来的。Folio把打开的跨页上的所有片段画进同一张纹理,一次最多八段;每次翻页停在某一页,它就开始播放这一页上自动播放的循环片段,这一页翻走时就停下。点击一段独占视频,它仍会单独带声音播放,循环片段等它停下再继续。
完整食谱
// ═══ Postext Cookbook · Nº 136 · A living newspaper of video loops ══════════════
// https://postext.dev/en/cookbook/living-newspaper-video-loops
// Code: MIT · Text: original (CC BY 4.0) · Clips: generated with diffusion models (CC BY 4.0)
// Fonts: Oswald, Libre Caslon Text, Courier Prime (SIL OFL 1.1) · Needs postext ≥ 1.28.0
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { createFolioFromDocument } from 'https://esm.sh/postext-folio';
const LANG = 'en'; // @lang: the language of the sample document ('en')
const RECIPE = 'living-newspaper-video-loops';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: newsprint, a warm black and a dark red for the flags
const palette = {
ink: '#16130f', // text, rules and the nameplate
paper: '#f3efe4', // newsprint, and type reversed out of ink or red
flag: '#8e1b14', // the one accent: section flags, kickers, the jump lines
tint: '#e6dfcf', // the In brief strip
rule: '#8f897c', // hairlines: the column rules
muted: '#5b554b', // bylines, captions' credits, the imprint
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [ // defaults link to 'main-color': point it at the ink, never blue
...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
const MARGIN = { top: 12, bottom: 12, side: 12 }; // mm: a tabloid's narrow margins
const GUTTER = 4.5; // mm between the four columns
const LEAD = 11.6; // body leading in pt: the baseline grid
const oswald = (size, weight, look = {}) => ({ fontFamily: 'Oswald', fontSize: pt(size),
fontWeight: weight, color: col('ink'), ...look });
const caps = (size, weight, colour = 'ink') => oswald(size, weight, { color: col(colour),
textTransform: 'uppercase', letterSpacing: pt(size * 0.12) });
const typed = (size, look = {}) => ({ fontFamily: 'Courier Prime', fontSize: pt(size),
color: col('ink'), ...look }); // the dateline and the captions: a typewriter
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, align: 'left',
overflow: 'wrap', color: col('ink'), ...look, placement }); // wraps, in a running head too
const rule = (id, under, weight, gap = 0) => ({ kind: 'rule', id, thickness: pt(weight),
color: col('ink'), placement: { ...at(under, 'above', 0, -gap), size: { width: 'fill' } } });
const depth = (lines) => ({ kind: 'box', id: 'depth', style: {}, placement: {
...at('container', 'top-left'), size: { width: 'fill', height: pt(lines * LEAD) } } });
// #region answer: every picture is a clip that loops, autoplays and plays with the others
// A video resource prints its poster (the first frame) on the flat page. In Folio, and in the
// HTML viewer, the poster comes alive: autoplay starts it muted when its page is on show, loop
组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)
变化
#让读者自己开始每段片段
去掉autoplay,图片在读者点击之前一直静止;开始播放之后,循环片段照样一起播放。
- player: { autoplay: true, loop: true, muted: true, exclusive: false, controls: false },
+ player: { loop: true, muted: true, exclusive: false, controls: false },#一段带声音的独占片段
单独一段视频可以保留默认值,按自己的方式播放:在这个资源的video上设置player: { exclusive: true, muted: false },它开始播放后,循环片段会等到它结束。
#六栏的对开大报
两栏的报纸头版用静态照片排一份较小的报纸;同样的网格用sizePreset: 'broadsheet',就能在对开大报的开本上排六栏。
常见问题
报纸的一个分版是一个另起一页的一级标题,浮动体从不越过它。在本版最后一页找不到空位的图片,会单独排在下一版之前的一页上,所以要让文字适合版面:这里电车那篇报道转到第2页,而不是把女飞行员挤出头版。
致谢
- 文本
- 原创文字, CC BY 4.0
- 图片
- Mrs Edith Rowe speaks at the opening of the Harbour line: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg · Generated With Diffusion Models · CC BY 4.0
- The first frame of the mayor loop, its printed picture · Generated With Diffusion Models · CC BY 4.0
- The Guildhall clock tower: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg · Generated With Diffusion Models · CC BY 4.0
- The first frame of the clock loop, its printed picture · Generated With Diffusion Models · CC BY 4.0
- Skipper Jacob Hosking with the cod: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg · Generated With Diffusion Models · CC BY 4.0
- The first frame of the fisherman loop, its printed picture · Generated With Diffusion Models · CC BY 4.0
- Miss Constance Lacey in the cockpit: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg · Generated With Diffusion Models · CC BY 4.0
- The first frame of the aviator loop, its printed picture · Generated With Diffusion Models · CC BY 4.0
- Miss Rosalind Avery on the stage: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg · Generated With Diffusion Models · CC BY 4.0
- The first frame of the actress loop, its printed picture · Generated With Diffusion Models · CC BY 4.0
- Tom Rundle in goal: a black-and-white loop of 5 s, a still generated from a text prompt and animated with the same first and last frame, encoded with ffmpeg · Generated With Diffusion Models · CC BY 4.0
- The first frame of the keeper loop, its printed picture · Generated With Diffusion Models · CC BY 4.0
- 字体
- Libre Caslon Text (SIL OFL 1.1) · Oswald (SIL OFL 1.1) · Courier Prime (SIL OFL 1.1)


