@netless/forge-slide 1.1.4 → 1.1.5
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/slide.esm.js +26 -5
- package/dist/slide.esm.js.map +2 -2
- package/dist/slide.js +26 -5
- package/dist/slide.js.map +2 -2
- package/package.json +3 -3
package/dist/slide.esm.js
CHANGED
|
@@ -61535,14 +61535,33 @@ var CurveModel = class extends ElementModel {
|
|
|
61535
61535
|
}
|
|
61536
61536
|
});
|
|
61537
61537
|
}
|
|
61538
|
+
isPressureValue(value) {
|
|
61539
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
61540
|
+
}
|
|
61541
|
+
pointStride(points) {
|
|
61542
|
+
if (points.length >= 3 && points.length % 3 === 0) {
|
|
61543
|
+
let hasPressureSlot = false;
|
|
61544
|
+
for (let i = 2; i < points.length; i += 3) {
|
|
61545
|
+
if (!this.isPressureValue(points[i])) {
|
|
61546
|
+
return 2;
|
|
61547
|
+
}
|
|
61548
|
+
hasPressureSlot = true;
|
|
61549
|
+
}
|
|
61550
|
+
if (hasPressureSlot) {
|
|
61551
|
+
return 3;
|
|
61552
|
+
}
|
|
61553
|
+
}
|
|
61554
|
+
return 2;
|
|
61555
|
+
}
|
|
61538
61556
|
matrixedPoints() {
|
|
61539
61557
|
const points = this.localPoints.length === 0 ? this.points : this.localPoints;
|
|
61540
61558
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
61541
61559
|
const output = [];
|
|
61542
|
-
|
|
61560
|
+
const stride = this.pointStride(points);
|
|
61561
|
+
for (let i = 0, len = points.length; i + 1 < len; i += stride) {
|
|
61543
61562
|
const p = new this.scope.Point(points[i], points[i + 1]);
|
|
61544
61563
|
const tp = p.transform(matrix);
|
|
61545
|
-
const pressure = points[i + 2] ?? 0;
|
|
61564
|
+
const pressure = stride === 3 ? points[i + 2] ?? 0 : 0;
|
|
61546
61565
|
output.push([tp.x, tp.y, pressure]);
|
|
61547
61566
|
}
|
|
61548
61567
|
return output;
|
|
@@ -61618,11 +61637,13 @@ var CurveModel = class extends ElementModel {
|
|
|
61618
61637
|
}
|
|
61619
61638
|
liveCursorPoint() {
|
|
61620
61639
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
61621
|
-
|
|
61640
|
+
const points = yArray.toArray();
|
|
61641
|
+
const stride = this.pointStride(points);
|
|
61642
|
+
if (points.length < stride) {
|
|
61622
61643
|
return null;
|
|
61623
61644
|
}
|
|
61624
|
-
const len =
|
|
61625
|
-
const point = new this.scope.Point(
|
|
61645
|
+
const len = points.length;
|
|
61646
|
+
const point = new this.scope.Point(points[len - stride], points[len - stride + 1]);
|
|
61626
61647
|
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
61627
61648
|
}
|
|
61628
61649
|
onStyleKeyUpdate(key) {
|