html2canvas-pro 2.4.1 → 2.4.2
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/html2canvas-pro.cjs +15 -12
- package/dist/html2canvas-pro.cjs.map +1 -1
- package/dist/html2canvas-pro.esm.js +15 -12
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +15 -12
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +2 -2
- package/dist/lib/render/canvas/background-renderer.js +20 -9
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* html2canvas-pro 2.4.
|
|
2
|
+
* html2canvas-pro 2.4.2 <https://yorickshan.github.io/html2canvas-pro/>
|
|
3
3
|
* Copyright (c) 2024-present yorickshan and html2canvas-pro contributors
|
|
4
4
|
* Released under MIT License
|
|
5
5
|
*/
|
|
@@ -9729,21 +9729,20 @@ var BackgroundRenderer = class {
|
|
|
9729
9729
|
}
|
|
9730
9730
|
if (rx > 0 && ry > 0) {
|
|
9731
9731
|
const cacheKey = `rg|${Math.round(x)}x${Math.round(y)}|${Math.round(rx)}x${Math.round(ry)}|${JSON.stringify(backgroundImage.stops)}`;
|
|
9732
|
+
const stops = processColorStops(backgroundImage.stops, rx * 2);
|
|
9733
|
+
const lastStop = stops[stops.length - 1];
|
|
9732
9734
|
let pattern = this.patternCache.get(cacheKey);
|
|
9733
9735
|
if (!pattern) {
|
|
9734
|
-
const
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
offscreen.width = size;
|
|
9738
|
-
offscreen.height = size;
|
|
9736
|
+
const offscreen = (this.canvas.ownerDocument ?? document).createElement("canvas");
|
|
9737
|
+
offscreen.width = Math.ceil(rx * 2);
|
|
9738
|
+
offscreen.height = Math.ceil(ry * 2);
|
|
9739
9739
|
const offCtx = offscreen.getContext("2d");
|
|
9740
9740
|
if (offCtx) {
|
|
9741
|
-
const
|
|
9742
|
-
|
|
9743
|
-
processColorStops(backgroundImage.stops, offRadius * 2).forEach((s) => gradient.addColorStop(s.stop, asString(s.color)));
|
|
9741
|
+
const gradient = offCtx.createRadialGradient(rx, rx, 0, rx, rx, rx);
|
|
9742
|
+
stops.forEach((s) => gradient.addColorStop(s.stop, asString(s.color)));
|
|
9744
9743
|
offCtx.fillStyle = gradient;
|
|
9745
9744
|
if (rx !== ry) offCtx.scale(1, ry / rx);
|
|
9746
|
-
offCtx.fillRect(0, 0,
|
|
9745
|
+
offCtx.fillRect(0, 0, rx * 2, rx * 2);
|
|
9747
9746
|
pattern = this.ctx.createPattern(offscreen, "no-repeat");
|
|
9748
9747
|
this.patternCache.set(cacheKey, pattern);
|
|
9749
9748
|
}
|
|
@@ -9752,9 +9751,13 @@ var BackgroundRenderer = class {
|
|
|
9752
9751
|
this.path(path);
|
|
9753
9752
|
this.ctx.save();
|
|
9754
9753
|
this.ctx.clip();
|
|
9755
|
-
|
|
9754
|
+
if (lastStop) {
|
|
9755
|
+
this.ctx.fillStyle = asString(lastStop.color);
|
|
9756
|
+
this.ctx.fill();
|
|
9757
|
+
}
|
|
9758
|
+
this.ctx.translate(left + x - rx, top + y - ry);
|
|
9756
9759
|
this.ctx.fillStyle = pattern;
|
|
9757
|
-
this.ctx.fillRect(0, 0,
|
|
9760
|
+
this.ctx.fillRect(0, 0, rx * 2, ry * 2);
|
|
9758
9761
|
this.ctx.restore();
|
|
9759
9762
|
}
|
|
9760
9763
|
}
|