@pixldocs/canvas-renderer 0.5.102 → 0.5.103

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.103";
260
260
 
261
261
  export declare interface PageSettings {
262
262
  backgroundColor?: string;
package/dist/index.js CHANGED
@@ -6248,9 +6248,11 @@ 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;
6253
+ const seamGuardPx = 2;
6252
6254
  const innerAlpha = (t) => {
6253
- const keepProgress = Math.pow(t, hardness);
6255
+ const keepProgress = Math.pow(t, gamma);
6254
6256
  const erase = (1 - amount) * (1 - keepProgress);
6255
6257
  return 1 - erase;
6256
6258
  };
@@ -6286,8 +6288,8 @@ function bakeEdgeFade(source, fade) {
6286
6288
  }
6287
6289
  mctx.fillStyle = g;
6288
6290
  mctx.fillRect(x, y, rectW, rectH);
6289
- if (amount <= 1e-3) {
6290
- const edgePx = Math.min(2, side === "top" || side === "bottom" ? rectH : rectW);
6291
+ {
6292
+ const edgePx = Math.min(seamGuardPx, side === "top" || side === "bottom" ? rectH : rectW);
6291
6293
  mctx.fillStyle = "rgba(0,0,0,0)";
6292
6294
  mctx.globalCompositeOperation = "copy";
6293
6295
  if (side === "top") mctx.fillRect(0, 0, mask.width, edgePx);
@@ -9710,11 +9712,13 @@ const PageCanvas = forwardRef(
9710
9712
  ctx.globalCompositeOperation = "destination-out";
9711
9713
  let gradient;
9712
9714
  const eraseAtEdge = 1 - amount;
9713
- const STOPS = 24;
9715
+ const STOPS = 64;
9716
+ const gamma = 1 / hardness;
9717
+ const seamGuardPx = 2;
9714
9718
  const addStops = (g) => {
9715
9719
  for (let i = 0; i <= STOPS; i++) {
9716
9720
  const t = i / STOPS;
9717
- const keepProgress = Math.pow(t, hardness);
9721
+ const keepProgress = Math.pow(t, gamma);
9718
9722
  const a = eraseAtEdge * (1 - keepProgress);
9719
9723
  g.addColorStop(t, `rgba(0,0,0,${a})`);
9720
9724
  }
@@ -9725,28 +9729,32 @@ const PageCanvas = forwardRef(
9725
9729
  addStops(gradient);
9726
9730
  ctx.fillStyle = gradient;
9727
9731
  ctx.fillRect(x, y, w, band);
9728
- if (amount <= 1e-3) ctx.fillRect(x, y, w, Math.min(2, band));
9732
+ ctx.fillStyle = "rgba(0,0,0,1)";
9733
+ ctx.fillRect(x, y, w, Math.min(seamGuardPx, band));
9729
9734
  } else if (side === "bottom") {
9730
9735
  const band = Math.max(1, h * size);
9731
9736
  gradient = ctx.createLinearGradient(0, y + h, 0, y + h - band);
9732
9737
  addStops(gradient);
9733
9738
  ctx.fillStyle = gradient;
9734
9739
  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));
9740
+ ctx.fillStyle = "rgba(0,0,0,1)";
9741
+ ctx.fillRect(x, y + h - Math.min(seamGuardPx, band), w, Math.min(seamGuardPx, band));
9736
9742
  } else if (side === "left") {
9737
9743
  const band = Math.max(1, w * size);
9738
9744
  gradient = ctx.createLinearGradient(x, 0, x + band, 0);
9739
9745
  addStops(gradient);
9740
9746
  ctx.fillStyle = gradient;
9741
9747
  ctx.fillRect(x, y, band, h);
9742
- if (amount <= 1e-3) ctx.fillRect(x, y, Math.min(2, band), h);
9748
+ ctx.fillStyle = "rgba(0,0,0,1)";
9749
+ ctx.fillRect(x, y, Math.min(seamGuardPx, band), h);
9743
9750
  } else {
9744
9751
  const band = Math.max(1, w * size);
9745
9752
  gradient = ctx.createLinearGradient(x + w, 0, x + w - band, 0);
9746
9753
  addStops(gradient);
9747
9754
  ctx.fillStyle = gradient;
9748
9755
  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);
9756
+ ctx.fillStyle = "rgba(0,0,0,1)";
9757
+ ctx.fillRect(x + w - Math.min(seamGuardPx, band), y, Math.min(seamGuardPx, band), h);
9750
9758
  }
9751
9759
  ctx.restore();
9752
9760
  };
@@ -13416,7 +13424,7 @@ function PixldocsPreview(props) {
13416
13424
  !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
13425
  ] });
13418
13426
  }
13419
- const PACKAGE_VERSION = "0.5.101";
13427
+ const PACKAGE_VERSION = "0.5.103";
13420
13428
  const roundParityValue = (value) => {
13421
13429
  if (typeof value !== "number") return value;
13422
13430
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;