UNPKG

printmaker

Version:

Generate PDF documents and from JavaScript objects

47 lines (46 loc) 1.35 kB
export declare type Pos = { x: number; y: number; }; export declare type Size = { width: number; height: number; }; export declare type Box = Size & Pos; export declare type BoxEdges = { left: number; right: number; top: number; bottom: number; }; export declare const ZERO_EDGES: Readonly<BoxEdges>; /** * Computes an inner box by subtracting the given space (e.g. a padding) from the given box. * * @param box The outer box. * @param edges The space to subtract. * @returns The resulting inner box. */ export declare function subtractEdges(box: Box, edges: BoxEdges): { x: number; y: number; width: number; height: number; }; /** * Parses a given value as a box lengths definition (`BoxLengths | Length`) to the lengths of the * edges. * Throws if the given input is invalid. * * @param input the input value * @returns an object with the four edges in `pt`, or `undefined` if the input is missing or `null` */ export declare function parseEdges(input: unknown): BoxEdges; /** * Converts a length definition into the corresponding value in points (`pt`). * Throws if the given value is not a valid length. * * @param input the input value * @returns the length in `pt`, or `undefined` if the input is missing or `null` */ export declare function parseLength(input: unknown): number;