/** * The geometry of a comic page (#555): the frame cut into convex polygon * cells by the lines of its split tree, gutters taken off, bleeding panels * run out to the bleed box, and the split lines the Sandbox drags. * * Every line is placed against the bounding box of the cell its list * splits, before gutters (a line at 30 % sits exactly at 30 %); each cell * then loses half the gutter on every side it shares with another cell, * measured across the line (a slanted line keeps its gutter width). Rows * stack top to bottom; columns run from the start side, so a page read * right to left (`'rtl'`) sets its first panel at the right, with the same * source. */ import type { BoundingBox, VDTPoint } from '../vdt.js'; import { type ComicSplitAxis, type ComicSplitList } from './split.js'; /** A half-plane: the points where `nx·x + ny·y <= c`. */ export interface HalfPlane { nx: number; ny: number; c: number; } /** A side of the frame (physical). */ export type ComicFrameSide = 'top' | 'bottom' | 'left' | 'right'; /** One leaf cell of the split, in reading order. */ export interface ComicCell { /** The item path of the cell (indices walked down from the top list). */ path: number[]; /** The cell's outline, clockwise, gutters off, bleeding sides out. */ polygon: VDTPoint[]; bbox: BoundingBox; /** An axis-aligned rectangle (round corners allowed). */ rect: boolean; /** The frame sides the cell touches (before any bleed). */ touches: ComicFrameSide[]; /** The cell before gutters: the box its art anchors and a nested list's * percentages are read against. */ raw: BoundingBox; } /** One split line, as the VDT carries it (without its source range). */ export interface ComicSplitLine { path: number[]; boundary: number; axis: ComicSplitAxis; a: VDTPoint; b: VDTPoint; gutter: number; parent: BoundingBox; startPercent: number; endPercent: number; min: number; max: number; } export interface ComicGeometryInput { tree: ComicSplitList; /** The box the panels are cut from (page px). */ frame: BoundingBox; /** The box bleeding panels run out to (the trim, or the trim plus the * bleed). */ bleedBox: BoundingBox; direction: 'ltr' | 'rtl'; /** Gutter between tiers (rows) and between panels side by side * (columns), px. */ gutter: { rows: number; columns: number; }; /** The frame sides cell `index` (reading order) bleeds through when it * touches them. */ bleed?: (index: number) => readonly ComicFrameSide[]; } export interface ComicGeometry { cells: ComicCell[]; lines: ComicSplitLine[]; } /** Sutherland–Hodgman against one half-plane. */ export declare function clipPolygon(poly: readonly VDTPoint[], h: HalfPlane): VDTPoint[]; export declare function polygonBBox(poly: readonly VDTPoint[]): BoundingBox; /** Whether `p` lies inside a convex polygon (on the edge counts). */ export declare function pointInPolygon(poly: readonly VDTPoint[], p: VDTPoint): boolean; /** Physical side of a logical one on a page read in `direction`. */ export declare function physicalSide(side: string, direction: 'ltr' | 'rtl'): ComicFrameSide | undefined; /** * Cut the frame into the cells of a split tree, in reading order, and list * its split lines. */ export declare function comicGeometry(input: ComicGeometryInput): ComicGeometry; //# sourceMappingURL=geometry.d.ts.map