/** * SVG geometry reader for the pattern generator. * * A drawing exported by ANY vector editor (Illustrator, Figma, Inkscape) is * mostly Bezier curves inside transformed groups — not the straight `M/L` * segments a naive reader assumes. This module turns such a file into a plain * list of points: * * 1. walk the document keeping a transform stack (nested ``); * 2. read every curve-ish element (`path`, `polyline`, `polygon`, `line`); * 3. flatten Beziers and arcs into points; * 4. map through the accumulated matrix. * * Flattening is deterministic (a fixed subdivision count derived from the * control polygon), so every language implementation produces identical points. * * SVG's y axis points DOWN — the caller flips it, because for a graph "higher on * the screen" must mean "a larger value". */ export type Pt = [number, number]; /** An affine matrix `[a b c d e f]` as used by SVG's `transform`. */ export type Matrix = readonly [number, number, number, number, number, number]; export declare const IDENTITY: Matrix; export declare function multiply(m: Matrix, n: Matrix): Matrix; export declare function apply(m: Matrix, p: Pt): Pt; /** Parse an SVG `transform` attribute (a chain of primitives) into one matrix. */ export declare function parseTransform(raw: string): Matrix; /** * Flatten a path `d` into points. Supports every command: M L H V C S Q T A Z, * absolute and relative. Sub-paths are concatenated (a graph is normally one). */ export declare function flattenPathD(d: string): Pt[]; /** One curve found in the document, already in user space. */ export interface SvgCurve { readonly points: Pt[]; /** Horizontal extent — used to pick the graph line among decorations. */ readonly width: number; /** * A shape PRIMITIVE — ``, ``, `` — rather than a drawn * curve. In a chart export these are frames and backgrounds, so the * one-line reading ranks them below anything actually drawn; in a band they * count like every other shape, because the drawing IS the region. */ readonly primitive: boolean; } /** * Walk the SVG source, tracking the transform stack, and collect every curve. * A hand-rolled tag scan (not a full XML parser) is enough: we only need element * names, their attributes and the nesting of ``. */ export declare function collectSvgCurves(svg: string): SvgCurve[]; /** * The curve to read a graph from: the one spanning the most horizontal space. * A chart export usually also carries axes, a frame and a legend; the data line * is the widest path, so this picks the signal without the user selecting it. * * Y is flipped (SVG grows downward, a graph grows upward). */ export declare function svgGraphPoints(svg: string): Pt[]; /** * Measure the drawing the same way the raster reader does: at each position * along the horizontal axis, take the HIGHEST and the LOWEST point of every * shape in the file. * * One stroke gives the same point twice — an exact value. Two strokes (or any * closed outline: draw a car and it still has a top and a bottom) give two * different points — a band. A single file may do both: run as one line and * split into a corridor further along. * * A shape is crossed segment by segment, so a stroke that doubles back over the * same x contributes every crossing, not just the first. */ export declare function svgEnvelope(svg: string, samples?: number): { top: Pt[]; bottom: Pt[]; }; //# sourceMappingURL=svg-path.d.ts.map