@shotstack/shotstack-canvas 1.1.7 → 1.1.9

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/entry.web.js CHANGED
@@ -1210,6 +1210,7 @@ function createWebPainter(canvas) {
1210
1210
  return {
1211
1211
  async render(ops) {
1212
1212
  const globalBox = computeGlobalTextBounds(ops);
1213
+ const gradientCache = /* @__PURE__ */ new Map();
1213
1214
  for (const op of ops) {
1214
1215
  if (op.op === "BeginFrame") {
1215
1216
  const dpr = op.pixelRatio;
@@ -1248,7 +1249,19 @@ function createWebPainter(canvas) {
1248
1249
  const s = fillOp.scale ?? 1;
1249
1250
  ctx.scale(s, -s);
1250
1251
  const bbox = fillOp.gradientBBox ?? globalBox;
1251
- const fill = makeGradientFromBBox(ctx, fillOp.fill, bbox);
1252
+ const localBBox = {
1253
+ x: (bbox.x - fillOp.x) / s,
1254
+ y: -(bbox.y - fillOp.y) / s,
1255
+ w: bbox.w / s,
1256
+ h: bbox.h / s
1257
+ };
1258
+ const cacheKey = JSON.stringify({ fill: fillOp.fill, bbox: localBBox });
1259
+ let fill = gradientCache.get(cacheKey);
1260
+ if (!fill) {
1261
+ fill = makeGradientFromBBox(ctx, fillOp.fill, localBBox);
1262
+ gradientCache.set(cacheKey, fill);
1263
+ console.log("[Web Painter] Created NEW gradient for local bbox:", localBBox);
1264
+ }
1252
1265
  ctx.fillStyle = fill;
1253
1266
  ctx.fill(p);
1254
1267
  ctx.restore();