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