@netless/forge-whiteboard 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.
|
@@ -11,6 +11,8 @@ export declare class CurveModel extends ElementModel<paper.Path> {
|
|
|
11
11
|
constructor(root: Y.Map<any>, scope: paper.PaperScope, liveCursor: LiveCursor, isPerformanceMode: () => boolean);
|
|
12
12
|
private average;
|
|
13
13
|
private parsePoints;
|
|
14
|
+
private isPressureValue;
|
|
15
|
+
private pointStride;
|
|
14
16
|
private matrixedPoints;
|
|
15
17
|
private createPath;
|
|
16
18
|
protected onVectorUpdate(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveModel.d.ts","sourceRoot":"","sources":["../../../src/model/renderable/CurveModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,UAAW,SAAQ,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC;IAE/C,IAAI,EAAE,KAAK,CAAC,IAAI,GAAG,IAAI,CAAQ;IAEtC,OAAO,CAAC,KAAK,CAAkB;IAC/B,SAAS,CAAC,iCAAiC,UAAS;IACpD,SAAS,CAAC,oBAAoB,UAAQ;IACtC,SAAS,CAAC,eAAe,SAAK;gBAEX,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,OAAO;IAUtH,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,WAAW;IAsBnB,OAAO,CAAC,cAAc;
|
|
1
|
+
{"version":3,"file":"CurveModel.d.ts","sourceRo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ends ElementModel {
|
|
|
26230
26230
|
}
|
|
26231
26231
|
});
|
|
26232
26232
|
}
|
|
26233
|
+
isPressureValue(value) {
|
|
26234
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
26235
|
+
}
|
|
26236
|
+
pointStride(points) {
|
|
26237
|
+
if (points.length >= 3 && points.length % 3 === 0) {
|
|
26238
|
+
let hasPressureSlot = false;
|
|
26239
|
+
for (let i = 2; i < points.length; i += 3) {
|
|
26240
|
+
if (!this.isPressureValue(points[i])) {
|
|
26241
|
+
return 2;
|
|
26242
|
+
}
|
|
26243
|
+
hasPressureSlot = true;
|
|
26244
|
+
}
|
|
26245
|
+
if (hasPressureSlot) {
|
|
26246
|
+
return 3;
|
|
26247
|
+
}
|
|
26248
|
+
}
|
|
26249
|
+
return 2;
|
|
26250
|
+
}
|
|
26233
26251
|
matrixedPoints() {
|
|
26234
26252
|
const points = this.localPoints.length === 0 ? this.points : this.localPoints;
|
|
26235
26253
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26236
26254
|
const output = [];
|
|
26237
|
-
|
|
26255
|
+
const stride = this.pointStride(points);
|
|
26256
|
+
for (let i = 0, len = points.length; i + 1 < len; i += stride) {
|
|
26238
26257
|
const p = new this.scope.Point(points[i], points[i + 1]);
|
|
26239
26258
|
const tp = p.transform(matrix);
|
|
26240
|
-
const pressure = points[i + 2] ?? 0;
|
|
26259
|
+
const pressure = stride === 3 ? points[i + 2] ?? 0 : 0;
|
|
26241
26260
|
output.push([tp.x, tp.y, pressure]);
|
|
26242
26261
|
}
|
|
26243
26262
|
return output;
|
|
@@ -26313,11 +26332,13 @@ var CurveModel = class extends ElementModel {
|
|
|
26313
26332
|
}
|
|
26314
26333
|
liveCursorPoint() {
|
|
26315
26334
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
26316
|
-
|
|
26335
|
+
const points = yArray.toArray();
|
|
26336
|
+
const stride = this.pointStride(points);
|
|
26337
|
+
if (points.length < stride) {
|
|
26317
26338
|
return null;
|
|
26318
26339
|
}
|
|
26319
|
-
const len =
|
|
26320
|
-
const point = new this.scope.Point(
|
|
26340
|
+
const len = points.length;
|
|
26341
|
+
const point = new this.scope.Point(points[len - stride], points[len - stride + 1]);
|
|
26321
26342
|
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
26322
26343
|
}
|
|
26323
26344
|
onStyleKeyUpdate(key) {
|