/** * Box shapes (DESIGN §12.8, #1059): a box with one radius per corner, a * border per side, and a card joined to its label tab, drawn as vector * outlines (`VDTDesignPathBlock`, §12.1) that every backend paints alike. * * An outline is a rectilinear polygon walked clockwise on the sheet (y * down): each vertex a corner, rounded convex (a box corner, a tab's outer * corner) or concave (the fillet where a tab meets the box), each edge on * one side of the box. The border's inner edge is the outline with each * edge moved in by its side's width: a convex corner's radius shrinks by * the widths beside it (an ellipse when they differ, CSS's inner border * edge), a fillet's grows. A side's piece of border runs between the two * corners where the side changes, each split where the widths meet (the * whole corner to a side whose neighbour has no width), as CSS splits it. */ import type { BorderSides, ColorValue, CornerRadius, Dimension } from '../types.js'; import type { BoundingBox, VDTDesignBoxStyle, VDTDesignPathBlock, VDTPathCommand } from '../vdt.js'; export type ShapeSide = 'top' | 'right' | 'bottom' | 'left'; export declare const SHAPE_SIDES: readonly ShapeSide[]; /** A corner of an outline: the point where its two edges meet and its * radius (concave: a fillet). */ export interface ShapeVertex { x: number; y: number; r: number; concave?: boolean; } /** A closed rectilinear outline: `sides[i]` is the side of the edge from * `vertices[i]` to the next vertex. */ export interface ShapeOutline { vertices: ShapeVertex[]; sides: ShapeSide[]; } /** A label tab grown out of a box (`label.joined`): it stands on the * `edge` side, from `x0` to `x1` across, `height` out from the edge, its * outer corners rounded `radius` (one for both, or the corner at `x0` * and the one at `x1`, #1102), its sides meeting the box in fillets of * `fillet`. */ export interface ShapeTab { edge: 'top' | 'bottom'; x0: number; x1: number; height: number; radius: number | readonly [number, number]; fillet: number; } /** The outline of a box `(x, y, w, h)` with corner radii `[tl, tr, br, * bl]` and, optionally, a joined tab. The radii are clamped so two * corners never take more than their edge (each scaled by the edge's * share, as CSS does per edge). */ export declare function boxOutline(box: BoundingBox, radii: readonly [number, number, number, number], tab?: ShapeTab): ShapeOutline; /** The part of a joined box-and-tab outline that is the tab (#1102): the * tab out of the box's edge with its outer corners and the fillets that * flare into the edge, closed along the edge. Painted over the box's * fill in the tab's own colour, under the border. */ export declare function tabRegionOutline(box: BoundingBox, radii: readonly [number, number, number, number], tab: ShapeTab): ShapeOutline; /** The closed outline, moved in by `inset` per side (none: the outer * edge). */ export declare function outlineSubpath(o: ShapeOutline, inset?: Record): VDTPathCommand[]; /** The pieces of border, one closed subpath per run of edges on a side * that has a width in `widths`. */ export declare function borderPieces(o: ShapeOutline, widths: Record): Map; /** The border of a shape, per side: colour and width, `null` for none. */ export type ShapeBorder = Record; /** The path blocks that paint `outline` filled in `fill` with `border` * inside it: the fill, then the border — one ring when all four sides * have a border of one colour, else the pieces of each colour. A border that * leaves no room inside fills the shape in its colour. */ export declare function shapePathBlocks(outline: ShapeOutline, fill: string | undefined, border: ShapeBorder | undefined): VDTDesignPathBlock[]; /** Whether a box style needs the shape painter: corners of more than one * radius, or a border that differs per side. A box with neither paints * as it always has. */ export declare function boxNeedsShape(style: VDTDesignBoxStyle): boolean; /** The per-side border of a box style: its `borderSides`, else the whole * border on every side. */ export declare function boxStyleBorder(style: VDTDesignBoxStyle): ShapeBorder; /** The corner radii of a box style. */ export declare function boxStyleRadii(style: VDTDesignBoxStyle): [number, number, number, number]; /** The path blocks of a box style painted at `(x, y, w, h)`: what the * backends draw for a box that {@link boxNeedsShape}. */ export declare function boxStylePathBlocks(x: number, y: number, w: number, h: number, style: VDTDesignBoxStyle): VDTDesignPathBlock[]; /** A box style with its corners and sides folded down to the plain fields * when they say no more than those (every corner one radius, every side * the same border), so a style that sets them alike paints as before. */ export declare function normalizeBoxStyle(style: VDTDesignBoxStyle): VDTDesignBoxStyle; /** Whether a corner radius names its corners (`{ topLeft, … }`) rather * than being one length for all four. */ export declare function isCornerRadii(r: CornerRadius | undefined): r is Exclude; /** The radius of every corner when a corner radius is one length; absent * when it names its corners. */ export declare function uniformRadius(r: CornerRadius | undefined): Dimension | undefined; /** The four radii (px), top-left, top-right, bottom-right, bottom-left, of * a corner radius: one length on every corner, or each corner's own (a * corner left out is square). */ export declare function cornerRadiiPx(r: CornerRadius | undefined, toPx: (d: Dimension) => number): [number, number, number, number]; /** The border per side of a box (px / hex): each side over the whole * border's `enabled`, colour and width; a side is drawn when it is on and * has a colour and a width. */ export declare function borderSidesPx(whole: { enabled: boolean; color: ColorValue | undefined; width: Dimension | undefined; }, sides: BorderSides | undefined, toPx: (d: Dimension) => number): ShapeBorder; //# sourceMappingURL=boxShape.d.ts.map