emf-converter 4.4.6 → 4.4.7

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.
package/dist/browser.js CHANGED
@@ -11333,7 +11333,7 @@ var GdiRasterPath = class {
11333
11333
  /** Appends every figure of `other`. */
11334
11334
  append(other) {
11335
11335
  for (const f of other.figures) {
11336
- this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents) });
11336
+ this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents), roundWiden: f.roundWiden });
11337
11337
  }
11338
11338
  for (let i = 0; i < other.getPath.types.length; i++) {
11339
11339
  this.log(other.getPath.pts[2 * i], other.getPath.pts[2 * i + 1], other.getPath.types[i]);
@@ -28073,7 +28073,8 @@ var Outliner = class {
28073
28073
  this.pen = penPolygon(opts.width);
28074
28074
  this.n = this.pen.length;
28075
28075
  this.rr = opts.cap === "round" && opts.join === "round";
28076
- this.roundJoinSides = opts.join === "round" && opts.cap !== "flat";
28076
+ this.originalRoundJoinSides = opts.join === "round" && opts.cap !== "flat";
28077
+ this.roundJoinSides = !!opts.roundCurveJoins || this.originalRoundJoinSides;
28077
28078
  this.maxX = Math.max(...this.pen.map((q) => Math.abs(q[0])));
28078
28079
  }
28079
28080
  /**
@@ -28086,7 +28087,8 @@ var Outliner = class {
28086
28087
  const dy = dir ? dir[1] : b[1] - a[1];
28087
28088
  const d = drawDir ?? [dx, dy];
28088
28089
  const [L, R] = drawVertices(this.pen, d[0], d[1]);
28089
- return { dx, dy, L, R, v: flatVector(this.opts.width, dx, dy), e: squareExtension(this.opts.width, dx, dy) };
28090
+ const perpendicular = this.opts.roundCurveJoins && drawDir ? drawDir : [dx, dy];
28091
+ return { dx, dy, L, R, v: flatVector(this.opts.width, perpendicular[0], perpendicular[1]), e: squareExtension(this.opts.width, dx, dy), curveEnd: !!drawDir };
28090
28092
  }
28091
28093
  push(p, v) {
28092
28094
  this.pts.push([p[0] + v[0], p[1] + v[1]]);
@@ -28205,12 +28207,17 @@ var Outliner = class {
28205
28207
  * segment).
28206
28208
  */
28207
28209
  join(p, a, b, side, outer) {
28208
- const { join, cap, width, miterLimit } = this.opts;
28209
- const sa = this.joinSide(a, side);
28210
- const sb = this.joinSide(b, side);
28210
+ const { cap, width, miterLimit } = this.opts;
28211
+ const join = this.opts.roundCurveJoins ? "round" : this.opts.join;
28212
+ let sa = this.joinSide(a, side);
28213
+ let sb = this.joinSide(b, side);
28214
+ if (this.opts.roundCurveJoins && !this.originalRoundJoinSides && a.curveEnd && b.curveEnd) {
28215
+ sa = side === "R" ? a.v : [-a.v[0], -a.v[1]];
28216
+ sb = side === "R" ? b.v : [-b.v[0], -b.v[1]];
28217
+ }
28211
28218
  const Da = side === "R" ? a.R : a.L;
28212
28219
  const Db = side === "R" ? b.R : b.L;
28213
- if (this.roundJoinSides && Da === Db) {
28220
+ if (this.roundJoinSides && (Da === Db || this.opts.roundCurveJoins && sa[0] === sb[0] && sa[1] === sb[1])) {
28214
28221
  this.push(p, sa);
28215
28222
  return;
28216
28223
  }
@@ -28234,7 +28241,12 @@ var Outliner = class {
28234
28241
  }
28235
28242
  } else {
28236
28243
  this.pts.push([p[0], p[1]]);
28237
- if (join === "round" && cap === "flat") {
28244
+ if (this.opts.roundCurveJoins && !this.originalRoundJoinSides) {
28245
+ this.push(p, sb);
28246
+ this.push(p, sa);
28247
+ this.pts.push([p[0], p[1]]);
28248
+ }
28249
+ if (join === "round" && cap === "flat" && !this.opts.roundCurveJoins) {
28238
28250
  this.push(p, sb);
28239
28251
  this.wedge(p, sb, sa, false, false);
28240
28252
  this.push(p, sa);
@@ -28404,9 +28416,9 @@ function dashPieces(P, tangents, pattern, shorten) {
28404
28416
  }
28405
28417
  function widenPath(path, opts) {
28406
28418
  const out = [];
28407
- const outliner = new Outliner(opts, out);
28408
28419
  const dashed = !!opts.dashes && opts.dashes.length > 0;
28409
28420
  for (const fig of path.figures) {
28421
+ const outliner = new Outliner(fig.roundWiden ? { ...opts, roundCurveJoins: true } : opts, out);
28410
28422
  let P = [];
28411
28423
  const dirs = [];
28412
28424
  for (let i = 0; i + 1 < fig.pts.length; i += 2) {
@@ -28518,6 +28530,7 @@ function ellipseRasterPath(box, clockwise = false) {
28518
28530
  const path = new GdiRasterPath();
28519
28531
  path.addBeziers(ellipseBeziersBox(box, clockwise), true);
28520
28532
  path.closeFigure();
28533
+ path.figures[0].roundWiden = true;
28521
28534
  return path;
28522
28535
  }
28523
28536
  function frameMapper(box, l, t, w, h) {
@@ -28637,7 +28650,7 @@ function penWidenOptions(rCtx, opts = {}) {
28637
28650
  const { state } = rCtx;
28638
28651
  const flags = state.penFlags ?? state.penStyle;
28639
28652
  const matrix = gdiDeviceMatrix(rCtx);
28640
- const widthPx = opts.rectangle && rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
28653
+ const widthPx = rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
28641
28654
  const capBits = flags & 3840;
28642
28655
  const joinBits = flags & 61440;
28643
28656
  const dashes = state.penExtended ? geometricStyle(flags, widthPx, state.penUserStyle, widthPx / (state.penWidth || 1)) : null;
@@ -33507,6 +33520,7 @@ function flattenBracketPath(rCtx) {
33507
33520
  }
33508
33521
  for (const f of rCtx.rasterPath.figures) {
33509
33522
  delete f.tangents;
33523
+ delete f.roundWiden;
33510
33524
  }
33511
33525
  syncPathCmds(rCtx);
33512
33526
  }
@@ -37534,19 +37548,12 @@ function compatBox(p, l, t, r, b, opts = {}) {
37534
37548
  if (w > 1) {
37535
37549
  const matrix = gdiDeviceMatrix(p.rCtx);
37536
37550
  const rawWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) / p.kx;
37537
- if (!opts.curved) {
37538
- box.x1 += Math.round(ux);
37539
- box.y1 += Math.round(uy);
37540
- box.x0 += Math.round(rawWidth * ux / 2);
37541
- box.y0 += Math.round(rawWidth * uy / 2);
37542
- box.x1 -= Math.round(rawWidth * ux / 2);
37543
- box.y1 -= Math.round(rawWidth * uy / 2);
37544
- return box;
37545
- }
37546
- box.x0 += Math.round(Math.floor(w / 2) * ux);
37547
- box.y0 += Math.round(Math.floor(w / 2) * uy);
37548
- box.x1 -= Math.round(Math.floor((w - 1) / 2) * ux);
37549
- box.y1 -= Math.round(Math.floor((w - 1) / 2) * uy);
37551
+ box.x1 += Math.round(ux);
37552
+ box.y1 += Math.round(uy);
37553
+ box.x0 += Math.round(rawWidth * ux / 2);
37554
+ box.y0 += Math.round(rawWidth * uy / 2);
37555
+ box.x1 -= Math.round(rawWidth * ux / 2);
37556
+ box.y1 -= Math.round(rawWidth * uy / 2);
37550
37557
  }
37551
37558
  }
37552
37559
  return box;
@@ -37610,6 +37617,11 @@ function compatCorner(p, w, h, box) {
37610
37617
  const ch = Math.round(Math.abs(h * m[3]) * 16);
37611
37618
  const ux = 16 * p.kx;
37612
37619
  const uy = 16 * p.ky;
37620
+ if ((p.rCtx.state.penStyle & 15) === PS_INSIDEFRAME && !penIsCosmetic(p.rCtx)) {
37621
+ const penWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])) * 16;
37622
+ const width = box.x1 - box.x0, height = box.y1 - box.y0;
37623
+ return [Math.min(cw, width + penWidth) * width / (width + penWidth), Math.min(ch, height + penWidth) * height / (height + penWidth)];
37624
+ }
37613
37625
  if (!penIsNull(p) && penIsCosmetic(p.rCtx)) {
37614
37626
  const width = box.x1 - box.x0, height = box.y1 - box.y0;
37615
37627
  return [Math.min(cw, width + ux) * width / (width + ux), Math.min(ch, height + uy) * height / (height + uy)];
package/dist/browser.mjs CHANGED
@@ -11331,7 +11331,7 @@ var GdiRasterPath = class {
11331
11331
  /** Appends every figure of `other`. */
11332
11332
  append(other) {
11333
11333
  for (const f of other.figures) {
11334
- this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents) });
11334
+ this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents), roundWiden: f.roundWiden });
11335
11335
  }
11336
11336
  for (let i = 0; i < other.getPath.types.length; i++) {
11337
11337
  this.log(other.getPath.pts[2 * i], other.getPath.pts[2 * i + 1], other.getPath.types[i]);
@@ -28071,7 +28071,8 @@ var Outliner = class {
28071
28071
  this.pen = penPolygon(opts.width);
28072
28072
  this.n = this.pen.length;
28073
28073
  this.rr = opts.cap === "round" && opts.join === "round";
28074
- this.roundJoinSides = opts.join === "round" && opts.cap !== "flat";
28074
+ this.originalRoundJoinSides = opts.join === "round" && opts.cap !== "flat";
28075
+ this.roundJoinSides = !!opts.roundCurveJoins || this.originalRoundJoinSides;
28075
28076
  this.maxX = Math.max(...this.pen.map((q) => Math.abs(q[0])));
28076
28077
  }
28077
28078
  /**
@@ -28084,7 +28085,8 @@ var Outliner = class {
28084
28085
  const dy = dir ? dir[1] : b[1] - a[1];
28085
28086
  const d = drawDir ?? [dx, dy];
28086
28087
  const [L, R] = drawVertices(this.pen, d[0], d[1]);
28087
- return { dx, dy, L, R, v: flatVector(this.opts.width, dx, dy), e: squareExtension(this.opts.width, dx, dy) };
28088
+ const perpendicular = this.opts.roundCurveJoins && drawDir ? drawDir : [dx, dy];
28089
+ return { dx, dy, L, R, v: flatVector(this.opts.width, perpendicular[0], perpendicular[1]), e: squareExtension(this.opts.width, dx, dy), curveEnd: !!drawDir };
28088
28090
  }
28089
28091
  push(p, v) {
28090
28092
  this.pts.push([p[0] + v[0], p[1] + v[1]]);
@@ -28203,12 +28205,17 @@ var Outliner = class {
28203
28205
  * segment).
28204
28206
  */
28205
28207
  join(p, a, b, side, outer) {
28206
- const { join, cap, width, miterLimit } = this.opts;
28207
- const sa = this.joinSide(a, side);
28208
- const sb = this.joinSide(b, side);
28208
+ const { cap, width, miterLimit } = this.opts;
28209
+ const join = this.opts.roundCurveJoins ? "round" : this.opts.join;
28210
+ let sa = this.joinSide(a, side);
28211
+ let sb = this.joinSide(b, side);
28212
+ if (this.opts.roundCurveJoins && !this.originalRoundJoinSides && a.curveEnd && b.curveEnd) {
28213
+ sa = side === "R" ? a.v : [-a.v[0], -a.v[1]];
28214
+ sb = side === "R" ? b.v : [-b.v[0], -b.v[1]];
28215
+ }
28209
28216
  const Da = side === "R" ? a.R : a.L;
28210
28217
  const Db = side === "R" ? b.R : b.L;
28211
- if (this.roundJoinSides && Da === Db) {
28218
+ if (this.roundJoinSides && (Da === Db || this.opts.roundCurveJoins && sa[0] === sb[0] && sa[1] === sb[1])) {
28212
28219
  this.push(p, sa);
28213
28220
  return;
28214
28221
  }
@@ -28232,7 +28239,12 @@ var Outliner = class {
28232
28239
  }
28233
28240
  } else {
28234
28241
  this.pts.push([p[0], p[1]]);
28235
- if (join === "round" && cap === "flat") {
28242
+ if (this.opts.roundCurveJoins && !this.originalRoundJoinSides) {
28243
+ this.push(p, sb);
28244
+ this.push(p, sa);
28245
+ this.pts.push([p[0], p[1]]);
28246
+ }
28247
+ if (join === "round" && cap === "flat" && !this.opts.roundCurveJoins) {
28236
28248
  this.push(p, sb);
28237
28249
  this.wedge(p, sb, sa, false, false);
28238
28250
  this.push(p, sa);
@@ -28402,9 +28414,9 @@ function dashPieces(P, tangents, pattern, shorten) {
28402
28414
  }
28403
28415
  function widenPath(path, opts) {
28404
28416
  const out = [];
28405
- const outliner = new Outliner(opts, out);
28406
28417
  const dashed = !!opts.dashes && opts.dashes.length > 0;
28407
28418
  for (const fig of path.figures) {
28419
+ const outliner = new Outliner(fig.roundWiden ? { ...opts, roundCurveJoins: true } : opts, out);
28408
28420
  let P = [];
28409
28421
  const dirs = [];
28410
28422
  for (let i = 0; i + 1 < fig.pts.length; i += 2) {
@@ -28516,6 +28528,7 @@ function ellipseRasterPath(box, clockwise = false) {
28516
28528
  const path = new GdiRasterPath();
28517
28529
  path.addBeziers(ellipseBeziersBox(box, clockwise), true);
28518
28530
  path.closeFigure();
28531
+ path.figures[0].roundWiden = true;
28519
28532
  return path;
28520
28533
  }
28521
28534
  function frameMapper(box, l, t, w, h) {
@@ -28635,7 +28648,7 @@ function penWidenOptions(rCtx, opts = {}) {
28635
28648
  const { state } = rCtx;
28636
28649
  const flags = state.penFlags ?? state.penStyle;
28637
28650
  const matrix = gdiDeviceMatrix(rCtx);
28638
- const widthPx = opts.rectangle && rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
28651
+ const widthPx = rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
28639
28652
  const capBits = flags & 3840;
28640
28653
  const joinBits = flags & 61440;
28641
28654
  const dashes = state.penExtended ? geometricStyle(flags, widthPx, state.penUserStyle, widthPx / (state.penWidth || 1)) : null;
@@ -33505,6 +33518,7 @@ function flattenBracketPath(rCtx) {
33505
33518
  }
33506
33519
  for (const f of rCtx.rasterPath.figures) {
33507
33520
  delete f.tangents;
33521
+ delete f.roundWiden;
33508
33522
  }
33509
33523
  syncPathCmds(rCtx);
33510
33524
  }
@@ -37532,19 +37546,12 @@ function compatBox(p, l, t, r, b, opts = {}) {
37532
37546
  if (w > 1) {
37533
37547
  const matrix = gdiDeviceMatrix(p.rCtx);
37534
37548
  const rawWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) / p.kx;
37535
- if (!opts.curved) {
37536
- box.x1 += Math.round(ux);
37537
- box.y1 += Math.round(uy);
37538
- box.x0 += Math.round(rawWidth * ux / 2);
37539
- box.y0 += Math.round(rawWidth * uy / 2);
37540
- box.x1 -= Math.round(rawWidth * ux / 2);
37541
- box.y1 -= Math.round(rawWidth * uy / 2);
37542
- return box;
37543
- }
37544
- box.x0 += Math.round(Math.floor(w / 2) * ux);
37545
- box.y0 += Math.round(Math.floor(w / 2) * uy);
37546
- box.x1 -= Math.round(Math.floor((w - 1) / 2) * ux);
37547
- box.y1 -= Math.round(Math.floor((w - 1) / 2) * uy);
37549
+ box.x1 += Math.round(ux);
37550
+ box.y1 += Math.round(uy);
37551
+ box.x0 += Math.round(rawWidth * ux / 2);
37552
+ box.y0 += Math.round(rawWidth * uy / 2);
37553
+ box.x1 -= Math.round(rawWidth * ux / 2);
37554
+ box.y1 -= Math.round(rawWidth * uy / 2);
37548
37555
  }
37549
37556
  }
37550
37557
  return box;
@@ -37608,6 +37615,11 @@ function compatCorner(p, w, h, box) {
37608
37615
  const ch = Math.round(Math.abs(h * m[3]) * 16);
37609
37616
  const ux = 16 * p.kx;
37610
37617
  const uy = 16 * p.ky;
37618
+ if ((p.rCtx.state.penStyle & 15) === PS_INSIDEFRAME && !penIsCosmetic(p.rCtx)) {
37619
+ const penWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])) * 16;
37620
+ const width = box.x1 - box.x0, height = box.y1 - box.y0;
37621
+ return [Math.min(cw, width + penWidth) * width / (width + penWidth), Math.min(ch, height + penWidth) * height / (height + penWidth)];
37622
+ }
37611
37623
  if (!penIsNull(p) && penIsCosmetic(p.rCtx)) {
37612
37624
  const width = box.x1 - box.x0, height = box.y1 - box.y0;
37613
37625
  return [Math.min(cw, width + ux) * width / (width + ux), Math.min(ch, height + uy) * height / (height + uy)];
package/dist/index.js CHANGED
@@ -11334,7 +11334,7 @@ var GdiRasterPath = class {
11334
11334
  /** Appends every figure of `other`. */
11335
11335
  append(other) {
11336
11336
  for (const f of other.figures) {
11337
- this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents) });
11337
+ this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents), roundWiden: f.roundWiden });
11338
11338
  }
11339
11339
  for (let i = 0; i < other.getPath.types.length; i++) {
11340
11340
  this.log(other.getPath.pts[2 * i], other.getPath.pts[2 * i + 1], other.getPath.types[i]);
@@ -28074,7 +28074,8 @@ var Outliner = class {
28074
28074
  this.pen = penPolygon(opts.width);
28075
28075
  this.n = this.pen.length;
28076
28076
  this.rr = opts.cap === "round" && opts.join === "round";
28077
- this.roundJoinSides = opts.join === "round" && opts.cap !== "flat";
28077
+ this.originalRoundJoinSides = opts.join === "round" && opts.cap !== "flat";
28078
+ this.roundJoinSides = !!opts.roundCurveJoins || this.originalRoundJoinSides;
28078
28079
  this.maxX = Math.max(...this.pen.map((q) => Math.abs(q[0])));
28079
28080
  }
28080
28081
  /**
@@ -28087,7 +28088,8 @@ var Outliner = class {
28087
28088
  const dy = dir ? dir[1] : b[1] - a[1];
28088
28089
  const d = drawDir ?? [dx, dy];
28089
28090
  const [L, R] = drawVertices(this.pen, d[0], d[1]);
28090
- return { dx, dy, L, R, v: flatVector(this.opts.width, dx, dy), e: squareExtension(this.opts.width, dx, dy) };
28091
+ const perpendicular = this.opts.roundCurveJoins && drawDir ? drawDir : [dx, dy];
28092
+ return { dx, dy, L, R, v: flatVector(this.opts.width, perpendicular[0], perpendicular[1]), e: squareExtension(this.opts.width, dx, dy), curveEnd: !!drawDir };
28091
28093
  }
28092
28094
  push(p, v) {
28093
28095
  this.pts.push([p[0] + v[0], p[1] + v[1]]);
@@ -28206,12 +28208,17 @@ var Outliner = class {
28206
28208
  * segment).
28207
28209
  */
28208
28210
  join(p, a, b, side, outer) {
28209
- const { join, cap, width, miterLimit } = this.opts;
28210
- const sa = this.joinSide(a, side);
28211
- const sb = this.joinSide(b, side);
28211
+ const { cap, width, miterLimit } = this.opts;
28212
+ const join = this.opts.roundCurveJoins ? "round" : this.opts.join;
28213
+ let sa = this.joinSide(a, side);
28214
+ let sb = this.joinSide(b, side);
28215
+ if (this.opts.roundCurveJoins && !this.originalRoundJoinSides && a.curveEnd && b.curveEnd) {
28216
+ sa = side === "R" ? a.v : [-a.v[0], -a.v[1]];
28217
+ sb = side === "R" ? b.v : [-b.v[0], -b.v[1]];
28218
+ }
28212
28219
  const Da = side === "R" ? a.R : a.L;
28213
28220
  const Db = side === "R" ? b.R : b.L;
28214
- if (this.roundJoinSides && Da === Db) {
28221
+ if (this.roundJoinSides && (Da === Db || this.opts.roundCurveJoins && sa[0] === sb[0] && sa[1] === sb[1])) {
28215
28222
  this.push(p, sa);
28216
28223
  return;
28217
28224
  }
@@ -28235,7 +28242,12 @@ var Outliner = class {
28235
28242
  }
28236
28243
  } else {
28237
28244
  this.pts.push([p[0], p[1]]);
28238
- if (join === "round" && cap === "flat") {
28245
+ if (this.opts.roundCurveJoins && !this.originalRoundJoinSides) {
28246
+ this.push(p, sb);
28247
+ this.push(p, sa);
28248
+ this.pts.push([p[0], p[1]]);
28249
+ }
28250
+ if (join === "round" && cap === "flat" && !this.opts.roundCurveJoins) {
28239
28251
  this.push(p, sb);
28240
28252
  this.wedge(p, sb, sa, false, false);
28241
28253
  this.push(p, sa);
@@ -28405,9 +28417,9 @@ function dashPieces(P, tangents, pattern, shorten) {
28405
28417
  }
28406
28418
  function widenPath(path, opts) {
28407
28419
  const out = [];
28408
- const outliner = new Outliner(opts, out);
28409
28420
  const dashed = !!opts.dashes && opts.dashes.length > 0;
28410
28421
  for (const fig of path.figures) {
28422
+ const outliner = new Outliner(fig.roundWiden ? { ...opts, roundCurveJoins: true } : opts, out);
28411
28423
  let P = [];
28412
28424
  const dirs = [];
28413
28425
  for (let i = 0; i + 1 < fig.pts.length; i += 2) {
@@ -28519,6 +28531,7 @@ function ellipseRasterPath(box, clockwise = false) {
28519
28531
  const path = new GdiRasterPath();
28520
28532
  path.addBeziers(ellipseBeziersBox(box, clockwise), true);
28521
28533
  path.closeFigure();
28534
+ path.figures[0].roundWiden = true;
28522
28535
  return path;
28523
28536
  }
28524
28537
  function frameMapper(box, l, t, w, h) {
@@ -28638,7 +28651,7 @@ function penWidenOptions(rCtx, opts = {}) {
28638
28651
  const { state } = rCtx;
28639
28652
  const flags = state.penFlags ?? state.penStyle;
28640
28653
  const matrix = gdiDeviceMatrix(rCtx);
28641
- const widthPx = opts.rectangle && rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
28654
+ const widthPx = rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
28642
28655
  const capBits = flags & 3840;
28643
28656
  const joinBits = flags & 61440;
28644
28657
  const dashes = state.penExtended ? geometricStyle(flags, widthPx, state.penUserStyle, widthPx / (state.penWidth || 1)) : null;
@@ -33508,6 +33521,7 @@ function flattenBracketPath(rCtx) {
33508
33521
  }
33509
33522
  for (const f of rCtx.rasterPath.figures) {
33510
33523
  delete f.tangents;
33524
+ delete f.roundWiden;
33511
33525
  }
33512
33526
  syncPathCmds(rCtx);
33513
33527
  }
@@ -37535,19 +37549,12 @@ function compatBox(p, l, t, r, b, opts = {}) {
37535
37549
  if (w > 1) {
37536
37550
  const matrix = gdiDeviceMatrix(p.rCtx);
37537
37551
  const rawWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) / p.kx;
37538
- if (!opts.curved) {
37539
- box.x1 += Math.round(ux);
37540
- box.y1 += Math.round(uy);
37541
- box.x0 += Math.round(rawWidth * ux / 2);
37542
- box.y0 += Math.round(rawWidth * uy / 2);
37543
- box.x1 -= Math.round(rawWidth * ux / 2);
37544
- box.y1 -= Math.round(rawWidth * uy / 2);
37545
- return box;
37546
- }
37547
- box.x0 += Math.round(Math.floor(w / 2) * ux);
37548
- box.y0 += Math.round(Math.floor(w / 2) * uy);
37549
- box.x1 -= Math.round(Math.floor((w - 1) / 2) * ux);
37550
- box.y1 -= Math.round(Math.floor((w - 1) / 2) * uy);
37552
+ box.x1 += Math.round(ux);
37553
+ box.y1 += Math.round(uy);
37554
+ box.x0 += Math.round(rawWidth * ux / 2);
37555
+ box.y0 += Math.round(rawWidth * uy / 2);
37556
+ box.x1 -= Math.round(rawWidth * ux / 2);
37557
+ box.y1 -= Math.round(rawWidth * uy / 2);
37551
37558
  }
37552
37559
  }
37553
37560
  return box;
@@ -37611,6 +37618,11 @@ function compatCorner(p, w, h, box) {
37611
37618
  const ch = Math.round(Math.abs(h * m[3]) * 16);
37612
37619
  const ux = 16 * p.kx;
37613
37620
  const uy = 16 * p.ky;
37621
+ if ((p.rCtx.state.penStyle & 15) === PS_INSIDEFRAME && !penIsCosmetic(p.rCtx)) {
37622
+ const penWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])) * 16;
37623
+ const width = box.x1 - box.x0, height = box.y1 - box.y0;
37624
+ return [Math.min(cw, width + penWidth) * width / (width + penWidth), Math.min(ch, height + penWidth) * height / (height + penWidth)];
37625
+ }
37614
37626
  if (!penIsNull(p) && penIsCosmetic(p.rCtx)) {
37615
37627
  const width = box.x1 - box.x0, height = box.y1 - box.y0;
37616
37628
  return [Math.min(cw, width + ux) * width / (width + ux), Math.min(ch, height + uy) * height / (height + uy)];
package/dist/index.mjs CHANGED
@@ -11332,7 +11332,7 @@ var GdiRasterPath = class {
11332
11332
  /** Appends every figure of `other`. */
11333
11333
  append(other) {
11334
11334
  for (const f of other.figures) {
11335
- this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents) });
11335
+ this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents), roundWiden: f.roundWiden });
11336
11336
  }
11337
11337
  for (let i = 0; i < other.getPath.types.length; i++) {
11338
11338
  this.log(other.getPath.pts[2 * i], other.getPath.pts[2 * i + 1], other.getPath.types[i]);
@@ -28072,7 +28072,8 @@ var Outliner = class {
28072
28072
  this.pen = penPolygon(opts.width);
28073
28073
  this.n = this.pen.length;
28074
28074
  this.rr = opts.cap === "round" && opts.join === "round";
28075
- this.roundJoinSides = opts.join === "round" && opts.cap !== "flat";
28075
+ this.originalRoundJoinSides = opts.join === "round" && opts.cap !== "flat";
28076
+ this.roundJoinSides = !!opts.roundCurveJoins || this.originalRoundJoinSides;
28076
28077
  this.maxX = Math.max(...this.pen.map((q) => Math.abs(q[0])));
28077
28078
  }
28078
28079
  /**
@@ -28085,7 +28086,8 @@ var Outliner = class {
28085
28086
  const dy = dir ? dir[1] : b[1] - a[1];
28086
28087
  const d = drawDir ?? [dx, dy];
28087
28088
  const [L, R] = drawVertices(this.pen, d[0], d[1]);
28088
- return { dx, dy, L, R, v: flatVector(this.opts.width, dx, dy), e: squareExtension(this.opts.width, dx, dy) };
28089
+ const perpendicular = this.opts.roundCurveJoins && drawDir ? drawDir : [dx, dy];
28090
+ return { dx, dy, L, R, v: flatVector(this.opts.width, perpendicular[0], perpendicular[1]), e: squareExtension(this.opts.width, dx, dy), curveEnd: !!drawDir };
28089
28091
  }
28090
28092
  push(p, v) {
28091
28093
  this.pts.push([p[0] + v[0], p[1] + v[1]]);
@@ -28204,12 +28206,17 @@ var Outliner = class {
28204
28206
  * segment).
28205
28207
  */
28206
28208
  join(p, a, b, side, outer) {
28207
- const { join, cap, width, miterLimit } = this.opts;
28208
- const sa = this.joinSide(a, side);
28209
- const sb = this.joinSide(b, side);
28209
+ const { cap, width, miterLimit } = this.opts;
28210
+ const join = this.opts.roundCurveJoins ? "round" : this.opts.join;
28211
+ let sa = this.joinSide(a, side);
28212
+ let sb = this.joinSide(b, side);
28213
+ if (this.opts.roundCurveJoins && !this.originalRoundJoinSides && a.curveEnd && b.curveEnd) {
28214
+ sa = side === "R" ? a.v : [-a.v[0], -a.v[1]];
28215
+ sb = side === "R" ? b.v : [-b.v[0], -b.v[1]];
28216
+ }
28210
28217
  const Da = side === "R" ? a.R : a.L;
28211
28218
  const Db = side === "R" ? b.R : b.L;
28212
- if (this.roundJoinSides && Da === Db) {
28219
+ if (this.roundJoinSides && (Da === Db || this.opts.roundCurveJoins && sa[0] === sb[0] && sa[1] === sb[1])) {
28213
28220
  this.push(p, sa);
28214
28221
  return;
28215
28222
  }
@@ -28233,7 +28240,12 @@ var Outliner = class {
28233
28240
  }
28234
28241
  } else {
28235
28242
  this.pts.push([p[0], p[1]]);
28236
- if (join === "round" && cap === "flat") {
28243
+ if (this.opts.roundCurveJoins && !this.originalRoundJoinSides) {
28244
+ this.push(p, sb);
28245
+ this.push(p, sa);
28246
+ this.pts.push([p[0], p[1]]);
28247
+ }
28248
+ if (join === "round" && cap === "flat" && !this.opts.roundCurveJoins) {
28237
28249
  this.push(p, sb);
28238
28250
  this.wedge(p, sb, sa, false, false);
28239
28251
  this.push(p, sa);
@@ -28403,9 +28415,9 @@ function dashPieces(P, tangents, pattern, shorten) {
28403
28415
  }
28404
28416
  function widenPath(path, opts) {
28405
28417
  const out = [];
28406
- const outliner = new Outliner(opts, out);
28407
28418
  const dashed = !!opts.dashes && opts.dashes.length > 0;
28408
28419
  for (const fig of path.figures) {
28420
+ const outliner = new Outliner(fig.roundWiden ? { ...opts, roundCurveJoins: true } : opts, out);
28409
28421
  let P = [];
28410
28422
  const dirs = [];
28411
28423
  for (let i = 0; i + 1 < fig.pts.length; i += 2) {
@@ -28517,6 +28529,7 @@ function ellipseRasterPath(box, clockwise = false) {
28517
28529
  const path = new GdiRasterPath();
28518
28530
  path.addBeziers(ellipseBeziersBox(box, clockwise), true);
28519
28531
  path.closeFigure();
28532
+ path.figures[0].roundWiden = true;
28520
28533
  return path;
28521
28534
  }
28522
28535
  function frameMapper(box, l, t, w, h) {
@@ -28636,7 +28649,7 @@ function penWidenOptions(rCtx, opts = {}) {
28636
28649
  const { state } = rCtx;
28637
28650
  const flags = state.penFlags ?? state.penStyle;
28638
28651
  const matrix = gdiDeviceMatrix(rCtx);
28639
- const widthPx = opts.rectangle && rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
28652
+ const widthPx = rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
28640
28653
  const capBits = flags & 3840;
28641
28654
  const joinBits = flags & 61440;
28642
28655
  const dashes = state.penExtended ? geometricStyle(flags, widthPx, state.penUserStyle, widthPx / (state.penWidth || 1)) : null;
@@ -33506,6 +33519,7 @@ function flattenBracketPath(rCtx) {
33506
33519
  }
33507
33520
  for (const f of rCtx.rasterPath.figures) {
33508
33521
  delete f.tangents;
33522
+ delete f.roundWiden;
33509
33523
  }
33510
33524
  syncPathCmds(rCtx);
33511
33525
  }
@@ -37533,19 +37547,12 @@ function compatBox(p, l, t, r, b, opts = {}) {
37533
37547
  if (w > 1) {
37534
37548
  const matrix = gdiDeviceMatrix(p.rCtx);
37535
37549
  const rawWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) / p.kx;
37536
- if (!opts.curved) {
37537
- box.x1 += Math.round(ux);
37538
- box.y1 += Math.round(uy);
37539
- box.x0 += Math.round(rawWidth * ux / 2);
37540
- box.y0 += Math.round(rawWidth * uy / 2);
37541
- box.x1 -= Math.round(rawWidth * ux / 2);
37542
- box.y1 -= Math.round(rawWidth * uy / 2);
37543
- return box;
37544
- }
37545
- box.x0 += Math.round(Math.floor(w / 2) * ux);
37546
- box.y0 += Math.round(Math.floor(w / 2) * uy);
37547
- box.x1 -= Math.round(Math.floor((w - 1) / 2) * ux);
37548
- box.y1 -= Math.round(Math.floor((w - 1) / 2) * uy);
37550
+ box.x1 += Math.round(ux);
37551
+ box.y1 += Math.round(uy);
37552
+ box.x0 += Math.round(rawWidth * ux / 2);
37553
+ box.y0 += Math.round(rawWidth * uy / 2);
37554
+ box.x1 -= Math.round(rawWidth * ux / 2);
37555
+ box.y1 -= Math.round(rawWidth * uy / 2);
37549
37556
  }
37550
37557
  }
37551
37558
  return box;
@@ -37609,6 +37616,11 @@ function compatCorner(p, w, h, box) {
37609
37616
  const ch = Math.round(Math.abs(h * m[3]) * 16);
37610
37617
  const ux = 16 * p.kx;
37611
37618
  const uy = 16 * p.ky;
37619
+ if ((p.rCtx.state.penStyle & 15) === PS_INSIDEFRAME && !penIsCosmetic(p.rCtx)) {
37620
+ const penWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])) * 16;
37621
+ const width = box.x1 - box.x0, height = box.y1 - box.y0;
37622
+ return [Math.min(cw, width + penWidth) * width / (width + penWidth), Math.min(ch, height + penWidth) * height / (height + penWidth)];
37623
+ }
37612
37624
  if (!penIsNull(p) && penIsCosmetic(p.rCtx)) {
37613
37625
  const width = box.x1 - box.x0, height = box.y1 - box.y0;
37614
37626
  return [Math.min(cw, width + ux) * width / (width + ux), Math.min(ch, height + uy) * height / (height + uy)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emf-converter",
3
- "version": "4.4.6",
3
+ "version": "4.4.7",
4
4
  "description": "Convert EMF/WMF metafile binaries to PNG data URLs or SVG (markup, data URL, React/JSX)",
5
5
  "keywords": [
6
6
  "canvas",