canvu-react 0.4.69 → 0.4.70
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/react.cjs +49 -20
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +49 -20
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -8383,6 +8383,47 @@ function shallowEqualStringArray(a, b) {
|
|
|
8383
8383
|
return true;
|
|
8384
8384
|
}
|
|
8385
8385
|
|
|
8386
|
+
// src/react/stroke-input.ts
|
|
8387
|
+
function getPointerEventSamples(event) {
|
|
8388
|
+
if (typeof event.getCoalescedEvents !== "function") {
|
|
8389
|
+
return [event];
|
|
8390
|
+
}
|
|
8391
|
+
const samples = event.getCoalescedEvents();
|
|
8392
|
+
return samples.length > 0 ? samples : [event];
|
|
8393
|
+
}
|
|
8394
|
+
var resolveInterpolatedPressure = (lastPoint, nextPoint, ratio) => {
|
|
8395
|
+
if (lastPoint.pressure != null && nextPoint.pressure != null) {
|
|
8396
|
+
return lastPoint.pressure + (nextPoint.pressure - lastPoint.pressure) * ratio;
|
|
8397
|
+
}
|
|
8398
|
+
return ratio === 1 ? nextPoint.pressure : void 0;
|
|
8399
|
+
};
|
|
8400
|
+
var resolveMaxStepWorld = (maxStepWorld) => Number.isFinite(maxStepWorld) && maxStepWorld > 0 ? maxStepWorld : Number.POSITIVE_INFINITY;
|
|
8401
|
+
function appendInterpolatedStrokePoint(points, nextPoint, maxStepWorld) {
|
|
8402
|
+
if (points.length === 0) return [nextPoint];
|
|
8403
|
+
const lastPoint = points[points.length - 1];
|
|
8404
|
+
if (!lastPoint) return [...points, nextPoint];
|
|
8405
|
+
const deltaX = nextPoint.x - lastPoint.x;
|
|
8406
|
+
const deltaY = nextPoint.y - lastPoint.y;
|
|
8407
|
+
const distanceSquared = deltaX * deltaX + deltaY * deltaY;
|
|
8408
|
+
if (distanceSquared < 1e-12) return points;
|
|
8409
|
+
const distance = Math.sqrt(distanceSquared);
|
|
8410
|
+
const stepCount = Math.max(
|
|
8411
|
+
1,
|
|
8412
|
+
Math.ceil(distance / resolveMaxStepWorld(maxStepWorld))
|
|
8413
|
+
);
|
|
8414
|
+
if (stepCount === 1) return [...points, nextPoint];
|
|
8415
|
+
const interpolatedPoints = Array.from({ length: stepCount }, (_, index) => {
|
|
8416
|
+
const ratio = (index + 1) / stepCount;
|
|
8417
|
+
const pressure = resolveInterpolatedPressure(lastPoint, nextPoint, ratio);
|
|
8418
|
+
return {
|
|
8419
|
+
x: lastPoint.x + deltaX * ratio,
|
|
8420
|
+
y: lastPoint.y + deltaY * ratio,
|
|
8421
|
+
...pressure != null ? { pressure } : {}
|
|
8422
|
+
};
|
|
8423
|
+
});
|
|
8424
|
+
return [...points, ...interpolatedPoints];
|
|
8425
|
+
}
|
|
8426
|
+
|
|
8386
8427
|
// src/react/TextEditOverlay.tsx
|
|
8387
8428
|
init_rect();
|
|
8388
8429
|
init_text_svg();
|
|
@@ -8642,13 +8683,6 @@ function pointInSelectedItemBounds(item, worldX, worldY) {
|
|
|
8642
8683
|
);
|
|
8643
8684
|
return local.x >= 0 && local.x <= bounds.width && local.y >= 0 && local.y <= bounds.height;
|
|
8644
8685
|
}
|
|
8645
|
-
function pointerEventSamples(ev) {
|
|
8646
|
-
if (ev.pointerType !== "pen" || typeof ev.getCoalescedEvents !== "function") {
|
|
8647
|
-
return [ev];
|
|
8648
|
-
}
|
|
8649
|
-
const samples = ev.getCoalescedEvents();
|
|
8650
|
-
return samples.length > 0 ? samples : [ev];
|
|
8651
|
-
}
|
|
8652
8686
|
var CANVU_PEN_ACTIVE_UI_BLOCK_CSS = `
|
|
8653
8687
|
[data-canvu-pen-active="true"] [data-slot="vector-canvas-toolbar"],
|
|
8654
8688
|
[data-canvu-pen-active="true"] [data-slot="vector-canvas-toolbar"] *,
|
|
@@ -8750,15 +8784,6 @@ function VectorViewportPluginInstances({
|
|
|
8750
8784
|
] }, plugin.id);
|
|
8751
8785
|
}) });
|
|
8752
8786
|
}
|
|
8753
|
-
function appendInterpolatedPoints(points, next, maxStepWorld) {
|
|
8754
|
-
if (points.length === 0) return [next];
|
|
8755
|
-
const last = points[points.length - 1];
|
|
8756
|
-
if (!last) return [...points, next];
|
|
8757
|
-
const dx = next.x - last.x;
|
|
8758
|
-
const dy = next.y - last.y;
|
|
8759
|
-
if (dx * dx + dy * dy < 1e-12) return points;
|
|
8760
|
-
return [...points, next];
|
|
8761
|
-
}
|
|
8762
8787
|
function pointerSampleToWorldPoint(screenToWorldFn, clientX, clientY, pressure) {
|
|
8763
8788
|
const { worldX, worldY } = screenToWorldFn(clientX, clientY);
|
|
8764
8789
|
const safePressure = pressure != null && Number.isFinite(pressure) ? Math.min(1, Math.max(0, pressure)) : void 0;
|
|
@@ -8789,15 +8814,19 @@ function isLikelyStylusTouch(touch) {
|
|
|
8789
8814
|
}
|
|
8790
8815
|
function appendPointerEventSamplesToStrokePoints(points, ev, zoom, screenToWorldFn) {
|
|
8791
8816
|
let interpolated = points;
|
|
8792
|
-
ev.pointerType === "pen" ? 0.35 / zoom : 1 / zoom;
|
|
8793
|
-
for (const sample of
|
|
8817
|
+
const maxStepWorld = ev.pointerType === "pen" ? 0.35 / zoom : 1 / zoom;
|
|
8818
|
+
for (const sample of getPointerEventSamples(ev)) {
|
|
8794
8819
|
const nextPoint = pointerSampleToWorldPoint(
|
|
8795
8820
|
screenToWorldFn,
|
|
8796
8821
|
sample.clientX,
|
|
8797
8822
|
sample.clientY,
|
|
8798
8823
|
sample.pointerType === "pen" ? sample.pressure : void 0
|
|
8799
8824
|
);
|
|
8800
|
-
interpolated =
|
|
8825
|
+
interpolated = appendInterpolatedStrokePoint(
|
|
8826
|
+
interpolated,
|
|
8827
|
+
nextPoint,
|
|
8828
|
+
maxStepWorld
|
|
8829
|
+
);
|
|
8801
8830
|
}
|
|
8802
8831
|
return interpolated;
|
|
8803
8832
|
}
|
|
@@ -8808,7 +8837,7 @@ function appendTouchToStrokePoints(points, touch, zoom, screenToWorldFn) {
|
|
|
8808
8837
|
touch.clientY,
|
|
8809
8838
|
touchPressure(touch)
|
|
8810
8839
|
);
|
|
8811
|
-
return
|
|
8840
|
+
return appendInterpolatedStrokePoint(points, nextPoint, 0.35 / zoom);
|
|
8812
8841
|
}
|
|
8813
8842
|
function createStraightStrokeState(anchorPoint, clientX, clientY) {
|
|
8814
8843
|
return {
|