@inditextech/weave-sdk 0.56.2 → 0.57.1
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/sdk.cjs +141 -168
- package/dist/sdk.d.cts +164 -170
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +164 -170
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +153 -181
- package/dist/sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.cjs
CHANGED
|
@@ -21930,7 +21930,7 @@ var WeaveRegisterManager = class {
|
|
|
21930
21930
|
|
|
21931
21931
|
//#endregion
|
|
21932
21932
|
//#region package.json
|
|
21933
|
-
var version = "0.
|
|
21933
|
+
var version = "0.57.1";
|
|
21934
21934
|
|
|
21935
21935
|
//#endregion
|
|
21936
21936
|
//#region src/managers/setup.ts
|
|
@@ -25094,9 +25094,8 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
25094
25094
|
//#region src/nodes/stroke/constants.ts
|
|
25095
25095
|
const WEAVE_STROKE_NODE_TYPE = "stroke";
|
|
25096
25096
|
const WEAVE_STROKE_NODE_DEFAULT_CONFIG = {
|
|
25097
|
-
|
|
25098
|
-
resamplingSpacing: 2
|
|
25099
|
-
pressureScale: 1
|
|
25097
|
+
splineResolution: 8,
|
|
25098
|
+
resamplingSpacing: 2
|
|
25100
25099
|
};
|
|
25101
25100
|
|
|
25102
25101
|
//#endregion
|
|
@@ -25108,143 +25107,147 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
25108
25107
|
const { config } = params ?? {};
|
|
25109
25108
|
this.config = (0, import_merge.default)(WEAVE_STROKE_NODE_DEFAULT_CONFIG, config);
|
|
25110
25109
|
}
|
|
25111
|
-
resamplePoints(pts,
|
|
25110
|
+
resamplePoints(pts, minDist = 2) {
|
|
25112
25111
|
if (pts.length < 2) return pts;
|
|
25113
|
-
const
|
|
25112
|
+
const result = [pts[0]];
|
|
25113
|
+
let last = pts[0];
|
|
25114
25114
|
for (let i = 1; i < pts.length; i++) {
|
|
25115
|
-
|
|
25116
|
-
const
|
|
25117
|
-
|
|
25118
|
-
|
|
25119
|
-
|
|
25120
|
-
|
|
25121
|
-
const t = spacing / segDist;
|
|
25122
|
-
const newPt = this.lerpPoint(last, current, t);
|
|
25123
|
-
resampled.push(newPt);
|
|
25124
|
-
last = newPt;
|
|
25125
|
-
remaining = this.dist(last, current);
|
|
25126
|
-
}
|
|
25127
|
-
}
|
|
25128
|
-
return resampled;
|
|
25129
|
-
}
|
|
25130
|
-
dist(a, b) {
|
|
25131
|
-
const dx = b.x - a.x, dy = b.y - a.y;
|
|
25132
|
-
return Math.hypot(dx, dy);
|
|
25133
|
-
}
|
|
25134
|
-
lerpPoint(a, b, t) {
|
|
25135
|
-
return {
|
|
25136
|
-
x: a.x + (b.x - a.x) * t,
|
|
25137
|
-
y: a.y + (b.y - a.y) * t,
|
|
25138
|
-
pressure: a.pressure + (b.pressure - a.pressure) * t
|
|
25139
|
-
};
|
|
25140
|
-
}
|
|
25141
|
-
buildPolygonFromPressure(pts, baseWidth) {
|
|
25142
|
-
if (pts.length < 2) return [];
|
|
25143
|
-
const left = [];
|
|
25144
|
-
const right = [];
|
|
25145
|
-
for (let i = 0; i < pts.length; i++) {
|
|
25146
|
-
const p = pts[i];
|
|
25147
|
-
const w = (baseWidth + p.pressure * this.config.pressureScale) / 2;
|
|
25148
|
-
let dx, dy;
|
|
25149
|
-
if (i === 0) {
|
|
25150
|
-
dx = pts[1].x - p.x;
|
|
25151
|
-
dy = pts[1].y - p.y;
|
|
25152
|
-
} else if (i === pts.length - 1) {
|
|
25153
|
-
dx = p.x - pts[i - 1].x;
|
|
25154
|
-
dy = p.y - pts[i - 1].y;
|
|
25155
|
-
} else {
|
|
25156
|
-
dx = pts[i + 1].x - pts[i - 1].x;
|
|
25157
|
-
dy = pts[i + 1].y - pts[i - 1].y;
|
|
25158
|
-
}
|
|
25159
|
-
const len = Math.hypot(dx, dy) || 1;
|
|
25160
|
-
const nx = -dy / len;
|
|
25161
|
-
const ny = dx / len;
|
|
25162
|
-
left.push({
|
|
25163
|
-
x: p.x + nx * w,
|
|
25164
|
-
y: p.y + ny * w
|
|
25165
|
-
});
|
|
25166
|
-
right.push({
|
|
25167
|
-
x: p.x - nx * w,
|
|
25168
|
-
y: p.y - ny * w
|
|
25169
|
-
});
|
|
25115
|
+
const dx = pts[i].x - last.x;
|
|
25116
|
+
const dy = pts[i].y - last.y;
|
|
25117
|
+
if (dx * dx + dy * dy >= minDist * minDist) {
|
|
25118
|
+
result.push(pts[i]);
|
|
25119
|
+
last = pts[i];
|
|
25120
|
+
}
|
|
25170
25121
|
}
|
|
25171
|
-
|
|
25172
|
-
return left.concat(reversed);
|
|
25122
|
+
return result;
|
|
25173
25123
|
}
|
|
25174
|
-
|
|
25175
|
-
const
|
|
25176
|
-
let
|
|
25177
|
-
|
|
25178
|
-
|
|
25179
|
-
|
|
25180
|
-
|
|
25181
|
-
let
|
|
25182
|
-
|
|
25183
|
-
const
|
|
25184
|
-
const
|
|
25185
|
-
|
|
25186
|
-
|
|
25187
|
-
|
|
25188
|
-
|
|
25189
|
-
|
|
25190
|
-
|
|
25191
|
-
|
|
25192
|
-
pts[i - 1] = mid;
|
|
25193
|
-
}
|
|
25194
|
-
segPts.push(pts[i]);
|
|
25195
|
-
patDist -= d;
|
|
25196
|
-
}
|
|
25197
|
-
if (draw && segPts.length > 1) segments.push(segPts);
|
|
25198
|
-
return segments;
|
|
25199
|
-
}
|
|
25200
|
-
catmullRomSpline(pts, spacing) {
|
|
25201
|
-
const curvePoints = [];
|
|
25202
|
-
for (let i = 0; i < pts.length - 1; i++) {
|
|
25203
|
-
const p0 = pts[i - 1] || pts[i];
|
|
25204
|
-
const p1 = pts[i];
|
|
25205
|
-
const p2 = pts[i + 1];
|
|
25206
|
-
const p3 = pts[i + 2] || p2;
|
|
25207
|
-
for (let t = 0; t < 1; t += spacing) {
|
|
25208
|
-
const t2 = t * t;
|
|
25209
|
-
const t3 = t2 * t;
|
|
25210
|
-
const x = .5 * (2 * p1.x + (-p0.x + p2.x) * t + (2 * p0.x - 5 * p1.x + 4 * p2.x - p3.x) * t2 + (-p0.x + 3 * p1.x - 3 * p2.x + p3.x) * t3);
|
|
25211
|
-
const y = .5 * (2 * p1.y + (-p0.y + p2.y) * t + (2 * p0.y - 5 * p1.y + 4 * p2.y - p3.y) * t2 + (-p0.y + 3 * p1.y - 3 * p2.y + p3.y) * t3);
|
|
25212
|
-
const pressure = .5 * (2 * p1.pressure + (-p0.pressure + p2.pressure) * t + (2 * p0.pressure - 5 * p1.pressure + 4 * p2.pressure - p3.pressure) * t2 + (-p0.pressure + 3 * p1.pressure - 3 * p2.pressure + p3.pressure) * t3);
|
|
25213
|
-
curvePoints.push({
|
|
25124
|
+
getSplinePoints(pts, resolution = 8) {
|
|
25125
|
+
const result = [];
|
|
25126
|
+
for (let i = -1; i < pts.length - 2; i++) {
|
|
25127
|
+
const p0 = pts[Math.max(i, 0)];
|
|
25128
|
+
const p1 = pts[i + 1];
|
|
25129
|
+
const p2 = pts[i + 2];
|
|
25130
|
+
const p3 = pts[Math.min(i + 3, pts.length - 1)];
|
|
25131
|
+
for (let t = 0; t < 1; t += 1 / resolution) {
|
|
25132
|
+
const tt = t * t;
|
|
25133
|
+
const ttt = tt * t;
|
|
25134
|
+
const q1 = -ttt + 2 * tt - t;
|
|
25135
|
+
const q2 = 3 * ttt - 5 * tt + 2;
|
|
25136
|
+
const q3 = -3 * ttt + 4 * tt + t;
|
|
25137
|
+
const q4 = ttt - tt;
|
|
25138
|
+
const x = (q1 * p0.x + q2 * p1.x + q3 * p2.x + q4 * p3.x) / 2;
|
|
25139
|
+
const y = (q1 * p0.y + q2 * p1.y + q3 * p2.y + q4 * p3.y) / 2;
|
|
25140
|
+
const pressure = (q1 * p0.pressure + q2 * p1.pressure + q3 * p2.pressure + q4 * p3.pressure) / 2;
|
|
25141
|
+
result.push({
|
|
25214
25142
|
x,
|
|
25215
25143
|
y,
|
|
25216
25144
|
pressure
|
|
25217
25145
|
});
|
|
25218
25146
|
}
|
|
25219
25147
|
}
|
|
25220
|
-
|
|
25148
|
+
result.push(pts[pts.length - 1]);
|
|
25149
|
+
return result;
|
|
25150
|
+
}
|
|
25151
|
+
drawRibbonWithDash(ctx, pts, baseW, color, dash) {
|
|
25152
|
+
if (pts.length < 2) return;
|
|
25153
|
+
const filtered = this.resamplePoints(pts, 2);
|
|
25154
|
+
const centerline = this.getSplinePoints(filtered, 8);
|
|
25155
|
+
let dashIndex = 0;
|
|
25156
|
+
let dashOn = true;
|
|
25157
|
+
let dashRemaining = dash.length ? dash[0] : Infinity;
|
|
25158
|
+
let leftSide = [];
|
|
25159
|
+
let rightSide = [];
|
|
25160
|
+
for (let i = 0; i < centerline.length - 1; i++) {
|
|
25161
|
+
const p0 = centerline[i];
|
|
25162
|
+
const p1 = centerline[i + 1];
|
|
25163
|
+
const dx = p1.x - p0.x;
|
|
25164
|
+
const dy = p1.y - p0.y;
|
|
25165
|
+
const segLen = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
25166
|
+
const nx = -dy / segLen;
|
|
25167
|
+
const ny = dx / segLen;
|
|
25168
|
+
const w0 = baseW * p0.pressure / 2;
|
|
25169
|
+
const w1 = baseW * p1.pressure / 2;
|
|
25170
|
+
let traveled = 0;
|
|
25171
|
+
while (traveled < segLen) {
|
|
25172
|
+
const step = Math.min(dashRemaining, segLen - traveled);
|
|
25173
|
+
const t0 = traveled / segLen;
|
|
25174
|
+
const t1 = (traveled + step) / segLen;
|
|
25175
|
+
const x0 = p0.x + dx * t0;
|
|
25176
|
+
const y0 = p0.y + dy * t0;
|
|
25177
|
+
const x1 = p0.x + dx * t1;
|
|
25178
|
+
const y1 = p0.y + dy * t1;
|
|
25179
|
+
const pw0 = w0 + (w1 - w0) * t0;
|
|
25180
|
+
const pw1 = w0 + (w1 - w0) * t1;
|
|
25181
|
+
if (dashOn) {
|
|
25182
|
+
leftSide.push({
|
|
25183
|
+
x: x0 + nx * pw0,
|
|
25184
|
+
y: y0 + ny * pw0,
|
|
25185
|
+
pressure: 1
|
|
25186
|
+
});
|
|
25187
|
+
rightSide.push({
|
|
25188
|
+
x: x0 - nx * pw0,
|
|
25189
|
+
y: y0 - ny * pw0,
|
|
25190
|
+
pressure: 1
|
|
25191
|
+
});
|
|
25192
|
+
leftSide.push({
|
|
25193
|
+
x: x1 + nx * pw1,
|
|
25194
|
+
y: y1 + ny * pw1,
|
|
25195
|
+
pressure: 1
|
|
25196
|
+
});
|
|
25197
|
+
rightSide.push({
|
|
25198
|
+
x: x1 - nx * pw1,
|
|
25199
|
+
y: y1 - ny * pw1,
|
|
25200
|
+
pressure: 1
|
|
25201
|
+
});
|
|
25202
|
+
}
|
|
25203
|
+
dashRemaining -= step;
|
|
25204
|
+
if (dashRemaining <= 0) {
|
|
25205
|
+
if (dashOn && leftSide.length && rightSide.length) {
|
|
25206
|
+
const smoothLeft = this.getSplinePoints(leftSide, 4);
|
|
25207
|
+
const smoothRight = this.getSplinePoints(rightSide.reverse(), 4);
|
|
25208
|
+
ctx.beginPath();
|
|
25209
|
+
ctx.fillStyle = color;
|
|
25210
|
+
ctx.moveTo(smoothLeft[0].x, smoothLeft[0].y);
|
|
25211
|
+
for (const p of smoothLeft) ctx.lineTo(p.x, p.y);
|
|
25212
|
+
for (const p of smoothRight) ctx.lineTo(p.x, p.y);
|
|
25213
|
+
ctx.closePath();
|
|
25214
|
+
ctx.fill();
|
|
25215
|
+
}
|
|
25216
|
+
leftSide = [];
|
|
25217
|
+
rightSide = [];
|
|
25218
|
+
dashOn = !dashOn;
|
|
25219
|
+
dashIndex = (dashIndex + 1) % dash.length;
|
|
25220
|
+
dashRemaining = dash[dashIndex];
|
|
25221
|
+
}
|
|
25222
|
+
traveled += step;
|
|
25223
|
+
}
|
|
25224
|
+
}
|
|
25225
|
+
if (dashOn && leftSide.length && rightSide.length) {
|
|
25226
|
+
const smoothLeft = this.getSplinePoints(leftSide, 4);
|
|
25227
|
+
const smoothRight = this.getSplinePoints(rightSide.reverse(), 4);
|
|
25228
|
+
ctx.beginPath();
|
|
25229
|
+
ctx.fillStyle = color;
|
|
25230
|
+
ctx.moveTo(smoothLeft[0].x, smoothLeft[0].y);
|
|
25231
|
+
for (const p of smoothLeft) ctx.lineTo(p.x, p.y);
|
|
25232
|
+
for (const p of smoothRight) ctx.lineTo(p.x, p.y);
|
|
25233
|
+
ctx.closePath();
|
|
25234
|
+
ctx.fill();
|
|
25235
|
+
}
|
|
25236
|
+
}
|
|
25237
|
+
drawShape(ctx, shape) {
|
|
25238
|
+
const strokeElements = shape.getAttrs().strokeElements;
|
|
25239
|
+
if (strokeElements.length === 0) return;
|
|
25240
|
+
const color = shape.getAttrs().stroke ?? "black";
|
|
25241
|
+
const strokeWidth = shape.getAttrs().strokeWidth ?? 1;
|
|
25242
|
+
const dash = shape.getAttrs().dash ?? [];
|
|
25243
|
+
this.drawRibbonWithDash(ctx, strokeElements, strokeWidth, color, dash);
|
|
25221
25244
|
}
|
|
25222
25245
|
onRender(props) {
|
|
25223
25246
|
const stroke = new konva.default.Shape({
|
|
25224
25247
|
...props,
|
|
25225
25248
|
name: "node",
|
|
25226
25249
|
sceneFunc: (ctx, shape) => {
|
|
25227
|
-
|
|
25228
|
-
if (strokeElements.length === 0) return;
|
|
25229
|
-
if (strokeElements.length < 2) return;
|
|
25230
|
-
const color = shape.getAttrs().stroke ?? "black";
|
|
25231
|
-
const strokeWidth = shape.getAttrs().strokeWidth ?? 1;
|
|
25232
|
-
const smoothPoints = this.catmullRomSpline(strokeElements, this.config.smoothingFactor);
|
|
25233
|
-
const evenlySpaced = this.resamplePoints(smoothPoints, this.config.resamplingSpacing);
|
|
25234
|
-
const dashes = this.dashSegments(evenlySpaced, shape.getAttrs().dash || []);
|
|
25235
|
-
dashes.forEach((segment) => {
|
|
25236
|
-
const poly = this.buildPolygonFromPressure(segment, strokeWidth);
|
|
25237
|
-
if (!poly.length) return;
|
|
25238
|
-
ctx.beginPath();
|
|
25239
|
-
ctx.moveTo(poly[0].x, poly[0].y);
|
|
25240
|
-
for (let i = 1; i < poly.length; i++) ctx.lineTo(poly[i].x, poly[i].y);
|
|
25241
|
-
ctx.strokeStyle = color;
|
|
25242
|
-
ctx.lineCap = shape.getAttrs().lineCap ?? "butt";
|
|
25243
|
-
ctx.lineJoin = shape.getAttrs().lineJoin ?? "miter";
|
|
25244
|
-
ctx.closePath();
|
|
25245
|
-
ctx.fillStyle = color;
|
|
25246
|
-
ctx.fill();
|
|
25247
|
-
});
|
|
25250
|
+
this.drawShape(ctx, shape);
|
|
25248
25251
|
},
|
|
25249
25252
|
dashEnabled: false,
|
|
25250
25253
|
hitFunc: (context, shape) => {
|
|
@@ -25267,6 +25270,10 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
25267
25270
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
25268
25271
|
if (nodesSelectionPlugin) nodesSelectionPlugin.getTransformer().forceUpdate();
|
|
25269
25272
|
}
|
|
25273
|
+
getZoomPlugin() {
|
|
25274
|
+
const zoomPlugin = this.instance.getPlugin("stageZoom");
|
|
25275
|
+
return zoomPlugin;
|
|
25276
|
+
}
|
|
25270
25277
|
scaleReset(node) {
|
|
25271
25278
|
const strokeNode = node;
|
|
25272
25279
|
const oldPoints = [...strokeNode.getAttrs().strokeElements];
|
|
@@ -26781,7 +26788,6 @@ const BRUSH_TOOL_DEFAULT_CONFIG = { interpolationSteps: 10 };
|
|
|
26781
26788
|
//#region src/actions/brush-tool/brush-tool.ts
|
|
26782
26789
|
var WeaveBrushToolAction = class extends WeaveAction {
|
|
26783
26790
|
initialized = false;
|
|
26784
|
-
rawPoints = [];
|
|
26785
26791
|
onPropsChange = void 0;
|
|
26786
26792
|
onInit = void 0;
|
|
26787
26793
|
constructor(params) {
|
|
@@ -26805,10 +26811,9 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
26805
26811
|
opacity: 1
|
|
26806
26812
|
};
|
|
26807
26813
|
}
|
|
26808
|
-
|
|
26809
|
-
|
|
26810
|
-
|
|
26811
|
-
return pressure;
|
|
26814
|
+
getEventPressure(e) {
|
|
26815
|
+
if (e.evt.pointerType && e.evt.pointerType === "pen") return e.evt.pressure || .5;
|
|
26816
|
+
return .5;
|
|
26812
26817
|
}
|
|
26813
26818
|
setupEvents() {
|
|
26814
26819
|
const stage = this.instance.getStage();
|
|
@@ -26827,30 +26832,27 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
26827
26832
|
const handlePointerDown = (e) => {
|
|
26828
26833
|
if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
|
|
26829
26834
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
26830
|
-
const pointPressure = this.
|
|
26835
|
+
const pointPressure = this.getEventPressure(e);
|
|
26831
26836
|
this.handleStartStroke(pointPressure);
|
|
26832
26837
|
e.evt.stopPropagation();
|
|
26833
26838
|
};
|
|
26834
|
-
|
|
26835
|
-
else stage.on("pointerdown", handlePointerDown);
|
|
26839
|
+
stage.on("pointerdown", handlePointerDown);
|
|
26836
26840
|
const handlePointerMove = (e) => {
|
|
26837
26841
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
26838
26842
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
26839
26843
|
stage.container().style.cursor = "crosshair";
|
|
26840
|
-
const pointPressure = this.
|
|
26844
|
+
const pointPressure = this.getEventPressure(e);
|
|
26841
26845
|
this.handleMovement(pointPressure);
|
|
26842
26846
|
e.evt.stopPropagation();
|
|
26843
26847
|
};
|
|
26844
|
-
|
|
26845
|
-
else stage.on("pointermove", handlePointerMove);
|
|
26848
|
+
stage.on("pointermove", handlePointerMove);
|
|
26846
26849
|
const handlePointerUp = (e) => {
|
|
26847
26850
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
26848
26851
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
26849
26852
|
this.handleEndStroke();
|
|
26850
26853
|
e.evt.stopPropagation();
|
|
26851
26854
|
};
|
|
26852
|
-
|
|
26853
|
-
else stage.on("pointerup", handlePointerUp);
|
|
26855
|
+
stage.on("pointerup", handlePointerUp);
|
|
26854
26856
|
this.initialized = true;
|
|
26855
26857
|
}
|
|
26856
26858
|
setState(state) {
|
|
@@ -26908,24 +26910,6 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
26908
26910
|
}
|
|
26909
26911
|
this.setState(BRUSH_TOOL_STATE.DEFINE_STROKE);
|
|
26910
26912
|
}
|
|
26911
|
-
catmullRom1D(p0, p1, p2, p3, t) {
|
|
26912
|
-
const t2 = t * t;
|
|
26913
|
-
const t3 = t2 * t;
|
|
26914
|
-
return .5 * (2 * p1 + (-p0 + p2) * t + (2 * p0 - 5 * p1 + 4 * p2 - p3) * t2 + (-p0 + 3 * p1 - 3 * p2 + p3) * t3);
|
|
26915
|
-
}
|
|
26916
|
-
smoothInterpolation(last4Points, steps) {
|
|
26917
|
-
const [p0, p1, p2, p3] = last4Points;
|
|
26918
|
-
const pts = [];
|
|
26919
|
-
for (let i = 0; i <= steps; i++) {
|
|
26920
|
-
const t = i / steps;
|
|
26921
|
-
pts.push({
|
|
26922
|
-
x: this.catmullRom1D(p0.x, p1.x, p2.x, p3.x, t),
|
|
26923
|
-
y: this.catmullRom1D(p0.y, p1.y, p2.y, p3.y, t),
|
|
26924
|
-
pressure: this.catmullRom1D(p0.pressure, p1.pressure, p2.pressure, p3.pressure, t)
|
|
26925
|
-
});
|
|
26926
|
-
}
|
|
26927
|
-
return pts;
|
|
26928
|
-
}
|
|
26929
26913
|
handleMovement(pressure) {
|
|
26930
26914
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
26931
26915
|
const tempStroke = this.instance.getStage().findOne(`#${this.strokeId}`);
|
|
@@ -26936,16 +26920,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
26936
26920
|
y: mousePoint.y - tempStroke.y(),
|
|
26937
26921
|
pressure
|
|
26938
26922
|
};
|
|
26939
|
-
|
|
26940
|
-
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
26941
|
-
const smoothPoints = [];
|
|
26942
|
-
if (isIOS()) if (this.rawPoints.length >= 4) {
|
|
26943
|
-
const last4 = this.rawPoints.slice(-4);
|
|
26944
|
-
const interpolatedPts = this.smoothInterpolation(last4, this.config.interpolationSteps);
|
|
26945
|
-
smoothPoints.push(...interpolatedPts);
|
|
26946
|
-
} else smoothPoints.push(currentPoint);
|
|
26947
|
-
else smoothPoints.push(currentPoint);
|
|
26948
|
-
newStrokeElements = [...newStrokeElements, ...smoothPoints];
|
|
26923
|
+
const newStrokeElements = [...tempStroke.getAttrs().strokeElements, currentPoint];
|
|
26949
26924
|
const box = this.getBoundingBox(newStrokeElements);
|
|
26950
26925
|
tempStroke.setAttrs({
|
|
26951
26926
|
width: box.width,
|
|
@@ -26982,7 +26957,6 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
26982
26957
|
if (realNode) realNode.destroy();
|
|
26983
26958
|
if (tempStroke.getAttrs().strokeElements.length >= 3) this.instance.addNode(nodeHandler.serialize(tempStroke), this.container?.getAttrs().id);
|
|
26984
26959
|
}
|
|
26985
|
-
this.rawPoints = [];
|
|
26986
26960
|
this.clickPoint = null;
|
|
26987
26961
|
stage.container().style.cursor = "crosshair";
|
|
26988
26962
|
stage.container().tabIndex = 1;
|
|
@@ -27018,7 +26992,6 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
27018
26992
|
if (node) selectionPlugin.setSelectedNodes([node]);
|
|
27019
26993
|
this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
|
|
27020
26994
|
}
|
|
27021
|
-
this.rawPoints = [];
|
|
27022
26995
|
this.clickPoint = null;
|
|
27023
26996
|
this.setState(BRUSH_TOOL_STATE.INACTIVE);
|
|
27024
26997
|
}
|