emf-converter 4.8.17 → 4.8.19
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 +33 -9
- package/dist/browser.mjs +33 -9
- package/dist/index.js +33 -9
- package/dist/index.mjs +33 -9
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -15872,6 +15872,19 @@ function lerpArgb(a, b, t) {
|
|
|
15872
15872
|
};
|
|
15873
15873
|
return (ch(24) << 24 | ch(16) << 16 | ch(8) << 8 | ch(0)) >>> 0;
|
|
15874
15874
|
}
|
|
15875
|
+
function lerpUniformPathArgb(a, b, t) {
|
|
15876
|
+
const aa = a >>> 24 & 255;
|
|
15877
|
+
const ab = b >>> 24 & 255;
|
|
15878
|
+
if (aa === ab) return lerpArgb(a, b, t);
|
|
15879
|
+
const alpha = Math.round(aa + (ab - aa) * t);
|
|
15880
|
+
if (alpha === 0) return 0;
|
|
15881
|
+
const ch = (shift) => {
|
|
15882
|
+
const ca = (a >>> shift & 255) * aa / 255;
|
|
15883
|
+
const cb = (b >>> shift & 255) * ab / 255;
|
|
15884
|
+
return Math.min(255, Math.max(0, Math.round((ca + (cb - ca) * t) * 255 / alpha)));
|
|
15885
|
+
};
|
|
15886
|
+
return (alpha << 24 | ch(16) << 16 | ch(8) << 8 | ch(0)) >>> 0;
|
|
15887
|
+
}
|
|
15875
15888
|
function piecewise2(xs, ys, x) {
|
|
15876
15889
|
const n = Math.min(xs.length, ys.length);
|
|
15877
15890
|
if (n === 0) {
|
|
@@ -15977,10 +15990,10 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
15977
15990
|
let hits = 0;
|
|
15978
15991
|
let hitT = 0;
|
|
15979
15992
|
let hitU = 0;
|
|
15980
|
-
for (const
|
|
15981
|
-
if (
|
|
15982
|
-
const sx = fx + dx *
|
|
15983
|
-
const sy = fy + dy *
|
|
15993
|
+
for (const t2 of roots) {
|
|
15994
|
+
if (t2 < -eps || t2 > 1 + eps) continue;
|
|
15995
|
+
const sx = fx + dx * t2;
|
|
15996
|
+
const sy = fy + dy * t2;
|
|
15984
15997
|
if (sy === 0 && sx > 0 && Math.abs(py) < eps && ey > 0 && Math.max(ay, ay + ey) > 0 && Math.abs(ex) > eps) {
|
|
15985
15998
|
const u2 = (px / sx - ax) / ex;
|
|
15986
15999
|
if (u2 >= -eps && u2 <= 1 + eps) {
|
|
@@ -15994,7 +16007,7 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
15994
16007
|
const u = Math.abs(ex) > Math.abs(ey) ? (px / sx - ax) / ex : (py / sy - ay) / ey;
|
|
15995
16008
|
if (u >= -eps && u <= 1 + eps) {
|
|
15996
16009
|
hits++;
|
|
15997
|
-
hitT = Math.max(0,
|
|
16010
|
+
hitT = Math.max(0, t2);
|
|
15998
16011
|
hitU = Math.min(1, Math.max(0, u));
|
|
15999
16012
|
}
|
|
16000
16013
|
}
|
|
@@ -16026,7 +16039,8 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
16026
16039
|
const c1 = boundaryArgb[(found + 1) % n] ?? c0;
|
|
16027
16040
|
const surround = lerpArgb(c0, c1, bestU);
|
|
16028
16041
|
const factor = shape.blend ? piecewise2(shape.blend.positions, shape.blend.factors, pos) : pos;
|
|
16029
|
-
|
|
16042
|
+
const t = Math.min(1, Math.max(0, factor));
|
|
16043
|
+
return surround >>> 24 !== shape.centerArgb >>> 24 && boundaryArgb.every((color) => color === boundaryArgb[0]) ? lerpUniformPathArgb(surround, shape.centerArgb, t) : lerpArgb(surround, shape.centerArgb, t);
|
|
16030
16044
|
}
|
|
16031
16045
|
var MAX_TILE = 2048;
|
|
16032
16046
|
function mirrorFlags(wrap) {
|
|
@@ -20534,6 +20548,7 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20534
20548
|
const hq = kernel === "hq-bilinear" || kernel === "hq-bicubic";
|
|
20535
20549
|
const axisAligned = m[1] === 0 && m[2] === 0;
|
|
20536
20550
|
const integerBicubic = kernel === "bicubic" && axisAligned;
|
|
20551
|
+
const unitBicubicCopy = integerBicubic && !spec.halfPixelOffset && m[0] === 1 && m[3] === 1 && m[4] - Math.round(m[4]) > -1 / 64 && m[4] - Math.round(m[4]) <= 1 / 64 && m[5] - Math.round(m[5]) > -1 / 64 && m[5] - Math.round(m[5]) <= 1 / 64;
|
|
20537
20552
|
let farFade = false;
|
|
20538
20553
|
let shiftX = 0;
|
|
20539
20554
|
let shiftY = 0;
|
|
@@ -20598,8 +20613,9 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20598
20613
|
const integral = (v) => Math.abs(v - Math.round(v)) < 1e-9;
|
|
20599
20614
|
const copyU = axisAligned && Math.abs(scaleU - 1) < 1e-9 && integral(m[4]);
|
|
20600
20615
|
const copyV = axisAligned && Math.abs(scaleV - 1) < 1e-9 && integral(m[5]);
|
|
20601
|
-
const
|
|
20602
|
-
const
|
|
20616
|
+
const copy = copyU && copyV;
|
|
20617
|
+
const fu = axisFilter(kernel, scaleU, copy);
|
|
20618
|
+
const fv = axisFilter(kernel, scaleV, copy);
|
|
20603
20619
|
const out = new Uint8ClampedArray(w * h * 4);
|
|
20604
20620
|
const o = spec.halfPixelOffset ? 0.5 : 0;
|
|
20605
20621
|
const uMax = spec.srcX + spec.srcW;
|
|
@@ -20641,6 +20657,10 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20641
20657
|
}
|
|
20642
20658
|
u = Math.floor((su + (i - start) * bicubicDu) / (FIX16 / 64)) / 64;
|
|
20643
20659
|
v = Math.floor((sv + (i - start) * bicubicDv) / (FIX16 / 64)) / 64;
|
|
20660
|
+
if (unitBicubicCopy) {
|
|
20661
|
+
u = Math.round(u);
|
|
20662
|
+
v = Math.round(v);
|
|
20663
|
+
}
|
|
20644
20664
|
}
|
|
20645
20665
|
const box = { x0: 0, y0: 0, x1: width, y1: height };
|
|
20646
20666
|
const sampleAt = (cu, cv) => {
|
|
@@ -25188,7 +25208,7 @@ var HintedSize = class _HintedSize {
|
|
|
25188
25208
|
case 11: {
|
|
25189
25209
|
const y = this.pop() << 16 >> 16;
|
|
25190
25210
|
const x = this.pop() << 16 >> 16;
|
|
25191
|
-
const
|
|
25211
|
+
const vx = x, vy = y;
|
|
25192
25212
|
if (op === 10) {
|
|
25193
25213
|
gs.pvx = gs.dvx = vx;
|
|
25194
25214
|
gs.pvy = gs.dvy = vy;
|
|
@@ -32527,6 +32547,7 @@ function drawSourceMapped(target, decoded, req, offsetX, offsetY, mode, brushOrg
|
|
|
32527
32547
|
}
|
|
32528
32548
|
canvasPutImageData(tile.ctx, createImageDataCompat(px.data, px.width, px.height), 0, 0);
|
|
32529
32549
|
target.save();
|
|
32550
|
+
target.setTransform(1, 0, 0, 1, 0, 0);
|
|
32530
32551
|
target.globalCompositeOperation = "source-over";
|
|
32531
32552
|
canvasDrawImage(target, tile.canvas, Math.round(dLeft), Math.round(dTop), px.width, px.height);
|
|
32532
32553
|
target.restore();
|
|
@@ -32566,9 +32587,12 @@ function decodeSource(rCtx, req, rotated = false) {
|
|
|
32566
32587
|
function fillRectWith(ctx, style, gco, req) {
|
|
32567
32588
|
const prevGco = ctx.globalCompositeOperation;
|
|
32568
32589
|
const prevFill = ctx.fillStyle;
|
|
32590
|
+
ctx.save();
|
|
32591
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
32569
32592
|
ctx.globalCompositeOperation = gco;
|
|
32570
32593
|
ctx.fillStyle = style;
|
|
32571
32594
|
ctx.fillRect(req.dx, req.dy, req.dw, req.dh);
|
|
32595
|
+
ctx.restore();
|
|
32572
32596
|
ctx.globalCompositeOperation = prevGco;
|
|
32573
32597
|
ctx.fillStyle = prevFill;
|
|
32574
32598
|
}
|
package/dist/browser.mjs
CHANGED
|
@@ -15870,6 +15870,19 @@ function lerpArgb(a, b, t) {
|
|
|
15870
15870
|
};
|
|
15871
15871
|
return (ch(24) << 24 | ch(16) << 16 | ch(8) << 8 | ch(0)) >>> 0;
|
|
15872
15872
|
}
|
|
15873
|
+
function lerpUniformPathArgb(a, b, t) {
|
|
15874
|
+
const aa = a >>> 24 & 255;
|
|
15875
|
+
const ab = b >>> 24 & 255;
|
|
15876
|
+
if (aa === ab) return lerpArgb(a, b, t);
|
|
15877
|
+
const alpha = Math.round(aa + (ab - aa) * t);
|
|
15878
|
+
if (alpha === 0) return 0;
|
|
15879
|
+
const ch = (shift) => {
|
|
15880
|
+
const ca = (a >>> shift & 255) * aa / 255;
|
|
15881
|
+
const cb = (b >>> shift & 255) * ab / 255;
|
|
15882
|
+
return Math.min(255, Math.max(0, Math.round((ca + (cb - ca) * t) * 255 / alpha)));
|
|
15883
|
+
};
|
|
15884
|
+
return (alpha << 24 | ch(16) << 16 | ch(8) << 8 | ch(0)) >>> 0;
|
|
15885
|
+
}
|
|
15873
15886
|
function piecewise2(xs, ys, x) {
|
|
15874
15887
|
const n = Math.min(xs.length, ys.length);
|
|
15875
15888
|
if (n === 0) {
|
|
@@ -15975,10 +15988,10 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
15975
15988
|
let hits = 0;
|
|
15976
15989
|
let hitT = 0;
|
|
15977
15990
|
let hitU = 0;
|
|
15978
|
-
for (const
|
|
15979
|
-
if (
|
|
15980
|
-
const sx = fx + dx *
|
|
15981
|
-
const sy = fy + dy *
|
|
15991
|
+
for (const t2 of roots) {
|
|
15992
|
+
if (t2 < -eps || t2 > 1 + eps) continue;
|
|
15993
|
+
const sx = fx + dx * t2;
|
|
15994
|
+
const sy = fy + dy * t2;
|
|
15982
15995
|
if (sy === 0 && sx > 0 && Math.abs(py) < eps && ey > 0 && Math.max(ay, ay + ey) > 0 && Math.abs(ex) > eps) {
|
|
15983
15996
|
const u2 = (px / sx - ax) / ex;
|
|
15984
15997
|
if (u2 >= -eps && u2 <= 1 + eps) {
|
|
@@ -15992,7 +16005,7 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
15992
16005
|
const u = Math.abs(ex) > Math.abs(ey) ? (px / sx - ax) / ex : (py / sy - ay) / ey;
|
|
15993
16006
|
if (u >= -eps && u <= 1 + eps) {
|
|
15994
16007
|
hits++;
|
|
15995
|
-
hitT = Math.max(0,
|
|
16008
|
+
hitT = Math.max(0, t2);
|
|
15996
16009
|
hitU = Math.min(1, Math.max(0, u));
|
|
15997
16010
|
}
|
|
15998
16011
|
}
|
|
@@ -16024,7 +16037,8 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
16024
16037
|
const c1 = boundaryArgb[(found + 1) % n] ?? c0;
|
|
16025
16038
|
const surround = lerpArgb(c0, c1, bestU);
|
|
16026
16039
|
const factor = shape.blend ? piecewise2(shape.blend.positions, shape.blend.factors, pos) : pos;
|
|
16027
|
-
|
|
16040
|
+
const t = Math.min(1, Math.max(0, factor));
|
|
16041
|
+
return surround >>> 24 !== shape.centerArgb >>> 24 && boundaryArgb.every((color) => color === boundaryArgb[0]) ? lerpUniformPathArgb(surround, shape.centerArgb, t) : lerpArgb(surround, shape.centerArgb, t);
|
|
16028
16042
|
}
|
|
16029
16043
|
var MAX_TILE = 2048;
|
|
16030
16044
|
function mirrorFlags(wrap) {
|
|
@@ -20532,6 +20546,7 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20532
20546
|
const hq = kernel === "hq-bilinear" || kernel === "hq-bicubic";
|
|
20533
20547
|
const axisAligned = m[1] === 0 && m[2] === 0;
|
|
20534
20548
|
const integerBicubic = kernel === "bicubic" && axisAligned;
|
|
20549
|
+
const unitBicubicCopy = integerBicubic && !spec.halfPixelOffset && m[0] === 1 && m[3] === 1 && m[4] - Math.round(m[4]) > -1 / 64 && m[4] - Math.round(m[4]) <= 1 / 64 && m[5] - Math.round(m[5]) > -1 / 64 && m[5] - Math.round(m[5]) <= 1 / 64;
|
|
20535
20550
|
let farFade = false;
|
|
20536
20551
|
let shiftX = 0;
|
|
20537
20552
|
let shiftY = 0;
|
|
@@ -20596,8 +20611,9 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20596
20611
|
const integral = (v) => Math.abs(v - Math.round(v)) < 1e-9;
|
|
20597
20612
|
const copyU = axisAligned && Math.abs(scaleU - 1) < 1e-9 && integral(m[4]);
|
|
20598
20613
|
const copyV = axisAligned && Math.abs(scaleV - 1) < 1e-9 && integral(m[5]);
|
|
20599
|
-
const
|
|
20600
|
-
const
|
|
20614
|
+
const copy = copyU && copyV;
|
|
20615
|
+
const fu = axisFilter(kernel, scaleU, copy);
|
|
20616
|
+
const fv = axisFilter(kernel, scaleV, copy);
|
|
20601
20617
|
const out = new Uint8ClampedArray(w * h * 4);
|
|
20602
20618
|
const o = spec.halfPixelOffset ? 0.5 : 0;
|
|
20603
20619
|
const uMax = spec.srcX + spec.srcW;
|
|
@@ -20639,6 +20655,10 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20639
20655
|
}
|
|
20640
20656
|
u = Math.floor((su + (i - start) * bicubicDu) / (FIX16 / 64)) / 64;
|
|
20641
20657
|
v = Math.floor((sv + (i - start) * bicubicDv) / (FIX16 / 64)) / 64;
|
|
20658
|
+
if (unitBicubicCopy) {
|
|
20659
|
+
u = Math.round(u);
|
|
20660
|
+
v = Math.round(v);
|
|
20661
|
+
}
|
|
20642
20662
|
}
|
|
20643
20663
|
const box = { x0: 0, y0: 0, x1: width, y1: height };
|
|
20644
20664
|
const sampleAt = (cu, cv) => {
|
|
@@ -25186,7 +25206,7 @@ var HintedSize = class _HintedSize {
|
|
|
25186
25206
|
case 11: {
|
|
25187
25207
|
const y = this.pop() << 16 >> 16;
|
|
25188
25208
|
const x = this.pop() << 16 >> 16;
|
|
25189
|
-
const
|
|
25209
|
+
const vx = x, vy = y;
|
|
25190
25210
|
if (op === 10) {
|
|
25191
25211
|
gs.pvx = gs.dvx = vx;
|
|
25192
25212
|
gs.pvy = gs.dvy = vy;
|
|
@@ -32525,6 +32545,7 @@ function drawSourceMapped(target, decoded, req, offsetX, offsetY, mode, brushOrg
|
|
|
32525
32545
|
}
|
|
32526
32546
|
canvasPutImageData(tile.ctx, createImageDataCompat(px.data, px.width, px.height), 0, 0);
|
|
32527
32547
|
target.save();
|
|
32548
|
+
target.setTransform(1, 0, 0, 1, 0, 0);
|
|
32528
32549
|
target.globalCompositeOperation = "source-over";
|
|
32529
32550
|
canvasDrawImage(target, tile.canvas, Math.round(dLeft), Math.round(dTop), px.width, px.height);
|
|
32530
32551
|
target.restore();
|
|
@@ -32564,9 +32585,12 @@ function decodeSource(rCtx, req, rotated = false) {
|
|
|
32564
32585
|
function fillRectWith(ctx, style, gco, req) {
|
|
32565
32586
|
const prevGco = ctx.globalCompositeOperation;
|
|
32566
32587
|
const prevFill = ctx.fillStyle;
|
|
32588
|
+
ctx.save();
|
|
32589
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
32567
32590
|
ctx.globalCompositeOperation = gco;
|
|
32568
32591
|
ctx.fillStyle = style;
|
|
32569
32592
|
ctx.fillRect(req.dx, req.dy, req.dw, req.dh);
|
|
32593
|
+
ctx.restore();
|
|
32570
32594
|
ctx.globalCompositeOperation = prevGco;
|
|
32571
32595
|
ctx.fillStyle = prevFill;
|
|
32572
32596
|
}
|
package/dist/index.js
CHANGED
|
@@ -15873,6 +15873,19 @@ function lerpArgb(a, b, t) {
|
|
|
15873
15873
|
};
|
|
15874
15874
|
return (ch(24) << 24 | ch(16) << 16 | ch(8) << 8 | ch(0)) >>> 0;
|
|
15875
15875
|
}
|
|
15876
|
+
function lerpUniformPathArgb(a, b, t) {
|
|
15877
|
+
const aa = a >>> 24 & 255;
|
|
15878
|
+
const ab = b >>> 24 & 255;
|
|
15879
|
+
if (aa === ab) return lerpArgb(a, b, t);
|
|
15880
|
+
const alpha = Math.round(aa + (ab - aa) * t);
|
|
15881
|
+
if (alpha === 0) return 0;
|
|
15882
|
+
const ch = (shift) => {
|
|
15883
|
+
const ca = (a >>> shift & 255) * aa / 255;
|
|
15884
|
+
const cb = (b >>> shift & 255) * ab / 255;
|
|
15885
|
+
return Math.min(255, Math.max(0, Math.round((ca + (cb - ca) * t) * 255 / alpha)));
|
|
15886
|
+
};
|
|
15887
|
+
return (alpha << 24 | ch(16) << 16 | ch(8) << 8 | ch(0)) >>> 0;
|
|
15888
|
+
}
|
|
15876
15889
|
function piecewise2(xs, ys, x) {
|
|
15877
15890
|
const n = Math.min(xs.length, ys.length);
|
|
15878
15891
|
if (n === 0) {
|
|
@@ -15978,10 +15991,10 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
15978
15991
|
let hits = 0;
|
|
15979
15992
|
let hitT = 0;
|
|
15980
15993
|
let hitU = 0;
|
|
15981
|
-
for (const
|
|
15982
|
-
if (
|
|
15983
|
-
const sx = fx + dx *
|
|
15984
|
-
const sy = fy + dy *
|
|
15994
|
+
for (const t2 of roots) {
|
|
15995
|
+
if (t2 < -eps || t2 > 1 + eps) continue;
|
|
15996
|
+
const sx = fx + dx * t2;
|
|
15997
|
+
const sy = fy + dy * t2;
|
|
15985
15998
|
if (sy === 0 && sx > 0 && Math.abs(py) < eps && ey > 0 && Math.max(ay, ay + ey) > 0 && Math.abs(ex) > eps) {
|
|
15986
15999
|
const u2 = (px / sx - ax) / ex;
|
|
15987
16000
|
if (u2 >= -eps && u2 <= 1 + eps) {
|
|
@@ -15995,7 +16008,7 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
15995
16008
|
const u = Math.abs(ex) > Math.abs(ey) ? (px / sx - ax) / ex : (py / sy - ay) / ey;
|
|
15996
16009
|
if (u >= -eps && u <= 1 + eps) {
|
|
15997
16010
|
hits++;
|
|
15998
|
-
hitT = Math.max(0,
|
|
16011
|
+
hitT = Math.max(0, t2);
|
|
15999
16012
|
hitU = Math.min(1, Math.max(0, u));
|
|
16000
16013
|
}
|
|
16001
16014
|
}
|
|
@@ -16027,7 +16040,8 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
16027
16040
|
const c1 = boundaryArgb[(found + 1) % n] ?? c0;
|
|
16028
16041
|
const surround = lerpArgb(c0, c1, bestU);
|
|
16029
16042
|
const factor = shape.blend ? piecewise2(shape.blend.positions, shape.blend.factors, pos) : pos;
|
|
16030
|
-
|
|
16043
|
+
const t = Math.min(1, Math.max(0, factor));
|
|
16044
|
+
return surround >>> 24 !== shape.centerArgb >>> 24 && boundaryArgb.every((color) => color === boundaryArgb[0]) ? lerpUniformPathArgb(surround, shape.centerArgb, t) : lerpArgb(surround, shape.centerArgb, t);
|
|
16031
16045
|
}
|
|
16032
16046
|
var MAX_TILE = 2048;
|
|
16033
16047
|
function mirrorFlags(wrap) {
|
|
@@ -20535,6 +20549,7 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20535
20549
|
const hq = kernel === "hq-bilinear" || kernel === "hq-bicubic";
|
|
20536
20550
|
const axisAligned = m[1] === 0 && m[2] === 0;
|
|
20537
20551
|
const integerBicubic = kernel === "bicubic" && axisAligned;
|
|
20552
|
+
const unitBicubicCopy = integerBicubic && !spec.halfPixelOffset && m[0] === 1 && m[3] === 1 && m[4] - Math.round(m[4]) > -1 / 64 && m[4] - Math.round(m[4]) <= 1 / 64 && m[5] - Math.round(m[5]) > -1 / 64 && m[5] - Math.round(m[5]) <= 1 / 64;
|
|
20538
20553
|
let farFade = false;
|
|
20539
20554
|
let shiftX = 0;
|
|
20540
20555
|
let shiftY = 0;
|
|
@@ -20599,8 +20614,9 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20599
20614
|
const integral = (v) => Math.abs(v - Math.round(v)) < 1e-9;
|
|
20600
20615
|
const copyU = axisAligned && Math.abs(scaleU - 1) < 1e-9 && integral(m[4]);
|
|
20601
20616
|
const copyV = axisAligned && Math.abs(scaleV - 1) < 1e-9 && integral(m[5]);
|
|
20602
|
-
const
|
|
20603
|
-
const
|
|
20617
|
+
const copy = copyU && copyV;
|
|
20618
|
+
const fu = axisFilter(kernel, scaleU, copy);
|
|
20619
|
+
const fv = axisFilter(kernel, scaleV, copy);
|
|
20604
20620
|
const out = new Uint8ClampedArray(w * h * 4);
|
|
20605
20621
|
const o = spec.halfPixelOffset ? 0.5 : 0;
|
|
20606
20622
|
const uMax = spec.srcX + spec.srcW;
|
|
@@ -20642,6 +20658,10 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20642
20658
|
}
|
|
20643
20659
|
u = Math.floor((su + (i - start) * bicubicDu) / (FIX16 / 64)) / 64;
|
|
20644
20660
|
v = Math.floor((sv + (i - start) * bicubicDv) / (FIX16 / 64)) / 64;
|
|
20661
|
+
if (unitBicubicCopy) {
|
|
20662
|
+
u = Math.round(u);
|
|
20663
|
+
v = Math.round(v);
|
|
20664
|
+
}
|
|
20645
20665
|
}
|
|
20646
20666
|
const box = { x0: 0, y0: 0, x1: width, y1: height };
|
|
20647
20667
|
const sampleAt = (cu, cv) => {
|
|
@@ -25189,7 +25209,7 @@ var HintedSize = class _HintedSize {
|
|
|
25189
25209
|
case 11: {
|
|
25190
25210
|
const y = this.pop() << 16 >> 16;
|
|
25191
25211
|
const x = this.pop() << 16 >> 16;
|
|
25192
|
-
const
|
|
25212
|
+
const vx = x, vy = y;
|
|
25193
25213
|
if (op === 10) {
|
|
25194
25214
|
gs.pvx = gs.dvx = vx;
|
|
25195
25215
|
gs.pvy = gs.dvy = vy;
|
|
@@ -32528,6 +32548,7 @@ function drawSourceMapped(target, decoded, req, offsetX, offsetY, mode, brushOrg
|
|
|
32528
32548
|
}
|
|
32529
32549
|
canvasPutImageData(tile.ctx, createImageDataCompat(px.data, px.width, px.height), 0, 0);
|
|
32530
32550
|
target.save();
|
|
32551
|
+
target.setTransform(1, 0, 0, 1, 0, 0);
|
|
32531
32552
|
target.globalCompositeOperation = "source-over";
|
|
32532
32553
|
canvasDrawImage(target, tile.canvas, Math.round(dLeft), Math.round(dTop), px.width, px.height);
|
|
32533
32554
|
target.restore();
|
|
@@ -32567,9 +32588,12 @@ function decodeSource(rCtx, req, rotated = false) {
|
|
|
32567
32588
|
function fillRectWith(ctx, style, gco, req) {
|
|
32568
32589
|
const prevGco = ctx.globalCompositeOperation;
|
|
32569
32590
|
const prevFill = ctx.fillStyle;
|
|
32591
|
+
ctx.save();
|
|
32592
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
32570
32593
|
ctx.globalCompositeOperation = gco;
|
|
32571
32594
|
ctx.fillStyle = style;
|
|
32572
32595
|
ctx.fillRect(req.dx, req.dy, req.dw, req.dh);
|
|
32596
|
+
ctx.restore();
|
|
32573
32597
|
ctx.globalCompositeOperation = prevGco;
|
|
32574
32598
|
ctx.fillStyle = prevFill;
|
|
32575
32599
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -15871,6 +15871,19 @@ function lerpArgb(a, b, t) {
|
|
|
15871
15871
|
};
|
|
15872
15872
|
return (ch(24) << 24 | ch(16) << 16 | ch(8) << 8 | ch(0)) >>> 0;
|
|
15873
15873
|
}
|
|
15874
|
+
function lerpUniformPathArgb(a, b, t) {
|
|
15875
|
+
const aa = a >>> 24 & 255;
|
|
15876
|
+
const ab = b >>> 24 & 255;
|
|
15877
|
+
if (aa === ab) return lerpArgb(a, b, t);
|
|
15878
|
+
const alpha = Math.round(aa + (ab - aa) * t);
|
|
15879
|
+
if (alpha === 0) return 0;
|
|
15880
|
+
const ch = (shift) => {
|
|
15881
|
+
const ca = (a >>> shift & 255) * aa / 255;
|
|
15882
|
+
const cb = (b >>> shift & 255) * ab / 255;
|
|
15883
|
+
return Math.min(255, Math.max(0, Math.round((ca + (cb - ca) * t) * 255 / alpha)));
|
|
15884
|
+
};
|
|
15885
|
+
return (alpha << 24 | ch(16) << 16 | ch(8) << 8 | ch(0)) >>> 0;
|
|
15886
|
+
}
|
|
15874
15887
|
function piecewise2(xs, ys, x) {
|
|
15875
15888
|
const n = Math.min(xs.length, ys.length);
|
|
15876
15889
|
if (n === 0) {
|
|
@@ -15976,10 +15989,10 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
15976
15989
|
let hits = 0;
|
|
15977
15990
|
let hitT = 0;
|
|
15978
15991
|
let hitU = 0;
|
|
15979
|
-
for (const
|
|
15980
|
-
if (
|
|
15981
|
-
const sx = fx + dx *
|
|
15982
|
-
const sy = fy + dy *
|
|
15992
|
+
for (const t2 of roots) {
|
|
15993
|
+
if (t2 < -eps || t2 > 1 + eps) continue;
|
|
15994
|
+
const sx = fx + dx * t2;
|
|
15995
|
+
const sy = fy + dy * t2;
|
|
15983
15996
|
if (sy === 0 && sx > 0 && Math.abs(py) < eps && ey > 0 && Math.max(ay, ay + ey) > 0 && Math.abs(ex) > eps) {
|
|
15984
15997
|
const u2 = (px / sx - ax) / ex;
|
|
15985
15998
|
if (u2 >= -eps && u2 <= 1 + eps) {
|
|
@@ -15993,7 +16006,7 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
15993
16006
|
const u = Math.abs(ex) > Math.abs(ey) ? (px / sx - ax) / ex : (py / sy - ay) / ey;
|
|
15994
16007
|
if (u >= -eps && u <= 1 + eps) {
|
|
15995
16008
|
hits++;
|
|
15996
|
-
hitT = Math.max(0,
|
|
16009
|
+
hitT = Math.max(0, t2);
|
|
15997
16010
|
hitU = Math.min(1, Math.max(0, u));
|
|
15998
16011
|
}
|
|
15999
16012
|
}
|
|
@@ -16025,7 +16038,8 @@ function pathGradientColorAt(shape, x, y, focusPoint) {
|
|
|
16025
16038
|
const c1 = boundaryArgb[(found + 1) % n] ?? c0;
|
|
16026
16039
|
const surround = lerpArgb(c0, c1, bestU);
|
|
16027
16040
|
const factor = shape.blend ? piecewise2(shape.blend.positions, shape.blend.factors, pos) : pos;
|
|
16028
|
-
|
|
16041
|
+
const t = Math.min(1, Math.max(0, factor));
|
|
16042
|
+
return surround >>> 24 !== shape.centerArgb >>> 24 && boundaryArgb.every((color) => color === boundaryArgb[0]) ? lerpUniformPathArgb(surround, shape.centerArgb, t) : lerpArgb(surround, shape.centerArgb, t);
|
|
16029
16043
|
}
|
|
16030
16044
|
var MAX_TILE = 2048;
|
|
16031
16045
|
function mirrorFlags(wrap) {
|
|
@@ -20533,6 +20547,7 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20533
20547
|
const hq = kernel === "hq-bilinear" || kernel === "hq-bicubic";
|
|
20534
20548
|
const axisAligned = m[1] === 0 && m[2] === 0;
|
|
20535
20549
|
const integerBicubic = kernel === "bicubic" && axisAligned;
|
|
20550
|
+
const unitBicubicCopy = integerBicubic && !spec.halfPixelOffset && m[0] === 1 && m[3] === 1 && m[4] - Math.round(m[4]) > -1 / 64 && m[4] - Math.round(m[4]) <= 1 / 64 && m[5] - Math.round(m[5]) > -1 / 64 && m[5] - Math.round(m[5]) <= 1 / 64;
|
|
20536
20551
|
let farFade = false;
|
|
20537
20552
|
let shiftX = 0;
|
|
20538
20553
|
let shiftY = 0;
|
|
@@ -20597,8 +20612,9 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20597
20612
|
const integral = (v) => Math.abs(v - Math.round(v)) < 1e-9;
|
|
20598
20613
|
const copyU = axisAligned && Math.abs(scaleU - 1) < 1e-9 && integral(m[4]);
|
|
20599
20614
|
const copyV = axisAligned && Math.abs(scaleV - 1) < 1e-9 && integral(m[5]);
|
|
20600
|
-
const
|
|
20601
|
-
const
|
|
20615
|
+
const copy = copyU && copyV;
|
|
20616
|
+
const fu = axisFilter(kernel, scaleU, copy);
|
|
20617
|
+
const fv = axisFilter(kernel, scaleV, copy);
|
|
20602
20618
|
const out = new Uint8ClampedArray(w * h * 4);
|
|
20603
20619
|
const o = spec.halfPixelOffset ? 0.5 : 0;
|
|
20604
20620
|
const uMax = spec.srcX + spec.srcW;
|
|
@@ -20640,6 +20656,10 @@ function resampleImage(rgba, width, height, spec, surface) {
|
|
|
20640
20656
|
}
|
|
20641
20657
|
u = Math.floor((su + (i - start) * bicubicDu) / (FIX16 / 64)) / 64;
|
|
20642
20658
|
v = Math.floor((sv + (i - start) * bicubicDv) / (FIX16 / 64)) / 64;
|
|
20659
|
+
if (unitBicubicCopy) {
|
|
20660
|
+
u = Math.round(u);
|
|
20661
|
+
v = Math.round(v);
|
|
20662
|
+
}
|
|
20643
20663
|
}
|
|
20644
20664
|
const box = { x0: 0, y0: 0, x1: width, y1: height };
|
|
20645
20665
|
const sampleAt = (cu, cv) => {
|
|
@@ -25187,7 +25207,7 @@ var HintedSize = class _HintedSize {
|
|
|
25187
25207
|
case 11: {
|
|
25188
25208
|
const y = this.pop() << 16 >> 16;
|
|
25189
25209
|
const x = this.pop() << 16 >> 16;
|
|
25190
|
-
const
|
|
25210
|
+
const vx = x, vy = y;
|
|
25191
25211
|
if (op === 10) {
|
|
25192
25212
|
gs.pvx = gs.dvx = vx;
|
|
25193
25213
|
gs.pvy = gs.dvy = vy;
|
|
@@ -32526,6 +32546,7 @@ function drawSourceMapped(target, decoded, req, offsetX, offsetY, mode, brushOrg
|
|
|
32526
32546
|
}
|
|
32527
32547
|
canvasPutImageData(tile.ctx, createImageDataCompat(px.data, px.width, px.height), 0, 0);
|
|
32528
32548
|
target.save();
|
|
32549
|
+
target.setTransform(1, 0, 0, 1, 0, 0);
|
|
32529
32550
|
target.globalCompositeOperation = "source-over";
|
|
32530
32551
|
canvasDrawImage(target, tile.canvas, Math.round(dLeft), Math.round(dTop), px.width, px.height);
|
|
32531
32552
|
target.restore();
|
|
@@ -32565,9 +32586,12 @@ function decodeSource(rCtx, req, rotated = false) {
|
|
|
32565
32586
|
function fillRectWith(ctx, style, gco, req) {
|
|
32566
32587
|
const prevGco = ctx.globalCompositeOperation;
|
|
32567
32588
|
const prevFill = ctx.fillStyle;
|
|
32589
|
+
ctx.save();
|
|
32590
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
32568
32591
|
ctx.globalCompositeOperation = gco;
|
|
32569
32592
|
ctx.fillStyle = style;
|
|
32570
32593
|
ctx.fillRect(req.dx, req.dy, req.dw, req.dh);
|
|
32594
|
+
ctx.restore();
|
|
32571
32595
|
ctx.globalCompositeOperation = prevGco;
|
|
32572
32596
|
ctx.fillStyle = prevFill;
|
|
32573
32597
|
}
|