emf-converter 4.8.19 → 4.8.21
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/README.md +4 -33
- package/dist/browser.js +151 -34
- package/dist/browser.mjs +151 -34
- package/dist/index.js +151 -34
- package/dist/index.mjs +151 -34
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -11660,11 +11660,20 @@ function ellipseBeziersBox(box, clockwise = false) {
|
|
|
11660
11660
|
if (!clockwise) {
|
|
11661
11661
|
return ellipsePoints(box, false);
|
|
11662
11662
|
}
|
|
11663
|
-
const
|
|
11663
|
+
const { halfX, ...plain } = box;
|
|
11664
|
+
const e = clockwiseEllipseBeziersBox(plain);
|
|
11664
11665
|
const out = [];
|
|
11665
11666
|
for (let i = e.length - 2; i >= 0; i -= 2) {
|
|
11666
11667
|
out.push(e[i], e[i + 1]);
|
|
11667
11668
|
}
|
|
11669
|
+
const odd = Math.abs(plain.exx) % 2;
|
|
11670
|
+
out[18] += odd;
|
|
11671
|
+
out[6] -= odd;
|
|
11672
|
+
if (halfX) {
|
|
11673
|
+
for (const k of [0, 1, 2, 3, 4, 5, 12]) {
|
|
11674
|
+
out[2 * k]++;
|
|
11675
|
+
}
|
|
11676
|
+
}
|
|
11668
11677
|
return out;
|
|
11669
11678
|
}
|
|
11670
11679
|
function clockwiseEllipseBeziersBox(box) {
|
|
@@ -11680,10 +11689,10 @@ function ellipsePoints(box, cwControls) {
|
|
|
11680
11689
|
const vMidHi = (v) => half(v, true);
|
|
11681
11690
|
const vCtl = (v) => Math.floor(v / 2) - Math.floor(KAPPA * Math.floor(v / 2));
|
|
11682
11691
|
const vCtlR = (v) => v - vCtl(v);
|
|
11683
|
-
const vDist = (v) => Math.ceil(KAPPA * Math.floor(v / 2));
|
|
11684
|
-
const rightUpper = cwControls ? (v) =>
|
|
11692
|
+
const vDist = (v) => v % 2 === 0 ? Math.ceil(KAPPA * Math.floor(v / 2)) : Math.floor(KAPPA * Math.ceil(v / 2));
|
|
11693
|
+
const rightUpper = cwControls ? (v) => vMidLo(v) - vDist(v) : vCtl;
|
|
11685
11694
|
const leftUpper = cwControls ? (v) => vMidLo(v) - vDist(v) : vCtl;
|
|
11686
|
-
const leftLower = cwControls ? (v) =>
|
|
11695
|
+
const leftLower = cwControls ? (v) => vMidHi(v) + vDist(v) : vCtlR;
|
|
11687
11696
|
const rightLower = cwControls ? (v) => vMidHi(v) + vDist(v) : vCtlR;
|
|
11688
11697
|
const zero = () => 0;
|
|
11689
11698
|
const full = (v) => v;
|
|
@@ -11925,7 +11934,7 @@ function unitPiece(from, to, small) {
|
|
|
11925
11934
|
}
|
|
11926
11935
|
return { start: p0, ctrl };
|
|
11927
11936
|
}
|
|
11928
|
-
function arcBeziers(l, t, r, b, xs, ys, xe, ye, clockwise) {
|
|
11937
|
+
function arcBeziers(l, t, r, b, xs, ys, xe, ye, clockwise, halfX = false, framed = false) {
|
|
11929
11938
|
const w = r - l;
|
|
11930
11939
|
const h = b - t;
|
|
11931
11940
|
const Q = Math.PI / 2;
|
|
@@ -11945,11 +11954,25 @@ function arcBeziers(l, t, r, b, xs, ys, xe, ye, clockwise) {
|
|
|
11945
11954
|
} else {
|
|
11946
11955
|
while (a1 >= a0) a1 -= 2 * Math.PI;
|
|
11947
11956
|
}
|
|
11948
|
-
const px = (u) => Math.round(cx + rx * u);
|
|
11957
|
+
const px = (u, v) => clockwise && halfX ? Math.ceil(cx + rx * u + 0.5 - v) : Math.round(cx + rx * u + (halfX ? 1 + v : 0));
|
|
11949
11958
|
const py = (v) => Math.round(cy - ry * v);
|
|
11950
|
-
const
|
|
11959
|
+
const eb = axisBox(l, t, r, b);
|
|
11960
|
+
if (halfX) eb.halfX = true;
|
|
11961
|
+
const E = ellipseBeziersBox(eb);
|
|
11962
|
+
if (clockwise) {
|
|
11963
|
+
const cwPts = ellipseBeziersBox(eb, true);
|
|
11964
|
+
for (let i = 0; i < cwPts.length; i += 2) {
|
|
11965
|
+
E[cwPts.length - 2 - i] = cwPts[i];
|
|
11966
|
+
E[cwPts.length - 1 - i] = cwPts[i + 1];
|
|
11967
|
+
}
|
|
11968
|
+
}
|
|
11951
11969
|
const startUnit = small ? [Math.cos(a0), Math.sin(a0)] : polygonTrig(a0);
|
|
11952
|
-
const out = [px(startUnit[0]), py(startUnit[1])];
|
|
11970
|
+
const out = [px(startUnit[0], startUnit[1]), py(startUnit[1])];
|
|
11971
|
+
const onAxis = (angle2) => Math.abs(angle2 / Q - Math.round(angle2 / Q)) < 1e-9;
|
|
11972
|
+
const axisQuadrant = (angle2) => (Math.round(angle2 / Q) % 4 + 4) % 4;
|
|
11973
|
+
if (framed && onAxis(a0) && (s > 0 ? axisQuadrant(a0) === 1 || axisQuadrant(a0) === 2 : axisQuadrant(a0) === 2 || axisQuadrant(a0) === 3)) {
|
|
11974
|
+
out.push(out[0], out[1], out[0], out[1], out[0], out[1]);
|
|
11975
|
+
}
|
|
11953
11976
|
let a = a0;
|
|
11954
11977
|
for (let guard = 0; guard < 8 && (s > 0 ? a < a1 - 1e-12 : a > a1 + 1e-12); guard++) {
|
|
11955
11978
|
const next = s > 0 ? Math.floor(a / Q + 1e-9) * Q + Q : Math.ceil(a / Q - 1e-9) * Q - Q;
|
|
@@ -11971,10 +11994,16 @@ function arcBeziers(l, t, r, b, xs, ys, xe, ye, clockwise) {
|
|
|
11971
11994
|
const e = s > 0 ? Math.min(next, a1) : Math.max(next, a1);
|
|
11972
11995
|
const piece = unitPiece(a, e, small);
|
|
11973
11996
|
for (let i = 0; i < 6; i += 2) {
|
|
11974
|
-
out.push(px(piece.ctrl[i]), py(piece.ctrl[i + 1]));
|
|
11997
|
+
out.push(px(piece.ctrl[i], piece.ctrl[i + 1]), py(piece.ctrl[i + 1]));
|
|
11975
11998
|
}
|
|
11976
11999
|
a = e;
|
|
11977
12000
|
}
|
|
12001
|
+
if (framed && onAxis(a1) && (s > 0 ? axisQuadrant(a1) === 3 || axisQuadrant(a1) === 0 : axisQuadrant(a1) === 1 || axisQuadrant(a1) === 0)) {
|
|
12002
|
+
const endUnit = polygonTrig(a1);
|
|
12003
|
+
const ex = px(endUnit[0], endUnit[1]);
|
|
12004
|
+
const ey = py(endUnit[1]);
|
|
12005
|
+
out.push(ex, ey, ex, ey, ex, ey);
|
|
12006
|
+
}
|
|
11978
12007
|
return out;
|
|
11979
12008
|
}
|
|
11980
12009
|
var GdiRasterPath = class {
|
|
@@ -29792,6 +29821,10 @@ function flipBox(box) {
|
|
|
29792
29821
|
}
|
|
29793
29822
|
function rectRasterPath(box, clockwise = false) {
|
|
29794
29823
|
const c = boxCorners(clockwise ? flipBox(box) : box);
|
|
29824
|
+
if (box.halfXRect) {
|
|
29825
|
+
c[4]--;
|
|
29826
|
+
c[6]--;
|
|
29827
|
+
}
|
|
29795
29828
|
const path = new GdiRasterPath();
|
|
29796
29829
|
path.moveTo(c[0], c[1]);
|
|
29797
29830
|
path.lineTo(c[2], c[3]);
|
|
@@ -29838,8 +29871,49 @@ function roundRectDeviceBeziers(box, cw, ch, clockwise = false, compatible = fal
|
|
|
29838
29871
|
pts.push(...map(q[i], clockwise ? f.t + f.b - q[i + 1] : q[i + 1]));
|
|
29839
29872
|
}
|
|
29840
29873
|
if (box.halfX) {
|
|
29841
|
-
|
|
29842
|
-
|
|
29874
|
+
if (box.halfXCompat || !clockwise) {
|
|
29875
|
+
const cy = (f.t + f.b) / 2;
|
|
29876
|
+
const ry = (f.b - f.t) / 2 || 1;
|
|
29877
|
+
for (let k = 0; k < 16; k++) {
|
|
29878
|
+
const v = (cy - pts[2 * k + 1]) / ry;
|
|
29879
|
+
pts[2 * k] += k >= 8 ? Math.round(1 + v) : Math.ceil(v - 0.5);
|
|
29880
|
+
}
|
|
29881
|
+
} else {
|
|
29882
|
+
const tall = box.cornerExact !== void 0 && box.cornerExact[1] * 2 >= Math.abs(box.eyy) - 1e-9;
|
|
29883
|
+
for (const k of tall ? [1, 2, 3, 4, 5, 6, 8, 15] : [0, 1, 2, 3, 4, 5, 6, 7]) {
|
|
29884
|
+
pts[2 * k]++;
|
|
29885
|
+
}
|
|
29886
|
+
}
|
|
29887
|
+
}
|
|
29888
|
+
if (box.cornerExact && isAxisBox(box)) {
|
|
29889
|
+
const w = f.r - f.l;
|
|
29890
|
+
const h = f.b - f.t;
|
|
29891
|
+
if (w >= 0 && h >= 0) {
|
|
29892
|
+
const hx = w === 0 ? 0 : Math.round(box.cornerExact[0] * (w + w % 2) / w / 2);
|
|
29893
|
+
const hy = h === 0 ? 0 : Math.round(box.cornerExact[1] * (clockwise ? h + h % 2 : h - h % 2) / h / 2);
|
|
29894
|
+
const hc = Math.ceil(KAPPA * hx);
|
|
29895
|
+
const vc = clockwise ? Math.ceil(KAPPA * hy) : Math.floor(KAPPA * hy);
|
|
29896
|
+
const set = (k, x, y) => {
|
|
29897
|
+
if (x !== null) pts[2 * k] = x;
|
|
29898
|
+
pts[2 * k + 1] = clockwise ? f.t + f.b - y : y;
|
|
29899
|
+
};
|
|
29900
|
+
const a = box.halfX ? 1 : 0;
|
|
29901
|
+
set(0, null, f.t + hy);
|
|
29902
|
+
set(1, null, f.t + hy - vc);
|
|
29903
|
+
set(2, f.r + a - hx + hc, f.t);
|
|
29904
|
+
set(3, f.r + a - hx, f.t);
|
|
29905
|
+
set(4, f.l + a + hx, f.t);
|
|
29906
|
+
set(5, f.l + a + hx - hc, f.t);
|
|
29907
|
+
set(6, null, f.t + hy - vc);
|
|
29908
|
+
set(7, null, f.t + hy);
|
|
29909
|
+
set(8, null, f.b - hy);
|
|
29910
|
+
set(9, null, f.b - hy + vc);
|
|
29911
|
+
set(10, f.l + hx - hc, f.b);
|
|
29912
|
+
set(11, f.l + hx, f.b);
|
|
29913
|
+
set(12, f.r - hx, f.b);
|
|
29914
|
+
set(13, f.r - hx + hc, f.b);
|
|
29915
|
+
set(14, null, f.b - hy + vc);
|
|
29916
|
+
set(15, null, f.b - hy);
|
|
29843
29917
|
}
|
|
29844
29918
|
}
|
|
29845
29919
|
return pts;
|
|
@@ -29882,7 +29956,7 @@ function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPat
|
|
|
29882
29956
|
cw = !cw;
|
|
29883
29957
|
}
|
|
29884
29958
|
}
|
|
29885
|
-
const bz = arcBeziers(f.l, f.t, f.r, f.b, sx, sy, ex, ey, cw);
|
|
29959
|
+
const bz = arcBeziers(f.l, f.t, f.r, f.b, sx, sy, ex, ey, cw, !!box.halfX, !!box.framed);
|
|
29886
29960
|
const pts = [];
|
|
29887
29961
|
for (let i = 0; i < bz.length; i += 2) {
|
|
29888
29962
|
pts.push(...map(bz[i], bz[i + 1]));
|
|
@@ -29896,7 +29970,7 @@ function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPat
|
|
|
29896
29970
|
if (kind === "pie") {
|
|
29897
29971
|
const w = f.r - f.l;
|
|
29898
29972
|
const h = f.b - f.t;
|
|
29899
|
-
const [cx, cy] = map(f.l + Math.ceil(w / 2), f.t + Math.ceil(h / 2));
|
|
29973
|
+
const [cx, cy] = map(f.l + Math.ceil(w / 2) + (box.halfX ? 1 : 0), f.t + Math.ceil(h / 2));
|
|
29900
29974
|
path.lineTo(cx, cy);
|
|
29901
29975
|
}
|
|
29902
29976
|
if (kind === "pie" || kind === "chord") {
|
|
@@ -30953,9 +31027,24 @@ function insideFrameInset(rCtx, box, rectangle = false, clockwiseRoundRect = fal
|
|
|
30953
31027
|
right: Math.round((rectangle ? lo : hi) * px),
|
|
30954
31028
|
top: y,
|
|
30955
31029
|
bottom: y,
|
|
30956
|
-
half: wx % 2 === 1 && !rectangle
|
|
31030
|
+
half: wx % 2 === 1 && !rectangle,
|
|
31031
|
+
halfRect: wx % 2 === 1 && rectangle
|
|
30957
31032
|
};
|
|
30958
31033
|
}
|
|
31034
|
+
function insideFramePenTooWide(rCtx, box) {
|
|
31035
|
+
if ((rCtx.state.penStyle & 15) !== PS_INSIDEFRAME || !isAxisBox(box) || hasWorldRotation(rCtx)) {
|
|
31036
|
+
return false;
|
|
31037
|
+
}
|
|
31038
|
+
const m = gdiDeviceMatrix(rCtx);
|
|
31039
|
+
const px = gdiDevicePixelX(rCtx);
|
|
31040
|
+
const py = gdiDevicePixelY(rCtx);
|
|
31041
|
+
const widthX = Math.abs(rCtx.state.penWidth * m[0]) / px * 16;
|
|
31042
|
+
const widthY = Math.abs(rCtx.state.penWidth * m[3]) / py * 16;
|
|
31043
|
+
if (Math.max(widthX, widthY) < 24) {
|
|
31044
|
+
return false;
|
|
31045
|
+
}
|
|
31046
|
+
return Math.abs(box.exx) / px < Math.round(widthX) || Math.abs(box.eyy) / py < Math.round(widthY);
|
|
31047
|
+
}
|
|
30959
31048
|
function insetFixBox(box, inset) {
|
|
30960
31049
|
const sx = box.exx < 0 ? -1 : 1;
|
|
30961
31050
|
const sy = box.eyy < 0 ? -1 : 1;
|
|
@@ -30965,11 +31054,15 @@ function insetFixBox(box, inset) {
|
|
|
30965
31054
|
exx: box.exx - sx * (inset.left + inset.right),
|
|
30966
31055
|
exy: 0,
|
|
30967
31056
|
eyx: 0,
|
|
30968
|
-
eyy: box.eyy - sy * (inset.top + inset.bottom)
|
|
31057
|
+
eyy: box.eyy - sy * (inset.top + inset.bottom),
|
|
31058
|
+
framed: true
|
|
30969
31059
|
};
|
|
30970
31060
|
if (inset.half && sx > 0) {
|
|
30971
31061
|
framed.halfX = true;
|
|
30972
31062
|
}
|
|
31063
|
+
if (inset.halfRect && sx > 0) {
|
|
31064
|
+
framed.halfXRect = true;
|
|
31065
|
+
}
|
|
30973
31066
|
return framed;
|
|
30974
31067
|
}
|
|
30975
31068
|
function sameEllipseRay(l, t, r, b, sx, sy, ex, ey) {
|
|
@@ -31052,7 +31145,7 @@ function handleRectangle(rCtx, dataOff, recSize) {
|
|
|
31052
31145
|
const r = view.getInt32(dataOff + 8, true);
|
|
31053
31146
|
const b = view.getInt32(dataOff + 12, true);
|
|
31054
31147
|
const unframed = uprightFixBox(rCtx, l, t, r, b);
|
|
31055
|
-
const inset = insideFrameInset(rCtx, unframed, true);
|
|
31148
|
+
const inset = insideFrameInset(rCtx, unframed, true, rCtx.state.arcDirection === 2);
|
|
31056
31149
|
const box = inset ? insetFixBox(unframed, inset) : unframed;
|
|
31057
31150
|
const clockwise = rCtx.state.arcDirection === 2;
|
|
31058
31151
|
if (!inPath) {
|
|
@@ -31238,6 +31331,13 @@ function handleRoundRect(rCtx, dataOff, recSize) {
|
|
|
31238
31331
|
gmh(rCtx, cornerH) / 2,
|
|
31239
31332
|
null
|
|
31240
31333
|
);
|
|
31334
|
+
if (inset) {
|
|
31335
|
+
const fullW = Math.abs((r - l) * devM[0]) * 16;
|
|
31336
|
+
const fullH = Math.abs((b - t) * devM[3]) * 16;
|
|
31337
|
+
if (fullW > 0 && fullH > 0) {
|
|
31338
|
+
framed.cornerExact = [Math.min(cornerFixW, fullW) * Math.abs(framed.exx) / fullW, Math.min(cornerFixH, fullH) * Math.abs(framed.eyy) / fullH];
|
|
31339
|
+
}
|
|
31340
|
+
}
|
|
31241
31341
|
const raster = (box = framed) => roundRectRasterPath(box, cw, ch, clockwise, cornerW === 0 || cornerH === 0);
|
|
31242
31342
|
if (inPath) {
|
|
31243
31343
|
const box = framed;
|
|
@@ -31291,7 +31391,7 @@ function handleEllipse(rCtx, dataOff, recSize) {
|
|
|
31291
31391
|
const b = view.getInt32(dataOff + 12, true);
|
|
31292
31392
|
const clockwise = rCtx.state.arcDirection === 2;
|
|
31293
31393
|
const unframed = uprightFixBox(rCtx, l, t, r, b);
|
|
31294
|
-
const inset = insideFrameInset(rCtx, unframed);
|
|
31394
|
+
const inset = insideFrameInset(rCtx, unframed, false, rCtx.state.arcDirection === 2);
|
|
31295
31395
|
const framed = inset ? insetFixBox(unframed, inset) : unframed;
|
|
31296
31396
|
const params = inset ? { cx: (framed.ax + framed.exx / 2) / 16, cy: (framed.ay + framed.eyy / 2) / 16, rx: Math.abs(framed.exx) / 32, ry: Math.abs(framed.eyy) / 32, rotation: 0 } : hasWorldRotation(rCtx) ? gdiEllipseParams(rCtx, (l + r) / 2, (t + b) / 2, Math.abs(r - l) / 2, Math.abs(b - t) / 2) : {
|
|
31297
31397
|
cx: gmx(rCtx, (l + r) / 2),
|
|
@@ -31341,7 +31441,10 @@ function handleArcFamily(rCtx, recType, dataOff, recSize) {
|
|
|
31341
31441
|
const endAngle = fullEllipse ? startAngle + (clockwise ? 2 : -2) * Math.PI : Math.atan2((endY - cyA) / (ry || 1), (endX - cxA) / (rx || 1));
|
|
31342
31442
|
const rotated = hasWorldRotation(rCtx);
|
|
31343
31443
|
const unframed = fixBox(rCtx, l, t, r, b);
|
|
31344
|
-
|
|
31444
|
+
if (recType !== EMR_ARCTO && insideFramePenTooWide(rCtx, unframed)) {
|
|
31445
|
+
return true;
|
|
31446
|
+
}
|
|
31447
|
+
const inset = insideFrameInset(rCtx, unframed, false, rCtx.state.arcDirection === 2);
|
|
31345
31448
|
const framed = inset ? insetFixBox(unframed, inset) : unframed;
|
|
31346
31449
|
const params = inset ? { cx: (framed.ax + framed.exx / 2) / 16, cy: (framed.ay + framed.eyy / 2) / 16, rx: Math.abs(framed.exx) / 32, ry: Math.abs(framed.eyy) / 32, rotation: 0 } : rotated ? gdiEllipseParams(rCtx, cxA, cyA, rx, ry) : {
|
|
31347
31450
|
cx: gmx(rCtx, cxA),
|
|
@@ -31372,20 +31475,25 @@ function handleArcFamily(rCtx, recType, dataOff, recSize) {
|
|
|
31372
31475
|
}
|
|
31373
31476
|
};
|
|
31374
31477
|
const kind = isArcTo ? "arcto" : recType === EMR_PIE ? "pie" : recType === EMR_CHORD ? "chord" : "arc";
|
|
31375
|
-
const
|
|
31478
|
+
const devM = gdiDeviceMatrix(rCtx);
|
|
31479
|
+
const rawFix = (x, y) => [(devM[0] * x + devM[2] * y + devM[4]) * 16, (devM[1] * x + devM[3] * y + devM[5]) * 16];
|
|
31480
|
+
const radialOnBox = (p, raw) => {
|
|
31376
31481
|
if (!inset) {
|
|
31377
31482
|
return p;
|
|
31378
31483
|
}
|
|
31379
|
-
const
|
|
31380
|
-
const
|
|
31381
|
-
|
|
31484
|
+
const [rl, rt] = rawFix(l, t);
|
|
31485
|
+
const [rr, rb] = rawFix(r, b);
|
|
31486
|
+
const kx = rr !== rl ? framed.exx / (rr - rl) : 1;
|
|
31487
|
+
const ky = rb !== rt ? framed.eyy / (rb - rt) : 1;
|
|
31488
|
+
const snap = (v) => Math.abs(v) < 1e-6 ? 0 : v;
|
|
31489
|
+
return [framed.ax + framed.exx / 2 + snap(raw[0] - (rl + rr) / 2) * kx, framed.ay + framed.eyy / 2 + snap(raw[1] - (rt + rb) / 2) * ky];
|
|
31382
31490
|
};
|
|
31383
31491
|
const rasterArgs = (immediate = false) => ({
|
|
31384
31492
|
box: inset ? framed : immediate && needsFill ? curvedFixBox(rCtx, l, t, r, b) : unframed,
|
|
31385
|
-
s: radialOnBox(fixPoint(rCtx, startX, startY)),
|
|
31493
|
+
s: radialOnBox(fixPoint(rCtx, startX, startY), rawFix(startX, startY)),
|
|
31386
31494
|
// Device FIX rounding can separate distinct radial points on the
|
|
31387
31495
|
// same logical ray. Preserve their proven endpoint identity.
|
|
31388
|
-
e: fullEllipse ? radialOnBox(fixPoint(rCtx, startX, startY)) : radialOnBox(fixPoint(rCtx, endX, endY)),
|
|
31496
|
+
e: fullEllipse ? radialOnBox(fixPoint(rCtx, startX, startY), rawFix(startX, startY)) : radialOnBox(fixPoint(rCtx, endX, endY), rawFix(endX, endY)),
|
|
31389
31497
|
from: currentFix(rCtx)
|
|
31390
31498
|
});
|
|
31391
31499
|
if (inPath) {
|
|
@@ -39682,6 +39790,7 @@ function compatBox(p, l, t, r, b, opts = {}) {
|
|
|
39682
39790
|
if ((p.rCtx.state.penStyle & 15) === PS_INSIDEFRAME2) {
|
|
39683
39791
|
const w = Math.round(penDeviceWidth(p.rCtx) / p.kx);
|
|
39684
39792
|
if (w > 1) {
|
|
39793
|
+
const whole = { ...box };
|
|
39685
39794
|
const matrix = gdiDeviceMatrix(p.rCtx);
|
|
39686
39795
|
const wx = Math.round(Math.abs(p.rCtx.state.penWidth * matrix[0]) / p.kx * 16);
|
|
39687
39796
|
const wy = Math.round(Math.abs(p.rCtx.state.penWidth * matrix[3]) / p.ky * 16);
|
|
@@ -39695,14 +39804,21 @@ function compatBox(p, l, t, r, b, opts = {}) {
|
|
|
39695
39804
|
if (half) {
|
|
39696
39805
|
box.halfX = true;
|
|
39697
39806
|
}
|
|
39807
|
+
if (opts.clampEmpty && (box.x1 < box.x0 || box.y1 < box.y0)) {
|
|
39808
|
+
return { x0: whole.x0, y0: whole.y0, x1: whole.x1 + Math.round(ux), y1: whole.y1 + Math.round(uy) };
|
|
39809
|
+
}
|
|
39698
39810
|
}
|
|
39699
39811
|
}
|
|
39700
39812
|
return box;
|
|
39701
39813
|
}
|
|
39702
|
-
function fixBoxOf(box) {
|
|
39703
|
-
const fix = axisBox(box.x0, box.y0, Math.max(box.x0, box.x1), Math.max(box.y0, box.y1));
|
|
39814
|
+
function fixBoxOf(box, cornerExact, keepInverted = false) {
|
|
39815
|
+
const fix = keepInverted ? axisBox(box.x0, box.y0, box.x1, box.y1) : axisBox(box.x0, box.y0, Math.max(box.x0, box.x1), Math.max(box.y0, box.y1));
|
|
39704
39816
|
if (box.halfX) {
|
|
39705
39817
|
fix.halfX = true;
|
|
39818
|
+
fix.halfXCompat = true;
|
|
39819
|
+
}
|
|
39820
|
+
if (cornerExact) {
|
|
39821
|
+
fix.cornerExact = cornerExact;
|
|
39706
39822
|
}
|
|
39707
39823
|
return fix;
|
|
39708
39824
|
}
|
|
@@ -39766,7 +39882,8 @@ function compatCorner(p, w, h, box, logical) {
|
|
|
39766
39882
|
const width2 = box.x1 - box.x0, height2 = box.y1 - box.y0;
|
|
39767
39883
|
const fullW2 = Math.abs((logical[2] - logical[0]) * m[0]) * 16 || width2;
|
|
39768
39884
|
const fullH2 = Math.abs((logical[3] - logical[1]) * m[3]) * 16 || height2;
|
|
39769
|
-
|
|
39885
|
+
const cornerW = Math.min(Math.abs(w * m[0]) * 16, fullW2) * width2 / fullW2;
|
|
39886
|
+
return [Math.floor(cornerW), Math.floor(Math.min(Math.abs(h * m[3]) * 16, fullH2) * height2 / fullH2), [cornerW, Math.min(Math.abs(h * m[3]) * 16, fullH2) * height2 / fullH2]];
|
|
39770
39887
|
}
|
|
39771
39888
|
const width = box.x1 - box.x0, height = box.y1 - box.y0;
|
|
39772
39889
|
const fullW = Math.abs((logical[2] - logical[0]) * m[0]) * 16 || width + ux;
|
|
@@ -39775,11 +39892,11 @@ function compatCorner(p, w, h, box, logical) {
|
|
|
39775
39892
|
return penIsCosmetic(p.rCtx) && !penIsNull(p) ? scaled2 : [Math.floor(scaled2[0]), Math.floor(scaled2[1])];
|
|
39776
39893
|
}
|
|
39777
39894
|
function wmfRoundRect(p, l, t, r, b, w, h) {
|
|
39778
|
-
const box = compatBox(p, l, t, r, b, { curved: true, half: true });
|
|
39895
|
+
const box = compatBox(p, l, t, r, b, { curved: true, half: true, clampEmpty: true });
|
|
39779
39896
|
if (box.x1 < box.x0 || box.y1 < box.y0) {
|
|
39780
39897
|
return;
|
|
39781
39898
|
}
|
|
39782
|
-
const [cw, ch] = compatCorner(p, w, h, box, [l, t, r, b]);
|
|
39899
|
+
const [cw, ch, half] = compatCorner(p, w, h, box, [l, t, r, b]);
|
|
39783
39900
|
const cr = canvasRect(box);
|
|
39784
39901
|
paintGdiShape(p.rCtx, {
|
|
39785
39902
|
build: (c) => {
|
|
@@ -39804,14 +39921,14 @@ function wmfRoundRect(p, l, t, r, b, w, h) {
|
|
|
39804
39921
|
c.ellipse(cr.x + ex, cr.y + ey, ex, ey, 0, 2 * q, 3 * q);
|
|
39805
39922
|
c.closePath();
|
|
39806
39923
|
},
|
|
39807
|
-
raster: () => roundRectRasterPath(fixBoxOf(box), cw, ch, clockwiseOf(p), w === 0 || h === 0, !penIsNull(p) && penIsCosmetic(p.rCtx)),
|
|
39924
|
+
raster: () => roundRectRasterPath(fixBoxOf(box, half), cw, ch, clockwiseOf(p), w === 0 || h === 0, !penIsNull(p) && penIsCosmetic(p.rCtx)),
|
|
39808
39925
|
roundPen: true,
|
|
39809
39926
|
fill: true,
|
|
39810
39927
|
stroke: true
|
|
39811
39928
|
});
|
|
39812
39929
|
}
|
|
39813
39930
|
function wmfEllipse(p, l, t, r, b) {
|
|
39814
|
-
const box = compatBox(p, l, t, r, b, { curved: true, half: true });
|
|
39931
|
+
const box = compatBox(p, l, t, r, b, { curved: true, half: true, clampEmpty: true });
|
|
39815
39932
|
if (box.x1 < box.x0 || box.y1 < box.y0) {
|
|
39816
39933
|
return;
|
|
39817
39934
|
}
|
|
@@ -39827,9 +39944,9 @@ function wmfEllipse(p, l, t, r, b) {
|
|
|
39827
39944
|
stroke: true
|
|
39828
39945
|
});
|
|
39829
39946
|
}
|
|
39830
|
-
function compatArc(p, kind, l, t, r, b, xs, ys, xe, ye) {
|
|
39831
|
-
const box = compatBox(p, l, t, r, b, { curved: kind === "chord" || kind === "pie", roundFrame: true });
|
|
39832
|
-
if (box.
|
|
39947
|
+
function compatArc(p, kind, l, t, r, b, xs, ys, xe, ye, keepInverted = false) {
|
|
39948
|
+
const box = compatBox(p, l, t, r, b, { curved: kind === "chord" || kind === "pie", roundFrame: true, half: true });
|
|
39949
|
+
if (box.y1 < box.y0 || !keepInverted && box.x1 < box.x0) {
|
|
39833
39950
|
return null;
|
|
39834
39951
|
}
|
|
39835
39952
|
const m = gdiDeviceMatrix(p.rCtx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emf-converter",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.21",
|
|
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",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"docs:preview": "vitepress preview docs"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@napi-rs/canvas": "^1.0.
|
|
62
|
-
"@types/node": "^26.
|
|
61
|
+
"@napi-rs/canvas": "^1.0.10",
|
|
62
|
+
"@types/node": "^26.6.4",
|
|
63
63
|
"@types/react": "^19.3.0",
|
|
64
64
|
"@types/react-dom": "^19.3.0",
|
|
65
65
|
"@types/utif": "^3.0.6",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"typescript": "^6.0.3",
|
|
72
72
|
"utif": "3.1.0",
|
|
73
73
|
"vitepress": "^1.6.4",
|
|
74
|
-
"vitest": "^5.0.
|
|
75
|
-
"vue-tsc": "^3.3.
|
|
74
|
+
"vitest": "^5.0.3",
|
|
75
|
+
"vue-tsc": "^3.3.12"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@napi-rs/canvas": "^1.0.9"
|