Documentation
    Preparing search index...

    Interface LinearGradientPaint

    A §58 linear gradient: colour as a function of signed distance along the axis from from to to, both in the shape's own local space — the space its path coordinates live in, so a gradient authored across a Rectangle's width stays put when the node moves (Canvas's user-space rule).

    const sky: LinearGradientPaint = {
    kind: "linear-gradient",
    from: { x: 0, y: -1 },
    to: { x: 0, y: 1 },
    stops: [
    { offset: 0, color: [0.02, 0.05, 0.2, 1] },
    { offset: 1, color: [0.4, 0.7, 1, 1] },
    ],
    };

    from and to must differ (§85): a zero-length axis has no direction, and inventing one would draw a picture the author never described. Any stop count ≥ 2 is exact — the lowering evaluates the piecewise ramp per fragment, so there is no per-vertex facet to see (the R-16 boundary, closed).

    interface LinearGradientPaint {
        from: Point2D;
        kind: "linear-gradient";
        opacity?: number;
        stops: readonly GradientStop[];
        to: Point2D;
    }
    Index
    from: Point2D

    Where the gradient reads offset 0, in local space; finite (§85).

    kind: "linear-gradient"

    Discriminant (§58 "linear gradient").

    opacity?: number

    See SolidPaint.opacity; multiplies every stop's alpha.

    stops: readonly GradientStop[]

    At least two sorted stops (§85) — see GradientStop.

    Where it reads offset 1, in local space; finite, not from (§85).