LineAttachmentUtil.d.ts 975 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Return the attachment of the given point on the specified line.
  3. *
  4. * The attachment is either a bendpoint (attached to the given point)
  5. * or segment (attached to a location on a line segment) attachment:
  6. *
  7. * ```javascript
  8. * var pointAttachment = {
  9. * type: 'bendpoint',
  10. * bendpointIndex: 3,
  11. * position: { x: 10, y: 10 } // the attach point on the line
  12. * };
  13. *
  14. * var segmentAttachment = {
  15. * type: 'segment',
  16. * segmentIndex: 2,
  17. * relativeLocation: 0.31, // attach point location between 0 (at start) and 1 (at end)
  18. * position: { x: 10, y: 10 } // the attach point on the line
  19. * };
  20. * ```
  21. *
  22. * @param point
  23. * @param line
  24. *
  25. * @return
  26. */
  27. export function getAttachment(point: Point, line: Point[]): Attachment;
  28. type Point = import('diagram-js/lib/util/Types').Point;
  29. export type Attachment = {
  30. type: 'bendpoint' | 'segment';
  31. position: Point;
  32. segmentIndex: number;
  33. bendpointIndex?: number;
  34. relativeLocation?: number;
  35. };