@pixldocs/canvas-renderer 0.5.45 → 0.5.46

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
@@ -221,7 +221,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
221
221
  * Package version banner. Bump alongside package.json so we can confirm
222
222
  * (via browser:log) that the deployed bundle matches the expected build.
223
223
  */
224
- export declare const PACKAGE_VERSION = "0.5.45";
224
+ export declare const PACKAGE_VERSION = "0.5.46";
225
225
 
226
226
  export declare interface PageSettings {
227
227
  backgroundColor?: string;
package/dist/index.js CHANGED
@@ -4937,26 +4937,9 @@ function applyTextBackground(obj, cfg) {
4937
4937
  if (recoloredText) textLayers.push(`<g ${attrs}>${recoloredText}</g>`);
4938
4938
  };
4939
4939
  if (blur > 0) {
4940
- const ringCount = Math.min(6, Math.max(2, Math.round(blur / 2)));
4941
- for (let i = 1; i <= ringCount; i++) {
4942
- const t = i / ringCount;
4943
- const dist = blur * t * 0.6;
4944
- const op = (0.18 * (1 - t * 0.7)).toFixed(3);
4945
- const ringOffsets = [
4946
- [dist, 0],
4947
- [-dist, 0],
4948
- [0, dist],
4949
- [0, -dist],
4950
- [dist * 0.7, dist * 0.7],
4951
- [-dist * 0.7, dist * 0.7],
4952
- [dist * 0.7, -dist * 0.7],
4953
- [-dist * 0.7, -dist * 0.7]
4954
- ];
4955
- for (const [dx, dy] of ringOffsets) {
4956
- pushShadowPass(ox + dx, oy + dy, op);
4957
- }
4940
+ for (const pass of buildNormalizedShadowPasses(blur)) {
4941
+ pushShadowPass(ox + pass.dx, oy + pass.dy, pass.opacity);
4958
4942
  }
4959
- pushShadowPass(ox, oy, "0.25");
4960
4943
  } else {
4961
4944
  pushShadowPass(ox, oy);
4962
4945
  }
@@ -4992,6 +4975,36 @@ function recolorSvgFills(svg, color) {
4992
4975
  );
4993
4976
  return out;
4994
4977
  }
4978
+ function buildNormalizedShadowPasses(blur) {
4979
+ const safeBlur = Math.max(0, Number(blur) || 0);
4980
+ const ringCount = Math.min(5, Math.max(2, Math.round(safeBlur / 5)));
4981
+ const targetOpacity = Math.max(0.16, Math.min(0.38, 0.46 - safeBlur * 0.01));
4982
+ const weighted = [
4983
+ { dx: 0, dy: 0, weight: 0.7 }
4984
+ ];
4985
+ for (let i = 1; i <= ringCount; i++) {
4986
+ const t = i / ringCount;
4987
+ const dist = safeBlur * t * 0.42;
4988
+ const weight = Math.exp(-2.4 * t * t);
4989
+ const diag = dist * 0.7071;
4990
+ weighted.push(
4991
+ { dx: dist, dy: 0, weight },
4992
+ { dx: -dist, dy: 0, weight },
4993
+ { dx: 0, dy: dist, weight },
4994
+ { dx: 0, dy: -dist, weight },
4995
+ { dx: diag, dy: diag, weight: weight * 0.72 },
4996
+ { dx: -diag, dy: diag, weight: weight * 0.72 },
4997
+ { dx: diag, dy: -diag, weight: weight * 0.72 },
4998
+ { dx: -diag, dy: -diag, weight: weight * 0.72 }
4999
+ );
5000
+ }
5001
+ const totalWeight = weighted.reduce((sum, pass) => sum + pass.weight, 0) || 1;
5002
+ return weighted.map((pass) => ({
5003
+ dx: pass.dx,
5004
+ dy: pass.dy,
5005
+ opacity: Math.max(3e-3, targetOpacity * pass.weight / totalWeight).toFixed(4)
5006
+ }));
5007
+ }
4995
5008
  function buildRoundedRectPathD(x, y, w, h, rTL, rTR, rBR, rBL) {
4996
5009
  const maxR = Math.min(w, h) / 2;
4997
5010
  const tl = Math.min(Math.max(0, rTL), maxR);
@@ -12343,7 +12356,7 @@ function PixldocsPreview(props) {
12343
12356
  !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..." }) })
12344
12357
  ] });
12345
12358
  }
12346
- const PACKAGE_VERSION = "0.5.45";
12359
+ const PACKAGE_VERSION = "0.5.46";
12347
12360
  let __underlineFixInstalled = false;
12348
12361
  function installUnderlineFix(fab) {
12349
12362
  var _a;