index.d.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { Point, Line, Rectangle, Polyline, Ellipse, Path } from '@antv/x6-geometry';
  2. import { PointData, PointLike } from '@antv/x6-common';
  3. import { normalize } from '../registry/marker/util';
  4. export declare namespace Util {
  5. const normalizeMarker: typeof normalize;
  6. /**
  7. * Transforms point by an SVG transformation represented by `matrix`.
  8. */
  9. function transformPoint(point: Point.PointLike, matrix: DOMMatrix): Point;
  10. /**
  11. * Transforms line by an SVG transformation represented by `matrix`.
  12. */
  13. function transformLine(line: Line, matrix: DOMMatrix): Line;
  14. /**
  15. * Transforms polyline by an SVG transformation represented by `matrix`.
  16. */
  17. function transformPolyline(polyline: Polyline, matrix: DOMMatrix): Polyline;
  18. function transformRectangle(rect: Rectangle.RectangleLike, matrix: DOMMatrix): Rectangle;
  19. /**
  20. * Returns the bounding box of the element after transformations are
  21. * applied. If `withoutTransformations` is `true`, transformations of
  22. * the element will not be considered when computing the bounding box.
  23. * If `target` is specified, bounding box will be computed relatively
  24. * to the `target` element.
  25. */
  26. function bbox(elem: SVGElement, withoutTransformations?: boolean, target?: SVGElement): Rectangle;
  27. /**
  28. * Returns the bounding box of the element after transformations are
  29. * applied. Unlike `bbox()`, this function fixes a browser implementation
  30. * bug to return the correct bounding box if this elemenent is a group of
  31. * svg elements (if `options.recursive` is specified).
  32. */
  33. function getBBox(elem: SVGElement, options?: {
  34. target?: SVGElement | null;
  35. recursive?: boolean;
  36. }): Rectangle;
  37. function getBoundingOffsetRect(elem: HTMLElement): {
  38. left: number;
  39. top: number;
  40. width: number;
  41. height: number;
  42. };
  43. /**
  44. * Convert the SVGElement to an equivalent geometric shape. The element's
  45. * transformations are not taken into account.
  46. *
  47. * SVGRectElement => Rectangle
  48. *
  49. * SVGLineElement => Line
  50. *
  51. * SVGCircleElement => Ellipse
  52. *
  53. * SVGEllipseElement => Ellipse
  54. *
  55. * SVGPolygonElement => Polyline
  56. *
  57. * SVGPolylineElement => Polyline
  58. *
  59. * SVGPathElement => Path
  60. *
  61. * others => Rectangle
  62. */
  63. function toGeometryShape(elem: SVGElement): Path | Rectangle | Line | Polyline | Ellipse;
  64. function translateAndAutoOrient(elem: SVGElement, position: PointLike | PointData, reference: PointLike | PointData, target?: SVGElement): void;
  65. function findShapeNode(magnet: Element): Element | null;
  66. function getBBoxV2(elem: SVGElement): Rectangle;
  67. }