parseSVG.d.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import Group from '../graphic/Group';
  2. import Element from '../Element';
  3. import { RectLike } from '../core/BoundingRect';
  4. import { parseXML } from './parseXML';
  5. interface SVGParserOption {
  6. width?: number;
  7. height?: number;
  8. ignoreViewBox?: boolean;
  9. ignoreRootClip?: boolean;
  10. }
  11. export interface SVGParserResult {
  12. root: Group;
  13. width: number;
  14. height: number;
  15. viewBoxRect: RectLike;
  16. viewBoxTransform: {
  17. x: number;
  18. y: number;
  19. scale: number;
  20. };
  21. named: SVGParserResultNamedItem[];
  22. }
  23. export interface SVGParserResultNamedItem {
  24. name: string;
  25. namedFrom: SVGParserResultNamedItem;
  26. svgNodeTagLower: SVGNodeTagLower;
  27. el: Element;
  28. }
  29. export declare type SVGNodeTagLower = 'g' | 'rect' | 'circle' | 'line' | 'ellipse' | 'polygon' | 'polyline' | 'image' | 'text' | 'tspan' | 'path' | 'defs' | 'switch';
  30. export declare function makeViewBoxTransform(viewBoxRect: RectLike, boundingRect: RectLike): {
  31. scale: number;
  32. x: number;
  33. y: number;
  34. };
  35. export declare function parseSVG(xml: string | Document | SVGElement, opt: SVGParserOption): SVGParserResult;
  36. export { parseXML };