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
package/dist/html2canvas-pro.cjs
CHANGED
|
@@ -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
|
*/
|
|
@@ -9733,21 +9733,20 @@ var BackgroundRenderer = class {
|
|
|
9733
9733
|
}
|
|
9734
9734
|
if (rx > 0 && ry > 0) {
|
|
9735
9735
|
const cacheKey = `rg|${Math.round(x)}x${Math.round(y)}|${Math.round(rx)}x${Math.round(ry)}|${JSON.stringify(backgroundImage.stops)}`;
|
|
9736
|
+
const stops = processColorStops(backgroundImage.stops, rx * 2);
|
|
9737
|
+
const lastStop = stops[stops.length - 1];
|
|
9736
9738
|
let pattern = this.patternCache.get(cacheKey);
|
|
9737
9739
|
if (!pattern) {
|
|
9738
|
-
const
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
offscreen.width = size;
|
|
9742
|
-
offscreen.height = size;
|
|
9740
|
+
const offscreen = (this.canvas.ownerDocument ?? document).createElement("canvas");
|
|
9741
|
+
offscreen.width = Math.ceil(rx * 2);
|
|
9742
|
+
offscreen.height = Math.ceil(ry * 2);
|
|
9743
9743
|
const offCtx = offscreen.getContext("2d");
|
|
9744
9744
|
if (offCtx) {
|
|
9745
|
-
const
|
|
9746
|
-
|
|
9747
|
-
processColorStops(backgroundImage.stops, offRadius * 2).forEach((s) => gradient.addColorStop(s.stop, asString(s.color)));
|
|
9745
|
+
const gradient = offCtx.createRadialGradient(rx, rx, 0, rx, rx, rx);
|
|
9746
|
+
stops.forEach((s) => gradient.addColorStop(s.stop, asString(s.color)));
|
|
9748
9747
|
offCtx.fillStyle = gradient;
|
|
9749
9748
|
if (rx !== ry) offCtx.scale(1, ry / rx);
|
|
9750
|
-
offCtx.fillRect(0, 0,
|
|
9749
|
+
offCtx.fillRect(0, 0, rx * 2, rx * 2);
|
|
9751
9750
|
pattern = this.ctx.createPattern(offscreen, "no-repeat");
|
|
9752
9751
|
this.patternCache.set(cacheKey, pattern);
|
|
9753
9752
|
}
|
|
@@ -9756,9 +9755,13 @@ var BackgroundRenderer = class {
|
|
|
9756
9755
|
this.path(path);
|
|
9757
9756
|
this.ctx.save();
|
|
9758
9757
|
this.ctx.clip();
|
|
9759
|
-
|
|
9758
|
+
if (lastStop) {
|
|
9759
|
+
this.ctx.fillStyle = asString(lastStop.color);
|
|
9760
|
+
this.ctx.fill();
|
|
9761
|
+
}
|
|
9762
|
+
this.ctx.translate(left + x - rx, top + y - ry);
|
|
9760
9763
|
this.ctx.fillStyle = pattern;
|
|
9761
|
-
this.ctx.fillRect(0, 0,
|
|
9764
|
+
this.ctx.fillRect(0, 0, rx * 2, ry * 2);
|
|
9762
9765
|
this.ctx.restore();
|
|
9763
9766
|
}
|
|
9764
9767
|
}
|