/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * Which of a ruler's labels it draws (#1269): where its columns are narrower * than their labels, every k-th — k the smallest step at which every label it * draws fits whole, with a gap between two — and each period's first column * (a week's Monday under days, a month's first week under weeks, a year's * January under months) always among them, as the user ruled. Where even the * periods' first columns crowd each other, each draws that clears the one * drawn before it, and no other label does. A preferred label — the narrow * ruler's now bucket, which wears the brand where a chip has no room — draws * wherever it clears every period's first column drawn, and the labels it * crowds give way to it. * * A label is centred on its column, and may run past it into the columns * either side, which draw none. One that would run past the track's start or * end sits against its own column's edge there instead; one that cannot lie * inside the track either way draws nowhere. * * Pure: decided from the labels' widths as the ruler measured them, each * drawn whole. * * @packageDocumentation */ /** One column's label, as the ruler measured it. */ export interface RulerLabel { /** The column's centre, in px. */ readonly centre: number; /** The column's inside start edge, in px: where its label sits when, centred, it would run past the track's start. */ readonly start: number; /** The column's inside end edge, in px: where its label sits when, centred, it would run past the track's end. */ readonly end: number; /** The label's width, drawn whole, in px. */ readonly width: number; /** Whether the column starts a period: its label draws unless it crowds the period's first column drawn before it. */ readonly anchor: boolean; /** Whether the column's label draws wherever it clears every period's first column drawn. */ readonly prefer: boolean; } /** * One column as a ruler measured it, its label drawn whole and centred on it: the label's box — its paper, whose * padding every label wears — and the column's inside edges, in px. */ export interface RulerColumn { /** The label's box. */ readonly box: { readonly left: number; readonly right: number; }; /** The column's inside edges: where a label set against its start or its end lies, by its box. */ readonly column: { readonly left: number; readonly right: number; }; /** Whether the column starts a period. */ readonly anchor: boolean; /** Whether its label draws wherever it clears every period's first column drawn. */ readonly prefer: boolean; } /** * What a ruler thins its labels by, from its columns as measured: each label is its text — its box less its paper's * padding — centred where its box is. A label set against its column's edge lies there by its box, so its text stands * its padding in from that edge (#1680's review; taken as its text against the edge, a label crowded the one before it * by its padding), and the track's ends are the first column's start and the last's end on the same terms. Two texts * keep the gap apart, and at least the two papers' padding: the later's paper would cover the end of the words before * it. * * @param columns - Each column, in order * @param pad - The paper's padding either side of a label's text, in px * @param gap - The least room between two labels' texts, in px * @returns The labels, the track and the gap {@link thinTicks} takes; `undefined` with no column, or no room on the track */ export declare function rulerLabels(columns: readonly RulerColumn[], pad: { readonly left: number; readonly right: number; }, gap: number): { labels: RulerLabel[]; track: { left: number; right: number; }; gap: number; } | undefined; /** Where a label sits against its column: centred on it, or against its start or its end edge. */ export type RulerAlign = "centre" | "start" | "end"; /** What the ruler draws: each column's label shown or not, and where it sits. */ export interface RulerFit { /** Whether each column's label is drawn. */ readonly shown: readonly boolean[]; /** Where each column's label sits. */ readonly align: readonly RulerAlign[]; } /** * The labels a ruler draws — see the module docs. * * @param labels - Each column's label, in order * @param track - The track's ends, in px * @param gap - The room between two labels, in px * @returns Which labels draw, and where each sits */ export declare function thinTicks(labels: readonly RulerLabel[], track: { left: number; right: number; }, gap: number): RulerFit; //# sourceMappingURL=ruler-thin.d.ts.map