@knowvah/dot-engine 2.8.0 → 2.8.1

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.
@@ -10,7 +10,7 @@
10
10
  import type { Graph } from '../model/graph.js';
11
11
  import type { Node } from '../model/node.js';
12
12
  import type { Edge } from '../model/edge.js';
13
- import type { Point } from '../model/geom.js';
13
+ import type { Box, Point } from '../model/geom.js';
14
14
  import type { TextSpan } from '../common/emit-types.js';
15
15
  import type { RendererPlugin } from '../gvc/context.js';
16
16
  import { EdgeDrawBase } from './dot/edge-draw.js';
@@ -108,6 +108,11 @@ export declare class XdotRenderer extends EdgeDrawBase implements RendererPlugin
108
108
  polygon(pts: Point[], filled: boolean, job: RenderJob): void;
109
109
  bezier(pts: Point[], filled: boolean, job: RenderJob): void;
110
110
  polyline(pts: Point[], job: RenderJob): void;
111
+ /**
112
+ * The `I` op: `x y w h` of the box, then the image name as an xdot string.
113
+ * @see plugin/core/gvrender_core_dot.c:core_loadimage_xdot
114
+ */
115
+ usershape(src: string, b: Box, job: RenderJob): void;
111
116
  /** Pen color op from the resolved graphics state (default black). */
112
117
  protected penOp(job: RenderJob): string;
113
118
  /**
@@ -152,6 +157,8 @@ export declare class DotRenderer extends XdotRenderer {
152
157
  polygon(_pts: Point[], _filled: boolean, _job: RenderJob): void;
153
158
  bezier(_pts: Point[], _filled: boolean, _job: RenderJob): void;
154
159
  polyline(_pts: Point[], _job: RenderJob): void;
160
+ /** No loadimage engine for "dot" (only "<type>:xdot"). */
161
+ usershape(_src: string, _b: Box, _job: RenderJob): void;
155
162
  }
156
163
  /** @see plugin/core/gvrender_core_dot.c FORMAT_DOT */
157
164
  export declare function createDotRenderer(): RendererPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"dot.d.ts","sourceRoot":"","sources":["../../src/render/dot.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAA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O,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAC/D,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAC9D,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IACvD,0DAA0D;IACjD,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;CACjE;AAED,sDAAsD;AACtD,wBAAgB,iBAAiB,IAAI,cAAc,CAElD;AAED,uDAAuD;AACvD,wBAAgB,kBAAkB,IAAI,cAAc,CAEnD"}
package/dist/render.js CHANGED
@@ -11055,6 +11055,139 @@ function gvrenderTextspan(renderer, pos, span, job) {
11055
11055
  }
11056
11056
  }
11057
11057
 
