emf-converter 4.8.6 → 4.8.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 +126 -31
- package/dist/browser.mjs +126 -31
- package/dist/index.js +126 -31
- package/dist/index.mjs +126 -31
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -31818,40 +31818,121 @@ function halftoneReduceTaps(srcLen, dstLen, reverse) {
|
|
|
31818
31818
|
if (reverse) taps.reverse();
|
|
31819
31819
|
return taps;
|
|
31820
31820
|
}
|
|
31821
|
-
var
|
|
31822
|
-
|
|
31823
|
-
|
|
31824
|
-
|
|
31825
|
-
|
|
31826
|
-
|
|
31827
|
-
|
|
31828
|
-
|
|
31829
|
-
|
|
31830
|
-
|
|
31831
|
-
|
|
31832
|
-
|
|
31833
|
-
|
|
31834
|
-
|
|
31835
|
-
|
|
31836
|
-
|
|
31837
|
-
|
|
31838
|
-
|
|
31839
|
-
|
|
31840
|
-
|
|
31841
|
-
|
|
31821
|
+
var ENLARGE_INNER = [
|
|
31822
|
+
1e3,
|
|
31823
|
+
992.47,
|
|
31824
|
+
984.9399,
|
|
31825
|
+
977.4099,
|
|
31826
|
+
969.8798,
|
|
31827
|
+
962.3498,
|
|
31828
|
+
954.8198,
|
|
31829
|
+
947.2897,
|
|
31830
|
+
939.7597,
|
|
31831
|
+
932.2296,
|
|
31832
|
+
924.6996,
|
|
31833
|
+
917.1695,
|
|
31834
|
+
909.6395,
|
|
31835
|
+
902.1095,
|
|
31836
|
+
894.5665,
|
|
31837
|
+
886.8087,
|
|
31838
|
+
879.045,
|
|
31839
|
+
871.2813,
|
|
31840
|
+
863.4349,
|
|
31841
|
+
855.5885,
|
|
31842
|
+
847.7421,
|
|
31843
|
+
839.8269,
|
|
31844
|
+
831.9046,
|
|
31845
|
+
823.912,
|
|
31846
|
+
815.9193,
|
|
31847
|
+
807.9266,
|
|
31848
|
+
799.847,
|
|
31849
|
+
791.7283,
|
|
31850
|
+
783.6096,
|
|
31851
|
+
775.449,
|
|
31852
|
+
767.3204,
|
|
31853
|
+
758.9233,
|
|
31854
|
+
750.5263,
|
|
31855
|
+
742.4271,
|
|
31856
|
+
734.0547,
|
|
31857
|
+
725.6823,
|
|
31858
|
+
717.232,
|
|
31859
|
+
708.7675,
|
|
31860
|
+
700.2393,
|
|
31861
|
+
691.7111,
|
|
31862
|
+
683.0734,
|
|
31863
|
+
674.4357,
|
|
31864
|
+
665.7105,
|
|
31865
|
+
656.9854,
|
|
31866
|
+
648.2603,
|
|
31867
|
+
639.3747,
|
|
31868
|
+
630.4873,
|
|
31869
|
+
621.5157,
|
|
31870
|
+
612.5442
|
|
31871
|
+
];
|
|
31872
|
+
var ENLARGE_OUTER = [
|
|
31873
|
+
375.1388,
|
|
31874
|
+
364.2093,
|
|
31875
|
+
353.2797,
|
|
31876
|
+
342.4714,
|
|
31877
|
+
331.7615,
|
|
31878
|
+
321.1462,
|
|
31879
|
+
310.6456,
|
|
31880
|
+
300.2252,
|
|
31881
|
+
289.9229,
|
|
31882
|
+
279.7227,
|
|
31883
|
+
269.6439,
|
|
31884
|
+
259.6535,
|
|
31885
|
+
249.7825,
|
|
31886
|
+
240.0362,
|
|
31887
|
+
230.3856,
|
|
31888
|
+
220.8799,
|
|
31889
|
+
211.4594,
|
|
31890
|
+
202.1844,
|
|
31891
|
+
192.9996,
|
|
31892
|
+
183.9679,
|
|
31893
|
+
175.1064,
|
|
31894
|
+
166.2864,
|
|
31895
|
+
157.6436,
|
|
31896
|
+
149.1447,
|
|
31897
|
+
140.7609,
|
|
31898
|
+
132.5474,
|
|
31899
|
+
124.4802,
|
|
31900
|
+
116.5636,
|
|
31901
|
+
108.778,
|
|
31902
|
+
101.1602,
|
|
31903
|
+
93.7098,
|
|
31904
|
+
86.4419,
|
|
31905
|
+
79.3251,
|
|
31906
|
+
72.4091,
|
|
31907
|
+
65.6853,
|
|
31908
|
+
59.1472,
|
|
31909
|
+
52.812,
|
|
31910
|
+
46.6978,
|
|
31911
|
+
40.8001,
|
|
31912
|
+
35.1449,
|
|
31913
|
+
29.7494,
|
|
31914
|
+
24.6096,
|
|
31915
|
+
19.7977,
|
|
31916
|
+
15.2801,
|
|
31917
|
+
11.1442,
|
|
31918
|
+
7.3916,
|
|
31919
|
+
4.1415,
|
|
31920
|
+
1.4039,
|
|
31842
31921
|
0
|
|
31843
31922
|
];
|
|
31844
|
-
var
|
|
31845
|
-
var
|
|
31923
|
+
var ENLARGE_HALF = 500.0106;
|
|
31924
|
+
var ENLARGE_KNOTS = 96;
|
|
31846
31925
|
function enlargeKernel(u) {
|
|
31847
|
-
|
|
31848
|
-
|
|
31849
|
-
const
|
|
31850
|
-
|
|
31926
|
+
if (u >= 1) return 0;
|
|
31927
|
+
if (Math.abs(u - 0.5) < 1e-9) return ENLARGE_HALF;
|
|
31928
|
+
const table = u < 0.5 ? ENLARGE_INNER : ENLARGE_OUTER;
|
|
31929
|
+
const edge = u * ENLARGE_KNOTS - (u < 0.5 ? 0 : ENLARGE_KNOTS / 2);
|
|
31930
|
+
const i = Math.min(table.length - 2, Math.floor(edge + 1e-9));
|
|
31931
|
+
return table[i] + (table[i + 1] - table[i]) * (edge - i);
|
|
31851
31932
|
}
|
|
31852
31933
|
function halftoneEnlargeTaps(src, dst) {
|
|
31853
31934
|
const ratio = dst / src;
|
|
31854
|
-
const reach = Math.ceil(
|
|
31935
|
+
const reach = Math.ceil(ratio) - 1;
|
|
31855
31936
|
const fir = [];
|
|
31856
31937
|
let total = 0;
|
|
31857
31938
|
for (let k = 0; k <= reach; k++) {
|
|
@@ -31880,7 +31961,17 @@ function halftoneEnlargeTaps(src, dst) {
|
|
|
31880
31961
|
weights.set(j, (weights.get(j) ?? 0) + w * v);
|
|
31881
31962
|
}
|
|
31882
31963
|
}
|
|
31883
|
-
|
|
31964
|
+
const sorted = [...weights.entries()].sort((a, b) => a[0] - b[0]);
|
|
31965
|
+
let prev = 0;
|
|
31966
|
+
let cum = 0;
|
|
31967
|
+
const row2 = [];
|
|
31968
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
31969
|
+
cum += sorted[i][1] * 8192;
|
|
31970
|
+
const c = i === sorted.length - 1 ? 8192 : Math.ceil(cum - 1e-7);
|
|
31971
|
+
row2.push([sorted[i][0], (c - prev) / 8192]);
|
|
31972
|
+
prev = c;
|
|
31973
|
+
}
|
|
31974
|
+
taps.push(row2);
|
|
31884
31975
|
}
|
|
31885
31976
|
return taps;
|
|
31886
31977
|
}
|
|
@@ -32097,8 +32188,10 @@ function stretchHalftone(src, sx, sy, sw, sh, dw, dh, adjust, adjustAfterSamplin
|
|
|
32097
32188
|
const sampleW = nativeMixed ? Math.min(SW, W) : W;
|
|
32098
32189
|
const sampleH = nativeMixed ? Math.min(SH, H) : H;
|
|
32099
32190
|
const axis = nativeMixed ? (n, d, r) => halftoneReduceTaps(n, d, r) : (n, d, r) => halftoneAxis(0, n, d, r);
|
|
32100
|
-
const
|
|
32101
|
-
const
|
|
32191
|
+
const enlargeX = nativeMixed && W > SW;
|
|
32192
|
+
const enlargeY = nativeMixed && H > SH;
|
|
32193
|
+
const cols = axis(SW, sampleW, flipX && !enlargeX);
|
|
32194
|
+
const rows = axis(SH, sampleH, flipY && !enlargeY);
|
|
32102
32195
|
if (nearestMixed) {
|
|
32103
32196
|
const nearest = (taps, src2, dst, reverse) => {
|
|
32104
32197
|
for (let i = 0; i < dst; i++) {
|
|
@@ -32207,6 +32300,8 @@ function stretchHalftone(src, sx, sy, sw, sh, dw, dh, adjust, adjustAfterSamplin
|
|
|
32207
32300
|
return halftoneEnlargeTaps(src2, dst);
|
|
32208
32301
|
};
|
|
32209
32302
|
const xt = axisTaps(sampleW, W), yt = axisTaps(sampleH, H);
|
|
32303
|
+
if (enlargeX && flipX) xt.reverse();
|
|
32304
|
+
if (enlargeY && flipY) yt.reverse();
|
|
32210
32305
|
for (let y = 0; y < H; y++) {
|
|
32211
32306
|
for (let x = 0; x < W; x++) {
|
|
32212
32307
|
for (let c = 0; c < 3; c++) {
|
package/dist/browser.mjs
CHANGED
|
@@ -31816,40 +31816,121 @@ function halftoneReduceTaps(srcLen, dstLen, reverse) {
|
|
|
31816
31816
|
if (reverse) taps.reverse();
|
|
31817
31817
|
return taps;
|
|
31818
31818
|
}
|
|
31819
|
-
var
|
|
31820
|
-
|
|
31821
|
-
|
|
31822
|
-
|
|
31823
|
-
|
|
31824
|
-
|
|
31825
|
-
|
|
31826
|
-
|
|
31827
|
-
|
|
31828
|
-
|
|
31829
|
-
|
|
31830
|
-
|
|
31831
|
-
|
|
31832
|
-
|
|
31833
|
-
|
|
31834
|
-
|
|
31835
|
-
|
|
31836
|
-
|
|
31837
|
-
|
|
31838
|
-
|
|
31839
|
-
|
|
31819
|
+
var ENLARGE_INNER = [
|
|
31820
|
+
1e3,
|
|
31821
|
+
992.47,
|
|
31822
|
+
984.9399,
|
|
31823
|
+
977.4099,
|
|
31824
|
+
969.8798,
|
|
31825
|
+
962.3498,
|
|
31826
|
+
954.8198,
|
|
31827
|
+
947.2897,
|
|
31828
|
+
939.7597,
|
|
31829
|
+
932.2296,
|
|
31830
|
+
924.6996,
|
|
31831
|
+
917.1695,
|
|
31832
|
+
909.6395,
|
|
31833
|
+
902.1095,
|
|
31834
|
+
894.5665,
|
|
31835
|
+
886.8087,
|
|
31836
|
+
879.045,
|
|
31837
|
+
871.2813,
|
|
31838
|
+
863.4349,
|
|
31839
|
+
855.5885,
|
|
31840
|
+
847.7421,
|
|
31841
|
+
839.8269,
|
|
31842
|
+
831.9046,
|
|
31843
|
+
823.912,
|
|
31844
|
+
815.9193,
|
|
31845
|
+
807.9266,
|
|
31846
|
+
799.847,
|
|
31847
|
+
791.7283,
|
|
31848
|
+
783.6096,
|
|
31849
|
+
775.449,
|
|
31850
|
+
767.3204,
|
|
31851
|
+
758.9233,
|
|
31852
|
+
750.5263,
|
|
31853
|
+
742.4271,
|
|
31854
|
+
734.0547,
|
|
31855
|
+
725.6823,
|
|
31856
|
+
717.232,
|
|
31857
|
+
708.7675,
|
|
31858
|
+
700.2393,
|
|
31859
|
+
691.7111,
|
|
31860
|
+
683.0734,
|
|
31861
|
+
674.4357,
|
|
31862
|
+
665.7105,
|
|
31863
|
+
656.9854,
|
|
31864
|
+
648.2603,
|
|
31865
|
+
639.3747,
|
|
31866
|
+
630.4873,
|
|
31867
|
+
621.5157,
|
|
31868
|
+
612.5442
|
|
31869
|
+
];
|
|
31870
|
+
var ENLARGE_OUTER = [
|
|
31871
|
+
375.1388,
|
|
31872
|
+
364.2093,
|
|
31873
|
+
353.2797,
|
|
31874
|
+
342.4714,
|
|
31875
|
+
331.7615,
|
|
31876
|
+
321.1462,
|
|
31877
|
+
310.6456,
|
|
31878
|
+
300.2252,
|
|
31879
|
+
289.9229,
|
|
31880
|
+
279.7227,
|
|
31881
|
+
269.6439,
|
|
31882
|
+
259.6535,
|
|
31883
|
+
249.7825,
|
|
31884
|
+
240.0362,
|
|
31885
|
+
230.3856,
|
|
31886
|
+
220.8799,
|
|
31887
|
+
211.4594,
|
|
31888
|
+
202.1844,
|
|
31889
|
+
192.9996,
|
|
31890
|
+
183.9679,
|
|
31891
|
+
175.1064,
|
|
31892
|
+
166.2864,
|
|
31893
|
+
157.6436,
|
|
31894
|
+
149.1447,
|
|
31895
|
+
140.7609,
|
|
31896
|
+
132.5474,
|
|
31897
|
+
124.4802,
|
|
31898
|
+
116.5636,
|
|
31899
|
+
108.778,
|
|
31900
|
+
101.1602,
|
|
31901
|
+
93.7098,
|
|
31902
|
+
86.4419,
|
|
31903
|
+
79.3251,
|
|
31904
|
+
72.4091,
|
|
31905
|
+
65.6853,
|
|
31906
|
+
59.1472,
|
|
31907
|
+
52.812,
|
|
31908
|
+
46.6978,
|
|
31909
|
+
40.8001,
|
|
31910
|
+
35.1449,
|
|
31911
|
+
29.7494,
|
|
31912
|
+
24.6096,
|
|
31913
|
+
19.7977,
|
|
31914
|
+
15.2801,
|
|
31915
|
+
11.1442,
|
|
31916
|
+
7.3916,
|
|
31917
|
+
4.1415,
|
|
31918
|
+
1.4039,
|
|
31840
31919
|
0
|
|
31841
31920
|
];
|
|
31842
|
-
var
|
|
31843
|
-
var
|
|
31921
|
+
var ENLARGE_HALF = 500.0106;
|
|
31922
|
+
var ENLARGE_KNOTS = 96;
|
|
31844
31923
|
function enlargeKernel(u) {
|
|
31845
|
-
|
|
31846
|
-
|
|
31847
|
-
const
|
|
31848
|
-
|
|
31924
|
+
if (u >= 1) return 0;
|
|
31925
|
+
if (Math.abs(u - 0.5) < 1e-9) return ENLARGE_HALF;
|
|
31926
|
+
const table = u < 0.5 ? ENLARGE_INNER : ENLARGE_OUTER;
|
|
31927
|
+
const edge = u * ENLARGE_KNOTS - (u < 0.5 ? 0 : ENLARGE_KNOTS / 2);
|
|
31928
|
+
const i = Math.min(table.length - 2, Math.floor(edge + 1e-9));
|
|
31929
|
+
return table[i] + (table[i + 1] - table[i]) * (edge - i);
|
|
31849
31930
|
}
|
|
31850
31931
|
function halftoneEnlargeTaps(src, dst) {
|
|
31851
31932
|
const ratio = dst / src;
|
|
31852
|
-
const reach = Math.ceil(
|
|
31933
|
+
const reach = Math.ceil(ratio) - 1;
|
|
31853
31934
|
const fir = [];
|
|
31854
31935
|
let total = 0;
|
|
31855
31936
|
for (let k = 0; k <= reach; k++) {
|
|
@@ -31878,7 +31959,17 @@ function halftoneEnlargeTaps(src, dst) {
|
|
|
31878
31959
|
weights.set(j, (weights.get(j) ?? 0) + w * v);
|
|
31879
31960
|
}
|
|
31880
31961
|
}
|
|
31881
|
-
|
|
31962
|
+
const sorted = [...weights.entries()].sort((a, b) => a[0] - b[0]);
|
|
31963
|
+
let prev = 0;
|
|
31964
|
+
let cum = 0;
|
|
31965
|
+
const row2 = [];
|
|
31966
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
31967
|
+
cum += sorted[i][1] * 8192;
|
|
31968
|
+
const c = i === sorted.length - 1 ? 8192 : Math.ceil(cum - 1e-7);
|
|
31969
|
+
row2.push([sorted[i][0], (c - prev) / 8192]);
|
|
31970
|
+
prev = c;
|
|
31971
|
+
}
|
|
31972
|
+
taps.push(row2);
|
|
31882
31973
|
}
|
|
31883
31974
|
return taps;
|
|
31884
31975
|
}
|
|
@@ -32095,8 +32186,10 @@ function stretchHalftone(src, sx, sy, sw, sh, dw, dh, adjust, adjustAfterSamplin
|
|
|
32095
32186
|
const sampleW = nativeMixed ? Math.min(SW, W) : W;
|
|
32096
32187
|
const sampleH = nativeMixed ? Math.min(SH, H) : H;
|
|
32097
32188
|
const axis = nativeMixed ? (n, d, r) => halftoneReduceTaps(n, d, r) : (n, d, r) => halftoneAxis(0, n, d, r);
|
|
32098
|
-
const
|
|
32099
|
-
const
|
|
32189
|
+
const enlargeX = nativeMixed && W > SW;
|
|
32190
|
+
const enlargeY = nativeMixed && H > SH;
|
|
32191
|
+
const cols = axis(SW, sampleW, flipX && !enlargeX);
|
|
32192
|
+
const rows = axis(SH, sampleH, flipY && !enlargeY);
|
|
32100
32193
|
if (nearestMixed) {
|
|
32101
32194
|
const nearest = (taps, src2, dst, reverse) => {
|
|
32102
32195
|
for (let i = 0; i < dst; i++) {
|
|
@@ -32205,6 +32298,8 @@ function stretchHalftone(src, sx, sy, sw, sh, dw, dh, adjust, adjustAfterSamplin
|
|
|
32205
32298
|
return halftoneEnlargeTaps(src2, dst);
|
|
32206
32299
|
};
|
|
32207
32300
|
const xt = axisTaps(sampleW, W), yt = axisTaps(sampleH, H);
|
|
32301
|
+
if (enlargeX && flipX) xt.reverse();
|
|
32302
|
+
if (enlargeY && flipY) yt.reverse();
|
|
32208
32303
|
for (let y = 0; y < H; y++) {
|
|
32209
32304
|
for (let x = 0; x < W; x++) {
|
|
32210
32305
|
for (let c = 0; c < 3; c++) {
|
package/dist/index.js
CHANGED
|
@@ -31819,40 +31819,121 @@ function halftoneReduceTaps(srcLen, dstLen, reverse) {
|
|
|
31819
31819
|
if (reverse) taps.reverse();
|
|
31820
31820
|
return taps;
|
|
31821
31821
|
}
|
|
31822
|
-
var
|
|
31823
|
-
|
|
31824
|
-
|
|
31825
|
-
|
|
31826
|
-
|
|
31827
|
-
|
|
31828
|
-
|
|
31829
|
-
|
|
31830
|
-
|
|
31831
|
-
|
|
31832
|
-
|
|
31833
|
-
|
|
31834
|
-
|
|
31835
|
-
|
|
31836
|
-
|
|
31837
|
-
|
|
31838
|
-
|
|
31839
|
-
|
|
31840
|
-
|
|
31841
|
-
|
|
31842
|
-
|
|
31822
|
+
var ENLARGE_INNER = [
|
|
31823
|
+
1e3,
|
|
31824
|
+
992.47,
|
|
31825
|
+
984.9399,
|
|
31826
|
+
977.4099,
|
|
31827
|
+
969.8798,
|
|
31828
|
+
962.3498,
|
|
31829
|
+
954.8198,
|
|
31830
|
+
947.2897,
|
|
31831
|
+
939.7597,
|
|
31832
|
+
932.2296,
|
|
31833
|
+
924.6996,
|
|
31834
|
+
917.1695,
|
|
31835
|
+
909.6395,
|
|
31836
|
+
902.1095,
|
|
31837
|
+
894.5665,
|
|
31838
|
+
886.8087,
|
|
31839
|
+
879.045,
|
|
31840
|
+
871.2813,
|
|
31841
|
+
863.4349,
|
|
31842
|
+
855.5885,
|
|
31843
|
+
847.7421,
|
|
31844
|
+
839.8269,
|
|
31845
|
+
831.9046,
|
|
31846
|
+
823.912,
|
|
31847
|
+
815.9193,
|
|
31848
|
+
807.9266,
|
|
31849
|
+
799.847,
|
|
31850
|
+
791.7283,
|
|
31851
|
+
783.6096,
|
|
31852
|
+
775.449,
|
|
31853
|
+
767.3204,
|
|
31854
|
+
758.9233,
|
|
31855
|
+
750.5263,
|
|
31856
|
+
742.4271,
|
|
31857
|
+
734.0547,
|
|
31858
|
+
725.6823,
|
|
31859
|
+
717.232,
|
|
31860
|
+
708.7675,
|
|
31861
|
+
700.2393,
|
|
31862
|
+
691.7111,
|
|
31863
|
+
683.0734,
|
|
31864
|
+
674.4357,
|
|
31865
|
+
665.7105,
|
|
31866
|
+
656.9854,
|
|
31867
|
+
648.2603,
|
|
31868
|
+
639.3747,
|
|
31869
|
+
630.4873,
|
|
31870
|
+
621.5157,
|
|
31871
|
+
612.5442
|
|
31872
|
+
];
|
|
31873
|
+
var ENLARGE_OUTER = [
|
|
31874
|
+
375.1388,
|
|
31875
|
+
364.2093,
|
|
31876
|
+
353.2797,
|
|
31877
|
+
342.4714,
|
|
31878
|
+
331.7615,
|
|
31879
|
+
321.1462,
|
|
31880
|
+
310.6456,
|
|
31881
|
+
300.2252,
|
|
31882
|
+
289.9229,
|
|
31883
|
+
279.7227,
|
|
31884
|
+
269.6439,
|
|
31885
|
+
259.6535,
|
|
31886
|
+
249.7825,
|
|
31887
|
+
240.0362,
|
|
31888
|
+
230.3856,
|
|
31889
|
+
220.8799,
|
|
31890
|
+
211.4594,
|
|
31891
|
+
202.1844,
|
|
31892
|
+
192.9996,
|
|
31893
|
+
183.9679,
|
|
31894
|
+
175.1064,
|
|
31895
|
+
166.2864,
|
|
31896
|
+
157.6436,
|
|
31897
|
+
149.1447,
|
|
31898
|
+
140.7609,
|
|
31899
|
+
132.5474,
|
|
31900
|
+
124.4802,
|
|
31901
|
+
116.5636,
|
|
31902
|
+
108.778,
|
|
31903
|
+
101.1602,
|
|
31904
|
+
93.7098,
|
|
31905
|
+
86.4419,
|
|
31906
|
+
79.3251,
|
|
31907
|
+
72.4091,
|
|
31908
|
+
65.6853,
|
|
31909
|
+
59.1472,
|
|
31910
|
+
52.812,
|
|
31911
|
+
46.6978,
|
|
31912
|
+
40.8001,
|
|
31913
|
+
35.1449,
|
|
31914
|
+
29.7494,
|
|
31915
|
+
24.6096,
|
|
31916
|
+
19.7977,
|
|
31917
|
+
15.2801,
|
|
31918
|
+
11.1442,
|
|
31919
|
+
7.3916,
|
|
31920
|
+
4.1415,
|
|
31921
|
+
1.4039,
|
|
31843
31922
|
0
|
|
31844
31923
|
];
|
|
31845
|
-
var
|
|
31846
|
-
var
|
|
31924
|
+
var ENLARGE_HALF = 500.0106;
|
|
31925
|
+
var ENLARGE_KNOTS = 96;
|
|
31847
31926
|
function enlargeKernel(u) {
|
|
31848
|
-
|
|
31849
|
-
|
|
31850
|
-
const
|
|
31851
|
-
|
|
31927
|
+
if (u >= 1) return 0;
|
|
31928
|
+
if (Math.abs(u - 0.5) < 1e-9) return ENLARGE_HALF;
|
|
31929
|
+
const table = u < 0.5 ? ENLARGE_INNER : ENLARGE_OUTER;
|
|
31930
|
+
const edge = u * ENLARGE_KNOTS - (u < 0.5 ? 0 : ENLARGE_KNOTS / 2);
|
|
31931
|
+
const i = Math.min(table.length - 2, Math.floor(edge + 1e-9));
|
|
31932
|
+
return table[i] + (table[i + 1] - table[i]) * (edge - i);
|
|
31852
31933
|
}
|
|
31853
31934
|
function halftoneEnlargeTaps(src, dst) {
|
|
31854
31935
|
const ratio = dst / src;
|
|
31855
|
-
const reach = Math.ceil(
|
|
31936
|
+
const reach = Math.ceil(ratio) - 1;
|
|
31856
31937
|
const fir = [];
|
|
31857
31938
|
let total = 0;
|
|
31858
31939
|
for (let k = 0; k <= reach; k++) {
|
|
@@ -31881,7 +31962,17 @@ function halftoneEnlargeTaps(src, dst) {
|
|
|
31881
31962
|
weights.set(j, (weights.get(j) ?? 0) + w * v);
|
|
31882
31963
|
}
|
|
31883
31964
|
}
|
|
31884
|
-
|
|
31965
|
+
const sorted = [...weights.entries()].sort((a, b) => a[0] - b[0]);
|
|
31966
|
+
let prev = 0;
|
|
31967
|
+
let cum = 0;
|
|
31968
|
+
const row2 = [];
|
|
31969
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
31970
|
+
cum += sorted[i][1] * 8192;
|
|
31971
|
+
const c = i === sorted.length - 1 ? 8192 : Math.ceil(cum - 1e-7);
|
|
31972
|
+
row2.push([sorted[i][0], (c - prev) / 8192]);
|
|
31973
|
+
prev = c;
|
|
31974
|
+
}
|
|
31975
|
+
taps.push(row2);
|
|
31885
31976
|
}
|
|
31886
31977
|
return taps;
|
|
31887
31978
|
}
|
|
@@ -32098,8 +32189,10 @@ function stretchHalftone(src, sx, sy, sw, sh, dw, dh, adjust, adjustAfterSamplin
|
|
|
32098
32189
|
const sampleW = nativeMixed ? Math.min(SW, W) : W;
|
|
32099
32190
|
const sampleH = nativeMixed ? Math.min(SH, H) : H;
|
|
32100
32191
|
const axis = nativeMixed ? (n, d, r) => halftoneReduceTaps(n, d, r) : (n, d, r) => halftoneAxis(0, n, d, r);
|
|
32101
|
-
const
|
|
32102
|
-
const
|
|
32192
|
+
const enlargeX = nativeMixed && W > SW;
|
|
32193
|
+
const enlargeY = nativeMixed && H > SH;
|
|
32194
|
+
const cols = axis(SW, sampleW, flipX && !enlargeX);
|
|
32195
|
+
const rows = axis(SH, sampleH, flipY && !enlargeY);
|
|
32103
32196
|
if (nearestMixed) {
|
|
32104
32197
|
const nearest = (taps, src2, dst, reverse) => {
|
|
32105
32198
|
for (let i = 0; i < dst; i++) {
|
|
@@ -32208,6 +32301,8 @@ function stretchHalftone(src, sx, sy, sw, sh, dw, dh, adjust, adjustAfterSamplin
|
|
|
32208
32301
|
return halftoneEnlargeTaps(src2, dst);
|
|
32209
32302
|
};
|
|
32210
32303
|
const xt = axisTaps(sampleW, W), yt = axisTaps(sampleH, H);
|
|
32304
|
+
if (enlargeX && flipX) xt.reverse();
|
|
32305
|
+
if (enlargeY && flipY) yt.reverse();
|
|
32211
32306
|
for (let y = 0; y < H; y++) {
|
|
32212
32307
|
for (let x = 0; x < W; x++) {
|
|
32213
32308
|
for (let c = 0; c < 3; c++) {
|
package/dist/index.mjs
CHANGED
|
@@ -31817,40 +31817,121 @@ function halftoneReduceTaps(srcLen, dstLen, reverse) {
|
|
|
31817
31817
|
if (reverse) taps.reverse();
|
|
31818
31818
|
return taps;
|
|
31819
31819
|
}
|
|
31820
|
-
var
|
|
31821
|
-
|
|
31822
|
-
|
|
31823
|
-
|
|
31824
|
-
|
|
31825
|
-
|
|
31826
|
-
|
|
31827
|
-
|
|
31828
|
-
|
|
31829
|
-
|
|
31830
|
-
|
|
31831
|
-
|
|
31832
|
-
|
|
31833
|
-
|
|
31834
|
-
|
|
31835
|
-
|
|
31836
|
-
|
|
31837
|
-
|
|
31838
|
-
|
|
31839
|
-
|
|
31840
|
-
|
|
31820
|
+
var ENLARGE_INNER = [
|
|
31821
|
+
1e3,
|
|
31822
|
+
992.47,
|
|
31823
|
+
984.9399,
|
|
31824
|
+
977.4099,
|
|
31825
|
+
969.8798,
|
|
31826
|
+
962.3498,
|
|
31827
|
+
954.8198,
|
|
31828
|
+
947.2897,
|
|
31829
|
+
939.7597,
|
|
31830
|
+
932.2296,
|
|
31831
|
+
924.6996,
|
|
31832
|
+
917.1695,
|
|
31833
|
+
909.6395,
|
|
31834
|
+
902.1095,
|
|
31835
|
+
894.5665,
|
|
31836
|
+
886.8087,
|
|
31837
|
+
879.045,
|
|
31838
|
+
871.2813,
|
|
31839
|
+
863.4349,
|
|
31840
|
+
855.5885,
|
|
31841
|
+
847.7421,
|
|
31842
|
+
839.8269,
|
|
31843
|
+
831.9046,
|
|
31844
|
+
823.912,
|
|
31845
|
+
815.9193,
|
|
31846
|
+
807.9266,
|
|
31847
|
+
799.847,
|
|
31848
|
+
791.7283,
|
|
31849
|
+
783.6096,
|
|
31850
|
+
775.449,
|
|
31851
|
+
767.3204,
|
|
31852
|
+
758.9233,
|
|
31853
|
+
750.5263,
|
|
31854
|
+
742.4271,
|
|
31855
|
+
734.0547,
|
|
31856
|
+
725.6823,
|
|
31857
|
+
717.232,
|
|
31858
|
+
708.7675,
|
|
31859
|
+
700.2393,
|
|
31860
|
+
691.7111,
|
|
31861
|
+
683.0734,
|
|
31862
|
+
674.4357,
|
|
31863
|
+
665.7105,
|
|
31864
|
+
656.9854,
|
|
31865
|
+
648.2603,
|
|
31866
|
+
639.3747,
|
|
31867
|
+
630.4873,
|
|
31868
|
+
621.5157,
|
|
31869
|
+
612.5442
|
|
31870
|
+
];
|
|
31871
|
+
var ENLARGE_OUTER = [
|
|
31872
|
+
375.1388,
|
|
31873
|
+
364.2093,
|
|
31874
|
+
353.2797,
|
|
31875
|
+
342.4714,
|
|
31876
|
+
331.7615,
|
|
31877
|
+
321.1462,
|
|
31878
|
+
310.6456,
|
|
31879
|
+
300.2252,
|
|
31880
|
+
289.9229,
|
|
31881
|
+
279.7227,
|
|
31882
|
+
269.6439,
|
|
31883
|
+
259.6535,
|
|
31884
|
+
249.7825,
|
|
31885
|
+
240.0362,
|
|
31886
|
+
230.3856,
|
|
31887
|
+
220.8799,
|
|
31888
|
+
211.4594,
|
|
31889
|
+
202.1844,
|
|
31890
|
+
192.9996,
|
|
31891
|
+
183.9679,
|
|
31892
|
+
175.1064,
|
|
31893
|
+
166.2864,
|
|
31894
|
+
157.6436,
|
|
31895
|
+
149.1447,
|
|
31896
|
+
140.7609,
|
|
31897
|
+
132.5474,
|
|
31898
|
+
124.4802,
|
|
31899
|
+
116.5636,
|
|
31900
|
+
108.778,
|
|
31901
|
+
101.1602,
|
|
31902
|
+
93.7098,
|
|
31903
|
+
86.4419,
|
|
31904
|
+
79.3251,
|
|
31905
|
+
72.4091,
|
|
31906
|
+
65.6853,
|
|
31907
|
+
59.1472,
|
|
31908
|
+
52.812,
|
|
31909
|
+
46.6978,
|
|
31910
|
+
40.8001,
|
|
31911
|
+
35.1449,
|
|
31912
|
+
29.7494,
|
|
31913
|
+
24.6096,
|
|
31914
|
+
19.7977,
|
|
31915
|
+
15.2801,
|
|
31916
|
+
11.1442,
|
|
31917
|
+
7.3916,
|
|
31918
|
+
4.1415,
|
|
31919
|
+
1.4039,
|
|
31841
31920
|
0
|
|
31842
31921
|
];
|
|
31843
|
-
var
|
|
31844
|
-
var
|
|
31922
|
+
var ENLARGE_HALF = 500.0106;
|
|
31923
|
+
var ENLARGE_KNOTS = 96;
|
|
31845
31924
|
function enlargeKernel(u) {
|
|
31846
|
-
|
|
31847
|
-
|
|
31848
|
-
const
|
|
31849
|
-
|
|
31925
|
+
if (u >= 1) return 0;
|
|
31926
|
+
if (Math.abs(u - 0.5) < 1e-9) return ENLARGE_HALF;
|
|
31927
|
+
const table = u < 0.5 ? ENLARGE_INNER : ENLARGE_OUTER;
|
|
31928
|
+
const edge = u * ENLARGE_KNOTS - (u < 0.5 ? 0 : ENLARGE_KNOTS / 2);
|
|
31929
|
+
const i = Math.min(table.length - 2, Math.floor(edge + 1e-9));
|
|
31930
|
+
return table[i] + (table[i + 1] - table[i]) * (edge - i);
|
|
31850
31931
|
}
|
|
31851
31932
|
function halftoneEnlargeTaps(src, dst) {
|
|
31852
31933
|
const ratio = dst / src;
|
|
31853
|
-
const reach = Math.ceil(
|
|
31934
|
+
const reach = Math.ceil(ratio) - 1;
|
|
31854
31935
|
const fir = [];
|
|
31855
31936
|
let total = 0;
|
|
31856
31937
|
for (let k = 0; k <= reach; k++) {
|
|
@@ -31879,7 +31960,17 @@ function halftoneEnlargeTaps(src, dst) {
|
|
|
31879
31960
|
weights.set(j, (weights.get(j) ?? 0) + w * v);
|
|
31880
31961
|
}
|
|
31881
31962
|
}
|
|
31882
|
-
|
|
31963
|
+
const sorted = [...weights.entries()].sort((a, b) => a[0] - b[0]);
|
|
31964
|
+
let prev = 0;
|
|
31965
|
+
let cum = 0;
|
|
31966
|
+
const row2 = [];
|
|
31967
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
31968
|
+
cum += sorted[i][1] * 8192;
|
|
31969
|
+
const c = i === sorted.length - 1 ? 8192 : Math.ceil(cum - 1e-7);
|
|
31970
|
+
row2.push([sorted[i][0], (c - prev) / 8192]);
|
|
31971
|
+
prev = c;
|
|
31972
|
+
}
|
|
31973
|
+
taps.push(row2);
|
|
31883
31974
|
}
|
|
31884
31975
|
return taps;
|
|
31885
31976
|
}
|
|
@@ -32096,8 +32187,10 @@ function stretchHalftone(src, sx, sy, sw, sh, dw, dh, adjust, adjustAfterSamplin
|
|
|
32096
32187
|
const sampleW = nativeMixed ? Math.min(SW, W) : W;
|
|
32097
32188
|
const sampleH = nativeMixed ? Math.min(SH, H) : H;
|
|
32098
32189
|
const axis = nativeMixed ? (n, d, r) => halftoneReduceTaps(n, d, r) : (n, d, r) => halftoneAxis(0, n, d, r);
|
|
32099
|
-
const
|
|
32100
|
-
const
|
|
32190
|
+
const enlargeX = nativeMixed && W > SW;
|
|
32191
|
+
const enlargeY = nativeMixed && H > SH;
|
|
32192
|
+
const cols = axis(SW, sampleW, flipX && !enlargeX);
|
|
32193
|
+
const rows = axis(SH, sampleH, flipY && !enlargeY);
|
|
32101
32194
|
if (nearestMixed) {
|
|
32102
32195
|
const nearest = (taps, src2, dst, reverse) => {
|
|
32103
32196
|
for (let i = 0; i < dst; i++) {
|
|
@@ -32206,6 +32299,8 @@ function stretchHalftone(src, sx, sy, sw, sh, dw, dh, adjust, adjustAfterSamplin
|
|
|
32206
32299
|
return halftoneEnlargeTaps(src2, dst);
|
|
32207
32300
|
};
|
|
32208
32301
|
const xt = axisTaps(sampleW, W), yt = axisTaps(sampleH, H);
|
|
32302
|
+
if (enlargeX && flipX) xt.reverse();
|
|
32303
|
+
if (enlargeY && flipY) yt.reverse();
|
|
32209
32304
|
for (let y = 0; y < H; y++) {
|
|
32210
32305
|
for (let x = 0; x < W; x++) {
|
|
32211
32306
|
for (let c = 0; c < 3; c++) {
|