export { parseCSSColor } from 'csscolorparser-ts'; declare type SVGBaseAttributes = { id?: string; fill?: string; "fill-opacity"?: number; "fill-rule"?: string; stroke?: string; "stroke-opacity"?: number; "stroke-width"?: string; "stroke-linecap"?: string; transform?: string; mask?: string; }; declare type SVGRectAttributes = SVGBaseAttributes & { x: number; y: number; width: number; height: number; rx: number; ry: number; }; declare type SVGCircleAttributes = SVGBaseAttributes & { cx: number; cy: number; r: number; }; declare type SVGPolygonAttributes = SVGBaseAttributes & { points: string; }; declare type SVGPolylineAttributes = SVGBaseAttributes & { points: string; }; declare type SVGPathAttributes = SVGBaseAttributes & { d: string; }; declare type SVGUseAttributes = SVGBaseAttributes & { "xlink:href"?: string; href?: string; }; declare type SVGRootAttributes = SVGBaseAttributes & { viewBox: string; }; declare type SVGRect = { type: "element"; name: "rect"; attributes: SVGRectAttributes; }; declare type SVGCircle = { type: "element"; name: "circle"; attributes: SVGCircleAttributes; }; declare type SVGPolyline = { type: "element"; name: "polyline"; attributes: SVGPolylineAttributes; }; declare type SVGPolygon = { type: "element"; name: "polygon"; attributes: SVGPolygonAttributes; }; declare type SVGPath = { type: "element"; name: "path"; attributes: SVGPathAttributes; }; declare type SVGMask = { type: "element"; name: "mask"; attributes: SVGBaseAttributes; }; declare type SVGUse = { type: "element"; name: "use"; attributes: SVGUseAttributes; }; declare type SVGGroup = { type: "element"; name: "g"; attributes: SVGBaseAttributes; children: SVGChildNode[]; }; declare type SVGDefs = { type: "element"; name: "defs"; children: SVGChildNode[]; }; declare type SVGRoot = { type: "element"; name: "svg"; attributes: SVGRootAttributes; children: (SVGChildNode | SVGDefs)[]; }; declare type SVGUnknown = { type: "element"; name: "title" | "desc"; }; declare type SVGPathConvertibleNode = SVGPath | SVGPolyline | SVGPolygon | SVGCircle | SVGRect; declare type SVGDrawableNode = SVGPathConvertibleNode | SVGUse; declare type SVGChildNode = SVGDefs | SVGMask | SVGGroup | SVGDrawableNode | SVGUnknown; declare type Point = { x: number; y: number; }; declare type Size = { width: number; height: number; }; declare type Rect = Point & Size; declare const point: (x: number, y: number) => Point; declare const rect: (x: number, y: number, width: number, height: number) => Rect; declare const move: (to: Point) => { readonly type: "move"; readonly to: Point; }; declare const line: (to: Point) => { readonly type: "line"; readonly to: Point; }; declare const quadCurve: (to: Point, controlPoint: Point) => { readonly type: "quadCurve"; readonly to: Point; readonly controlPoint: Point; }; declare const cubicCurve: (to: Point, controlPoint1: Point, controlPoint2: Point) => { readonly type: "cubicCurve"; readonly to: Point; readonly controlPoint1: Point; readonly controlPoint2: Point; }; declare const close: () => { readonly type: "close"; }; declare type Move = ReturnType; declare type Line = ReturnType; declare type QuadCurve = ReturnType; declare type CubicCurve = ReturnType; declare type Close = ReturnType; declare type Command = Move | Line | QuadCurve | CubicCurve | Close; declare type LineCap = "butt" | "round" | "square"; declare type FillRule = "nonzero" | "evenodd"; /** * We use different defaults in our model than the SVG spec. * * The SVG defaults are convenient for writing SVG files, but less convenient for drawing. * We get rid of the value 'none', instead using undefined (or no key). * * Model defaults: * - fill: undefined * - stroke: undefined * - strokeWidth: 0 * - strokeLineCap: 'butt' * * SVG defaults: * - fill: 'black' * - stroke: 'none' * - strokeWidth: 1 * - strokeLineCap: 'butt' */ declare type Style = { fill?: string; fillRule: FillRule; stroke?: string; strokeWidth: number; strokeLineCap: LineCap; }; /** * Convert SVG properties to our model format. * * We apply default values and convert them to a more convenient model for drawing. */ declare const style: ({ fill, fillOpacity, fillRule, stroke, strokeWidth, strokeLineCap, strokeOpacity, }?: { fill?: string | undefined; fillOpacity?: number | undefined; fillRule?: string | undefined; stroke?: string | undefined; strokeWidth?: number | undefined; strokeLineCap?: string | undefined; strokeOpacity?: number | undefined; }) => Style; declare type Path = { id: string; commands: Command[]; style: Style; }; declare type SVG = { children: Path[]; viewBox?: Rect; metadata: { unsupportedFeatures: string[]; }; }; declare type CommandWithoutQuadratics = Exclude; declare type PathWithoutQuadratics = Omit & { commands: CommandWithoutQuadratics[]; }; declare type SVGWithoutQuadratics = Omit & { children: PathWithoutQuadratics[]; }; declare const path: (style: Style, commands: Command[]) => Path; declare const svg: (viewBox: Rect | undefined, unsupportedFeatures: string[]) => SVG; declare const parse: (string: string) => SVGRoot; /** * Synchronously convert an SVG file string into a data model. * * @param svg {string} * @param options {ConvertOptions} */ declare function convert(svg: string, options?: {}): SVG; declare function convert(svg: string, options?: { convertQuadraticsToCubics: true; }): SVGWithoutQuadratics; export { Close, Command, CommandWithoutQuadratics, CubicCurve, FillRule, Line, LineCap, Move, Path, PathWithoutQuadratics, Point, QuadCurve, Rect, SVG, SVGWithoutQuadratics, Size, Style, close, convert, cubicCurve, line, move, parse, path, point, quadCurve, rect, style, svg };