@leafer-draw/worker 1.0.0-rc.20 → 1.0.0-rc.22
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.esm.js +64 -47
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +122 -75
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +122 -75
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.js
CHANGED
|
@@ -120,7 +120,7 @@ var LeaferUI = (function (exports) {
|
|
|
120
120
|
|
|
121
121
|
const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
|
|
122
122
|
const { float: float$1 } = MathHelper;
|
|
123
|
-
const tempPoint$
|
|
123
|
+
const tempPoint$4 = {};
|
|
124
124
|
function getWorld() {
|
|
125
125
|
return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
|
|
126
126
|
}
|
|
@@ -161,8 +161,8 @@ var LeaferUI = (function (exports) {
|
|
|
161
161
|
t.d *= scaleY;
|
|
162
162
|
},
|
|
163
163
|
scaleOfOuter(t, origin, scaleX, scaleY) {
|
|
164
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
165
|
-
M$6.scaleOfInner(t, tempPoint$
|
|
164
|
+
M$6.toInnerPoint(t, origin, tempPoint$4);
|
|
165
|
+
M$6.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
|
|
166
166
|
},
|
|
167
167
|
scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
|
|
168
168
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -180,8 +180,8 @@ var LeaferUI = (function (exports) {
|
|
|
180
180
|
t.d = c * sinR + d * cosR;
|
|
181
181
|
},
|
|
182
182
|
rotateOfOuter(t, origin, rotation) {
|
|
183
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
184
|
-
M$6.rotateOfInner(t, tempPoint$
|
|
183
|
+
M$6.toInnerPoint(t, origin, tempPoint$4);
|
|
184
|
+
M$6.rotateOfInner(t, tempPoint$4, rotation);
|
|
185
185
|
},
|
|
186
186
|
rotateOfInner(t, origin, rotation) {
|
|
187
187
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -202,8 +202,8 @@ var LeaferUI = (function (exports) {
|
|
|
202
202
|
}
|
|
203
203
|
},
|
|
204
204
|
skewOfOuter(t, origin, skewX, skewY) {
|
|
205
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
206
|
-
M$6.skewOfInner(t, tempPoint$
|
|
205
|
+
M$6.toInnerPoint(t, origin, tempPoint$4);
|
|
206
|
+
M$6.skewOfInner(t, tempPoint$4, skewX, skewY);
|
|
207
207
|
},
|
|
208
208
|
skewOfInner(t, origin, skewX, skewY = 0) {
|
|
209
209
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -597,7 +597,7 @@ var LeaferUI = (function (exports) {
|
|
|
597
597
|
return this;
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
|
-
const tempPoint$
|
|
600
|
+
const tempPoint$3 = new Point();
|
|
601
601
|
|
|
602
602
|
class Matrix {
|
|
603
603
|
constructor(a, b, c, d, e, f) {
|
|
@@ -1209,11 +1209,19 @@ var LeaferUI = (function (exports) {
|
|
|
1209
1209
|
directionData,
|
|
1210
1210
|
tempPoint: {},
|
|
1211
1211
|
get: get$5,
|
|
1212
|
-
toPoint(around, bounds, to, onlySize) {
|
|
1212
|
+
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1213
1213
|
to || (to = {});
|
|
1214
1214
|
const point = get$5(around);
|
|
1215
1215
|
to.x = point.x * bounds.width;
|
|
1216
1216
|
to.y = point.y * bounds.height;
|
|
1217
|
+
if (pointBounds) {
|
|
1218
|
+
to.x -= pointBounds.x;
|
|
1219
|
+
to.y -= pointBounds.y;
|
|
1220
|
+
if (point.x)
|
|
1221
|
+
to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
|
|
1222
|
+
if (point.y)
|
|
1223
|
+
to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
|
|
1224
|
+
}
|
|
1217
1225
|
if (!onlySize) {
|
|
1218
1226
|
to.x += bounds.x;
|
|
1219
1227
|
to.y += bounds.y;
|
|
@@ -1268,7 +1276,8 @@ var LeaferUI = (function (exports) {
|
|
|
1268
1276
|
this.warn(...messages);
|
|
1269
1277
|
}
|
|
1270
1278
|
warn(...messages) {
|
|
1271
|
-
|
|
1279
|
+
if (D$4.showWarn)
|
|
1280
|
+
console.warn(this.name, ...messages);
|
|
1272
1281
|
}
|
|
1273
1282
|
repeat(name, ...messages) {
|
|
1274
1283
|
if (!this.repeatMap[name]) {
|
|
@@ -1287,6 +1296,7 @@ var LeaferUI = (function (exports) {
|
|
|
1287
1296
|
}
|
|
1288
1297
|
Debug.filterList = [];
|
|
1289
1298
|
Debug.excludeList = [];
|
|
1299
|
+
Debug.showWarn = true;
|
|
1290
1300
|
function getNameList(name) {
|
|
1291
1301
|
if (!name)
|
|
1292
1302
|
name = [];
|
|
@@ -2209,7 +2219,7 @@ var LeaferUI = (function (exports) {
|
|
|
2209
2219
|
const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
|
|
2210
2220
|
const { set: set$2 } = PointHelper;
|
|
2211
2221
|
const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
|
|
2212
|
-
const tempPoint$
|
|
2222
|
+
const tempPoint$2 = {};
|
|
2213
2223
|
const BezierHelper = {
|
|
2214
2224
|
points(data, points, curve, close) {
|
|
2215
2225
|
data.push(M$5, points[0], points[1]);
|
|
@@ -2399,8 +2409,8 @@ var LeaferUI = (function (exports) {
|
|
|
2399
2409
|
addMode ? addPoint$2(pointBounds, fromX, fromY) : setPoint$2(pointBounds, fromX, fromY);
|
|
2400
2410
|
addPoint$2(pointBounds, toX, toY);
|
|
2401
2411
|
for (let i = 0, len = tList.length; i < len; i++) {
|
|
2402
|
-
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$
|
|
2403
|
-
addPoint$2(pointBounds, tempPoint$
|
|
2412
|
+
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
|
|
2413
|
+
addPoint$2(pointBounds, tempPoint$2.x, tempPoint$2.y);
|
|
2404
2414
|
}
|
|
2405
2415
|
},
|
|
2406
2416
|
getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
|
|
@@ -3957,15 +3967,21 @@ var LeaferUI = (function (exports) {
|
|
|
3957
3967
|
}
|
|
3958
3968
|
return true;
|
|
3959
3969
|
},
|
|
3960
|
-
moveWorld(t, x, y) {
|
|
3961
|
-
const local = { x, y };
|
|
3970
|
+
moveWorld(t, x, y = 0) {
|
|
3971
|
+
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
3962
3972
|
if (t.parent)
|
|
3963
3973
|
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
3964
3974
|
L.moveLocal(t, local.x, local.y);
|
|
3965
3975
|
},
|
|
3966
3976
|
moveLocal(t, x, y = 0) {
|
|
3967
|
-
|
|
3968
|
-
|
|
3977
|
+
if (typeof x === 'object') {
|
|
3978
|
+
t.x += x.x;
|
|
3979
|
+
t.y += x.y;
|
|
3980
|
+
}
|
|
3981
|
+
else {
|
|
3982
|
+
t.x += x;
|
|
3983
|
+
t.y += y;
|
|
3984
|
+
}
|
|
3969
3985
|
},
|
|
3970
3986
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
3971
3987
|
L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -4527,12 +4543,15 @@ var LeaferUI = (function (exports) {
|
|
|
4527
4543
|
break;
|
|
4528
4544
|
}
|
|
4529
4545
|
}
|
|
4546
|
+
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4530
4547
|
},
|
|
4531
4548
|
emitEvent(event, capture) {
|
|
4532
4549
|
event.current = this;
|
|
4533
4550
|
this.emit(event.type, event, capture);
|
|
4534
4551
|
},
|
|
4535
4552
|
hasEvent(type, capture) {
|
|
4553
|
+
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4554
|
+
return true;
|
|
4536
4555
|
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4537
4556
|
const hasB = b && b[type], hasC = c && c[type];
|
|
4538
4557
|
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
@@ -4752,7 +4771,7 @@ var LeaferUI = (function (exports) {
|
|
|
4752
4771
|
};
|
|
4753
4772
|
|
|
4754
4773
|
const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
|
|
4755
|
-
const { toPoint, tempPoint } = AroundHelper;
|
|
4774
|
+
const { toPoint, tempPoint: tempPoint$1 } = AroundHelper;
|
|
4756
4775
|
const LeafMatrix = {
|
|
4757
4776
|
__updateWorldMatrix() {
|
|
4758
4777
|
multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
|
|
@@ -4769,8 +4788,8 @@ var LeaferUI = (function (exports) {
|
|
|
4769
4788
|
local.e = data.x;
|
|
4770
4789
|
local.f = data.y;
|
|
4771
4790
|
if (data.around) {
|
|
4772
|
-
toPoint(data.around, layout.boxBounds, tempPoint);
|
|
4773
|
-
translateInner(local, -tempPoint.x, -tempPoint.y);
|
|
4791
|
+
toPoint(data.around, layout.boxBounds, tempPoint$1);
|
|
4792
|
+
translateInner(local, -tempPoint$1.x, -tempPoint$1.y);
|
|
4774
4793
|
}
|
|
4775
4794
|
}
|
|
4776
4795
|
this.__layout.matrixChanged = false;
|
|
@@ -6336,7 +6355,11 @@ var LeaferUI = (function (exports) {
|
|
|
6336
6355
|
defineKey(target, key, {
|
|
6337
6356
|
set(value) { if (this.isLeafer)
|
|
6338
6357
|
this[privateKey] = value; },
|
|
6339
|
-
get() {
|
|
6358
|
+
get() {
|
|
6359
|
+
return this.isApp
|
|
6360
|
+
? this.tree.zoomLayer
|
|
6361
|
+
: (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
|
|
6362
|
+
}
|
|
6340
6363
|
});
|
|
6341
6364
|
};
|
|
6342
6365
|
}
|
|
@@ -6742,6 +6765,9 @@ var LeaferUI = (function (exports) {
|
|
|
6742
6765
|
pen.set(this.path = this.__.path || []);
|
|
6743
6766
|
return pen;
|
|
6744
6767
|
}
|
|
6768
|
+
get editConfig() { return undefined; }
|
|
6769
|
+
get editOuter() { return 'EditTool'; }
|
|
6770
|
+
get editInner() { return 'PathEditor'; }
|
|
6745
6771
|
constructor(data) {
|
|
6746
6772
|
super(data);
|
|
6747
6773
|
}
|
|
@@ -6803,7 +6829,8 @@ var LeaferUI = (function (exports) {
|
|
|
6803
6829
|
__drawPathByBox(drawer) {
|
|
6804
6830
|
const { x, y, width, height } = this.__layout.boxBounds;
|
|
6805
6831
|
if (this.__.cornerRadius) {
|
|
6806
|
-
|
|
6832
|
+
const { cornerRadius } = this.__;
|
|
6833
|
+
drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
|
|
6807
6834
|
}
|
|
6808
6835
|
else {
|
|
6809
6836
|
drawer.rect(x, y, width, height);
|
|
@@ -6824,6 +6851,9 @@ var LeaferUI = (function (exports) {
|
|
|
6824
6851
|
static registerData(data) {
|
|
6825
6852
|
dataProcessor(data)(this.prototype);
|
|
6826
6853
|
}
|
|
6854
|
+
static setEditConfig(_config) { }
|
|
6855
|
+
static setEditOuter(_toolName) { }
|
|
6856
|
+
static setEditInner(_editorName) { }
|
|
6827
6857
|
destroy() {
|
|
6828
6858
|
this.fill = this.stroke = null;
|
|
6829
6859
|
super.destroy();
|
|
@@ -6907,15 +6937,15 @@ var LeaferUI = (function (exports) {
|
|
|
6907
6937
|
__decorate([
|
|
6908
6938
|
dataType(false)
|
|
6909
6939
|
], exports.UI.prototype, "draggable", void 0);
|
|
6940
|
+
__decorate([
|
|
6941
|
+
dataType()
|
|
6942
|
+
], exports.UI.prototype, "dragBounds", void 0);
|
|
6910
6943
|
__decorate([
|
|
6911
6944
|
dataType(false)
|
|
6912
6945
|
], exports.UI.prototype, "editable", void 0);
|
|
6913
6946
|
__decorate([
|
|
6914
6947
|
dataType('size')
|
|
6915
6948
|
], exports.UI.prototype, "editSize", void 0);
|
|
6916
|
-
__decorate([
|
|
6917
|
-
dataType()
|
|
6918
|
-
], exports.UI.prototype, "editorStyle", void 0);
|
|
6919
6949
|
__decorate([
|
|
6920
6950
|
hitType(true)
|
|
6921
6951
|
], exports.UI.prototype, "hittable", void 0);
|
|
@@ -7107,7 +7137,6 @@ var LeaferUI = (function (exports) {
|
|
|
7107
7137
|
var Leafer_1;
|
|
7108
7138
|
const debug$1 = Debug.get('Leafer');
|
|
7109
7139
|
exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
7110
|
-
static get version() { return '1.0.0-rc.20'; }
|
|
7111
7140
|
get __tag() { return 'Leafer'; }
|
|
7112
7141
|
get isApp() { return false; }
|
|
7113
7142
|
get app() { return this.parent || this; }
|
|
@@ -7160,7 +7189,6 @@ var LeaferUI = (function (exports) {
|
|
|
7160
7189
|
if (this.isApp)
|
|
7161
7190
|
this.__setApp();
|
|
7162
7191
|
this.__checkAutoLayout(config);
|
|
7163
|
-
this.updateLazyBounds();
|
|
7164
7192
|
this.view = canvas.view;
|
|
7165
7193
|
if (parentApp) {
|
|
7166
7194
|
this.__bindApp(parentApp);
|
|
@@ -7404,6 +7432,7 @@ var LeaferUI = (function (exports) {
|
|
|
7404
7432
|
__listenEvents() {
|
|
7405
7433
|
const runId = Run.start('FirstCreate ' + this.innerName);
|
|
7406
7434
|
this.once(LeaferEvent.START, () => Run.end(runId));
|
|
7435
|
+
this.once(LayoutEvent.START, () => this.updateLazyBounds());
|
|
7407
7436
|
this.once(LayoutEvent.END, () => this.__onReady());
|
|
7408
7437
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
7409
7438
|
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
@@ -7922,6 +7951,7 @@ var LeaferUI = (function (exports) {
|
|
|
7922
7951
|
const { copyAndSpread, includes, spread, setList } = BoundsHelper;
|
|
7923
7952
|
exports.Text = class Text extends exports.UI {
|
|
7924
7953
|
get __tag() { return 'Text'; }
|
|
7954
|
+
get editInner() { return 'TextEditor'; }
|
|
7925
7955
|
get textDrawData() {
|
|
7926
7956
|
this.__layout.update();
|
|
7927
7957
|
return this.__.__textDrawData;
|
|
@@ -8150,7 +8180,7 @@ var LeaferUI = (function (exports) {
|
|
|
8150
8180
|
};
|
|
8151
8181
|
}
|
|
8152
8182
|
|
|
8153
|
-
const version = "1.0.0-rc.
|
|
8183
|
+
const version = "1.0.0-rc.21";
|
|
8154
8184
|
|
|
8155
8185
|
function fillText(ui, canvas) {
|
|
8156
8186
|
let row;
|
|
@@ -8454,79 +8484,75 @@ var LeaferUI = (function (exports) {
|
|
|
8454
8484
|
|
|
8455
8485
|
let origin = {};
|
|
8456
8486
|
const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
|
|
8457
|
-
function fillOrFitMode(data,
|
|
8487
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
8458
8488
|
const transform = get$4();
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
const sh = box.height / (swap ? width : height);
|
|
8462
|
-
const scale = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
|
|
8463
|
-
const x = box.x + (box.width - width * scale) / 2;
|
|
8464
|
-
const y = box.y + (box.height - height * scale) / 2;
|
|
8465
|
-
translate$1(transform, x, y);
|
|
8466
|
-
scaleHelper(transform, scale);
|
|
8489
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
8490
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
8467
8491
|
if (rotation)
|
|
8468
8492
|
rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
8469
|
-
data.scaleX = data.scaleY = scale;
|
|
8470
8493
|
data.transform = transform;
|
|
8471
8494
|
}
|
|
8472
8495
|
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
8473
8496
|
const transform = get$4();
|
|
8474
|
-
translate$1(transform, box.x, box.y);
|
|
8475
|
-
if (
|
|
8476
|
-
translate$1(transform, x, y);
|
|
8477
|
-
if (scaleX) {
|
|
8497
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
8498
|
+
if (scaleX)
|
|
8478
8499
|
scaleHelper(transform, scaleX, scaleY);
|
|
8479
|
-
data.scaleX = transform.a;
|
|
8480
|
-
data.scaleY = transform.d;
|
|
8481
|
-
}
|
|
8482
8500
|
if (rotation)
|
|
8483
8501
|
rotate(transform, rotation);
|
|
8484
8502
|
data.transform = transform;
|
|
8485
8503
|
}
|
|
8486
|
-
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
|
|
8504
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
|
|
8487
8505
|
const transform = get$4();
|
|
8488
8506
|
if (rotation) {
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8507
|
+
if (around === 'center') {
|
|
8508
|
+
rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
|
|
8509
|
+
}
|
|
8510
|
+
else {
|
|
8511
|
+
rotate(transform, rotation);
|
|
8512
|
+
switch (rotation) {
|
|
8513
|
+
case 90:
|
|
8514
|
+
translate$1(transform, height, 0);
|
|
8515
|
+
break;
|
|
8516
|
+
case 180:
|
|
8517
|
+
translate$1(transform, width, height);
|
|
8518
|
+
break;
|
|
8519
|
+
case 270:
|
|
8520
|
+
translate$1(transform, 0, width);
|
|
8521
|
+
break;
|
|
8522
|
+
}
|
|
8500
8523
|
}
|
|
8501
8524
|
}
|
|
8502
|
-
origin.x = box.x;
|
|
8503
|
-
origin.y = box.y;
|
|
8504
|
-
if (x || y)
|
|
8505
|
-
origin.x += x, origin.y += y;
|
|
8525
|
+
origin.x = box.x + x;
|
|
8526
|
+
origin.y = box.y + y;
|
|
8506
8527
|
translate$1(transform, origin.x, origin.y);
|
|
8507
|
-
if (scaleX)
|
|
8528
|
+
if (scaleX)
|
|
8508
8529
|
scaleOfOuter$2(transform, origin, scaleX, scaleY);
|
|
8509
|
-
data.scaleX = scaleX;
|
|
8510
|
-
data.scaleY = scaleY;
|
|
8511
|
-
}
|
|
8512
8530
|
data.transform = transform;
|
|
8513
8531
|
}
|
|
8514
8532
|
|
|
8515
8533
|
const { get: get$3, translate } = MatrixHelper;
|
|
8516
8534
|
const tempBox = new Bounds();
|
|
8535
|
+
const tempPoint = {};
|
|
8517
8536
|
function createData(leafPaint, image, paint, box) {
|
|
8518
8537
|
let { width, height } = image;
|
|
8519
8538
|
if (paint.padding)
|
|
8520
8539
|
box = tempBox.set(box).shrink(paint.padding);
|
|
8521
|
-
const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
|
|
8540
|
+
const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
|
|
8522
8541
|
const sameBox = box.width === width && box.height === height;
|
|
8523
8542
|
if (blendMode)
|
|
8524
8543
|
leafPaint.blendMode = blendMode;
|
|
8525
8544
|
const data = leafPaint.data = { mode };
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
if (
|
|
8545
|
+
const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
|
|
8546
|
+
const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
|
|
8547
|
+
let x = 0, y = 0, scaleX, scaleY;
|
|
8548
|
+
if (!mode || mode === 'cover' || mode === 'fit') {
|
|
8549
|
+
if (!sameBox || rotation) {
|
|
8550
|
+
const sw = box.width / swapWidth, sh = box.height / swapHeight;
|
|
8551
|
+
scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
|
|
8552
|
+
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
8553
|
+
}
|
|
8554
|
+
}
|
|
8555
|
+
else if (size) {
|
|
8530
8556
|
scaleX = (typeof size === 'number' ? size : size.width) / width;
|
|
8531
8557
|
scaleY = (typeof size === 'number' ? size : size.height) / height;
|
|
8532
8558
|
}
|
|
@@ -8534,26 +8560,36 @@ var LeaferUI = (function (exports) {
|
|
|
8534
8560
|
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
8535
8561
|
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
8536
8562
|
}
|
|
8563
|
+
if (around) {
|
|
8564
|
+
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
8565
|
+
if (scaleX)
|
|
8566
|
+
imageBounds.width *= scaleX, imageBounds.height *= scaleY;
|
|
8567
|
+
AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
|
|
8568
|
+
x += tempPoint.x, y += tempPoint.y;
|
|
8569
|
+
}
|
|
8570
|
+
if (offset)
|
|
8571
|
+
x += offset.x, y += offset.y;
|
|
8537
8572
|
switch (mode) {
|
|
8538
8573
|
case 'strench':
|
|
8539
8574
|
if (!sameBox)
|
|
8540
8575
|
width = box.width, height = box.height;
|
|
8541
8576
|
break;
|
|
8577
|
+
case 'normal':
|
|
8542
8578
|
case 'clip':
|
|
8543
|
-
if (
|
|
8579
|
+
if (x || y || scaleX || rotation)
|
|
8544
8580
|
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
8545
8581
|
break;
|
|
8546
8582
|
case 'repeat':
|
|
8547
8583
|
if (!sameBox || scaleX || rotation)
|
|
8548
|
-
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
|
|
8584
|
+
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
|
|
8549
8585
|
if (!repeat)
|
|
8550
8586
|
data.repeat = 'repeat';
|
|
8551
8587
|
break;
|
|
8552
8588
|
case 'fit':
|
|
8553
8589
|
case 'cover':
|
|
8554
8590
|
default:
|
|
8555
|
-
if (
|
|
8556
|
-
fillOrFitMode(data,
|
|
8591
|
+
if (scaleX)
|
|
8592
|
+
fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
8557
8593
|
}
|
|
8558
8594
|
if (!data.transform) {
|
|
8559
8595
|
if (box.x || box.y) {
|
|
@@ -8561,6 +8597,10 @@ var LeaferUI = (function (exports) {
|
|
|
8561
8597
|
translate(data.transform, box.x, box.y);
|
|
8562
8598
|
}
|
|
8563
8599
|
}
|
|
8600
|
+
if (scaleX && mode !== 'strench') {
|
|
8601
|
+
data.scaleX = scaleX;
|
|
8602
|
+
data.scaleY = scaleY;
|
|
8603
|
+
}
|
|
8564
8604
|
data.width = width;
|
|
8565
8605
|
data.height = height;
|
|
8566
8606
|
if (opacity)
|
|
@@ -9616,6 +9656,13 @@ var LeaferUI = (function (exports) {
|
|
|
9616
9656
|
resolve();
|
|
9617
9657
|
this.running = false;
|
|
9618
9658
|
};
|
|
9659
|
+
if (filename === 'json') {
|
|
9660
|
+
return over({ data: leaf.toJSON() });
|
|
9661
|
+
}
|
|
9662
|
+
else if (FileHelper.fileType(filename) === 'json') {
|
|
9663
|
+
Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
|
|
9664
|
+
return over({ data: true });
|
|
9665
|
+
}
|
|
9619
9666
|
const { leafer } = leaf;
|
|
9620
9667
|
if (leafer) {
|
|
9621
9668
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -9899,7 +9946,7 @@ var LeaferUI = (function (exports) {
|
|
|
9899
9946
|
exports.surfaceType = surfaceType;
|
|
9900
9947
|
exports.tempBounds = tempBounds$1;
|
|
9901
9948
|
exports.tempMatrix = tempMatrix;
|
|
9902
|
-
exports.tempPoint = tempPoint$
|
|
9949
|
+
exports.tempPoint = tempPoint$3;
|
|
9903
9950
|
exports.useCanvas = useCanvas;
|
|
9904
9951
|
exports.useModule = useModule;
|
|
9905
9952
|
exports.version = version;
|