@pixldocs/canvas-renderer 0.5.102 → 0.5.104

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/index.d.ts CHANGED
@@ -256,7 +256,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
256
256
  * Package version banner. Bump alongside package.json so we can confirm
257
257
  * (via browser:log) that the deployed bundle matches the expected build.
258
258
  */
259
- export declare const PACKAGE_VERSION = "0.5.101";
259
+ export declare const PACKAGE_VERSION = "0.5.104";
260
260
 
261
261
  export declare interface PageSettings {
262
262
  backgroundColor?: string;
package/dist/index.js CHANGED
@@ -6248,9 +6248,10 @@ function bakeEdgeFade(source, fade) {
6248
6248
  mctx.fillRect(0, 0, mask.width, mask.height);
6249
6249
  let g;
6250
6250
  let x = 0, y = 0, rectW = mask.width, rectH = mask.height;
6251
- const STOPS = 24;
6251
+ const STOPS = 64;
6252
+ const gamma = 1 / hardness;
6252
6253
  const innerAlpha = (t) => {
6253
- const keepProgress = Math.pow(t, hardness);
6254
+ const keepProgress = Math.pow(t, gamma);
6254
6255
  const erase = (1 - amount) * (1 - keepProgress);
6255
6256
  return 1 - erase;
6256
6257
  };
@@ -6286,16 +6287,6 @@ function bakeEdgeFade(source, fade) {
6286
6287
  }
6287
6288
  mctx.fillStyle = g;
6288
6289
  mctx.fillRect(x, y, rectW, rectH);
6289
- if (amount <= 1e-3) {
6290
- const edgePx = Math.min(2, side === "top" || side === "bottom" ? rectH : rectW);
6291
- mctx.fillStyle = "rgba(0,0,0,0)";
6292
- mctx.globalCompositeOperation = "copy";
6293
- if (side === "top") mctx.fillRect(0, 0, mask.width, edgePx);
6294
- if (side === "bottom") mctx.fillRect(0, mask.height - edgePx, mask.width, edgePx);
6295
- if (side === "left") mctx.fillRect(0, 0, edgePx, mask.height);
6296
- if (side === "right") mctx.fillRect(mask.width - edgePx, 0, edgePx, mask.height);
6297
- mctx.globalCompositeOperation = "source-over";
6298
- }
6299
6290
  ctx.globalCompositeOperation = "destination-in";
6300
6291
  ctx.drawImage(mask, 0, 0);
6301
6292
  ctx.globalCompositeOperation = "source-over";
@@ -9710,11 +9701,12 @@ const PageCanvas = forwardRef(
9710
9701
  ctx.globalCompositeOperation = "destination-out";
9711
9702
  let gradient;
9712
9703
  const eraseAtEdge = 1 - amount;
9713
- const STOPS = 24;
9704
+ const STOPS = 64;
9705
+ const gamma = 1 / hardness;
9714
9706
  const addStops = (g) => {
9715
9707
  for (let i = 0; i <= STOPS; i++) {
9716
9708
  const t = i / STOPS;
9717
- const keepProgress = Math.pow(t, hardness);
9709
+ const keepProgress = Math.pow(t, gamma);
9718
9710
  const a = eraseAtEdge * (1 - keepProgress);
9719
9711
  g.addColorStop(t, `rgba(0,0,0,${a})`);
9720
9712
  }
@@ -9725,28 +9717,24 @@ const PageCanvas = forwardRef(
9725
9717
  addStops(gradient);
9726
9718
  ctx.fillStyle = gradient;
9727
9719
  ctx.fillRect(x, y, w, band);
9728
- if (amount <= 1e-3) ctx.fillRect(x, y, w, Math.min(2, band));
9729
9720
  } else if (side === "bottom") {
9730
9721
  const band = Math.max(1, h * size);
9731
9722
  gradient = ctx.createLinearGradient(0, y + h, 0, y + h - band);
9732
9723
  addStops(gradient);
9733
9724
  ctx.fillStyle = gradient;
9734
9725
  ctx.fillRect(x, y + h - band, w, band);
9735
- if (amount <= 1e-3) ctx.fillRect(x, y + h - Math.min(2, band), w, Math.min(2, band));
9736
9726
  } else if (side === "left") {
9737
9727
  const band = Math.max(1, w * size);
9738
9728
  gradient = ctx.createLinearGradient(x, 0, x + band, 0);
9739
9729
  addStops(gradient);
9740
9730
  ctx.fillStyle = gradient;
9741
9731
  ctx.fillRect(x, y, band, h);
9742
- if (amount <= 1e-3) ctx.fillRect(x, y, Math.min(2, band), h);
9743
9732
  } else {
9744
9733
  const band = Math.max(1, w * size);
9745
9734
  gradient = ctx.createLinearGradient(x + w, 0, x + w - band, 0);
9746
9735
  addStops(gradient);
9747
9736
  ctx.fillStyle = gradient;
9748
9737
  ctx.fillRect(x + w - band, y, band, h);
9749
- if (amount <= 1e-3) ctx.fillRect(x + w - Math.min(2, band), y, Math.min(2, band), h);
9750
9738
  }
9751
9739
  ctx.restore();
9752
9740
  };
@@ -13416,7 +13404,7 @@ function PixldocsPreview(props) {
13416
13404
  !canvasSettled && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
13417
13405
  ] });
13418
13406
  }
13419
- const PACKAGE_VERSION = "0.5.101";
13407
+ const PACKAGE_VERSION = "0.5.104";
13420
13408
  const roundParityValue = (value) => {
13421
13409
  if (typeof value !== "number") return value;
13422
13410
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;