UNPKG

2.98 kBTypeScriptView Raw
1import { RenderingContext2D } from './types';
2import Parser, { IParserOptions } from './Parser';
3import Screen, { IScreenOptions, IScreenStartOptions } from './Screen';
4import Document, { IDocumentOptions } from './Document';
5declare type DOMDocument = typeof window.document;
6export interface IOptions extends IParserOptions, IScreenOptions, IScreenStartOptions, IDocumentOptions {
7}
8/**
9 * SVG renderer on canvas.
10 */
11export default class Canvg {
12 /**
13 * Create Canvg instance from SVG source string or URL.
14 * @param ctx - Rendering context.
15 * @param svg - SVG source string or URL.
16 * @param options - Rendering options.
17 */
18 static from(ctx: RenderingContext2D, svg: string, options?: IOptions): Promise<Canvg>;
19 /**
20 * Create Canvg instance from SVG source string.
21 * @param ctx - Rendering context.
22 * @param svg - SVG source string.
23 * @param options - Rendering options.
24 */
25 static fromString(ctx: RenderingContext2D, svg: string, options?: IOptions): Canvg;
26 /**
27 * XML/HTML parser instance.
28 */
29 readonly parser: Parser;
30 /**
31 * Screen instance.
32 */
33 readonly screen: Screen;
34 /**
35 * Canvg Document.
36 */
37 readonly document: Document;
38 private readonly documentElement;
39 private readonly options;
40 /**
41 * Main constructor.
42 * @param ctx - Rendering context.
43 * @param svg - SVG Document.
44 * @param options - Rendering options.
45 */
46 constructor(ctx: RenderingContext2D, svg: DOMDocument, options?: IOptions);
47 /**
48 * Create new Canvg instance with inherited options.
49 * @param ctx - Rendering context.
50 * @param svg - SVG source string or URL.
51 * @param options - Rendering options.
52 */
53 fork(ctx: RenderingContext2D, svg: string, options?: IOptions): Promise<Canvg>;
54 /**
55 * Create new Canvg instance with inherited options.
56 * @param ctx - Rendering context.
57 * @param svg - SVG source string.
58 * @param options - Rendering options.
59 */
60 forkString(ctx: RenderingContext2D, svg: string, options?: IOptions): Canvg;
61 /**
62 * Document is ready promise.
63 */
64 ready(): Promise<void>;
65 /**
66 * Document is ready value.
67 */
68 isReady(): boolean;
69 /**
70 * Render only first frame, ignoring animations and mouse.
71 * @param options - Rendering options.
72 */
73 render(options?: IScreenStartOptions): Promise<void>;
74 /**
75 * Start rendering.
76 * @param options - Render options.
77 */
78 start(options?: IScreenStartOptions): void;
79 /**
80 * Stop rendering.
81 */
82 stop(): void;
83 /**
84 * Resize SVG to fit in given size.
85 * @param width
86 * @param height
87 * @param preserveAspectRatio
88 */
89 resize(width: number, height?: number, preserveAspectRatio?: boolean | string): void;
90}
91export {};
92//# sourceMappingURL=Canvg.d.ts.map
\No newline at end of file