import { Options } from 'roughjs/bin/core'; declare enum OutputType { SVG = 0, CANVAS = 1 } /** * Svg2Roughjs parses an SVG and converts it to a hand-drawn sketch. */ declare class Svg2Roughjs { /** * Optional solid background color with which the canvas should be initialized. * It is drawn on a transparent canvas by default. */ backgroundColor: string | null; /** * Set a font-family for the rendering of text elements. * If set to `null`, then the font-family of the SVGTextElement is used. * By default, 'Comic Sans MS, cursive' is used. */ fontFamily: string | null; /** * Whether to randomize Rough.js' fillWeight, hachureAngle and hachureGap. * Also randomizes the disableMultiStroke option of Rough.js. * The randomness may be seeded with the `seed` property. * By default `true`. */ randomize: boolean; /** * Optional seed for the randomness when creating the sketch. * Providing a value implicitly seeds Rough.js which may be overwritten * by provding a different seed with the optional `roughConfig` property. * By default `null`. */ seed: number | null; /** * Whether pattern elements should be sketched or just copied to the output. * For smaller pattern base sizes, it's often beneficial to just copy it over * as the sketch will be too smalle to actually look sketched at all. */ sketchPatterns: boolean; /** * Whether to apply a pencil filter. */ pencilFilter: boolean; private $svg?; private width; private height; private $outputType; private $roughConfig; private idElements; private outputElement; private lastResult; /** * Set the SVG that should be sketched. */ set svg(svg: SVGSVGElement); /** * Returns the SVG that should be sketched. */ get svg(): SVGSVGElement | undefined; /** * Sets the output format of the sketch. * * Applies only to instances that have been created with a * container as output element instead of an actual SVG or canvas * element. * * Throws when the given mode does not match the output element * with which this instance was created. */ set outputType(type: OutputType); /** * Returns the currently configured output type. */ get outputType(): OutputType; /** * Sets the config object that is passed to Rough.js and considered * during rendering of the `SVGElement`s. * * Sets `fixedDecimalPlaceDigits` to `3` if not specified otherwise. */ set roughConfig(config: Options); /** * Returns the currently configured rendering configuration. */ get roughConfig(): Options; /** * Creates a new instance of Svg2roughjs. * @param target Either a container `HTMLDivElement` (or a selector for the container) to which a sketch should be added * or an `HTMLCanvasElement` or `SVGSVGElement` that should be used as output target. * @param outputType Whether the output should be an SVG or drawn to an HTML canvas. * Defaults to SVG or CANVAS depending if the given target is of type `HTMLCanvasElement` or `SVGSVGElement`, * otherwise it defaults to SVG. * @param roughConfig Config object that is passed to Rough.js and considered during * rendering of the `SVGElement`s. */ constructor(target: string | HTMLDivElement | HTMLCanvasElement | SVGSVGElement, outputType?: OutputType, roughConfig?: Options); /** * Triggers an entire redraw of the SVG which * processes the input element anew. * @param sourceSvgChanged When `true`, the given {@link svg} is re-evaluated as if it was set anew. * This allows the Svg2Rough.js instance to be used mutliple times with the same source SVG container but different contents. * @returns A promise that resolves with the sketched output element or null if no {@link svg} is set. */ sketch(sourceSvgChanged?: boolean): Promise; /** * Creates a new context which contains the current state of the * Svg2Roughs instance for rendering. */ private createRenderContext; /** * Helper method to draw the sketched SVG to a HTMLCanvasElement. */ private drawToCanvas; /** * Prepares the given SVG element depending on the set properties. */ private prepareRenderContainer; /** * Initializes the size based on the currently set SVG and collects elements * with an ID property that may be referenced in the SVG. */ private sourceSvgChanged; /** * Stores elements with IDs for later use. */ private collectElementsWithID; /** * Helper to handle percentage values for width / height of the input SVG. */ private coerceSize; } export { OutputType, Svg2Roughjs };