import type { Interval2d } from '../interval/interval2d.ts'; import type { LinearCurve2d } from '../curve/linear2d.ts'; import type { Closed } from '../interval/interval.ts'; import type * as Solution from '../solution/solution.ts'; import type { Pipeable } from '../utils.ts'; import type { Vector2 } from '../vector/vector2.ts'; import type { LinearPath2dTypeId } from './linear2d.internal.ts'; import type { Continuous, DecreasingX, DecreasingY, IncreasingX, IncreasingY, MonotonicX, MonotonicY, PathTraits } from './traits.ts'; export type { Continuous, DecreasingX, DecreasingY, IncreasingX, IncreasingY, MonotonicX, MonotonicY, } from './traits.ts'; /** * A linear path in 2D space. * * All fields are readonly and immutable, and all operations create new instances. * * The `Trait` type parameter accumulates trait brands as the path is refined * via `isContinuous` / `asContinuous`. A `Continuous` path's `toPathData` * skips the per-segment discontinuity check. * * @since 1.0.0 */ export interface LinearPath2d extends Pipeable, Iterable { readonly [LinearPath2dTypeId]: LinearPath2dTypeId; readonly [PathTraits]: Trait; } /** * Creates a new `LinearPath2d` instance from a sequence of curves. * * @param curves - The curves to create the path from. * @returns A new `LinearPath2d` instance. * @since 2.0.0 */ export declare const make: (...curves: ReadonlyArray) => LinearPath2d; /** * Creates a new `LinearPath2d` instance from an array of curves. * * @param curves - The curves to create the path from. * @returns A new `LinearPath2d` instance. * @since 2.0.0 */ export declare const fromArray: (curves: ReadonlyArray) => LinearPath2d; /** * Checks if a value is a `LinearPath2d`. * * @param p - The value to check. * @returns `true` if the value is a `LinearPath2d`, `false` otherwise. * @since 1.0.0 */ export declare const isLinearPath2d: (p: unknown) => p is LinearPath2d; export declare const append: { /** * Appends a linear curve to a linear path. * * @param c - The linear curve to append. * @returns A function that takes a linear path and returns a new linear path. * @since 1.0.0 */ (c: LinearCurve2d): (p: LinearPath2d) => LinearPath2d; /** * Appends a linear curve to a linear path. * * @param p - The linear path to append to. * @param c - The linear curve to append. * @returns A new `LinearPath2d` instance with the appended curve. * @since 1.0.0 */ (p: LinearPath2d, c: LinearCurve2d): LinearPath2d; }; /** * Calculates the length of a linear path. * * @param p - The linear path to calculate the length of. * @returns The length of the linear path. * @since 1.0.0 */ export declare const length: (p: LinearPath2d) => number; export declare const solve: { /** * Solves a linear path for a given parameter. * * @param u - The parameter to solve for. * @returns A function that takes a linear path and returns the solved point. * @since 1.0.0 */ (u: number): (p: LinearPath2d) => Vector2; /** * Solves a linear path for a given parameter. * * @param p - The linear path to solve. * @param u - The parameter to solve for. * @returns The solved point on the linear path. * @since 1.0.0 */ (p: LinearPath2d, u: number): Vector2; }; /** * Serializes a linear path as an SVG path data string (the value of a `` * element's `d` attribute), using `M` and `L` commands. Discontinuities between * curves emit a fresh `M` command. * * @param p - The linear path to serialize. * @returns The SVG path data string. * @since 2.0.0 */ export declare const toPathData: (p: LinearPath2d) => string; /** * Type-narrowing predicate: refines `LinearPath2d` to * `LinearPath2d` when adjacent curves connect at their join * points. * * @param p - The linear path to check. * @returns `true` when the path is continuous (G⁰). * @since 2.0.0 */ export declare const isContinuous: (p: LinearPath2d) => p is LinearPath2d; /** * Asserts that the linear path is continuous, throwing on failure. * * @param p - The linear path to assert against. * @returns The same path, typed with the `Continuous` brand. * @throws When the path has a discontinuity between adjacent curves. * @since 2.0.0 */ export declare const asContinuous: (p: LinearPath2d) => LinearPath2d; /** * Type-narrowing predicate: refines `LinearPath2d` to * `LinearPath2d` when every segment's x-polynomial is * strictly increasing and adjacent segments' x-ranges don't overlap. * * @since 2.0.0 */ export declare const isIncreasingX: (p: LinearPath2d) => p is LinearPath2d; /** * Type-narrowing predicate: refines `LinearPath2d` to * `LinearPath2d` when every segment's x-polynomial is * strictly decreasing and adjacent segments' x-ranges don't overlap. * * @since 2.0.0 */ export declare const isDecreasingX: (p: LinearPath2d) => p is LinearPath2d; /** * Type-narrowing predicate: refines `LinearPath2d` to * `LinearPath2d` when the path is either increasing or * decreasing in x along its full parameter domain. * * @since 2.0.0 */ export declare const isMonotonicX: (p: LinearPath2d) => p is LinearPath2d; /** * Type-narrowing predicate: refines `LinearPath2d` to * `LinearPath2d`. The y-axis analog of {@link isIncreasingX}. * * @since 2.0.0 */ export declare const isIncreasingY: (p: LinearPath2d) => p is LinearPath2d; /** * Type-narrowing predicate: refines `LinearPath2d` to * `LinearPath2d`. The y-axis analog of {@link isDecreasingX}. * * @since 2.0.0 */ export declare const isDecreasingY: (p: LinearPath2d) => p is LinearPath2d; /** * Type-narrowing predicate: refines `LinearPath2d` to * `LinearPath2d`. The y-axis analog of {@link isMonotonicX}. * * @since 2.0.0 */ export declare const isMonotonicY: (p: LinearPath2d) => p is LinearPath2d; /** * Asserts that the path is strictly increasing in x, throwing on failure. * * @since 2.0.0 */ export declare const asIncreasingX: (p: LinearPath2d) => LinearPath2d; /** * Asserts that the path is strictly decreasing in x, throwing on failure. * * @since 2.0.0 */ export declare const asDecreasingX: (p: LinearPath2d) => LinearPath2d; /** * Asserts that the path is monotonic in x, throwing on failure. * * @since 2.0.0 */ export declare const asMonotonicX: (p: LinearPath2d) => LinearPath2d; /** * Asserts that the path is strictly increasing in y, throwing on failure. * * @since 2.0.0 */ export declare const asIncreasingY: (p: LinearPath2d) => LinearPath2d; /** * Asserts that the path is strictly decreasing in y, throwing on failure. * * @since 2.0.0 */ export declare const asDecreasingY: (p: LinearPath2d) => LinearPath2d; /** * Asserts that the path is monotonic in y, throwing on failure. * * @since 2.0.0 */ export declare const asMonotonicY: (p: LinearPath2d) => LinearPath2d; export declare const solveAtX: { /** * Evaluates the path's y value at a given x. Requires the path to carry the * `MonotonicX` brand — without it, an x query could match multiple * segments and the return cardinality would be unbounded. * * Returns `Solution.none` when x falls outside the path's x-range. * * @param p - A path branded `MonotonicX`. * @param x - The x coordinate. * @returns The y value at x, or `none` when x is outside the path's range. * @since 2.0.0 */ (p: LinearPath2d, x: number): Solution.AtMostOne; /** @since 2.0.0 */ (x: number): (p: LinearPath2d) => Solution.AtMostOne; }; export declare const solveAtY: { /** * Evaluates the path's x value at a given y. Requires the path to carry the * `MonotonicY` brand. Returns `Solution.none` when y is outside the path's * y-range. * * @param p - A path branded `MonotonicY`. * @param y - The y coordinate. * @returns The x value at y, or `none` when y is outside the path's range. * @since 2.0.0 */ (p: LinearPath2d, y: number): Solution.AtMostOne; /** @since 2.0.0 */ (y: number): (p: LinearPath2d) => Solution.AtMostOne; }; /** * Computes the axis-aligned bounding box of the path — the smallest closed * `Box2d` enclosing every segment. * * @param p - The linear path. * @returns A closed `Box2d` enclosing the path. * @since 2.0.0 */ export declare const boundingBox: (p: LinearPath2d) => Interval2d;