Canvg.d.ts 3.1 KB

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