import type { LiveChartPoint } from "../types"; /** * Reusable scratch buffers for {@link drawSpline}. Pass a persistent instance * (created once per chart via `useMemo`) to avoid allocating three arrays sized * to the point count on every frame — the per-frame garbage scales with the * number of points (large `timeWindow`s push 1000+ points), so pooling these * meaningfully cuts UI-thread GC pressure on live charts. */ export interface SplineScratch { delta: number[]; h: number[]; m: number[]; } /** Allocate an empty {@link SplineScratch} (arrays grow on demand). */ export declare function makeSplineScratch(): SplineScratch; /** * Fritsch-Carlson monotone cubic interpolation. * Guarantees no overshoots — the curve never exceeds local min/max. * Same approach documented in liveline for smooth live line charts (adapted code; MIT). * * pts is a flat number array with stride 2: [x0, y0, x1, y1, ...]. * Caller must moveTo the first point before calling. * * Pass `scratch` (see {@link makeSplineScratch}) to reuse the tangent/interval * buffers across frames instead of allocating them each call. Only indices * `0..n-1` are read after being written, so stale tail entries are harmless. * * @see https://github.com/benjitaylor/liveline */ /** * Minimal structural sink for {@link drawSpline}: just the verb-emitting methods * it calls. Both `SkPath` and `SkPathBuilder` satisfy it, so the spline can be * built into either a mutable `SkPath` or a `Skia.PathBuilder`. */ export type SplinePathSink = { lineTo: (x: number, y: number) => unknown; cubicTo: (c1x: number, c1y: number, c2x: number, c2y: number, x: number, y: number) => unknown; }; export declare function drawSpline(path: SplinePathSink, pts: number[], scratch?: SplineScratch, /** Straight polyline (`lineTo` per point) instead of the monotone cubic — an * angular, hard-edged line. The caller has already `moveTo`'d point 0. */ linear?: boolean, /** First point index to draw (inclusive). The caller must moveTo this point. */ startPoint?: number, /** Last point index to draw (exclusive). Defaults to the full array. */ endPoint?: number): void; /** * Value of the Fritsch–Carlson monotone cubic — the same curve {@link drawSpline} * renders — at `time`. Use this to anchor overlays (e.g. markers) exactly on the * rendered line instead of on the straight chord between data points. Returns * `null` for empty data; clamps to the endpoints outside the data range. * * The data→pixel mapping is affine, so evaluating the monotone cubic in data * space and then projecting matches the pixel-space spline. Tangents use the * immediate neighbors and the overshoot clamp is applied for this segment only * (it does not cascade across segments as in `drawSpline`, which differs only on * very steep runs where the clamp fires). */ export declare function splineValueAtTime(points: LiveChartPoint[], time: number): number | null; //# sourceMappingURL=spline.d.ts.map