@shotstack/shotstack-canvas 1.1.8 → 1.2.0
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.node.cjs +15 -3
- package/dist/entry.node.cjs.map +1 -1
- package/dist/entry.node.js +15 -3
- package/dist/entry.node.js.map +1 -1
- package/dist/entry.web.js +13 -1
- package/dist/entry.web.js.map +1 -1
- package/package.json +1 -1
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,18 @@ 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
|
|
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
|
+
}
|
|
1252
1264
|
ctx.fillStyle = fill;
|
|
1253
1265
|
ctx.fill(p);
|
|
1254
1266
|
ctx.restore();
|