@shotstack/shotstack-canvas 1.1.2 → 1.1.3

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.
@@ -567,7 +567,7 @@ async function buildDrawOps(p) {
567
567
  height: p.canvas.height,
568
568
  pixelRatio: p.canvas.pixelRatio,
569
569
  clear: true,
570
- bg: p.background ? { color: p.background.color, opacity: p.background.opacity, radius: p.background.borderRadius } : void 0
570
+ bg: p.background && p.background.color ? { color: p.background.color, opacity: p.background.opacity, radius: p.background.borderRadius } : void 0
571
571
  });
572
572
  if (p.lines.length === 0) return ops;
573
573
  const upem = Math.max(1, await p.getUnitsPerEm());
@@ -1197,6 +1197,7 @@ async function createNodePainter(opts) {
1197
1197
  const globalBox = computeGlobalTextBounds(ops);
1198
1198
  for (const op of ops) {
1199
1199
  if (op.op === "BeginFrame") {
1200
+ if (op.clear) ctx.clearRect(0, 0, op.width, op.height);
1200
1201
  const dpr = op.pixelRatio ?? opts.pixelRatio;
1201
1202
  const wantW = Math.floor(op.width * dpr);
1202
1203
  const wantH = Math.floor(op.height * dpr);
@@ -1205,8 +1206,10 @@ async function createNodePainter(opts) {
1205
1206
  canvas.height = wantH;
1206
1207
  }
1207
1208
  ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
1208
- if (op.clear) ctx.clearRect(0, 0, op.width, op.height);
1209
- if (op.bg) {
1209
+ ctx.save();
1210
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
1211
+ ctx.restore();
1212
+ if (op.bg && op.bg.color) {
1210
1213
  const { color, opacity, radius } = op.bg;
1211
1214
  if (color) {
1212
1215
  const c = parseHex6(color, opacity);