import { SvgProportions } from '@src/models/SvgProportions'; import { PathOptions, Point, RenderOutput } from '@src/models'; export declare abstract class Path { /** * The main SVG element. You can reuse it if needed. */ protected svgElement: SVGSVGElement; /** * The path line drawn in the SVG, this will be appended automatically to `svgPath`. */ protected svgPathLine: SVGPathElement; /** * The div that will contain the svg, this is positioned in absolute relatively to the * DOM element `appendTo`, * This helps us position the SVG inside the div in absolute too. */ protected containerDiv: HTMLDivElement; /** * The SVG's defs can contain gradient stops, markers and other stuff. In this case, * we'll keep our marker(s) * appended to those defs. This lets the developer add his own defs if needed for * example. */ protected defs: SVGDefsElement; /** * The starting element BBox that we get from `getBoundingClientRect()`. This is used * to do the calculations * needed to draw our path. */ protected startBbox: DOMRect; /** * The ending element BBox that we get from `getBoundingClientRect()`. This is used to * do the calculations * needed to draw our path. */ protected endBbox: DOMRect; /** * The PathOptions supplied to our class when creating a new instance are stored here. */ options: PathOptions; constructor(options: PathOptions); /** * If you want your path to adapt to the DOM changes, * you'll have to call this function, it will recalculate * the path and re-append it if needed. * @returns: RenderOutput; Calling this will return the new rendered container, * svg, path and defs. * It might be useful for you to avoid dealing with async stuff for example. */ render(): RenderOutput; /** * @deprecated: this method is renamed to `redraw()` * Recalculates the positions of the div container, the svg element and the svg path */ recalculate(): void; /** * Redraws the SVG path by recalculating the positions of the div container */ redraw(): void; /** * Removes the div container and anything appended to it */ release(): void; /** * Adds the paths markers to the defs and adds them to the SVG path */ setPathMarkers(): void; /** * Set the svg attributes for the positioning and width/height */ setSvgAttrs(): void; /** * Sets the div attributes for the positioning and width/height */ setDivAttrs(): void; /** * Calculates the SVG width, height, and other key numbers that can then be used to * draw the path * @returns */ getSVGProportions(): SvgProportions; /** * Set custom CSS classes according to the dev's options * use `classList.add()` to simply add the classes if necessary * Assuming the user will enter the class list separated with white spaces, things will * go smoothly. */ setCustomClass(): void; /** * Returns an SVG path (or what's supposed to be in attribute `d`) * You can extend this function and add your own logic to draw whatever path you'd like. * @param endBbox bbox of the end dom element * @param startBbox bbox of the start dom element * @returns path string */ abstract getPath(): string; /** * This function is supposed to take points as input and output them as a string that * will be set to the `d` attribute of ``. * @param points: Point[]; Array of points that you want to write to your SVG * @returns The path string ready to be added to the `d` attribute. */ abstract svgPath(points: Point[]): string; }