/** Viewer transform: screen = world * k + t (per axis). */ export interface ViewTransform { x: number; y: number; k: number; } export interface GridLevel { /** grid step in world units (on the ladder) */ step: number; /** grid step in screen px = step * k */ px: number; /** 0..1 fade factor for smooth appearance while zooming */ alpha: number; } /** * Pick the finest radix-power step whose screen spacing >= minPx. */ export declare function readableStep(k: number, minPx?: number, radix?: number): number; /** * Grid levels for the current zoom: the major (readable) step plus the * next-finer minor step fading in as you zoom, so grid transitions are smooth. */ export declare function gridLevels(k: number, minPx?: number, radix?: number): GridLevel[]; /** One layer finer: step / radix. */ export declare function finerStep(step: number, radix?: number): number; /** * The layer a size LIVES on: the step L (radix power) where the size spans * 1..radix grids. This is a node's intrinsic scale — its position snaps to * this layer's lattice (or the viewing grid, whichever is coarser). */ export declare function sizeLayerStep(size: number, radix?: number, baseStep?: number): number; /** * The node-size law: a size must span an INTEGER number of grids between * 1 and radix at SOME layer. A size needing more than radix grids at a * layer promotes to the next layer, snapped to the upper limit — * e.g. 9 grids at layer s (radix 8) becomes 2 grids at layer s+1. */ export declare function snapSizeRadix(size: number, radix?: number, /** the finest layer's step (world units) to start from */ baseStep?: number): number; /** * How far the LONGER axis may descend below its natural layer to meet the * shorter one. The three named laws are one number in disguise — the count * of layers the long axis may drop, floored at the short axis's own layer: * * - "per-axis" (depth 0): the long axis stays on the layer the * size law hands it. A 9-grid height at radix 8 has outgrown layer 1, so * it sits on layer 8 as 2 grids — 16 fine grids. The other axis has no * say. (At radix 4 the same 9 lands on layer 4 as 3 grids: 12.) * - "sibling" (depth 1, DEFAULT): the long axis may drop ONE layer toward * the short one. 2 × 9 becomes 2 × 9; 2 × 513 becomes 2 × 576 rather than * 2 × 768 — a squat node keeps a fine height without a 1:256 node turning * into a 513-cell ruler. * - "finest-axis" (depth ∞): the short axis names the node's cell outright * and the long one is an integer count of it. 2 × 513 stays 2 × 513. * * Descending costs cells: the long axis may need more than `radix` grids, * which the depth-0 law forbids. Depth is exactly the budget for that. */ export type SizeLaw = "per-axis" | "sibling" | "finest-axis"; /** layers the long axis may drop under each law */ export declare function sizeLawDepth(law: SizeLaw): number; /** * The steps a node's two axes snap on. The short axis always sits on its * own layer; the long axis descends up to `depth` layers toward it, never * past it. */ export declare function sizeStepsFor(w: number, h: number, radix?: number, law?: SizeLaw, baseStep?: number): { w: number; h: number; }; /** * The step a node's WIDTH snaps on, given the height it will end up with. * Only under "per-axis" is the height irrelevant. */ export declare function sizeStepFor(w: number, h: number, radix?: number, law?: SizeLaw, baseStep?: number): number; /** snap a node's size under the active size law */ export declare function snapNodeSize(w: number, h: number, radix?: number, law?: SizeLaw, baseStep?: number): { w: number; h: number; }; /** Iterate world-space grid coordinates visible in a screen rect. */ export declare function gridRange(t: ViewTransform, screenMin: number, screenMax: number, offset: number, step: number): { start: number; end: number; }; /** Snap a world coordinate to the nearest grid point of the given step. */ export declare const snap: (v: number, step: number) => number; export declare const worldToScreen: (t: ViewTransform, wx: number, wy: number) => readonly [number, number]; export declare const screenToWorld: (t: ViewTransform, sx: number, sy: number) => readonly [number, number]; //# sourceMappingURL=grid.d.ts.map