11058
+ // src/gvc/render-usershape.ts
11059
+ var ImageScale = {
11060
+ False: "false",
11061
+ True: "true",
11062
+ Width: "width",
11063
+ Height: "height",
11064
+ Both: "both"
11065
+ };
11066
+ var ImagePos = {
11067
+ TopLeft: "tl",
11068
+ TopCenter: "tc",
11069
+ TopRight: "tr",
11070
+ MiddleLeft: "ml",
11071
+ MiddleCenter: "mc",
11072
+ MiddleRight: "mr",
11073
+ BottomLeft: "bl",
11074
+ BottomCenter: "bc",
11075
+ BottomRight: "br"
11076
+ };
11077
+ var IMAGE_POSITIONS = new Set(Object.values(ImagePos));
11078
+ function getImagescale(s) {
11079
+ if (s === "") return ImageScale.False;
11080
+ const l = s.toLowerCase();
11081
+ if (l === "width") return ImageScale.Width;
11082
+ if (l === "height") return ImageScale.Height;
11083
+ if (l === "both") return ImageScale.Both;
11084
+ if (mapbool(s)) return ImageScale.True;
11085
+ return ImageScale.False;
11086
+ }
11087
+ function getImagepos(s) {
11088
+ if (s === "") return ImagePos.MiddleCenter;
11089
+ const l = s.toLowerCase();
11090
+ return IMAGE_POSITIONS.has(l) ? l : ImagePos.MiddleCenter;
11091
+ }
11092
+ function scaleImage(mode, isz, pw, ph) {
11093
+ let iw = isz.w;
11094
+ let ih = isz.h;
11095
+ const scalex = pw / iw;
11096
+ const scaley = ph / ih;
11097
+ switch (mode) {
11098
+ case ImageScale.True:
11099
+ if (scalex < scaley) {
11100
+ iw *= scalex;
11101
+ ih *= scalex;
11102
+ } else {
11103
+ iw *= scaley;
11104
+ ih *= scaley;
11105
+ }
11106
+ break;
11107
+ case ImageScale.Width:
11108
+ iw *= scalex;
11109
+ break;
11110
+ case ImageScale.Height:
11111
+ ih *= scaley;
11112
+ break;
11113
+ case ImageScale.Both:
11114
+ iw *= scalex;
11115
+ ih *= scaley;
11116
+ break;
11117
+ case ImageScale.False:
11118
+ break;
11119
+ }
11120
+ return { iw, ih };
11121
+ }
11122
+ function positionX(b, position2, iw, pw) {
11123
+ if (!(iw < pw)) return;
11124
+ switch (position2) {
11125
+ case ImagePos.TopLeft:
11126
+ case ImagePos.MiddleLeft:
11127
+ case ImagePos.BottomLeft:
11128
+ b.ur.x = b.ll.x + iw;
11129
+ break;
11130
+ case ImagePos.TopRight:
11131
+ case ImagePos.MiddleRight:
11132
+ case ImagePos.BottomRight:
11133
+ b.ll.x += pw - iw;
11134
+ b.ur.x = b.ll.x + iw;
11135
+ break;
11136
+ default:
11137
+ b.ll.x += (pw - iw) / 2;
11138
+ b.ur.x -= (pw - iw) / 2;
11139
+ break;
11140
+ }
11141
+ }
11142
+ function positionY(b, position2, ih, ph) {
11143
+ if (!(ih < ph)) return;
11144
+ switch (position2) {
11145
+ case ImagePos.TopLeft:
11146
+ case ImagePos.TopCenter:
11147
+ case ImagePos.TopRight:
11148
+ b.ll.y = b.ur.y - ih;
11149
+ break;
11150
+ case ImagePos.BottomLeft:
11151
+ case ImagePos.BottomCenter:
11152
+ case ImagePos.BottomRight:
11153
+ b.ll.y += ih;
11154
+ b.ur.y = b.ll.y - ih;
11155
+ break;
11156
+ default:
11157
+ b.ll.y += (ph - ih) / 2;
11158
+ b.ur.y -= (ph - ih) / 2;
11159
+ break;
11160
+ }
11161
+ }
11162
+ function polygonBox(a) {
11163
+ const first = a[0];
11164
+ const b = { ll: { x: first.x, y: first.y }, ur: { x: first.x, y: first.y } };
11165
+ for (let i = 1; i < a.length; i++) {
11166
+ const p = a[i];
11167
+ if (p.x < b.ll.x) b.ll.x = p.x;
11168
+ if (p.x > b.ur.x) b.ur.x = p.x;
11169
+ if (p.y < b.ll.y) b.ll.y = p.y;
11170
+ if (p.y > b.ur.y) b.ur.y = p.y;
11171
+ }
11172
+ return b;
11173
+ }
11174
+ function gvrenderUsershape(job, name, a, _filled, imagescale, imagepos) {
11175
+ const sizer = job.imageSizer;
11176
+ if (!imageIsSupplied(name, sizer, job.imageResolver)) return;
11177
+ const isz = usershapeSizePts(name, job.dpi.x, sizer);
11178
+ if (isz === null || isz.x <= 0 && isz.y <= 0) return;
11179
+ const b = polygonBox(a);
11180
+ const pw = b.ur.x - b.ll.x;
11181
+ const ph = b.ur.y - b.ll.y;
11182
+ const { iw, ih } = scaleImage(getImagescale(imagescale), { w: isz.x, h: isz.y }, pw, ph);
11183
+ const position2 = getImagepos(imagepos);
11184
+ positionX(b, position2, iw, pw);
11185
+ positionY(b, position2, ih, ph);
11186
+ if (b.ll.x > b.ur.x) [b.ll.x, b.ur.x] = [b.ur.x, b.ll.x];
11187
+ if (b.ll.y > b.ur.y) [b.ll.y, b.ur.y] = [b.ur.y, b.ll.y];
11188
+ job.renderer?.usershape?.(name, b, job);
11189
+ }
11190
+
11058
11191
  // src/common/poly-shapes-util.ts
