@knowvah/dot-engine 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -92,7 +92,21 @@ export interface NodeGeometry {
92
92
  * type) still holds calloc-zero coordinates, so it is reported as absent
93
93
  * rather than as a label at the origin.
94
94
  *
95
+ * `sp`/`ep` are the arrow attachment points. When an end carries an arrow the
96
+ * spline is shortened to leave room for it, and the arrow spans from the
97
+ * terminal control point out to this point — so a consumer drawing its own
98
+ * arrowheads reads the tip here instead of extrapolating one. Each is present
99
+ * only when that end actually has an arrow (C `sflag`/`eflag`); with no arrow
100
+ * the field holds the calloc-zero point, which is not geometry.
101
+ *
102
+ * These are the *attachment* points on the node boundary, verbatim from the
103
+ * bezier — with `arrowhead=none` the spline simply ends there. Graphviz's own
104
+ * renderer insets the arrow polygon it draws by a penwidth-dependent amount
105
+ * (measured: ~1.5pt at `penwidth=1`, ~6.2pt at `penwidth=5`), so `ep` is the
106
+ * point to draw an arrow *to*, not a copy of the rendered polygon's tip.
107
+ *
95
108
  * @see lib/common/types.h:ED_spl, ED_label, ED_tail_label, ED_head_label
109
+ * @see lib/common/types.h:bezier (sflag/eflag, sp/ep)
96
110
  */
97
111
  export interface EdgeGeometry {
98
112
  tail: string;
@@ -102,6 +116,22 @@ export interface EdgeGeometry {
102
116
  x: number;
103
117
  y: number;
104
118
  }[];
119
+ /**
120
+ * Arrow attachment point at the tail end, if that end carries an arrow.
121
+ * @see lib/common/types.h:bezier.sp
122
+ */
123
+ sp?: {
124
+ x: number;
125
+ y: number;
126
+ };
127
+ /**
128
+ * Arrow attachment point at the head end, if that end carries an arrow.
129
+ * @see lib/common/types.h:bezier.ep
130
+ */
131
+ ep?: {
132
+ x: number;
133
+ y: number;
134
+ };
105
135
  /** Centre edge label position, if present. @see lib/common/types.h:ED_label */
106
136
  label?: {
107
137
  x: number;
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.d.ts","sourceRoot":"","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e,EAAE,CAAC;CAC7B;AAqKD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,cAAc,CAuB1E"}
package/dist/api.js CHANGED
@@ -690,6 +690,16 @@ function placedLabelPos(lbl, flipY) {
690
690
  if (lbl === void 0 || !lbl.set) return void 0;
691
691
  return { x: lbl.pos.x, y: flipY(lbl.pos.y) };
692
692
  }
693
+ function arrowAttachPoints(edge, flipY) {
694
+ const spl = edge.info.spl;
695
+ if (spl === void 0 || spl.size === 0) return {};
696
+ const out = {};
697
+ const first = spl.list[0];
698
+ if (first.sflag !== 0) out.sp = { x: first.sp.x, y: flipY(first.sp.y) };
699
+ const last = spl.list[spl.size - 1];
700
+ if (last.eflag !== 0) out.ep = { x: last.ep.x, y: flipY(last.ep.y) };
701
+ return out;
702
+ }
693
703
  function snapshotEdge(edge, flipY) {
694
704
  const geom = {
695
705
  tail: edge.tail.name,
@@ -704,6 +714,9 @@ function snapshotEdge(edge, flipY) {
704
714
  if (tailLabel !== void 0) geom.tailLabel = tailLabel;
705
715
  const headLabel = placedLabelPos(edge.info.head_label, flipY);
706
716
  if (headLabel !== void 0) geom.headLabel = headLabel;
717
+ const { sp, ep } = arrowAttachPoints(edge, flipY);
718
+ if (sp !== void 0) geom.sp = sp;
719
+ if (ep !== void 0) geom.ep = ep;
707
720
  return geom;
708
721
  }
709
722
  function snapshotCluster(sg, yAxis, flipY) {