import { vec, type Uniforms } from "@shopify/react-native-skia"; import { type SharedValue } from "react-native-reanimated"; import type { ChartEngineLayout } from "../core/useLiveChartEngine"; import type { ChartPadding } from "../draw/line"; import type { LiveChartPoint } from "../types"; /** A threshold value that is either a single live benchmark or a time-varying series. */ export type ThresholdValue = SharedValue | LiveChartPoint[]; /** `clipRight` sentinel when the threshold extends to "now" (no forward cutoff). */ export declare const THRESHOLD_NO_CLIP = 1000000000; /** `clipLeft` sentinel when the threshold extends to the window start. */ export declare const THRESHOLD_NO_CLIP_LEFT = -1000000000; export interface ThresholdGeometry { /** Threshold pixel-Y within the canvas, or NaN before layout / degenerate range. */ lineY: SharedValue; /** Whether the threshold sits within the plot area (drives marker-line opacity). */ visible: SharedValue; /** Vertical gradient end vector, `vec(0, canvasHeight)` — shared by stroke + fill. */ gradientEnd: SharedValue>; /** `[0, t, t, 1]` stop positions for the hard-split gradient — shared by stroke + fill. */ splitPositions: SharedValue; } /** * Per-frame screen geometry for the **constant** threshold split (a single * `SharedValue` benchmark), shared by the stroke gradient, the * profit/loss fill band, and the dashed marker line. Reads the live threshold * value + engine Y-range on the UI thread; the math lives in `math/threshold` so * it stays unit-testable without Reanimated. * * When the threshold is a time-varying series this geometry is unused — the * worklets short-circuit to a NaN `lineY` (→ off-screen, solid-above fallback) * and {@link useThresholdSeries} drives the render instead. */ export declare function useThreshold(engine: ChartEngineLayout, padding: ChartPadding, value: ThresholdValue): ThresholdGeometry; export interface ThresholdSeriesGeometry { /** Marker-line polyline in screen space `[x, y, …]`, projected from `samples` * (so it aligns exactly with the band edge + stroke split) and pinned to the * plot's left edge and to `min(plot right, clipRightX)`. */ screenPts: SharedValue; /** `THRESHOLD_SAMPLE_COUNT` threshold pixel-Y values on the time-anchored * sample grid — the split shader's `samples[]`, and the bottom edge of the * profit/loss band. Their pixel-X span is `thresholdSampleSpanX(...)`, which * glides with the window (NOT the static plot edges). */ samples: SharedValue; /** Whether any of the polyline is on-screen (drives marker-line opacity). */ visible: SharedValue; /** Threshold value at the configured badge anchor: the visible window's * left edge (`"first"`) or its live/right edge (`"last"`). */ badgeValue: SharedValue; /** Pixel-Y of `badgeValue` — anchors the badge. */ badgeLineY: SharedValue; /** Whether the configured badge anchor is on-plot and belongs to a visible * part of the threshold. (`visible` can still be true when that one endpoint * is off-plot.) */ badgeVisible: SharedValue; /** Pixel-X where the threshold starts: the first point's X with * `extendToStart` off, else {@link THRESHOLD_NO_CLIP_LEFT}. */ clipLeftX: SharedValue; /** Pixel-X where the threshold ends: the last point's X with `extendToNow` * off, else {@link THRESHOLD_NO_CLIP}. The shader paints its plain * `restColor` right of it; the marker polyline stops there. */ clipRightX: SharedValue; } /** * Per-frame screen geometry for a **time-varying** threshold — a plain * `LiveChartPoint[]` `value` or a live `SharedValue` `series` * (which wins when both are given): the screen polyline (marker line + * fill-band bottom), the shader's pixel-Y `samples[]`, the configured endpoint * value/anchor for the badge, and the endpoint cutoff X values. The array buffers * ping-pong (Reanimated only re-notifies subscribers when the returned reference * changes). When the threshold is a constant `SharedValue` every * worklet short-circuits cheaply and {@link useThreshold} drives the render * instead. */ export declare function useThresholdSeries(engine: ChartEngineLayout, padding: ChartPadding, value: ThresholdValue, series?: SharedValue | null, extendToNow?: boolean, extendToStart?: boolean, labelAnchor?: "first" | "last"): ThresholdSeriesGeometry; /** * Pack a series geometry + a color set into the {@link ThresholdSplitShader}'s * uniforms (one `SharedValue` per paint — stroke vs. the alpha-reduced fill band). * The object is rebuilt each frame so the shader re-paints as `samples` advance; * `sampleLeft`/`sampleRight` are the gliding pixel-X span of the sample grid and * `clipLeft`/`clipRight`/`restColor` implement the series endpoint cutoffs * (plain line color for the stroke, transparent for the band). */ export declare function useThresholdSplitUniforms(samples: SharedValue, engine: ChartEngineLayout, padding: ChartPadding, aboveColor: number[], belowColor: number[], restColor: number[], clipLeftX: SharedValue, clipRightX: SharedValue): SharedValue; //# sourceMappingURL=useThreshold.d.ts.map