@knowvah/dot-engine 1.2.2 → 1.2.3

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.
@@ -18,7 +18,7 @@ export declare function genTee(p0: Point, u: Point, _arrowsize: number, penwidth
18
18
  /** @see lib/common/arrows.c:arrow_length_tee (preserves the C `_at_start` reuse) */
19
19
  export declare function arrowLengthTee(lenfact: number, arrowsize: number, penwidth: number): number;
20
20
  /** @see lib/common/arrows.c:arrow_type_curve */
21
- export declare function genCurve(p0: Point, u: Point, _arrowsize: number, penwidth: number, flag: number): GenResult;
21
+ export declare function genCurve(p0: Point, u: Point, _arrowsize: number, penwidth: number, flag: number, rankdir?: number): GenResult;
22
22
  /** @see lib/common/arrows.c:arrow_length_curve */
23
23
  export declare const arrowLengthCurve: (lenfact: number, arrowsize: number, penwidth: number) => number;
24
24
  //# sourceMappingURL=arrows-shapes-poly.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arrows-shapes-poly.d.ts","sourceRoot":"","sources":["../../src/common/arrows-shapes-poly.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAkGzD,mFAAmF;AACnF,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAOxG;AAED,iDAAiD;AACjD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAa1G;AAOD,8CAA8C;AAC9C,wBAAgB,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAA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Aa1G;AAOD,8CAA8C;AAC9C,wBAAgB,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAG3G;AAOD,8CAA8C;AAC9C,wBAAgB,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAyBzG;AAED,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQ3F;AA8BD,gDAAgD;AAChD,wBAAgB,QAAQ,CACtB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EACvE,OAAO,SAAI,GACV,SAAS,CAgCX;AAED,kDAAkD;AAClD,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,EAAE,WAAW,MAAM,EAAE,UAAU,MAAM,KAAG,MACrC,CAAC"}
@@ -36,7 +36,7 @@ export declare function arrowLength(comps: ResolvedArrow[], arrowsize: number, p
36
36
  *
37
37
  * @see lib/common/arrows.c:arrow_gen_type
38
38
  */
39
- export declare function dispatchSimple(r: ResolvedArrow, tip: Point, dir: Point, arrowsize: number, penwidth: number): GenResult;
39
+ export declare function dispatchSimple(r: ResolvedArrow, tip: Point, dir: Point, arrowsize: number, penwidth: number, rankdir?: number): GenResult;
40
40
  /**
41
41
  * Generate all draw ops for a parsed compound arrow (up to 4 stacked
42
42
  * components). Each component is drawn at the running tip and advances the tip
@@ -44,5 +44,5 @@ export declare function dispatchSimple(r: ResolvedArrow, tip: Point, dir: Point,
44
44
  *
45
45
  * @see lib/common/arrows.c:arrow_gen
46
46
  */
47
- export declare function arrowDrawOps(comps: ResolvedArrow[], tip: Point, dir: Point, arrowsize: number, penwidth: number): ArrowDrawOp[];
47
+ export declare function arrowDrawOps(comps: ResolvedArrow[], tip: Point, dir: Point, arrowsize: number, penwidth: number, rankdir?: number): ArrowDrawOp[];
48
48
  //# sourceMappingURL=arrows-shapes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arrows-shapes.d.ts","sourceRoot":"","sources":["../../src/common/arrows-shapes.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAEkB,KAAK,SAAS,EACtC,MAAM,yBAAyB,CAAC;AA2PjC;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY5F;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM/F;AAOD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAC5E,SAAS,CAeX;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAClF,WAAW,EAAE,CAYf"}
1
+ {"version":3,"file":"arrows-shapes.d.ts","sourceRoot":"","sources":["../../src/common/arrows-shapes.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAEkB,KAAK,SAAS,EACtC,MAAM,yBAAyB,CAAC;AA2PjC;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY5F;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM/F;AAOD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAC7E,OAAO,SAAI,GACV,SAAS,CAiBX;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EACnF,OAAO,SAAI,GACV,WAAW,EAAE,CAYf"}
package/dist/index.js CHANGED
@@ -4535,6 +4535,20 @@ function ccwrotatepf(p, ccwrot) {
4535
4535
  return p;
4536
4536
  }
4537
4537
  }
4538
+ function cwrotatepf(p, cwrot) {
4539
+ switch (cwrot) {
4540
+ case 0:
4541
+ return p;
4542
+ case 90:
4543
+ return { x: p.y, y: -p.x };
4544
+ case 180:
4545
+ return { x: p.x, y: -p.y };
4546
+ case 270:
4547
+ return { x: p.y, y: p.x };
4548
+ default:
4549
+ return p;
4550
+ }
4551
+ }
4538
4552
  function boxOverlap(b0, b1) {
4539
4553
  return b0.ur.x >= b1.ll.x && b1.ur.x >= b0.ll.x && b0.ur.y >= b1.ll.y && b1.ur.y >= b0.ll.y;
4540
4554
  }
@@ -18815,7 +18829,15 @@ function curveControlPoints(p, v, w, flag) {
18815
18829
  const AF2 = { x: p.x - 0.95 * v.x + w.x + s * w.x * (4 / 3), y: AF3.y + s * w.y * (4 / 3) };
18816
18830
  return [AF0, AF1, AF2, AF3];
18817
18831
  }
18818
- function genCurve(p0, u, _arrowsize, penwidth, flag) {
18832
+ function genCurve(p0, u, _arrowsize, penwidth, flag, rankdir = 0) {
18833
+ if (rankdir !== 0) {
18834
+ const rot = rankdir * 90;
18835
+ const fin = genCurve(ccwrotatepf(p0, rot), ccwrotatepf(u, rot), _arrowsize, penwidth, flag);
18836
+ return {
18837
+ ops: fin.ops.map((op) => "points" in op ? { ...op, points: op.points.map((pt) => cwrotatepf(pt, rot)) } : op),
18838
+ q: cwrotatepf(fin.q, rot)
18839
+ };
18840
+ }
18819
18841
  const arrowwidth = penwidth > 4 ? 0.5 * penwidth / 4 : 0.5;
18820
18842
  const noShift = flag & ARR_MOD_INV || u.x === 0 && u.y === 0;
18821
18843
  const p = noShift ? p0 : vsub2(p0, backwardDelta(u, penwidth));
@@ -19030,7 +19052,7 @@ function arrowLength(comps, arrowsize, penwidth) {
19030
19052
  for (let i = 0; i < n; i++) length += arrowLengthOne(comps[i], arrowsize, penwidth);
19031
19053
  return length;
19032
19054
  }
19033
- function dispatchSimple(r, tip2, dir, arrowsize, penwidth) {
19055
+ function dispatchSimple(r, tip2, dir, arrowsize, penwidth, rankdir = 0) {
19034
19056
  const flag = arrowFlag(r);
19035
19057
  const u = componentU(dir, r.lenfact, arrowsize);
19036
19058
  switch (r.type & ARR_TYPE_MASK) {
@@ -19044,8 +19066,10 @@ function dispatchSimple(r, tip2, dir, arrowsize, penwidth) {
19044
19066
  return genDiamond(tip2, u, arrowsize, penwidth, flag);
19045
19067
  case ARR_TYPE_DOT:
19046
19068
  return genDot(tip2, u, arrowsize, penwidth, flag);
19069
+ // curve is the one generator that is not rotation-equivariant; it needs
19070
+ // the rankdir to reproduce C's render-time (final-frame) generation.
19047
19071
  case ARR_TYPE_CURVE:
19048
- return genCurve(tip2, u, arrowsize, penwidth, flag);
19072
+ return genCurve(tip2, u, arrowsize, penwidth, flag, rankdir);
19049
19073
  case ARR_TYPE_GAP:
19050
19074
  return genGap(tip2, u, arrowsize, penwidth, flag);
19051
19075
  case ARR_TYPE_NORM:
@@ -19053,14 +19077,14 @@ function dispatchSimple(r, tip2, dir, arrowsize, penwidth) {
19053
19077
  return genNormal(tip2, u, arrowsize, penwidth, flag);
19054
19078
  }
19055
19079
  }
19056
- function arrowDrawOps(comps, tip2, dir, arrowsize, penwidth) {
19080
+ function arrowDrawOps(comps, tip2, dir, arrowsize, penwidth, rankdir = 0) {
19057
19081
  const ops = [];
19058
19082
  let p = tip2;
19059
19083
  const n = Math.min(comps.length, 4);
19060
19084
  for (let i = 0; i < n; i++) {
19061
19085
  const r = comps[i];
19062
19086
  if ((r.type & ARR_TYPE_MASK) === ARR_TYPE_NONE) break;
19063
- const res = dispatchSimple(r, p, dir, arrowsize, penwidth);
19087
+ const res = dispatchSimple(r, p, dir, arrowsize, penwidth, rankdir);
19064
19088
  ops.push(...res.ops);
19065
19089
  p = res.q;
19066
19090
  }
@@ -19204,7 +19228,8 @@ function edgeArrowsize(e) {
19204
19228
  }
19205
19229
  function arrowDrawOpsForEnd(e, end, tip2, dir, penwidth) {
19206
19230
  const comps = parseArrow(edgeArrowName(e, end)).map(resolveArrowType);
19207
- return arrowDrawOps(comps, tip2, dir, edgeArrowsize(e), penwidth);
19231
+ const rankdir = (e.tail?.root?.info?.rankdir ?? 0) & 3;
19232
+ return arrowDrawOps(comps, tip2, dir, edgeArrowsize(e), penwidth, rankdir);
19208
19233
  }
19209
19234
 
19210
19235
  // src/common/splines-clip.ts
@@ -23939,7 +23964,7 @@ function gdRankdir(n) {
23939
23964
  function gdFlip(n) {
23940
23965
  return (gdRankdir(n) & 1) !== 0;
23941
23966
  }
23942
- function cwrotatepf(p, cwrot) {
23967
+ function cwrotatepf2(p, cwrot) {
23943
23968
  switch (cwrot) {
23944
23969
  case 90:
23945
23970
  return { x: p.y, y: -p.x };
@@ -24086,7 +24111,7 @@ function setOrder(pp, q) {
24086
24111
  pp.order = MC_SCALE * a / (2 * Math.PI) | 0;
24087
24112
  }
24088
24113
  function applyDir(pp, bp, dir, rd, definedFinal) {
24089
- const q = cwrotatepf(dir.p, 90 * rd);
24114
+ const q = cwrotatepf2(dir.p, 90 * rd);
24090
24115
  pp.p = q;
24091
24116
  pp.bp = bp;
24092
24117
  pp.side = dir.dyna ? dir.side : invflipSide(dir.side, rd);
@@ -24102,7 +24127,7 @@ function nodeInsideFn(n) {
24102
24127
  }
24103
24128
  function compassPoint(n, insideFn, yArg, xArg, rd) {
24104
24129
  let p = { x: xArg, y: yArg };
24105
- if (rd) p = cwrotatepf(p, 90 * rd);
24130
+ if (rd) p = cwrotatepf2(p, 90 * rd);
24106
24131
  const curve = [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: p.x, y: p.y }, { x: p.x, y: p.y }];
24107
24132
  const ctx = { nodeCoord: n.info.coord, rw: n.info.rw, bp: null, node: n };
24108
24133
  bezierClip(ctx, insideFn, curve, true);