@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.module.js
CHANGED
|
@@ -117,7 +117,7 @@ function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
|
|
|
117
117
|
|
|
118
118
|
const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
|
|
119
119
|
const { float: float$1 } = MathHelper;
|
|
120
|
-
const tempPoint$
|
|
120
|
+
const tempPoint$4 = {};
|
|
121
121
|
function getWorld() {
|
|
122
122
|
return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
|
|
123
123
|
}
|
|
@@ -158,8 +158,8 @@ const MatrixHelper = {
|
|
|
158
158
|
t.d *= scaleY;
|
|
159
159
|
},
|
|
160
160
|
scaleOfOuter(t, origin, scaleX, scaleY) {
|
|
161
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
162
|
-
M$6.scaleOfInner(t, tempPoint$
|
|
161
|
+
M$6.toInnerPoint(t, origin, tempPoint$4);
|
|
162
|
+
M$6.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
|
|
163
163
|
},
|
|
164
164
|
scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
|
|
165
165
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -177,8 +177,8 @@ const MatrixHelper = {
|
|
|
177
177
|
t.d = c * sinR + d * cosR;
|
|
178
178
|
},
|
|
179
179
|
rotateOfOuter(t, origin, rotation) {
|
|
180
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
181
|
-
M$6.rotateOfInner(t, tempPoint$
|
|
180
|
+
M$6.toInnerPoint(t, origin, tempPoint$4);
|
|
181
|
+
M$6.rotateOfInner(t, tempPoint$4, rotation);
|
|
182
182
|
},
|
|
183
183
|
rotateOfInner(t, origin, rotation) {
|
|
184
184
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -199,8 +199,8 @@ const MatrixHelper = {
|
|
|
199
199
|
}
|
|
200
200
|
},
|
|
201
201
|
skewOfOuter(t, origin, skewX, skewY) {
|
|
202
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
203
|
-
M$6.skewOfInner(t, tempPoint$
|
|
202
|
+
M$6.toInnerPoint(t, origin, tempPoint$4);
|
|
203
|
+
M$6.skewOfInner(t, tempPoint$4, skewX, skewY);
|
|
204
204
|
},
|
|
205
205
|
skewOfInner(t, origin, skewX, skewY = 0) {
|
|
206
206
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -594,7 +594,7 @@ class Point {
|
|
|
594
594
|
return this;
|
|
595
595
|
}
|
|
596
596
|
}
|
|
597
|
-
const tempPoint$
|
|
597
|
+
const tempPoint$3 = new Point();
|
|
598
598
|
|
|
599
599
|
class Matrix {
|
|
600
600
|
constructor(a, b, c, d, e, f) {
|
|
@@ -1206,11 +1206,19 @@ const AroundHelper = {
|
|
|
1206
1206
|
directionData,
|
|
1207
1207
|
tempPoint: {},
|
|
1208
1208
|
get: get$5,
|
|
1209
|
-
toPoint(around, bounds, to, onlySize) {
|
|
1209
|
+
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1210
1210
|
to || (to = {});
|
|
1211
1211
|
const point = get$5(around);
|
|
1212
1212
|
to.x = point.x * bounds.width;
|
|
1213
1213
|
to.y = point.y * bounds.height;
|
|
1214
|
+
if (pointBounds) {
|
|
1215
|
+
to.x -= pointBounds.x;
|
|
1216
|
+
to.y -= pointBounds.y;
|
|
1217
|
+
if (point.x)
|
|
1218
|
+
to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
|
|
1219
|
+
if (point.y)
|
|
1220
|
+
to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
|
|
1221
|
+
}
|
|
1214
1222
|
if (!onlySize) {
|
|
1215
1223
|
to.x += bounds.x;
|
|
1216
1224
|
to.y += bounds.y;
|
|
@@ -1265,7 +1273,8 @@ class Debug {
|
|
|
1265
1273
|
this.warn(...messages);
|
|
1266
1274
|
}
|
|
1267
1275
|
warn(...messages) {
|
|
1268
|
-
|
|
1276
|
+
if (D$4.showWarn)
|
|
1277
|
+
console.warn(this.name, ...messages);
|
|
1269
1278
|
}
|
|
1270
1279
|
repeat(name, ...messages) {
|
|
1271
1280
|
if (!this.repeatMap[name]) {
|
|
@@ -1284,6 +1293,7 @@ class Debug {
|
|
|
1284
1293
|
}
|
|
1285
1294
|
Debug.filterList = [];
|
|
1286
1295
|
Debug.excludeList = [];
|
|
1296
|
+
Debug.showWarn = true;
|
|
1287
1297
|
function getNameList(name) {
|
|
1288
1298
|
if (!name)
|
|
1289
1299
|
name = [];
|
|
@@ -2206,7 +2216,7 @@ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI
|
|
|
2206
2216
|
const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
|
|
2207
2217
|
const { set: set$2 } = PointHelper;
|
|
2208
2218
|
const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
|
|
2209
|
-
const tempPoint$
|
|
2219
|
+
const tempPoint$2 = {};
|
|
2210
2220
|
const BezierHelper = {
|
|
2211
2221
|
points(data, points, curve, close) {
|
|
2212
2222
|
data.push(M$5, points[0], points[1]);
|
|
@@ -2396,8 +2406,8 @@ const BezierHelper = {
|
|
|
2396
2406
|
addMode ? addPoint$2(pointBounds, fromX, fromY) : setPoint$2(pointBounds, fromX, fromY);
|
|
2397
2407
|
addPoint$2(pointBounds, toX, toY);
|
|
2398
2408
|
for (let i = 0, len = tList.length; i < len; i++) {
|
|
2399
|
-
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$
|
|
2400
|
-
addPoint$2(pointBounds, tempPoint$
|
|
2409
|
+
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
|
|
2410
|
+
addPoint$2(pointBounds, tempPoint$2.x, tempPoint$2.y);
|
|
2401
2411
|
}
|
|
2402
2412
|
},
|
|
2403
2413
|
getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
|
|
@@ -3954,15 +3964,21 @@ const LeafHelper = {
|
|
|
3954
3964
|
}
|
|
3955
3965
|
return true;
|
|
3956
3966
|
},
|
|
3957
|
-
moveWorld(t, x, y) {
|
|
3958
|
-
const local = { x, y };
|
|
3967
|
+
moveWorld(t, x, y = 0) {
|
|
3968
|
+
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
3959
3969
|
if (t.parent)
|
|
3960
3970
|
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
3961
3971
|
L.moveLocal(t, local.x, local.y);
|
|
3962
3972
|
},
|
|
3963
3973
|
moveLocal(t, x, y = 0) {
|
|
3964
|
-
|
|
3965
|
-
|
|
3974
|
+
if (typeof x === 'object') {
|
|
3975
|
+
t.x += x.x;
|
|
3976
|
+
t.y += x.y;
|
|
3977
|
+
}
|
|
3978
|
+
else {
|
|
3979
|
+
t.x += x;
|
|
3980
|
+
t.y += y;
|
|
3981
|
+
}
|
|
3966
3982
|
},
|
|
3967
3983
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
3968
3984
|
L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -4524,12 +4540,15 @@ const LeafEventer = {
|
|
|
4524
4540
|
break;
|
|
4525
4541
|
}
|
|
4526
4542
|
}
|
|
4543
|
+
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4527
4544
|
},
|
|
4528
4545
|
emitEvent(event, capture) {
|
|
4529
4546
|
event.current = this;
|
|
4530
4547
|
this.emit(event.type, event, capture);
|
|
4531
4548
|
},
|
|
4532
4549
|
hasEvent(type, capture) {
|
|
4550
|
+
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4551
|
+
return true;
|
|
4533
4552
|
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4534
4553
|
const hasB = b && b[type], hasC = c && c[type];
|
|
4535
4554
|
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
@@ -4749,7 +4768,7 @@ const LeafDataProxy = {
|
|
|
4749
4768
|
};
|
|
4750
4769
|
|
|
4751
4770
|
const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
|
|
4752
|
-
const { toPoint, tempPoint } = AroundHelper;
|
|
4771
|
+
const { toPoint, tempPoint: tempPoint$1 } = AroundHelper;
|
|
4753
4772
|
const LeafMatrix = {
|
|
4754
4773
|
__updateWorldMatrix() {
|
|
4755
4774
|
multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
|
|
@@ -4766,8 +4785,8 @@ const LeafMatrix = {
|
|
|
4766
4785
|
local.e = data.x;
|
|
4767
4786
|
local.f = data.y;
|
|
4768
4787
|
if (data.around) {
|
|
4769
|
-
toPoint(data.around, layout.boxBounds, tempPoint);
|
|
4770
|
-
translateInner(local, -tempPoint.x, -tempPoint.y);
|
|
4788
|
+
toPoint(data.around, layout.boxBounds, tempPoint$1);
|
|
4789
|
+
translateInner(local, -tempPoint$1.x, -tempPoint$1.y);
|
|
4771
4790
|
}
|
|
4772
4791
|
}
|
|
4773
4792
|
this.__layout.matrixChanged = false;
|
|
@@ -6333,7 +6352,11 @@ function zoomLayerType() {
|
|
|
6333
6352
|
defineKey(target, key, {
|
|
6334
6353
|
set(value) { if (this.isLeafer)
|
|
6335
6354
|
this[privateKey] = value; },
|
|
6336
|
-
get() {
|
|
6355
|
+
get() {
|
|
6356
|
+
return this.isApp
|
|
6357
|
+
? this.tree.zoomLayer
|
|
6358
|
+
: (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
|
|
6359
|
+
}
|
|
6337
6360
|
});
|
|
6338
6361
|
};
|
|
6339
6362
|
}
|
|
@@ -6739,6 +6762,9 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
6739
6762
|
pen.set(this.path = this.__.path || []);
|
|
6740
6763
|
return pen;
|
|
6741
6764
|
}
|
|
6765
|
+
get editConfig() { return undefined; }
|
|
6766
|
+
get editOuter() { return 'EditTool'; }
|
|
6767
|
+
get editInner() { return 'PathEditor'; }
|
|
6742
6768
|
constructor(data) {
|
|
6743
6769
|
super(data);
|
|
6744
6770
|
}
|
|
@@ -6800,7 +6826,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
6800
6826
|
__drawPathByBox(drawer) {
|
|
6801
6827
|
const { x, y, width, height } = this.__layout.boxBounds;
|
|
6802
6828
|
if (this.__.cornerRadius) {
|
|
6803
|
-
|
|
6829
|
+
const { cornerRadius } = this.__;
|
|
6830
|
+
drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
|
|
6804
6831
|
}
|
|
6805
6832
|
else {
|
|
6806
6833
|
drawer.rect(x, y, width, height);
|
|
@@ -6821,6 +6848,9 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
6821
6848
|
static registerData(data) {
|
|
6822
6849
|
dataProcessor(data)(this.prototype);
|
|
6823
6850
|
}
|
|
6851
|
+
static setEditConfig(_config) { }
|
|
6852
|
+
static setEditOuter(_toolName) { }
|
|
6853
|
+
static setEditInner(_editorName) { }
|
|
6824
6854
|
destroy() {
|
|
6825
6855
|
this.fill = this.stroke = null;
|
|
6826
6856
|
super.destroy();
|
|
@@ -6904,15 +6934,15 @@ __decorate([
|
|
|
6904
6934
|
__decorate([
|
|
6905
6935
|
dataType(false)
|
|
6906
6936
|
], UI.prototype, "draggable", void 0);
|
|
6937
|
+
__decorate([
|
|
6938
|
+
dataType()
|
|
6939
|
+
], UI.prototype, "dragBounds", void 0);
|
|
6907
6940
|
__decorate([
|
|
6908
6941
|
dataType(false)
|
|
6909
6942
|
], UI.prototype, "editable", void 0);
|
|
6910
6943
|
__decorate([
|
|
6911
6944
|
dataType('size')
|
|
6912
6945
|
], UI.prototype, "editSize", void 0);
|
|
6913
|
-
__decorate([
|
|
6914
|
-
dataType()
|
|
6915
|
-
], UI.prototype, "editorStyle", void 0);
|
|
6916
6946
|
__decorate([
|
|
6917
6947
|
hitType(true)
|
|
6918
6948
|
], UI.prototype, "hittable", void 0);
|
|
@@ -7104,7 +7134,6 @@ Group = __decorate([
|
|
|
7104
7134
|
var Leafer_1;
|
|
7105
7135
|
const debug$1 = Debug.get('Leafer');
|
|
7106
7136
|
let Leafer = Leafer_1 = class Leafer extends Group {
|
|
7107
|
-
static get version() { return '1.0.0-rc.20'; }
|
|
7108
7137
|
get __tag() { return 'Leafer'; }
|
|
7109
7138
|
get isApp() { return false; }
|
|
7110
7139
|
get app() { return this.parent || this; }
|
|
@@ -7157,7 +7186,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7157
7186
|
if (this.isApp)
|
|
7158
7187
|
this.__setApp();
|
|
7159
7188
|
this.__checkAutoLayout(config);
|
|
7160
|
-
this.updateLazyBounds();
|
|
7161
7189
|
this.view = canvas.view;
|
|
7162
7190
|
if (parentApp) {
|
|
7163
7191
|
this.__bindApp(parentApp);
|
|
@@ -7401,6 +7429,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7401
7429
|
__listenEvents() {
|
|
7402
7430
|
const runId = Run.start('FirstCreate ' + this.innerName);
|
|
7403
7431
|
this.once(LeaferEvent.START, () => Run.end(runId));
|
|
7432
|
+
this.once(LayoutEvent.START, () => this.updateLazyBounds());
|
|
7404
7433
|
this.once(LayoutEvent.END, () => this.__onReady());
|
|
7405
7434
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
7406
7435
|
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
@@ -7919,6 +7948,7 @@ Canvas = __decorate([
|
|
|
7919
7948
|
const { copyAndSpread, includes, spread, setList } = BoundsHelper;
|
|
7920
7949
|
let Text = class Text extends UI {
|
|
7921
7950
|
get __tag() { return 'Text'; }
|
|
7951
|
+
get editInner() { return 'TextEditor'; }
|
|
7922
7952
|
get textDrawData() {
|
|
7923
7953
|
this.__layout.update();
|
|
7924
7954
|
return this.__.__textDrawData;
|
|
@@ -8147,7 +8177,7 @@ function penPathType() {
|
|
|
8147
8177
|
};
|
|
8148
8178
|
}
|
|
8149
8179
|
|
|
8150
|
-
const version = "1.0.0-rc.
|
|
8180
|
+
const version = "1.0.0-rc.21";
|
|
8151
8181
|
|
|
8152
8182
|
function fillText(ui, canvas) {
|
|
8153
8183
|
let row;
|
|
@@ -8451,79 +8481,75 @@ const PaintModule = {
|
|
|
8451
8481
|
|
|
8452
8482
|
let origin = {};
|
|
8453
8483
|
const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
|
|
8454
|
-
function fillOrFitMode(data,
|
|
8484
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
8455
8485
|
const transform = get$4();
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
const sh = box.height / (swap ? width : height);
|
|
8459
|
-
const scale = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
|
|
8460
|
-
const x = box.x + (box.width - width * scale) / 2;
|
|
8461
|
-
const y = box.y + (box.height - height * scale) / 2;
|
|
8462
|
-
translate$1(transform, x, y);
|
|
8463
|
-
scaleHelper(transform, scale);
|
|
8486
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
8487
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
8464
8488
|
if (rotation)
|
|
8465
8489
|
rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
8466
|
-
data.scaleX = data.scaleY = scale;
|
|
8467
8490
|
data.transform = transform;
|
|
8468
8491
|
}
|
|
8469
8492
|
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
8470
8493
|
const transform = get$4();
|
|
8471
|
-
translate$1(transform, box.x, box.y);
|
|
8472
|
-
if (
|
|
8473
|
-
translate$1(transform, x, y);
|
|
8474
|
-
if (scaleX) {
|
|
8494
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
8495
|
+
if (scaleX)
|
|
8475
8496
|
scaleHelper(transform, scaleX, scaleY);
|
|
8476
|
-
data.scaleX = transform.a;
|
|
8477
|
-
data.scaleY = transform.d;
|
|
8478
|
-
}
|
|
8479
8497
|
if (rotation)
|
|
8480
8498
|
rotate(transform, rotation);
|
|
8481
8499
|
data.transform = transform;
|
|
8482
8500
|
}
|
|
8483
|
-
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
|
|
8501
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
|
|
8484
8502
|
const transform = get$4();
|
|
8485
8503
|
if (rotation) {
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8504
|
+
if (around === 'center') {
|
|
8505
|
+
rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
|
|
8506
|
+
}
|
|
8507
|
+
else {
|
|
8508
|
+
rotate(transform, rotation);
|
|
8509
|
+
switch (rotation) {
|
|
8510
|
+
case 90:
|
|
8511
|
+
translate$1(transform, height, 0);
|
|
8512
|
+
break;
|
|
8513
|
+
case 180:
|
|
8514
|
+
translate$1(transform, width, height);
|
|
8515
|
+
break;
|
|
8516
|
+
case 270:
|
|
8517
|
+
translate$1(transform, 0, width);
|
|
8518
|
+
break;
|
|
8519
|
+
}
|
|
8497
8520
|
}
|
|
8498
8521
|
}
|
|
8499
|
-
origin.x = box.x;
|
|
8500
|
-
origin.y = box.y;
|
|
8501
|
-
if (x || y)
|
|
8502
|
-
origin.x += x, origin.y += y;
|
|
8522
|
+
origin.x = box.x + x;
|
|
8523
|
+
origin.y = box.y + y;
|
|
8503
8524
|
translate$1(transform, origin.x, origin.y);
|
|
8504
|
-
if (scaleX)
|
|
8525
|
+
if (scaleX)
|
|
8505
8526
|
scaleOfOuter$2(transform, origin, scaleX, scaleY);
|
|
8506
|
-
data.scaleX = scaleX;
|
|
8507
|
-
data.scaleY = scaleY;
|
|
8508
|
-
}
|
|
8509
8527
|
data.transform = transform;
|
|
8510
8528
|
}
|
|
8511
8529
|
|
|
8512
8530
|
const { get: get$3, translate } = MatrixHelper;
|
|
8513
8531
|
const tempBox = new Bounds();
|
|
8532
|
+
const tempPoint = {};
|
|
8514
8533
|
function createData(leafPaint, image, paint, box) {
|
|
8515
8534
|
let { width, height } = image;
|
|
8516
8535
|
if (paint.padding)
|
|
8517
8536
|
box = tempBox.set(box).shrink(paint.padding);
|
|
8518
|
-
const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
|
|
8537
|
+
const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
|
|
8519
8538
|
const sameBox = box.width === width && box.height === height;
|
|
8520
8539
|
if (blendMode)
|
|
8521
8540
|
leafPaint.blendMode = blendMode;
|
|
8522
8541
|
const data = leafPaint.data = { mode };
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
if (
|
|
8542
|
+
const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
|
|
8543
|
+
const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
|
|
8544
|
+
let x = 0, y = 0, scaleX, scaleY;
|
|
8545
|
+
if (!mode || mode === 'cover' || mode === 'fit') {
|
|
8546
|
+
if (!sameBox || rotation) {
|
|
8547
|
+
const sw = box.width / swapWidth, sh = box.height / swapHeight;
|
|
8548
|
+
scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
|
|
8549
|
+
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
8550
|
+
}
|
|
8551
|
+
}
|
|
8552
|
+
else if (size) {
|
|
8527
8553
|
scaleX = (typeof size === 'number' ? size : size.width) / width;
|
|
8528
8554
|
scaleY = (typeof size === 'number' ? size : size.height) / height;
|
|
8529
8555
|
}
|
|
@@ -8531,26 +8557,36 @@ function createData(leafPaint, image, paint, box) {
|
|
|
8531
8557
|
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
8532
8558
|
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
8533
8559
|
}
|
|
8560
|
+
if (around) {
|
|
8561
|
+
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
8562
|
+
if (scaleX)
|
|
8563
|
+
imageBounds.width *= scaleX, imageBounds.height *= scaleY;
|
|
8564
|
+
AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
|
|
8565
|
+
x += tempPoint.x, y += tempPoint.y;
|
|
8566
|
+
}
|
|
8567
|
+
if (offset)
|
|
8568
|
+
x += offset.x, y += offset.y;
|
|
8534
8569
|
switch (mode) {
|
|
8535
8570
|
case 'strench':
|
|
8536
8571
|
if (!sameBox)
|
|
8537
8572
|
width = box.width, height = box.height;
|
|
8538
8573
|
break;
|
|
8574
|
+
case 'normal':
|
|
8539
8575
|
case 'clip':
|
|
8540
|
-
if (
|
|
8576
|
+
if (x || y || scaleX || rotation)
|
|
8541
8577
|
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
8542
8578
|
break;
|
|
8543
8579
|
case 'repeat':
|
|
8544
8580
|
if (!sameBox || scaleX || rotation)
|
|
8545
|
-
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
|
|
8581
|
+
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
|
|
8546
8582
|
if (!repeat)
|
|
8547
8583
|
data.repeat = 'repeat';
|
|
8548
8584
|
break;
|
|
8549
8585
|
case 'fit':
|
|
8550
8586
|
case 'cover':
|
|
8551
8587
|
default:
|
|
8552
|
-
if (
|
|
8553
|
-
fillOrFitMode(data,
|
|
8588
|
+
if (scaleX)
|
|
8589
|
+
fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
8554
8590
|
}
|
|
8555
8591
|
if (!data.transform) {
|
|
8556
8592
|
if (box.x || box.y) {
|
|
@@ -8558,6 +8594,10 @@ function createData(leafPaint, image, paint, box) {
|
|
|
8558
8594
|
translate(data.transform, box.x, box.y);
|
|
8559
8595
|
}
|
|
8560
8596
|
}
|
|
8597
|
+
if (scaleX && mode !== 'strench') {
|
|
8598
|
+
data.scaleX = scaleX;
|
|
8599
|
+
data.scaleY = scaleY;
|
|
8600
|
+
}
|
|
8561
8601
|
data.width = width;
|
|
8562
8602
|
data.height = height;
|
|
8563
8603
|
if (opacity)
|
|
@@ -9613,6 +9653,13 @@ const ExportModule = {
|
|
|
9613
9653
|
resolve();
|
|
9614
9654
|
this.running = false;
|
|
9615
9655
|
};
|
|
9656
|
+
if (filename === 'json') {
|
|
9657
|
+
return over({ data: leaf.toJSON() });
|
|
9658
|
+
}
|
|
9659
|
+
else if (FileHelper.fileType(filename) === 'json') {
|
|
9660
|
+
Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
|
|
9661
|
+
return over({ data: true });
|
|
9662
|
+
}
|
|
9616
9663
|
const { leafer } = leaf;
|
|
9617
9664
|
if (leafer) {
|
|
9618
9665
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -9751,4 +9798,4 @@ Object.assign(Export, ExportModule);
|
|
|
9751
9798
|
|
|
9752
9799
|
useCanvas();
|
|
9753
9800
|
|
|
9754
|
-
export { AnimateEvent, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$
|
|
9801
|
+
export { AnimateEvent, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, zoomLayerType };
|