/** * Spread templates (#861, DESIGN §2.1): a `spread: true` template laid as * one sheet of two facing pages, then cut at the spine, as comic spreads * are (`comics/spread.ts`). * * The sheet is in *spread coordinates*: the first page's frame, with the * second page's set against it so that the two trim boxes meet at the * spine (`shift` = the trim's width). The first page is the one on the * left of the flow: the left page of a left-to-right book, the right page * of a book whose flow is mirrored (right to left), whose frames are in * flow coordinates. The template's `area` spans both pages (both inner * margins inside it), the trim and the bleed run from one outer edge to * the other, with no bleed at the spine. * * - The gutter: a band of `gutter` centred on the spine. A frame without * `crossGutter` that meets it is kept off it, on the side of its centre * (its edge moved to the band's, or the frame moved out when it starts * inside it); an `'auto'` height is measured at the narrower width. * - The cut: each frame goes to the page that holds it. A frame crossing * the spine is read on the page holding its centre (the first page when * it is centred on the spine); the facing page gets * a copy of its blocks moved onto its own sheet (`VDTFrame.facingBlocks`), * painted, never read. Each page clips its frames and its decoration to * its bleed box (`VDTComposedPage.sheetClip`), so a band across the spine * shows its own half on each side. * - A figure label whose box meets the band is slid along the sheet to the * band's edge, on the side its anchor point lies on, so the fold does not * cut it (#990); an anchor with `gutter: 'cross'` stays put. * - Decoration is laid once, over the physical sheet of two pages, then * cut the same way ({@link splitSpreadDecoration}). * - A vertical (`vertical-rl`) book (#926) lays its frames in the pages' * flow frame, where the sheet's right edge is the top of the page and * the lines run down: there the second page follows the first along * the flow's y (`axis: 'y'`, the right page first), the spine is a * line across the flow, and everything above reads that axis. The * template is written in the flow's frame, as a vertical book's single * pages are. */ import type { BoundingBox, ContentWarning, VDTBlock, VDTComposedPage, VDTDesignSlot, VDTPage } from '../vdt.js'; import { type ComposedPageInput } from '../pipeline/composedLayout.js'; import type { FrameAreas, Rect } from './geometry.js'; import type { ResolvedFrame, ResolvedPageTemplate } from './types.js'; import type { ComposedContinuation } from './continuation.js'; /** The axis the second page of a spread follows the first along, in the * pages' flow frame: `'x'` on horizontal pages, `'y'` on vertical ones * (#926). */ export type SpreadAxis = 'x' | 'y'; /** The sheet of two pages a spread template is laid on. */ export interface SpreadSheet { /** Where the second page's sheet starts in spread coordinates. */ shift: number; /** The spine's x (its y on `axis: 'y'`). */ spine: number; axis: SpreadAxis; /** The template's area, the trim and the bleed of the sheet. */ areas: FrameAreas; /** What each page shows of the sheet: its bleed box, in spread * coordinates (the first page's, then the second's). */ shows: [Rect, Rect]; } /** * The sheet of two pages: `trim` and `bleed` are one page's boxes (the * same on every page, centred on the sheet, so a mirrored flow reads them * unchanged); `first` and `second` the pages' content areas. */ export declare function spreadSheet(area: ResolvedPageTemplate['area'], first: Rect, second: Rect, trim: Rect, bleed: Rect, axis?: SpreadAxis): SpreadSheet; /** * The box a frame takes on a spread: `rect` as placed, or, for a frame * without `crossGutter` that meets the spine band `[spine − g/2, spine + * g/2]`, the box kept off it on the side of its centre: a frame reaching * across the whole band is cut at the band's edge; one whose inner edge * falls inside the band moves out whole, keeping its width. */ export declare function keepOffGutter(frame: Pick, rect: Rect, spine: number, gutterPx: number, axis?: SpreadAxis): Rect; /** One page of a laid spread. */ export interface ComposedSpreadSide { page: VDTPage; composed: VDTComposedPage; /** Blocks the page reads (each frame's box first): its `page.floats` * and `doc.blocks`. The facing copies are on their frames. */ blocks: VDTBlock[]; } export interface ComposedSpreadLayout { /** The first page of the flow, then the second. */ sides: [ComposedSpreadSide, ComposedSpreadSide]; warnings: ContentWarning[]; laid: Set; /** Content the sheet's frames send on to other pages (#859). */ continuations?: ComposedContinuation[]; } export interface ComposedSpreadInput extends Omit { /** The page on the left of the flow, and the page after it in the flow * (on vertical pages, the right page and the left one). */ first: VDTPage; second: VDTPage; /** Each page's physical side of the open book. */ firstSide: 'left' | 'right'; /** One page's trim and bleed boxes, in the pages' flow frame. */ trim: Rect; bleed: Rect; /** Default `'x'`; `'y'` on vertical pages (#926). */ axis?: SpreadAxis; } /** * Lay a spread template over two facing pages: one composed layout on the * sheet of two pages ({@link spreadSheet}), frames kept off the spine band * ({@link keepOffGutter}), then each frame and its blocks moved to the page * that holds it, and the half of a frame crossing the spine copied onto * the facing page. */ export declare function layoutComposedSpread(input: ComposedSpreadInput): ComposedSpreadLayout; /** * The decoration of a spread, laid once over the physical sheet of two * pages (the left page's sheet with the right page's set against it at * `shift`), cut for each page: the blocks that reach the page's bleed box * (`shows`, in sheet coordinates), moved onto its own sheet. A block * crossing the spine goes to both pages; each paints it clipped to its * `sheetClip`. */ export declare function splitSpreadDecoration(slot: VDTDesignSlot, shift: number, shows: { left: BoundingBox; right: BoundingBox; }): { left: VDTDesignSlot; right: VDTDesignSlot; }; //# sourceMappingURL=spread.d.ts.map