import type { Interval2d } from '../interval/interval2d.ts'; import type { QuadraticCurve2d } from '../curve/quadratic2d.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 { QuadraticPath2dTypeId } from './quadratic2d.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 quadratic 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`. * * @since 1.0.0 */ export interface QuadraticPath2d extends Pipeable, Iterable { readonly [QuadraticPath2dTypeId]: QuadraticPath2dTypeId; readonly [PathTraits]: Trait; } /** * Creates a new `QuadraticPath2d` instance from a sequence of curves. * * @param curves - The curves to create the path from. * @returns A new `QuadraticPath2d` instance. * @since 2.0.0 */ export declare const make: (...curves: ReadonlyArray) => QuadraticPath2d; /** * Creates a new `QuadraticPath2d` instance from an array of curves. * * @param curves - The curves to create the path from. * @returns A new `QuadraticPath2d` instance. * @since 2.0.0 */ export declare const fromArray: (curves: ReadonlyArray) => QuadraticPath2d; /** * Checks if a value is a `QuadraticPath2d`. * * @param p - The value to check. * @returns `true` if the value is a `QuadraticPath2d`, `false` otherwise. * @since 1.0.0 */ export declare const isQuadraticPath2d: (p: unknown) => p is QuadraticPath2d; export declare const append: { /** * Appends a quadratic curve to a quadratic path. * * @param c - The quadratic curve to append. * @returns A function that takes a quadratic path and returns a new quadratic path. * @since 1.0.0 */ (c: QuadraticCurve2d): (p: QuadraticPath2d) => QuadraticPath2d; /** * Appends a quadratic curve to a quadratic path. * * @param p - The quadratic path to append to. * @param c - The quadratic curve to append. * @returns A new `QuadraticPath2d` instance with the appended curve. * @since 1.0.0 */ (p: QuadraticPath2d, c: QuadraticCurve2d): QuadraticPath2d; }; /** * Calculates the length of a quadratic path. * * @param p - The quadratic path to calculate the length of. * @returns The length of the path. */ export declare const length: (p: QuadraticPath2d) => number; export declare const solve: { /** * Solves a quadratic path at a given parameter. * * @param u - The parameter to solve for. * @returns A function that takes a quadratic path and returns the solved point. * @since 1.0.0 */ (u: number): (p: QuadraticPath2d) => Vector2; /** * Solves a quadratic path at a given parameter. * * @param p - The quadratic path to solve. * @param u - The parameter to solve for. * @returns The solved point. * @since 1.0.0 */ (p: QuadraticPath2d, u: number): Vector2; }; /** * Serializes a quadratic path as an SVG path data string (the value of a * `` element's `d` attribute), using `M` and `Q` commands. Discontinuities * between curves emit a fresh `M` command. * * @param p - The quadratic path to serialize. * @returns The SVG path data string. * @since 2.0.0 */ export declare const toPathData: (p: QuadraticPath2d) => string; /** * Type-narrowing predicate: refines `QuadraticPath2d` to * `QuadraticPath2d` when adjacent curves connect. * * @since 2.0.0 */ export declare const isContinuous: (p: QuadraticPath2d) => p is QuadraticPath2d; /** * Asserts that the quadratic path is continuous, throwing on failure. * * @since 2.0.0 */ export declare const asContinuous: (p: QuadraticPath2d) => QuadraticPath2d; /** * Type-narrowing predicate: refines `QuadraticPath2d` to * `QuadraticPath2d` when every segment's x-polynomial is * strictly increasing on `[0, 1]` and adjacent segments' x-ranges don't * overlap. * * @since 2.0.0 */ export declare const isIncreasingX: (p: QuadraticPath2d) => p is QuadraticPath2d; /** * Type-narrowing predicate: refines `QuadraticPath2d` to * `QuadraticPath2d`. * * @since 2.0.0 */ export declare const isDecreasingX: (p: QuadraticPath2d) => p is QuadraticPath2d; /** * Type-narrowing predicate: refines `QuadraticPath2d` to * `QuadraticPath2d`. * * @since 2.0.0 */ export declare const isMonotonicX: (p: QuadraticPath2d) => p is QuadraticPath2d; /** * Type-narrowing predicate: refines `QuadraticPath2d` to * `QuadraticPath2d`. * * @since 2.0.0 */ export declare const isIncreasingY: (p: QuadraticPath2d) => p is QuadraticPath2d; /** * Type-narrowing predicate: refines `QuadraticPath2d` to * `QuadraticPath2d`. * * @since 2.0.0 */ export declare const isDecreasingY: (p: QuadraticPath2d) => p is QuadraticPath2d; /** * Type-narrowing predicate: refines `QuadraticPath2d` to * `QuadraticPath2d`. * * @since 2.0.0 */ export declare const isMonotonicY: (p: QuadraticPath2d) => p is QuadraticPath2d; /** * Asserts that the path is strictly increasing in x, throwing on failure. * * @since 2.0.0 */ export declare const asIncreasingX: (p: QuadraticPath2d) => QuadraticPath2d; /** * Asserts that the path is strictly decreasing in x, throwing on failure. * * @since 2.0.0 */ export declare const asDecreasingX: (p: QuadraticPath2d) => QuadraticPath2d; /** * Asserts that the path is monotonic in x, throwing on failure. * * @since 2.0.0 */ export declare const asMonotonicX: (p: QuadraticPath2d) => QuadraticPath2d; /** * Asserts that the path is strictly increasing in y, throwing on failure. * * @since 2.0.0 */ export declare const asIncreasingY: (p: QuadraticPath2d) => QuadraticPath2d; /** * Asserts that the path is strictly decreasing in y, throwing on failure. * * @since 2.0.0 */ export declare const asDecreasingY: (p: QuadraticPath2d) => QuadraticPath2d; /** * Asserts that the path is monotonic in y, throwing on failure. * * @since 2.0.0 */ export declare const asMonotonicY: (p: QuadraticPath2d) => QuadraticPath2d; export declare const solveAtX: { /** * Evaluates the path's y value at a given x. Requires the path to carry * the `MonotonicX` brand. Returns `Solution.none` when x is 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: QuadraticPath2d, x: number): Solution.AtMostOne; /** @since 2.0.0 */ (x: number): (p: QuadraticPath2d) => 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: QuadraticPath2d, y: number): Solution.AtMostOne; /** @since 2.0.0 */ (y: number): (p: QuadraticPath2d) => Solution.AtMostOne; }; /** * Computes the axis-aligned bounding box of the path — the smallest closed * `Box2d` enclosing every segment. * * @param p - The quadratic path. * @returns A closed `Box2d` enclosing the path. * @since 2.0.0 */ export declare const boundingBox: (p: QuadraticPath2d) => Interval2d;