@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.cjs +19 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6267,9 +6267,11 @@ function bakeEdgeFade(source, fade) {
|
|
|
6267
6267
|
mctx.fillRect(0, 0, mask.width, mask.height);
|
|
6268
6268
|
let g;
|
|
6269
6269
|
let x = 0, y = 0, rectW = mask.width, rectH = mask.height;
|
|
6270
|
-
const STOPS =
|
|
6270
|
+
const STOPS = 64;
|
|
6271
|
+
const gamma = 1 / hardness;
|
|
6272
|
+
const seamGuardPx = 2;
|
|
6271
6273
|
const innerAlpha = (t) => {
|
|
6272
|
-
const keepProgress = Math.pow(t,
|
|
6274
|
+
const keepProgress = Math.pow(t, gamma);
|
|
6273
6275
|
const erase = (1 - amount) * (1 - keepProgress);
|
|
6274
6276
|
return 1 - erase;
|
|
6275
6277
|
};
|
|
@@ -6305,8 +6307,8 @@ function bakeEdgeFade(source, fade) {
|
|
|
6305
6307
|
}
|
|
6306
6308
|
mctx.fillStyle = g;
|
|
6307
6309
|
mctx.fillRect(x, y, rectW, rectH);
|
|
6308
|
-
|
|
6309
|
-
const edgePx = Math.min(
|
|
6310
|
+
{
|
|
6311
|
+
const edgePx = Math.min(seamGuardPx, side === "top" || side === "bottom" ? rectH : rectW);
|
|
6310
6312
|
mctx.fillStyle = "rgba(0,0,0,0)";
|
|
6311
6313
|
mctx.globalCompositeOperation = "copy";
|
|
6312
6314
|
if (side === "top") mctx.fillRect(0, 0, mask.width, edgePx);
|
|
@@ -9729,11 +9731,13 @@ const PageCanvas = react.forwardRef(
|
|
|
9729
9731
|
ctx.globalCompositeOperation = "destination-out";
|
|
9730
9732
|
let gradient;
|
|
9731
9733
|
const eraseAtEdge = 1 - amount;
|
|
9732
|
-
const STOPS =
|
|
9734
|
+
const STOPS = 64;
|
|
9735
|
+
const gamma = 1 / hardness;
|
|
9736
|
+
const seamGuardPx = 2;
|
|
9733
9737
|
const addStops = (g) => {
|
|
9734
9738
|
for (let i = 0; i <= STOPS; i++) {
|
|
9735
9739
|
const t = i / STOPS;
|
|
9736
|
-
const keepProgress = Math.pow(t,
|
|
9740
|
+
const keepProgress = Math.pow(t, gamma);
|
|
9737
9741
|
const a = eraseAtEdge * (1 - keepProgress);
|
|
9738
9742
|
g.addColorStop(t, `rgba(0,0,0,${a})`);
|
|
9739
9743
|
}
|
|
@@ -9744,28 +9748,32 @@ const PageCanvas = react.forwardRef(
|
|
|
9744
9748
|
addStops(gradient);
|
|
9745
9749
|
ctx.fillStyle = gradient;
|
|
9746
9750
|
ctx.fillRect(x, y, w, band);
|
|
9747
|
-
|
|
9751
|
+
ctx.fillStyle = "rgba(0,0,0,1)";
|
|
9752
|
+
ctx.fillRect(x, y, w, Math.min(seamGuardPx, band));
|
|
9748
9753
|
} else if (side === "bottom") {
|
|
9749
9754
|
const band = Math.max(1, h * size);
|
|
9750
9755
|
gradient = ctx.createLinearGradient(0, y + h, 0, y + h - band);
|
|
9751
9756
|
addStops(gradient);
|
|
9752
9757
|
ctx.fillStyle = gradient;
|
|
9753
9758
|
ctx.fillRect(x, y + h - band, w, band);
|
|
9754
|
-
|
|
9759
|
+
ctx.fillStyle = "rgba(0,0,0,1)";
|
|
9760
|
+
ctx.fillRect(x, y + h - Math.min(seamGuardPx, band), w, Math.min(seamGuardPx, band));
|
|
9755
9761
|
} else if (side === "left") {
|
|
9756
9762
|
const band = Math.max(1, w * size);
|
|
9757
9763
|
gradient = ctx.createLinearGradient(x, 0, x + band, 0);
|
|
9758
9764
|
addStops(gradient);
|
|
9759
9765
|
ctx.fillStyle = gradient;
|
|
9760
9766
|
ctx.fillRect(x, y, band, h);
|
|
9761
|
-
|
|
9767
|
+
ctx.fillStyle = "rgba(0,0,0,1)";
|
|
9768
|
+
ctx.fillRect(x, y, Math.min(seamGuardPx, band), h);
|
|
9762
9769
|
} else {
|
|
9763
9770
|
const band = Math.max(1, w * size);
|
|
9764
9771
|
gradient = ctx.createLinearGradient(x + w, 0, x + w - band, 0);
|
|
9765
9772
|
addStops(gradient);
|
|
9766
9773
|
ctx.fillStyle = gradient;
|
|
9767
9774
|
ctx.fillRect(x + w - band, y, band, h);
|
|
9768
|
-
|
|
9775
|
+
ctx.fillStyle = "rgba(0,0,0,1)";
|
|
9776
|
+
ctx.fillRect(x + w - Math.min(seamGuardPx, band), y, Math.min(seamGuardPx, band), h);
|
|
9769
9777
|
}
|
|
9770
9778
|
ctx.restore();
|
|
9771
9779
|
};
|
|
@@ -13435,7 +13443,7 @@ function PixldocsPreview(props) {
|
|
|
13435
13443
|
!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..." }) })
|
|
13436
13444
|
] });
|
|
13437
13445
|
}
|
|
13438
|
-
const PACKAGE_VERSION = "0.5.
|
|
13446
|
+
const PACKAGE_VERSION = "0.5.103";
|
|
13439
13447
|
const roundParityValue = (value) => {
|
|
13440
13448
|
if (typeof value !== "number") return value;
|
|
13441
13449
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|