@leafer-game/worker 1.0.9 → 1.1.0
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/worker.cjs +40 -20
- package/dist/worker.esm.js +41 -21
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +189 -120
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +189 -120
- package/dist/worker.module.min.js +1 -1
- package/package.json +4 -4
package/dist/worker.js
CHANGED
|
@@ -111,7 +111,7 @@ var LeaferUI = (function (exports) {
|
|
|
111
111
|
return rotation - oldRotation;
|
|
112
112
|
},
|
|
113
113
|
float(num, maxLength) {
|
|
114
|
-
const a = maxLength ? pow$2(10, maxLength) : 1000000000000;
|
|
114
|
+
const a = maxLength !== undefined ? pow$2(10, maxLength) : 1000000000000;
|
|
115
115
|
num = round$3(num * a) / a;
|
|
116
116
|
return num === -0 ? 0 : num;
|
|
117
117
|
},
|
|
@@ -1414,14 +1414,13 @@ var LeaferUI = (function (exports) {
|
|
|
1414
1414
|
list: {},
|
|
1415
1415
|
register(UI) {
|
|
1416
1416
|
const { __tag: tag } = UI.prototype;
|
|
1417
|
-
if (list$2[tag])
|
|
1417
|
+
if (list$2[tag])
|
|
1418
1418
|
debug$e.repeat(tag);
|
|
1419
|
-
|
|
1420
|
-
else {
|
|
1421
|
-
list$2[tag] = UI;
|
|
1422
|
-
}
|
|
1419
|
+
list$2[tag] = UI;
|
|
1423
1420
|
},
|
|
1424
1421
|
get(tag, data, x, y, width, height) {
|
|
1422
|
+
if (!list$2[tag])
|
|
1423
|
+
debug$e.error('not register ' + tag);
|
|
1425
1424
|
const ui = new list$2[tag](data);
|
|
1426
1425
|
if (x !== undefined) {
|
|
1427
1426
|
ui.x = x;
|
|
@@ -1445,7 +1444,7 @@ var LeaferUI = (function (exports) {
|
|
|
1445
1444
|
Object.keys(Event).forEach(key => {
|
|
1446
1445
|
name = Event[key];
|
|
1447
1446
|
if (typeof name === 'string')
|
|
1448
|
-
nameList[name]
|
|
1447
|
+
nameList[name] && debug$d.repeat(name), nameList[name] = Event;
|
|
1449
1448
|
});
|
|
1450
1449
|
},
|
|
1451
1450
|
changeName(oldName, newName) {
|
|
@@ -1647,7 +1646,7 @@ var LeaferUI = (function (exports) {
|
|
|
1647
1646
|
const t = this;
|
|
1648
1647
|
if (t.blendMode === 'pass-through') {
|
|
1649
1648
|
const leaf = this.__leaf;
|
|
1650
|
-
if ((t.opacity < 1 && leaf.isBranch) || leaf.__hasEraser || t.eraser) {
|
|
1649
|
+
if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser) {
|
|
1651
1650
|
t.__single = true;
|
|
1652
1651
|
}
|
|
1653
1652
|
else if (t.__single) {
|
|
@@ -2045,8 +2044,9 @@ var LeaferUI = (function (exports) {
|
|
|
2045
2044
|
takeCanvas = this.getSameCanvas();
|
|
2046
2045
|
takeCanvas.copyWorld(this);
|
|
2047
2046
|
}
|
|
2048
|
-
|
|
2049
|
-
|
|
2047
|
+
const s = this.size;
|
|
2048
|
+
DataHelper.copyAttrs(s, size, canvasSizeAttrs);
|
|
2049
|
+
canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
|
|
2050
2050
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2051
2051
|
if (this.context && !this.unreal) {
|
|
2052
2052
|
this.updateViewSize();
|
|
@@ -2160,6 +2160,17 @@ var LeaferUI = (function (exports) {
|
|
|
2160
2160
|
if (!onlyResetTransform)
|
|
2161
2161
|
this.useWorldTransform();
|
|
2162
2162
|
}
|
|
2163
|
+
useGrayscaleAlpha(bounds) {
|
|
2164
|
+
this.setTempBounds(bounds, true, true);
|
|
2165
|
+
let alpha, pixel;
|
|
2166
|
+
const { context } = this, imageData = context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height), { data } = imageData;
|
|
2167
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
2168
|
+
pixel = data[i] * 0.299 + data[i + 1] * 0.587 + data[i + 2] * 0.114;
|
|
2169
|
+
if (alpha = data[i + 3])
|
|
2170
|
+
data[i + 3] = alpha === 255 ? pixel : alpha * (pixel / 255);
|
|
2171
|
+
}
|
|
2172
|
+
context.putImageData(imageData, tempBounds$1.x, tempBounds$1.y);
|
|
2173
|
+
}
|
|
2163
2174
|
useMask(maskCanvas, fromBounds, toBounds) {
|
|
2164
2175
|
this.copyWorld(maskCanvas, fromBounds, toBounds, 'destination-in');
|
|
2165
2176
|
}
|
|
@@ -2170,7 +2181,7 @@ var LeaferUI = (function (exports) {
|
|
|
2170
2181
|
if (blendMode)
|
|
2171
2182
|
this.blendMode = blendMode;
|
|
2172
2183
|
this.fillStyle = color;
|
|
2173
|
-
|
|
2184
|
+
this.setTempBounds(bounds);
|
|
2174
2185
|
this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2175
2186
|
if (blendMode)
|
|
2176
2187
|
this.blendMode = 'source-over';
|
|
@@ -2179,22 +2190,18 @@ var LeaferUI = (function (exports) {
|
|
|
2179
2190
|
if (blendMode)
|
|
2180
2191
|
this.blendMode = blendMode;
|
|
2181
2192
|
this.strokeStyle = color;
|
|
2182
|
-
|
|
2193
|
+
this.setTempBounds(bounds);
|
|
2183
2194
|
this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2184
2195
|
if (blendMode)
|
|
2185
2196
|
this.blendMode = 'source-over';
|
|
2186
2197
|
}
|
|
2187
2198
|
clearWorld(bounds, ceilPixel) {
|
|
2188
|
-
|
|
2189
|
-
if (ceilPixel)
|
|
2190
|
-
tempBounds$1.ceil();
|
|
2199
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2191
2200
|
this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2192
2201
|
}
|
|
2193
2202
|
clipWorld(bounds, ceilPixel) {
|
|
2194
2203
|
this.beginPath();
|
|
2195
|
-
|
|
2196
|
-
if (ceilPixel)
|
|
2197
|
-
tempBounds$1.ceil();
|
|
2204
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2198
2205
|
this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2199
2206
|
this.clip();
|
|
2200
2207
|
}
|
|
@@ -2202,6 +2209,14 @@ var LeaferUI = (function (exports) {
|
|
|
2202
2209
|
const { pixelRatio } = this;
|
|
2203
2210
|
this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
|
|
2204
2211
|
}
|
|
2212
|
+
setTempBounds(bounds, ceil, intersect) {
|
|
2213
|
+
tempBounds$1.set(bounds);
|
|
2214
|
+
if (intersect)
|
|
2215
|
+
tempBounds$1.intersect(this.bounds);
|
|
2216
|
+
tempBounds$1.scale(this.pixelRatio);
|
|
2217
|
+
if (ceil)
|
|
2218
|
+
tempBounds$1.ceil();
|
|
2219
|
+
}
|
|
2205
2220
|
isSameSize(size) {
|
|
2206
2221
|
return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
|
|
2207
2222
|
}
|
|
@@ -4153,20 +4168,17 @@ var LeaferUI = (function (exports) {
|
|
|
4153
4168
|
}
|
|
4154
4169
|
return true;
|
|
4155
4170
|
},
|
|
4156
|
-
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4171
|
+
moveWorld(t, x, y = 0, isInnerPoint, transition) {
|
|
4157
4172
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4158
4173
|
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4159
|
-
L$1.moveLocal(t, local.x, local.y);
|
|
4174
|
+
L$1.moveLocal(t, local.x, local.y, transition);
|
|
4160
4175
|
},
|
|
4161
|
-
moveLocal(t, x, y = 0) {
|
|
4162
|
-
if (typeof x === 'object')
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
t.x += x;
|
|
4168
|
-
t.y += y;
|
|
4169
|
-
}
|
|
4176
|
+
moveLocal(t, x, y = 0, transition) {
|
|
4177
|
+
if (typeof x === 'object')
|
|
4178
|
+
y = x.y, x = x.x;
|
|
4179
|
+
x += t.x;
|
|
4180
|
+
y += t.y;
|
|
4181
|
+
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4170
4182
|
},
|
|
4171
4183
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
4172
4184
|
L$1.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -5215,13 +5227,14 @@ var LeaferUI = (function (exports) {
|
|
|
5215
5227
|
this.__.__checkSingle();
|
|
5216
5228
|
},
|
|
5217
5229
|
__render(canvas, options) {
|
|
5230
|
+
this.__nowWorld = this.__getNowWorld(options);
|
|
5218
5231
|
if (this.__worldOpacity) {
|
|
5219
5232
|
if (this.__.__single) {
|
|
5220
5233
|
if (this.__.eraser === 'path')
|
|
5221
5234
|
return this.__renderEraser(canvas, options);
|
|
5222
5235
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
5223
5236
|
this.__renderBranch(tempCanvas, options);
|
|
5224
|
-
const nowWorld = this.
|
|
5237
|
+
const nowWorld = this.__nowWorld;
|
|
5225
5238
|
canvas.opacity = this.__.opacity;
|
|
5226
5239
|
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true);
|
|
5227
5240
|
tempCanvas.recycle(nowWorld);
|
|
@@ -5545,11 +5558,11 @@ var LeaferUI = (function (exports) {
|
|
|
5545
5558
|
transform(matrix, resize) {
|
|
5546
5559
|
transform(this, matrix, resize);
|
|
5547
5560
|
}
|
|
5548
|
-
move(x, y) {
|
|
5549
|
-
moveLocal(this, x, y);
|
|
5561
|
+
move(x, y, transition) {
|
|
5562
|
+
moveLocal(this, x, y, transition);
|
|
5550
5563
|
}
|
|
5551
|
-
moveInner(x, y) {
|
|
5552
|
-
moveWorld(this, x, y, true);
|
|
5564
|
+
moveInner(x, y, transition) {
|
|
5565
|
+
moveWorld(this, x, y, true, transition);
|
|
5553
5566
|
}
|
|
5554
5567
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5555
5568
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
@@ -5563,8 +5576,8 @@ var LeaferUI = (function (exports) {
|
|
|
5563
5576
|
transformWorld(worldTransform, resize) {
|
|
5564
5577
|
transformWorld(this, worldTransform, resize);
|
|
5565
5578
|
}
|
|
5566
|
-
moveWorld(x, y) {
|
|
5567
|
-
moveWorld(this, x, y);
|
|
5579
|
+
moveWorld(x, y, transition) {
|
|
5580
|
+
moveWorld(this, x, y, false, transition);
|
|
5568
5581
|
}
|
|
5569
5582
|
scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
|
|
5570
5583
|
zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
|
|
@@ -5962,7 +5975,7 @@ var LeaferUI = (function (exports) {
|
|
|
5962
5975
|
}
|
|
5963
5976
|
}
|
|
5964
5977
|
|
|
5965
|
-
const version = "1.0
|
|
5978
|
+
const version = "1.1.0";
|
|
5966
5979
|
|
|
5967
5980
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5968
5981
|
get allowBackgroundColor() { return true; }
|
|
@@ -6431,7 +6444,8 @@ var LeaferUI = (function (exports) {
|
|
|
6431
6444
|
this.totalBounds = new Bounds();
|
|
6432
6445
|
debug$5.log(target.innerName, '--->');
|
|
6433
6446
|
try {
|
|
6434
|
-
target.
|
|
6447
|
+
if (!target.isApp)
|
|
6448
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6435
6449
|
this.emitRender(RenderEvent.START);
|
|
6436
6450
|
this.renderOnce(callback);
|
|
6437
6451
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6985,6 +6999,12 @@ var LeaferUI = (function (exports) {
|
|
|
6985
6999
|
return strokeWidth;
|
|
6986
7000
|
}
|
|
6987
7001
|
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
7002
|
+
get __hasMultiPaint() {
|
|
7003
|
+
const t = this;
|
|
7004
|
+
if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
|
|
7005
|
+
return true;
|
|
7006
|
+
return t.fill && this.__hasStroke;
|
|
7007
|
+
}
|
|
6988
7008
|
get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
|
|
6989
7009
|
get __autoWidth() { return !this._width; }
|
|
6990
7010
|
get __autoHeight() { return !this._height; }
|
|
@@ -7354,9 +7374,8 @@ var LeaferUI = (function (exports) {
|
|
|
7354
7374
|
canvas.strokeRect(half, half, width, height);
|
|
7355
7375
|
canvas.restore();
|
|
7356
7376
|
}
|
|
7357
|
-
else
|
|
7377
|
+
else
|
|
7358
7378
|
canvas.strokeRect(half, half, width, height);
|
|
7359
|
-
}
|
|
7360
7379
|
break;
|
|
7361
7380
|
case 'outside':
|
|
7362
7381
|
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
|
|
@@ -7386,11 +7405,15 @@ var LeaferUI = (function (exports) {
|
|
|
7386
7405
|
super(data);
|
|
7387
7406
|
}
|
|
7388
7407
|
reset(_data) { }
|
|
7389
|
-
set(data,
|
|
7390
|
-
if (
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7408
|
+
set(data, transition) {
|
|
7409
|
+
if (transition) {
|
|
7410
|
+
if (transition === 'temp') {
|
|
7411
|
+
this.lockNormalStyle = true;
|
|
7412
|
+
Object.assign(this, data);
|
|
7413
|
+
this.lockNormalStyle = false;
|
|
7414
|
+
}
|
|
7415
|
+
else
|
|
7416
|
+
this.animate(data, transition);
|
|
7394
7417
|
}
|
|
7395
7418
|
else
|
|
7396
7419
|
Object.assign(this, data);
|
|
@@ -7581,6 +7604,15 @@ var LeaferUI = (function (exports) {
|
|
|
7581
7604
|
__decorate([
|
|
7582
7605
|
boundsType(0)
|
|
7583
7606
|
], exports.UI.prototype, "padding", void 0);
|
|
7607
|
+
__decorate([
|
|
7608
|
+
boundsType(false)
|
|
7609
|
+
], exports.UI.prototype, "lockRatio", void 0);
|
|
7610
|
+
__decorate([
|
|
7611
|
+
boundsType()
|
|
7612
|
+
], exports.UI.prototype, "widthRange", void 0);
|
|
7613
|
+
__decorate([
|
|
7614
|
+
boundsType()
|
|
7615
|
+
], exports.UI.prototype, "heightRange", void 0);
|
|
7584
7616
|
__decorate([
|
|
7585
7617
|
dataType(false)
|
|
7586
7618
|
], exports.UI.prototype, "draggable", void 0);
|
|
@@ -7691,17 +7723,17 @@ var LeaferUI = (function (exports) {
|
|
|
7691
7723
|
if (!this.children)
|
|
7692
7724
|
this.children = [];
|
|
7693
7725
|
}
|
|
7694
|
-
set(data,
|
|
7726
|
+
set(data, transition) {
|
|
7695
7727
|
if (data.children) {
|
|
7696
7728
|
const { children } = data;
|
|
7697
7729
|
delete data.children;
|
|
7698
7730
|
this.children ? this.clear() : this.__setBranch();
|
|
7699
|
-
super.set(data,
|
|
7731
|
+
super.set(data, transition);
|
|
7700
7732
|
children.forEach(child => this.add(child));
|
|
7701
7733
|
data.children = children;
|
|
7702
7734
|
}
|
|
7703
7735
|
else
|
|
7704
|
-
super.set(data,
|
|
7736
|
+
super.set(data, transition);
|
|
7705
7737
|
}
|
|
7706
7738
|
toJSON(options) {
|
|
7707
7739
|
const data = super.toJSON(options);
|
|
@@ -7814,8 +7846,8 @@ var LeaferUI = (function (exports) {
|
|
|
7814
7846
|
}
|
|
7815
7847
|
onInit() { }
|
|
7816
7848
|
initType(_type) { }
|
|
7817
|
-
set(data) {
|
|
7818
|
-
this.waitInit(() => { super.set(data); });
|
|
7849
|
+
set(data, transition) {
|
|
7850
|
+
this.waitInit(() => { super.set(data, transition); });
|
|
7819
7851
|
}
|
|
7820
7852
|
start() {
|
|
7821
7853
|
clearTimeout(this.__startTimer);
|
|
@@ -7872,8 +7904,6 @@ var LeaferUI = (function (exports) {
|
|
|
7872
7904
|
__onResize(event) {
|
|
7873
7905
|
this.emitEvent(event);
|
|
7874
7906
|
DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
|
|
7875
|
-
if (!event.width || !event.height)
|
|
7876
|
-
debug$3.warn('w = 0 or h = 0');
|
|
7877
7907
|
setTimeout(() => { if (this.canvasManager)
|
|
7878
7908
|
this.canvasManager.clearRecycled(); }, 0);
|
|
7879
7909
|
}
|
|
@@ -8198,9 +8228,6 @@ var LeaferUI = (function (exports) {
|
|
|
8198
8228
|
__decorate([
|
|
8199
8229
|
dataType(false)
|
|
8200
8230
|
], exports.Box.prototype, "resizeChildren", void 0);
|
|
8201
|
-
__decorate([
|
|
8202
|
-
dataType(false)
|
|
8203
|
-
], exports.Box.prototype, "textBox", void 0);
|
|
8204
8231
|
__decorate([
|
|
8205
8232
|
affectRenderBoundsType('show')
|
|
8206
8233
|
], exports.Box.prototype, "overflow", void 0);
|
|
@@ -8310,7 +8337,7 @@ var LeaferUI = (function (exports) {
|
|
|
8310
8337
|
], exports.Ellipse);
|
|
8311
8338
|
|
|
8312
8339
|
const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
|
|
8313
|
-
const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$
|
|
8340
|
+
const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$3, defaultPoint } = PointHelper;
|
|
8314
8341
|
const { toBounds: toBounds$1 } = PathBounds;
|
|
8315
8342
|
exports.Line = class Line extends exports.UI {
|
|
8316
8343
|
get __tag() { return 'Line'; }
|
|
@@ -8324,7 +8351,7 @@ var LeaferUI = (function (exports) {
|
|
|
8324
8351
|
return to;
|
|
8325
8352
|
}
|
|
8326
8353
|
set toPoint(value) {
|
|
8327
|
-
this.width = getDistance$
|
|
8354
|
+
this.width = getDistance$3(defaultPoint, value);
|
|
8328
8355
|
this.rotation = getAngle$1(defaultPoint, value);
|
|
8329
8356
|
if (this.height)
|
|
8330
8357
|
this.height = 0;
|
|
@@ -8955,19 +8982,13 @@ var LeaferUI = (function (exports) {
|
|
|
8955
8982
|
Object.assign(this, params);
|
|
8956
8983
|
}
|
|
8957
8984
|
getBoxPoint(relative) {
|
|
8958
|
-
|
|
8959
|
-
relative = this.current;
|
|
8960
|
-
return relative.getBoxPoint(this);
|
|
8985
|
+
return (relative || this.current).getBoxPoint(this);
|
|
8961
8986
|
}
|
|
8962
8987
|
getInnerPoint(relative) {
|
|
8963
|
-
|
|
8964
|
-
relative = this.current;
|
|
8965
|
-
return relative.getInnerPoint(this);
|
|
8988
|
+
return (relative || this.current).getInnerPoint(this);
|
|
8966
8989
|
}
|
|
8967
8990
|
getLocalPoint(relative) {
|
|
8968
|
-
|
|
8969
|
-
relative = this.current;
|
|
8970
|
-
return relative.getLocalPoint(this);
|
|
8991
|
+
return (relative || this.current).getLocalPoint(this);
|
|
8971
8992
|
}
|
|
8972
8993
|
getPagePoint() {
|
|
8973
8994
|
return this.current.getPagePoint(this);
|
|
@@ -9015,10 +9036,8 @@ var LeaferUI = (function (exports) {
|
|
|
9015
9036
|
this.data = data;
|
|
9016
9037
|
}
|
|
9017
9038
|
static getValidMove(leaf, start, total) {
|
|
9018
|
-
const { draggable, dragBounds
|
|
9019
|
-
|
|
9020
|
-
move.x += start.x - x;
|
|
9021
|
-
move.y += start.y - y;
|
|
9039
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9040
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9022
9041
|
if (dragBounds)
|
|
9023
9042
|
this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9024
9043
|
if (draggable === 'x')
|
|
@@ -9028,8 +9047,7 @@ var LeaferUI = (function (exports) {
|
|
|
9028
9047
|
return move;
|
|
9029
9048
|
}
|
|
9030
9049
|
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9031
|
-
const x = childBox.x + move.x, y = childBox.y + move.y;
|
|
9032
|
-
const right = x + childBox.width, bottom = y + childBox.height;
|
|
9050
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9033
9051
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9034
9052
|
if (!change)
|
|
9035
9053
|
move = Object.assign({}, move);
|
|
@@ -9081,9 +9099,7 @@ var LeaferUI = (function (exports) {
|
|
|
9081
9099
|
return this.getLocalMove(relative, true);
|
|
9082
9100
|
}
|
|
9083
9101
|
getPageBounds() {
|
|
9084
|
-
const total = this.getPageTotal();
|
|
9085
|
-
const start = this.getPagePoint();
|
|
9086
|
-
const bounds = {};
|
|
9102
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9087
9103
|
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9088
9104
|
BoundsHelper.unsign(bounds);
|
|
9089
9105
|
return bounds;
|
|
@@ -9201,7 +9217,8 @@ var LeaferUI = (function (exports) {
|
|
|
9201
9217
|
const LeaferTypeCreator = {
|
|
9202
9218
|
list: {},
|
|
9203
9219
|
register(name, fn) {
|
|
9204
|
-
list[name]
|
|
9220
|
+
list[name] && debug$2.repeat(name);
|
|
9221
|
+
list[name] = fn;
|
|
9205
9222
|
},
|
|
9206
9223
|
run(name, leafer) {
|
|
9207
9224
|
const fn = list[name];
|
|
@@ -10470,6 +10487,8 @@ var LeaferUI = (function (exports) {
|
|
|
10470
10487
|
case 'center':
|
|
10471
10488
|
canvas.setStroke(stroke, __strokeWidth, options);
|
|
10472
10489
|
canvas.stroke();
|
|
10490
|
+
if (options.__useArrow)
|
|
10491
|
+
strokeArrow(ui, canvas);
|
|
10473
10492
|
break;
|
|
10474
10493
|
case 'inside':
|
|
10475
10494
|
canvas.save();
|
|
@@ -10507,6 +10526,8 @@ var LeaferUI = (function (exports) {
|
|
|
10507
10526
|
case 'center':
|
|
10508
10527
|
canvas.setStroke(undefined, __strokeWidth, options);
|
|
10509
10528
|
drawStrokesStyle(strokes, false, ui, canvas);
|
|
10529
|
+
if (options.__useArrow)
|
|
10530
|
+
strokeArrow(ui, canvas);
|
|
10510
10531
|
break;
|
|
10511
10532
|
case 'inside':
|
|
10512
10533
|
canvas.save();
|
|
@@ -10532,6 +10553,14 @@ var LeaferUI = (function (exports) {
|
|
|
10532
10553
|
}
|
|
10533
10554
|
}
|
|
10534
10555
|
}
|
|
10556
|
+
function strokeArrow(ui, canvas) {
|
|
10557
|
+
if (ui.__.dashPattern) {
|
|
10558
|
+
canvas.beginPath();
|
|
10559
|
+
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
10560
|
+
canvas.dashPattern = null;
|
|
10561
|
+
canvas.stroke();
|
|
10562
|
+
}
|
|
10563
|
+
}
|
|
10535
10564
|
|
|
10536
10565
|
const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
|
|
10537
10566
|
function shape(ui, current, options) {
|
|
@@ -11034,7 +11063,7 @@ var LeaferUI = (function (exports) {
|
|
|
11034
11063
|
}
|
|
11035
11064
|
}
|
|
11036
11065
|
|
|
11037
|
-
const { getAngle, getDistance: getDistance$
|
|
11066
|
+
const { getAngle, getDistance: getDistance$2 } = PointHelper;
|
|
11038
11067
|
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
|
|
11039
11068
|
const { toPoint: toPoint$1 } = AroundHelper;
|
|
11040
11069
|
const realFrom$1 = {};
|
|
@@ -11043,7 +11072,7 @@ var LeaferUI = (function (exports) {
|
|
|
11043
11072
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
11044
11073
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
11045
11074
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
11046
|
-
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$
|
|
11075
|
+
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$2(realFrom$1, realTo$1));
|
|
11047
11076
|
applyStops(style, paint.stops, opacity);
|
|
11048
11077
|
const data = { type, style };
|
|
11049
11078
|
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
@@ -11071,7 +11100,7 @@ var LeaferUI = (function (exports) {
|
|
|
11071
11100
|
return transform;
|
|
11072
11101
|
}
|
|
11073
11102
|
|
|
11074
|
-
const { getDistance } = PointHelper;
|
|
11103
|
+
const { getDistance: getDistance$1 } = PointHelper;
|
|
11075
11104
|
const { toPoint } = AroundHelper;
|
|
11076
11105
|
const realFrom = {};
|
|
11077
11106
|
const realTo = {};
|
|
@@ -11079,7 +11108,7 @@ var LeaferUI = (function (exports) {
|
|
|
11079
11108
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
11080
11109
|
toPoint(from || 'center', box, realFrom);
|
|
11081
11110
|
toPoint(to || 'bottom', box, realTo);
|
|
11082
|
-
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
|
|
11111
|
+
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance$1(realFrom, realTo));
|
|
11083
11112
|
applyStops(style, paint.stops, opacity);
|
|
11084
11113
|
const data = { type, style };
|
|
11085
11114
|
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
@@ -11217,16 +11246,16 @@ var LeaferUI = (function (exports) {
|
|
|
11217
11246
|
|
|
11218
11247
|
const { excludeRenderBounds } = LeafBoundsHelper;
|
|
11219
11248
|
exports.Group.prototype.__renderMask = function (canvas, options) {
|
|
11220
|
-
let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
|
|
11249
|
+
let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
|
|
11221
11250
|
const { children } = this;
|
|
11222
11251
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
11223
|
-
child = children[i];
|
|
11224
|
-
if (
|
|
11252
|
+
child = children[i], mask = child.__.mask;
|
|
11253
|
+
if (mask) {
|
|
11225
11254
|
if (currentMask) {
|
|
11226
11255
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
11227
11256
|
maskCanvas = contentCanvas = null;
|
|
11228
11257
|
}
|
|
11229
|
-
if (
|
|
11258
|
+
if (mask === 'path' || mask === 'clipping-path') {
|
|
11230
11259
|
if (child.opacity < 1) {
|
|
11231
11260
|
currentMask = 'opacity-path';
|
|
11232
11261
|
maskOpacity = child.opacity;
|
|
@@ -11240,14 +11269,14 @@ var LeaferUI = (function (exports) {
|
|
|
11240
11269
|
child.__clip(contentCanvas || canvas, options);
|
|
11241
11270
|
}
|
|
11242
11271
|
else {
|
|
11243
|
-
currentMask = 'alpha';
|
|
11272
|
+
currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
|
|
11244
11273
|
if (!maskCanvas)
|
|
11245
11274
|
maskCanvas = getCanvas(canvas);
|
|
11246
11275
|
if (!contentCanvas)
|
|
11247
11276
|
contentCanvas = getCanvas(canvas);
|
|
11248
11277
|
child.__render(maskCanvas, options);
|
|
11249
11278
|
}
|
|
11250
|
-
if (
|
|
11279
|
+
if (!(mask === 'clipping' || mask === 'clipping-path'))
|
|
11251
11280
|
continue;
|
|
11252
11281
|
}
|
|
11253
11282
|
if (excludeRenderBounds(child, options))
|
|
@@ -11258,6 +11287,8 @@ var LeaferUI = (function (exports) {
|
|
|
11258
11287
|
};
|
|
11259
11288
|
function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
|
|
11260
11289
|
switch (maskMode) {
|
|
11290
|
+
case 'grayscale':
|
|
11291
|
+
maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
|
|
11261
11292
|
case 'alpha':
|
|
11262
11293
|
usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
|
|
11263
11294
|
break;
|
|
@@ -11962,15 +11993,12 @@ var LeaferUI = (function (exports) {
|
|
|
11962
11993
|
const debug = Debug.get('@leafer-ui/export');
|
|
11963
11994
|
canvas.export = function (filename, options) {
|
|
11964
11995
|
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
11965
|
-
if (filename.includes('.'))
|
|
11996
|
+
if (filename.includes('.'))
|
|
11966
11997
|
return this.saveAs(filename, quality);
|
|
11967
|
-
|
|
11968
|
-
else if (blob) {
|
|
11998
|
+
else if (blob)
|
|
11969
11999
|
return this.toBlob(filename, quality);
|
|
11970
|
-
|
|
11971
|
-
else {
|
|
12000
|
+
else
|
|
11972
12001
|
return this.toDataURL(filename, quality);
|
|
11973
|
-
}
|
|
11974
12002
|
};
|
|
11975
12003
|
canvas.toBlob = function (type, quality) {
|
|
11976
12004
|
return new Promise((resolve) => {
|
|
@@ -12059,15 +12087,18 @@ var LeaferUI = (function (exports) {
|
|
|
12059
12087
|
if (typeof action === 'number') {
|
|
12060
12088
|
this.now = action;
|
|
12061
12089
|
}
|
|
12062
|
-
else if (action
|
|
12063
|
-
const
|
|
12090
|
+
else if (typeof action === 'object') {
|
|
12091
|
+
const isArray = action instanceof Array;
|
|
12092
|
+
const keyframes = isArray ? action : action.keyframes;
|
|
12093
|
+
this.__action = isArray ? undefined : action;
|
|
12094
|
+
const { length } = keyframes;
|
|
12064
12095
|
if (length > 1) {
|
|
12065
|
-
const start = this.now =
|
|
12096
|
+
const start = this.now = keyframes[0], end = keyframes[keyframes.length - 1];
|
|
12066
12097
|
this.play();
|
|
12067
12098
|
this.__runAction(start, end);
|
|
12068
12099
|
}
|
|
12069
12100
|
else if (length)
|
|
12070
|
-
this.now =
|
|
12101
|
+
this.now = keyframes[0];
|
|
12071
12102
|
}
|
|
12072
12103
|
}
|
|
12073
12104
|
__loadRobot(frame, start, end) {
|
|
@@ -12095,16 +12126,26 @@ var LeaferUI = (function (exports) {
|
|
|
12095
12126
|
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
12096
12127
|
}
|
|
12097
12128
|
__runAction(start, end) {
|
|
12129
|
+
let { FPS, loop, __action: a } = this;
|
|
12130
|
+
if (a) {
|
|
12131
|
+
if (a.FPS)
|
|
12132
|
+
FPS = a.FPS;
|
|
12133
|
+
if (a.loop !== undefined)
|
|
12134
|
+
loop = a.loop;
|
|
12135
|
+
}
|
|
12098
12136
|
this.__timer = setTimeout(() => {
|
|
12099
12137
|
if (this.running) {
|
|
12100
|
-
if (this.now === end)
|
|
12138
|
+
if (this.now === end) {
|
|
12139
|
+
if (!loop)
|
|
12140
|
+
return this.stop();
|
|
12101
12141
|
this.now = start;
|
|
12142
|
+
}
|
|
12102
12143
|
else
|
|
12103
12144
|
this.now++;
|
|
12104
12145
|
this.__updateRobotBounds();
|
|
12105
12146
|
}
|
|
12106
12147
|
this.__runAction(start, end);
|
|
12107
|
-
}, 1000 /
|
|
12148
|
+
}, 1000 / FPS);
|
|
12108
12149
|
}
|
|
12109
12150
|
__updateRobotBounds() {
|
|
12110
12151
|
const { nowFrame } = this;
|
|
@@ -12217,7 +12258,7 @@ var LeaferUI = (function (exports) {
|
|
|
12217
12258
|
const fromStyle = transition ? getFromStyle(leaf, style) : undefined;
|
|
12218
12259
|
leaf.killAnimate('transition');
|
|
12219
12260
|
if (normalStyle)
|
|
12220
|
-
leaf.set(normalStyle,
|
|
12261
|
+
leaf.set(normalStyle, 'temp');
|
|
12221
12262
|
const statesStyle = getStyle(leaf);
|
|
12222
12263
|
if (statesStyle) {
|
|
12223
12264
|
const { animation } = statesStyle;
|
|
@@ -12231,14 +12272,14 @@ var LeaferUI = (function (exports) {
|
|
|
12231
12272
|
delete statesStyle.animation;
|
|
12232
12273
|
}
|
|
12233
12274
|
leaf.normalStyle = filterStyle(statesStyle, leaf);
|
|
12234
|
-
leaf.set(statesStyle,
|
|
12275
|
+
leaf.set(statesStyle, 'temp');
|
|
12235
12276
|
}
|
|
12236
12277
|
else {
|
|
12237
12278
|
leaf.normalStyle = undefined;
|
|
12238
12279
|
}
|
|
12239
12280
|
if (transition) {
|
|
12240
12281
|
const toStyle = filterStyle(fromStyle, leaf);
|
|
12241
|
-
leaf.set(fromStyle,
|
|
12282
|
+
leaf.set(fromStyle, 'temp');
|
|
12242
12283
|
leaf.animate([fromStyle, toStyle], transition, 'transition', true);
|
|
12243
12284
|
}
|
|
12244
12285
|
leaf.__layout.stateStyleChanged = false;
|
|
@@ -12700,7 +12741,8 @@ var LeaferUI = (function (exports) {
|
|
|
12700
12741
|
return;
|
|
12701
12742
|
if (typeof time === 'object')
|
|
12702
12743
|
time = UnitConvert.number(time, this.duration);
|
|
12703
|
-
time
|
|
12744
|
+
if (time)
|
|
12745
|
+
time /= this.speed;
|
|
12704
12746
|
if (!this.started || time < this.time)
|
|
12705
12747
|
this.start(true);
|
|
12706
12748
|
this.time = time;
|
|
@@ -12935,7 +12977,7 @@ var LeaferUI = (function (exports) {
|
|
|
12935
12977
|
this.emit(AnimateEvent.UPDATE, this);
|
|
12936
12978
|
}
|
|
12937
12979
|
setStyle(style) {
|
|
12938
|
-
this.target.set(style, this.isTemp);
|
|
12980
|
+
this.target.set(style, this.isTemp ? 'temp' : false);
|
|
12939
12981
|
}
|
|
12940
12982
|
clearTimer(fn) {
|
|
12941
12983
|
if (this.timer) {
|
|
@@ -13311,6 +13353,9 @@ var LeaferUI = (function (exports) {
|
|
|
13311
13353
|
from = fourNumber(from), to = fourNumber(to);
|
|
13312
13354
|
return from.map((f, i) => number(f, to[i], t));
|
|
13313
13355
|
},
|
|
13356
|
+
text(from, to, t) {
|
|
13357
|
+
return (typeof from === 'number' || typeof to === 'number') ? MathHelper.float(number(from, to, t), Math.max(getDecimalLen(from), getDecimalLen(to))) : to;
|
|
13358
|
+
},
|
|
13314
13359
|
shadow,
|
|
13315
13360
|
innerShadow: shadow
|
|
13316
13361
|
};
|
|
@@ -13319,6 +13364,10 @@ var LeaferUI = (function (exports) {
|
|
|
13319
13364
|
number,
|
|
13320
13365
|
color
|
|
13321
13366
|
};
|
|
13367
|
+
function getDecimalLen(num) {
|
|
13368
|
+
const decimal = String(num).split('.')[1];
|
|
13369
|
+
return decimal ? decimal.length : 0;
|
|
13370
|
+
}
|
|
13322
13371
|
function value(from, to, t) {
|
|
13323
13372
|
return (typeof from === 'number' && typeof to === 'number') ? from + (to - from) * t : to;
|
|
13324
13373
|
}
|
|
@@ -13387,23 +13436,40 @@ var LeaferUI = (function (exports) {
|
|
|
13387
13436
|
const gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443];
|
|
13388
13437
|
const { sqrt } = Math;
|
|
13389
13438
|
const HighBezierHelper = {
|
|
13390
|
-
getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY) {
|
|
13391
|
-
let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y;
|
|
13439
|
+
getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, t = 1) {
|
|
13440
|
+
let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y, half = t / 2;
|
|
13392
13441
|
for (let i = 0; i < gaussNodes.length; i++) {
|
|
13393
|
-
t1 =
|
|
13394
|
-
t2 =
|
|
13442
|
+
t1 = half * (1 + gaussNodes[i]);
|
|
13443
|
+
t2 = half * (1 - gaussNodes[i]);
|
|
13395
13444
|
d1X = getDerivative(t1, fromX, x1, x2, toX);
|
|
13396
13445
|
d1Y = getDerivative(t1, fromY, y1, y2, toY);
|
|
13397
13446
|
d2X = getDerivative(t2, fromX, x1, x2, toX);
|
|
13398
13447
|
d2Y = getDerivative(t2, fromY, y1, y2, toY);
|
|
13399
13448
|
distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y));
|
|
13400
13449
|
}
|
|
13401
|
-
return distance *
|
|
13450
|
+
return distance * half;
|
|
13402
13451
|
},
|
|
13403
13452
|
getDerivative(t, fromV, v1, v2, toV) {
|
|
13404
13453
|
const o = 1 - t;
|
|
13405
13454
|
return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
|
|
13406
13455
|
},
|
|
13456
|
+
getRotation(t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
|
|
13457
|
+
const dx = getDerivative(t, fromX, x1, x2, toX);
|
|
13458
|
+
const dy = getDerivative(t, fromY, y1, y2, toY);
|
|
13459
|
+
return Math.atan2(dy, dx) / OneRadian;
|
|
13460
|
+
},
|
|
13461
|
+
getT(distance, totalDistance, fromX, fromY, x1, y1, x2, y2, toX, toY, precision = 1) {
|
|
13462
|
+
let low = 0, high = 1, middle = distance / totalDistance, realPrecision = precision / totalDistance / 3;
|
|
13463
|
+
if (middle >= 1)
|
|
13464
|
+
return 1;
|
|
13465
|
+
if (middle <= 0)
|
|
13466
|
+
return 0;
|
|
13467
|
+
while (high - low > realPrecision) {
|
|
13468
|
+
getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, middle) < distance ? low = middle : high = middle;
|
|
13469
|
+
middle = (low + high) / 2;
|
|
13470
|
+
}
|
|
13471
|
+
return middle;
|
|
13472
|
+
},
|
|
13407
13473
|
cut(data, t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
|
|
13408
13474
|
const o = 1 - t;
|
|
13409
13475
|
const ax = o * fromX + t * x1, ay = o * fromY + t * y1;
|
|
@@ -13415,7 +13481,7 @@ var LeaferUI = (function (exports) {
|
|
|
13415
13481
|
data.push(PathCommandMap.C, ax, ay, bx, by, cx, cy);
|
|
13416
13482
|
}
|
|
13417
13483
|
};
|
|
13418
|
-
const { getDerivative } = HighBezierHelper;
|
|
13484
|
+
const { getDerivative, getDistance } = HighBezierHelper;
|
|
13419
13485
|
|
|
13420
13486
|
const { M, L, C, Z } = PathCommandMap;
|
|
13421
13487
|
const tempPoint = {}, tempFrom = {};
|
|
@@ -13483,11 +13549,12 @@ var LeaferUI = (function (exports) {
|
|
|
13483
13549
|
}
|
|
13484
13550
|
return { total, segments, data };
|
|
13485
13551
|
},
|
|
13486
|
-
getDistancePoint(distanceData, motionDistance) {
|
|
13552
|
+
getDistancePoint(distanceData, motionDistance, motionPrecision) {
|
|
13487
13553
|
const { segments, data } = distanceData;
|
|
13488
13554
|
motionDistance = UnitConvert.number(motionDistance, distanceData.total);
|
|
13489
13555
|
let total = 0, distance, to = {};
|
|
13490
13556
|
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
13557
|
+
let x1, y1, x2, y2, t;
|
|
13491
13558
|
const len = data.length;
|
|
13492
13559
|
while (i < len) {
|
|
13493
13560
|
command = data[i];
|
|
@@ -13517,11 +13584,10 @@ var LeaferUI = (function (exports) {
|
|
|
13517
13584
|
toY = data[i + 6];
|
|
13518
13585
|
distance = segments[index];
|
|
13519
13586
|
if (total + distance > motionDistance) {
|
|
13520
|
-
|
|
13521
|
-
motionDistance
|
|
13522
|
-
BezierHelper.getPointAndSet(
|
|
13523
|
-
|
|
13524
|
-
to.rotation = PointHelper.getAngle(tempFrom, to);
|
|
13587
|
+
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
13588
|
+
t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
13589
|
+
BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
|
|
13590
|
+
to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
|
|
13525
13591
|
return to;
|
|
13526
13592
|
}
|
|
13527
13593
|
x = toX;
|
|
@@ -13538,11 +13604,12 @@ var LeaferUI = (function (exports) {
|
|
|
13538
13604
|
}
|
|
13539
13605
|
return to;
|
|
13540
13606
|
},
|
|
13541
|
-
getDistancePath(distanceData, motionDistance) {
|
|
13607
|
+
getDistancePath(distanceData, motionDistance, motionPrecision) {
|
|
13542
13608
|
const { segments, data } = distanceData, path = [];
|
|
13543
13609
|
motionDistance = UnitConvert.number(motionDistance, distanceData.total);
|
|
13544
13610
|
let total = 0, distance, to = {};
|
|
13545
13611
|
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
13612
|
+
let x1, y1, x2, y2, t;
|
|
13546
13613
|
const len = data.length;
|
|
13547
13614
|
while (i < len) {
|
|
13548
13615
|
command = data[i];
|
|
@@ -13569,12 +13636,13 @@ var LeaferUI = (function (exports) {
|
|
|
13569
13636
|
path.push(command, x, y);
|
|
13570
13637
|
break;
|
|
13571
13638
|
case C:
|
|
13572
|
-
|
|
13639
|
+
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
13573
13640
|
toX = data[i + 5];
|
|
13574
13641
|
toY = data[i + 6];
|
|
13575
13642
|
distance = segments[index];
|
|
13576
13643
|
if (total + distance > motionDistance) {
|
|
13577
|
-
HighBezierHelper.
|
|
13644
|
+
t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
13645
|
+
HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
|
|
13578
13646
|
return path;
|
|
13579
13647
|
}
|
|
13580
13648
|
x = toX;
|
|
@@ -13623,6 +13691,7 @@ var LeaferUI = (function (exports) {
|
|
|
13623
13691
|
const { updateMatrix, updateAllMatrix } = LeafHelper;
|
|
13624
13692
|
const { updateBounds } = BranchHelper;
|
|
13625
13693
|
motionPathType()(ui, 'motionPath');
|
|
13694
|
+
motionPathType(1)(ui, 'motionPrecision');
|
|
13626
13695
|
motionPathType()(ui, 'motion');
|
|
13627
13696
|
motionPathType(true)(ui, 'motionRotation');
|
|
13628
13697
|
ui.getMotionPathData = function () {
|
|
@@ -13633,7 +13702,7 @@ var LeaferUI = (function (exports) {
|
|
|
13633
13702
|
const data = getMotionPathData(path);
|
|
13634
13703
|
if (!data.total)
|
|
13635
13704
|
return {};
|
|
13636
|
-
const point = HighCurveHelper.getDistancePoint(data, motionDistance);
|
|
13705
|
+
const point = HighCurveHelper.getDistancePoint(data, motionDistance, path.motionPrecision);
|
|
13637
13706
|
MatrixHelper.toOuterPoint(path.localTransform, point);
|
|
13638
13707
|
const { motionRotation } = this;
|
|
13639
13708
|
if (motionRotation === false)
|
|
@@ -13673,7 +13742,7 @@ var LeaferUI = (function (exports) {
|
|
|
13673
13742
|
if (leaf.motionPath) {
|
|
13674
13743
|
const data = getMotionPathData(leaf);
|
|
13675
13744
|
if (data.total)
|
|
13676
|
-
leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion);
|
|
13745
|
+
leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
|
|
13677
13746
|
}
|
|
13678
13747
|
else {
|
|
13679
13748
|
leaf.set(leaf.getMotionPoint(motion));
|