@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.cjs +33 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +33 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4956,26 +4956,9 @@ function applyTextBackground(obj, cfg) {
|
|
|
4956
4956
|
if (recoloredText) textLayers.push(`<g ${attrs}>${recoloredText}</g>`);
|
|
4957
4957
|
};
|
|
4958
4958
|
if (blur > 0) {
|
|
4959
|
-
const
|
|
4960
|
-
|
|
4961
|
-
const t = i / ringCount;
|
|
4962
|
-
const dist = blur * t * 0.6;
|
|
4963
|
-
const op = (0.18 * (1 - t * 0.7)).toFixed(3);
|
|
4964
|
-
const ringOffsets = [
|
|
4965
|
-
[dist, 0],
|
|
4966
|
-
[-dist, 0],
|
|
4967
|
-
[0, dist],
|
|
4968
|
-
[0, -dist],
|
|
4969
|
-
[dist * 0.7, dist * 0.7],
|
|
4970
|
-
[-dist * 0.7, dist * 0.7],
|
|
4971
|
-
[dist * 0.7, -dist * 0.7],
|
|
4972
|
-
[-dist * 0.7, -dist * 0.7]
|
|
4973
|
-
];
|
|
4974
|
-
for (const [dx, dy] of ringOffsets) {
|
|
4975
|
-
pushShadowPass(ox + dx, oy + dy, op);
|
|
4976
|
-
}
|
|
4959
|
+
for (const pass of buildNormalizedShadowPasses(blur)) {
|
|
4960
|
+
pushShadowPass(ox + pass.dx, oy + pass.dy, pass.opacity);
|
|
4977
4961
|
}
|
|
4978
|
-
pushShadowPass(ox, oy, "0.25");
|
|
4979
4962
|
} else {
|
|
4980
4963
|
pushShadowPass(ox, oy);
|
|
4981
4964
|
}
|
|
@@ -5011,6 +4994,36 @@ function recolorSvgFills(svg, color) {
|
|
|
5011
4994
|
);
|
|
5012
4995
|
return out;
|
|
5013
4996
|
}
|
|
4997
|
+
function buildNormalizedShadowPasses(blur) {
|
|
4998
|
+
const safeBlur = Math.max(0, Number(blur) || 0);
|
|
4999
|
+
const ringCount = Math.min(5, Math.max(2, Math.round(safeBlur / 5)));
|
|
5000
|
+
const targetOpacity = Math.max(0.16, Math.min(0.38, 0.46 - safeBlur * 0.01));
|
|
5001
|
+
const weighted = [
|
|
5002
|
+
{ dx: 0, dy: 0, weight: 0.7 }
|
|
5003
|
+
];
|
|
5004
|
+
for (let i = 1; i <= ringCount; i++) {
|
|
5005
|
+
const t = i / ringCount;
|
|
5006
|
+
const dist = safeBlur * t * 0.42;
|
|
5007
|
+
const weight = Math.exp(-2.4 * t * t);
|
|
5008
|
+
const diag = dist * 0.7071;
|
|
5009
|
+
weighted.push(
|
|
5010
|
+
{ dx: dist, dy: 0, weight },
|
|
5011
|
+
{ dx: -dist, dy: 0, weight },
|
|
5012
|
+
{ dx: 0, dy: dist, weight },
|
|
5013
|
+
{ dx: 0, dy: -dist, weight },
|
|
5014
|
+
{ dx: diag, dy: diag, weight: weight * 0.72 },
|
|
5015
|
+
{ dx: -diag, dy: diag, weight: weight * 0.72 },
|
|
5016
|
+
{ dx: diag, dy: -diag, weight: weight * 0.72 },
|
|
5017
|
+
{ dx: -diag, dy: -diag, weight: weight * 0.72 }
|
|
5018
|
+
);
|
|
5019
|
+
}
|
|
5020
|
+
const totalWeight = weighted.reduce((sum, pass) => sum + pass.weight, 0) || 1;
|
|
5021
|
+
return weighted.map((pass) => ({
|
|
5022
|
+
dx: pass.dx,
|
|
5023
|
+
dy: pass.dy,
|
|
5024
|
+
opacity: Math.max(3e-3, targetOpacity * pass.weight / totalWeight).toFixed(4)
|
|
5025
|
+
}));
|
|
5026
|
+
}
|
|
5014
5027
|
function buildRoundedRectPathD(x, y, w, h, rTL, rTR, rBR, rBL) {
|
|
5015
5028
|
const maxR = Math.min(w, h) / 2;
|
|
5016
5029
|
const tl = Math.min(Math.max(0, rTL), maxR);
|
|
@@ -12362,7 +12375,7 @@ function PixldocsPreview(props) {
|
|
|
12362
12375
|
!canvasSettled && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
|
|
12363
12376
|
] });
|
|
12364
12377
|
}
|
|
12365
|
-
const PACKAGE_VERSION = "0.5.
|
|
12378
|
+
const PACKAGE_VERSION = "0.5.46";
|
|
12366
12379
|
let __underlineFixInstalled = false;
|
|
12367
12380
|
function installUnderlineFix(fab) {
|
|
12368
12381
|
var _a;
|