11059
11192
  var RBCONST = 12;
11060
11193
  var RBCURVE = 0.5;
@@ -11772,38 +11905,12 @@ function emitCellDecoration(cell2, pos, renderer, job) {
11772
11905
  emitBorder({ box: cell2.box, pos, border: cell2.border, color: cell2.color, sides: cell2.sides, style: cell2.style }, renderer, job);
11773
11906
  }
11774
11907
  }
11775
- function scaleImage(d) {
11776
- const sx = d.pw / d.iw;
11777
- const sy = d.ph / d.ih;
11778
- const mode = (d.scale ?? "").toLowerCase();
11779
- if (mode === "width") return { iw: d.iw * sx, ih: d.ih };
11780
- if (mode === "height") return { iw: d.iw, ih: d.ih * sy };
11781
- if (mode === "both") return { iw: d.iw * sx, ih: d.ih * sy };
11782
- if (mode === "true" || mode === "yes" || mode === "1") {
11783
- const f = Math.min(sx, sy);
11784
- return { iw: d.iw * f, ih: d.ih * f };
11785
- }
11786
- return { iw: d.iw, ih: d.ih };
11787
- }
11788
- function emitHtmlImg(img, pos, renderer, job) {
11789
- if (img.iw <= 0 && img.ih <= 0) return;
11790
- const b = {
11791
- ll: { x: img.box.ll.x + pos.x, y: img.box.ll.y + pos.y },
11792
- ur: { x: img.box.ur.x + pos.x, y: img.box.ur.y + pos.y }
11793
- };
11794
- const pw = b.ur.x - b.ll.x;
11795
- const ph = b.ur.y - b.ll.y;
11908
+ function emitHtmlImg(img, pos, _renderer, job) {
11909
+ const ll = { x: img.box.ll.x + pos.x, y: img.box.ll.y + pos.y };
11910
+ const ur = { x: img.box.ur.x + pos.x, y: img.box.ur.y + pos.y };
11911
+ const a = [ur, { x: ll.x, y: ur.y }, ll, { x: ur.x, y: ll.y }];
11796
11912
  const scale = img.scale !== void 0 ? img.scale : htmlObjImgscale();
11797
- const { iw, ih } = scaleImage({ iw: img.iw, ih: img.ih, pw, ph, scale });
11798
- if (iw < pw) {
11799
- b.ll.x += (pw - iw) / 2;
11800
- b.ur.x -= (pw - iw) / 2;
11801
- }
11802
- if (ih < ph) {
11803
- b.ll.y += (ph - ih) / 2;
11804
- b.ur.y -= (ph - ih) / 2;
11805
- }
11806
- renderer.usershape?.(img.src, b, job);
11913
+ gvrenderUsershape(job, img.src, a, true, scale, "mc");
11807
11914
  }
11808
11915
  function emitHtmlCell(cell2, pos, renderer, job) {
11809
11916
  const inAnchor = initHtmlAnchor(
@@ -12074,7 +12181,7 @@ var XPAD = 4 * GAP;
12074
12181
  var YPAD = 2 * GAP;
12075
12182
  var SQRT2 = 1.4142135623730951;
12076
12183
  var INCH2PS = 72;
12077
- function mapbool(s) {
12184
+ function mapbool2(s) {
12078
12185
  if (!s || s.toLowerCase() === "false" || s.toLowerCase() === "no") return false;
12079
12186
  if (s.toLowerCase() === "true" || s.toLowerCase() === "yes") return true;
12080
12187
  const n = parseInt(s, 10);
@@ -12298,7 +12405,7 @@ function applySizeConstraints(p, bb0, width0, height0) {
12298
12405
  let c;
12299
12406
  if (p.fixedsize === "shape") {
12300
12407
  c = { bb: { x: width0, y: height0 }, width: width0, height: height0, fixedshape: true };
12301
- } else if (mapbool(p.fixedsize)) {
12408
+ } else if (mapbool2(p.fixedsize)) {
12302
12409
  c = { bb: { x: width0, y: height0 }, width: width0, height: height0, fixedshape: false };
12303
12410
  } else {
12304
12411
  const bb = { x: Math.max(width0, bb0.x), y: Math.max(height0, bb0.y) };
@@ -12653,7 +12760,7 @@ function posReclbl(f, ul, sides2) {
12653
12760
  }
12654
12761
  }
12655
12762
  function attrBool(n, g, key) {
12656
- return mapbool2(nodeAttr(n, g, key));
12763
+ return mapbool(nodeAttr(n, g, key));
12657
12764
  }
12658
12765
  function recAttrSize(n, g) {
12659
12766
  const w = nodeAttr(n, g, "width");
@@ -12787,8 +12894,15 @@ function buildNodeLabel(n, g, measurer) {
12787
12894
  const content = isHtml ? htmlValueContent(labelAttr) : labelAttr ?? n.name;
12788
12895
  n.info.label = makeAnyLabel(content, isHtml, font, measurer, n);
12789
12896
  }
12790
- function warnMissingImage(n, g, shapefile) {
12791
- if (shapefile !== void 0 && shapefile !== "" && nodeAttr(n, g, "shape") !== "epsf") return;
12897
+ function warnPolyInitImages(n, g) {
12898
+ const shapefile = nodeAttr(n, g, "shapefile");
12899
+ if (shapefile !== void 0 && shapefile !== "") {
12900
+ if (nodeAttr(n, g, "shape") !== "epsf") {
12901
+ agwarningf(imageOpenWarning(shapefile));
12902
+ agwarningf(`No or improper shapefile="${shapefile}" for node "${n.name}"`);
12903
+ return;
12904
+ }
12905
+ }
12792
12906
  const image = nodeAttr(n, g, "image");
12793
12907
  if (image === void 0 || image === "") return;
12794
12908
  const gvc = g.root.info.gvc;
@@ -12809,14 +12923,10 @@ function polyInit(n, g, measurer) {
12809
12923
  const shapeName2 = nodeAttr(n, g, "shape") ?? "ellipse";
12810
12924
  const shapefile = nodeAttr(n, g, "shapefile");
12811
12925
  n.info.shape = bindShape(shapeName2, shapefile);
12812
- if (shapefile !== void 0 && shapefile !== "" && shapeName2 !== "epsf") {
12813
- agwarningf(`No or improper shapefile="${shapefile}" for node "${n.name}"`);
12814
- }
12815
12926
  if (n.info.shape.kind === 2 /* SH_RECORD */) {
12816
12927
  if (n.info.shape_info === void 0) recordNodeInit(n, g, measurer);
12817
12928
  return;
12818
12929
  }
12819
- warnMissingImage(n, g, shapefile);
12820
12930
  buildNodeLabel(n, g, measurer);
12821
12931
  if (n.info.shape_info !== void 0) return;
12822
12932
  const polyDesc = n.info.shape.polygon;
@@ -16456,7 +16566,7 @@ function applyClusterFill(obj, fillRes) {
16456
16566
  }
16457
16567
  if (fillRes.kind === "solid") {
16458
16568
  obj.fill = 1 /* Solid */;
16459
- obj.fillColor = resolveRenderColor(fillRes.color);
16569
+ obj.fillColor = resolveFillColorName(fillRes.color);
16460
16570
  return true;
16461
16571
  }
16462
16572
  applyClusterGradient(obj, fillRes);
@@ -16547,6 +16657,32 @@ function renderPeripheries(poly, coord, filled, ctx) {
16547
16657
  }
16548
16658
  }
16549
16659
  }
16660
+ var CUSTOM_SHAPE_NAME = "custom";
16661
+ function usershapeName(n) {
16662
+ const shape = n.info.shape;
16663
+ if (shape?.usershape === true) {
16664
+ if (shape.name !== CUSTOM_SHAPE_NAME) return shape.name;
16665
+ const shapefile = nodeAttr(n, n.root, "shapefile");
16666
+ return shapefile !== void 0 && shapefile !== "" ? shapefile : void 0;
16667
+ }
16668
+ const image = nodeAttr(n, n.root, "image");
16669
+ return image !== void 0 && image !== "" ? image : void 0;
16670
+ }
16671
+ function renderUsershape(n, d) {
16672
+ const name = usershapeName(n);
16673
+ if (name === void 0) return;
16674
+ const { poly, coord } = d;
16675
+ const sides2 = poly.sides <= 2 ? 2 : poly.sides;
16676
+ const af = poly.vertices.slice(0, sides2).map((v) => ({ x: v.x + coord.x, y: v.y + coord.y }));
16677
+ gvrenderUsershape(
16678
+ d.ringCtx.job,
16679
+ name,
16680
+ af,
16681
+ poly.peripheries === 0 && d.filled,
16682
+ nodeAttr(n, n.root, "imagescale") ?? "false",
16683
+ nodeAttr(n, n.root, "imagepos") ?? "mc"
16684
+ );
16685
+ }
16550
16686
  function renderLabel(label, coord, renderer, job) {
16551
16687
  if (label.u.kind !== "txt" || label.u.nspans < 1) return;
16552
16688
  reportColorNames([label.fontcolor]);
@@ -16633,7 +16769,7 @@ function applyFillState(obj, n, job) {
16633
16769
  }
16634
16770
  if (fillRes.kind === "solid") {
16635
16771
  obj.fill = 1 /* Solid */;
16636
- obj.fillColor = resolveRenderColor(fillRes.color);
16772
+ obj.fillColor = resolveFillColorName(fillRes.color);
16637
16773
  return true;
16638
16774
  }
16639
16775
  applyGradientFields(obj, fillRes);
@@ -16719,6 +16855,7 @@ function polyGencode(rawJob, rawNode) {
16719
16855
  const savedPts = job.obj?.urlMapPts;
16720
16856
  let inAnchor = clustersLast ? false : beginNodeAnchor(n, renderer, job);
16721
16857
  renderPeripheries(ctx.poly, ctx.coord, ctx.filled, ctx.ringCtx);
16858
+ if (!isPointNode(n)) renderUsershape(n, ctx);
16722
16859
  if (!isPointNode(n)) renderNodeLabel(n, ctx.coord, renderer, job);
16723
16860
  if (clustersLast) {
16724
16861
  if (job.obj && savedPts !== void 0 && savedShape !== void 0) {
@@ -18724,7 +18861,7 @@ function graphInit(g, useRankdir) {
18724
18861
  if (fn !== -1) g.info.fontnames = fn;
18725
18862
  parseRatioDrawing(g);
18726
18863
  setClType(maptoken(g.attrs.get("clusterrank"), RANK_NAMES, rankCodes()));
18727
- g.info.concentrate = mapbool2(g.attrs.get("concentrate"));
18864
+ g.info.concentrate = mapbool(g.attrs.get("concentrate"));
18728
18865
  g.info.edgeLabelsDone = false;
18729
18866
  doGraphLabel(g, layoutMeasurer(g));
18730
18867
  }
@@ -18766,7 +18903,7 @@ function sameNonemptyGroup(e) {
18766
18903
  }
18767
18904
  function initEdgeConstraint(e) {
18768
18905
  const s = e.attrs.get("constraint");
18769
- if (s !== void 0 && s !== "") e.info.constraint = mapbool2(s);
18906
+ if (s !== void 0 && s !== "") e.info.constraint = mapbool(s);
18770
18907
  }
18771
18908
  function applyGroupPenalty(e) {
18772
18909
  if (!sameNonemptyGroup(e)) return;
@@ -19438,6 +19575,7 @@ function initNodeFromLabel(n, g, measurer) {
19438
19575
  }
19439
19576
  buildNodeLabel(n, g, measurer);
19440
19577
  initNodeXLabel(n, g, measurer);
19578
+ if (shape.kind !== 3 /* SH_POINT */) warnPolyInitImages(n, g);
19441
19579
  const poly = shape.polygon;
19442
19580
  if (poly === null) return false;
19443
19581
  if (shape.kind === 3 /* SH_POINT */) {
@@ -21506,6 +21644,7 @@ function render(ctx, g, format, inlineImages = false) {
21506
21644
  const job = new RenderJob(format, ctx.textMeasurer);
21507
21645
  job.inlineImages = inlineImages;
21508
21646
  if (ctx.imageResolver !== void 0) job.imageResolver = ctx.imageResolver;
21647
+ if (ctx.imageSizer !== void 0) job.imageSizer = ctx.imageSizer;
21509
21648
  job.bb = g.info.bb;
21510
21649
  job.pad = parseGraphPad(g.attrs.get("pad"));
21511
21650
  job.margin = parseGraphMargin(g.attrs.get("margin"));
@@ -24319,10 +24458,10 @@ function xgWeak(Xg, t, h, orig, st) {
24319
24458
  function isNonConstraint(e) {
24320
24459
  const v = e.attrs.get("constraint");
24321
24460
  if (!v) return false;
24322
- return !mapbool2(v);
24461
+ return !mapbool(v);
24323
24462
  }
24324
24463
  function isAStrongCluster(g) {
24325
- return mapbool2(g.attrs.get("compact") ?? "");
24464
+ return mapbool(g.attrs.get("compact") ?? "");
24326
24465
  }
24327
24466
  function dotLca(c0, c1) {
24328
24467
  let a = c0;
@@ -24600,7 +24739,7 @@ function setClType(t) {
24600
24739
  registerRenderState(() => {
24601
24740
  clType = LOCAL;
24602
24741
  });
24603
- function mapbool2(s) {
24742
+ function mapbool(s) {
24604
24743
  if (!s || s === "") return false;
24605
24744
  const l = s.toLowerCase();
24606
24745
  if (l === "false" || l === "no") return false;
@@ -24616,7 +24755,7 @@ function scaleClamp(nnodes, scale) {
24616
24755
  function isACluster(g) {
24617
24756
  if (g === g.root) return true;
24618
24757
  if (g.name.toLowerCase().startsWith("cluster")) return true;
24619
- return mapbool2(g.attrs.get("cluster"));
24758
+ return mapbool(g.attrs.get("cluster"));
24620
24759
  }
24621
24760
  function cleanup1ClearNode(n) {
24622
24761
  if (n.info.in) n.info.in.size = 0;
@@ -24964,7 +25103,7 @@ function dot1Rank(g) {
24964
25103
  cleanup1(g);
24965
25104
  }
24966
25105
  function dotRank(g) {
24967
- if (mapbool2(g.attrs.get("newrank"))) {
25106
+ if (mapbool(g.attrs.get("newrank"))) {
24968
25107
  g.info.flags = (g.info.flags ?? 0) | NEW_RANK;
24969
25108
  dot2Rank(g);
24970
25109
  } else {
@@ -31320,7 +31459,7 @@ function runPlacement(gp) {
31320
31459
  const nObjs = gp.nodes.size + nSetLbls + nClbls + nElbls;
31321
31460
  const { ctx } = buildArrays(gp, nObjs, nLbls, nClbls, et);
31322
31461
  const forceStr = gp.attrs.get("forcelabels");
31323
- const force = forceStr === void 0 ? true : mapbool2(forceStr);
31462
+ const force = forceStr === void 0 ? true : mapbool(forceStr);
31324
31463
  const params = { bb: { ll: ctx.bb.ll, ur: ctx.bb.ur }, force };
31325
31464
  placeLabels(ctx.objs, ctx.lbls, params);
31326
31465
  writeBackLabels(gp, ctx.lbls, nLbls);
@@ -36799,7 +36938,7 @@ function dotPhasePostNoFinish(g) {
36799
36938
  dotSameports(g);
36800
36939
  const r = dotSplines(g);
36801
36940
  if (r !== 0) return r;
36802
- if (mapbool2(g.attrs.get("compound") ?? g.root.attrs.get("compound"))) dotCompoundEdges(g);
36941
+ if (mapbool(g.attrs.get("compound") ?? g.root.attrs.get("compound"))) dotCompoundEdges(g);
36803
36942
  return 0;
36804
36943
  }
36805
36944
  function dotPhasePost(g) {
@@ -37648,7 +37787,7 @@ function unsupported(attr2, value, what) {
37648
37787
  }
37649
37788
  function ipsepHasConstraints(g) {
37650
37789
  const dir = g.root.attrs.get("diredgeconstraints") ?? "";
37651
- if (mapbool2(dir) || /^hier/i.test(dir)) return true;
37790
+ if (mapbool(dir) || /^hier/i.test(dir)) return true;
37652
37791
  if ((g.root.attrs.get("overlap") ?? "").toLowerCase() === "ipsep") return true;
37653
37792
  return [...g.root.subgraphs.values()].some((s) => s !== g.root && isACluster(s));
37654
37793
  }
@@ -39801,7 +39940,7 @@ function userPos(n) {
39801
39940
  n.info.pos = [Number(m[1]) / div, Number(m[2]) / div];
39802
39941
  n.info.posSet = true;
39803
39942
  const pin = n.attrs.get("pin");
39804
- if (m[3] === "!" || pin !== void 0 && mapbool2(pin)) n.info.pinned = true;
39943
+ if (m[3] === "!" || pin !== void 0 && mapbool(pin)) n.info.pinned = true;
39805
39944
  return true;
39806
39945
  }
39807
39946
  function assignNodeIds2(g) {
@@ -42114,7 +42253,7 @@ function splineEdgesImpl(g, sep, edgetype) {
42114
42253
  function splineEdges(g) {
42115
42254
  const edgetype = g.info.flags & 15;
42116
42255
  if (edgetype === EDGETYPE_NONE) return;
42117
- g.root.info.concentrate = mapbool2(g.root.attrs.get("concentrate"));
42256
+ g.root.info.concentrate = mapbool(g.root.attrs.get("concentrate"));
42118
42257
  for (const n of nodesInSeq(g)) {
42119
42258
  for (const e of n.outEdges(g)) {
42120
42259
  if (e.info.tail_port.dyna) e.info.tail_port = resolvePort(e.tail, e.head, e.info.tail_port);
@@ -50982,7 +51121,7 @@ function PARENT(n) {
50982
51121
  function isCluster(g) {
50983
51122
  if (g === g.root) return true;
50984
51123
  if (g.name.toLowerCase().startsWith("cluster")) return true;
50985
- return mapbool2(g.attrs.get("cluster"));
51124
+ return mapbool(g.attrs.get("cluster"));
50986
51125
  }
50987
51126
  function clusterInitGraph(g) {
50988
51127
  graphInit(g, false);
@@ -51515,7 +51654,7 @@ function walkTree(tree) {
51515
51654
  function isCluster2(g) {
51516
51655
  if (g === g.root) return true;
51517
51656
  if (g.name.toLowerCase().startsWith("cluster")) return true;
51518
- return mapbool2(g.attrs.get("cluster"));
51657
+ return mapbool(g.attrs.get("cluster"));
51519
51658
  }
51520
51659
  function collectClusters2(g, clusters) {
51521
51660
  for (const subg of g.subgraphs.values()) {
@@ -51598,7 +51737,7 @@ var PATCHWORK_LAYOUT_ENGINE = {
51598
51737
  // src/gvc/edge-labels.ts
51599
51738
  function renderEdgeLabels(e, renderer, job) {
51600
51739
  const obj = job.obj;
51601
- const spl = mapbool2(e.attrs.get("decorate") ?? "false") ? e.info.spl : void 0;
51740
+ const spl = mapbool(e.attrs.get("decorate") ?? "false") ? e.info.spl : void 0;
51602
51741
  if (obj === null) {
51603
51742
  renderOneLabel(e.info.label, renderer, job);
51604
51743
  if (spl) emitAttachment(e.info.label, spl, renderer, job);
@@ -53611,6 +53750,18 @@ var XdotRenderer = class extends EdgeDrawBase {
53611
53750
  const buf = this.getBuf(job);
53612
53751
  buf.push(this.styleOp(job), this.penOp(job), xdotPoints("L", pts));
53613
53752
  }
53753
+ /**
53754
+ * The `I` op: `x y w h` of the box, then the image name as an xdot string.
53755
+ * @see plugin/core/gvrender_core_dot.c:core_loadimage_xdot
53756
+ */
53757
+ usershape(src, b, job) {
53758
+ this.getBuf(job).push(
53759
+ "I ",
53760
+ xdotPoint(b.ll),
53761
+ xdotNum(b.ur.x - b.ll.x) + " " + xdotNum(b.ur.y - b.ll.y) + " ",
53762
+ xdotStrOp("", src)
53763
+ );
53764
+ }
53614
53765
  // --- graphics-state ops ------------------------------------------------
53615
53766
  /** Pen color op from the resolved graphics state (default black). */
53616
53767
  penOp(job) {
@@ -53698,6 +53849,9 @@ var DotRenderer = class extends XdotRenderer {
53698
53849
  }
53699
53850
  polyline(_pts, _job) {
53700
53851
  }
53852
+ /** No loadimage engine for "dot" (only "<type>:xdot"). */
53853
+ usershape(_src, _b, _job) {
53854
+ }
53701
53855
  };
53702
53856
  function createDotRenderer() {
53703
53857
  return new DotRenderer();