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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * html2canvas-pro 2.4.1 <https://yorickshan.github.io/html2canvas-pro/>
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 ownerDocument = this.canvas.ownerDocument ?? document;
9735
- const size = Math.ceil(Math.max(rx, ry) * 2);
9736
- const offscreen = ownerDocument.createElement("canvas");
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 offRadius = Math.max(rx, ry);
9742
- const gradient = offCtx.createRadialGradient(offRadius, offRadius, 0, offRadius, offRadius, offRadius);
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, offRadius * 2, offRadius * 2);
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
- this.ctx.translate(left + x - Math.max(rx, ry), top + y - Math.max(rx, ry));
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, Math.max(rx, ry) * 2, Math.max(rx, ry) * 2);
9760
+ this.ctx.fillRect(0, 0, rx * 2, ry * 2);
9758
9761
  this.ctx.restore();
9759
9762
  }
9760
9763
  }