@leafer-draw/worker 1.0.0-rc.25 → 1.0.0-rc.27
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 +69 -48
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +146 -71
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +146 -71
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.module.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
const Platform = {
|
|
2
|
+
toURL(text, fileType) {
|
|
3
|
+
let url = encodeURIComponent(text);
|
|
4
|
+
if (fileType === 'text')
|
|
5
|
+
url = 'data:text/plain;charset=utf-8,' + url;
|
|
6
|
+
else if (fileType === 'svg')
|
|
7
|
+
url = 'data:image/svg+xml,' + url;
|
|
8
|
+
return url;
|
|
9
|
+
},
|
|
2
10
|
image: {
|
|
3
11
|
hitCanvasSize: 100,
|
|
4
12
|
maxCacheSize: 2560 * 1600,
|
|
@@ -956,6 +964,9 @@ const BoundsHelper = {
|
|
|
956
964
|
points.forEach((point, index) => index === 0 ? setPoint$3(tempPointBounds$1, point.x, point.y) : addPoint$3(tempPointBounds$1, point.x, point.y));
|
|
957
965
|
toBounds$4(tempPointBounds$1, t);
|
|
958
966
|
},
|
|
967
|
+
setPoint(t, point) {
|
|
968
|
+
B.set(t, point.x, point.y);
|
|
969
|
+
},
|
|
959
970
|
addPoint(t, point) {
|
|
960
971
|
add$1(t, point, true);
|
|
961
972
|
},
|
|
@@ -1104,6 +1115,10 @@ class Bounds {
|
|
|
1104
1115
|
BoundsHelper.setListWithFn(this, list, boundsDataFn);
|
|
1105
1116
|
return this;
|
|
1106
1117
|
}
|
|
1118
|
+
setPoint(point) {
|
|
1119
|
+
BoundsHelper.setPoint(this, point);
|
|
1120
|
+
return this;
|
|
1121
|
+
}
|
|
1107
1122
|
setPoints(points) {
|
|
1108
1123
|
BoundsHelper.setPoints(this, points);
|
|
1109
1124
|
return this;
|
|
@@ -1207,10 +1222,10 @@ directionData.forEach(item => item.type = 'percent');
|
|
|
1207
1222
|
const AroundHelper = {
|
|
1208
1223
|
directionData,
|
|
1209
1224
|
tempPoint: {},
|
|
1210
|
-
get: get$
|
|
1225
|
+
get: get$4,
|
|
1211
1226
|
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1212
1227
|
to || (to = {});
|
|
1213
|
-
const point = get$
|
|
1228
|
+
const point = get$4(around);
|
|
1214
1229
|
to.x = point.x;
|
|
1215
1230
|
to.y = point.y;
|
|
1216
1231
|
if (point.type === 'percent') {
|
|
@@ -1231,7 +1246,7 @@ const AroundHelper = {
|
|
|
1231
1246
|
}
|
|
1232
1247
|
}
|
|
1233
1248
|
};
|
|
1234
|
-
function get$
|
|
1249
|
+
function get$4(around) {
|
|
1235
1250
|
return typeof around === 'string' ? directionData[Direction9[around]] : around;
|
|
1236
1251
|
}
|
|
1237
1252
|
|
|
@@ -3808,6 +3823,7 @@ function hitType(defaultValue) {
|
|
|
3808
3823
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3809
3824
|
set(value) {
|
|
3810
3825
|
if (this.__setAttr(key, value)) {
|
|
3826
|
+
this.__layout.hitCanvasChanged = true;
|
|
3811
3827
|
if (Debug.showHitView) {
|
|
3812
3828
|
this.__layout.surfaceChanged || this.__layout.surfaceChange();
|
|
3813
3829
|
}
|
|
@@ -3950,7 +3966,7 @@ function registerUIEvent() {
|
|
|
3950
3966
|
};
|
|
3951
3967
|
}
|
|
3952
3968
|
|
|
3953
|
-
const { copy: copy$6, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$
|
|
3969
|
+
const { copy: copy$6, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3954
3970
|
const matrix = {};
|
|
3955
3971
|
const LeafHelper = {
|
|
3956
3972
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4036,7 +4052,7 @@ const LeafHelper = {
|
|
|
4036
4052
|
},
|
|
4037
4053
|
zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
|
|
4038
4054
|
copy$6(matrix, t.__localMatrix);
|
|
4039
|
-
scaleOfOuter$
|
|
4055
|
+
scaleOfOuter$2(matrix, origin, scaleX, scaleY);
|
|
4040
4056
|
moveByMatrix(t, matrix);
|
|
4041
4057
|
t.scaleResize(scaleX, scaleY, resize !== true);
|
|
4042
4058
|
},
|
|
@@ -4045,7 +4061,7 @@ const LeafHelper = {
|
|
|
4045
4061
|
},
|
|
4046
4062
|
rotateOfLocal(t, origin, angle) {
|
|
4047
4063
|
copy$6(matrix, t.__localMatrix);
|
|
4048
|
-
rotateOfOuter$
|
|
4064
|
+
rotateOfOuter$2(matrix, origin, angle);
|
|
4049
4065
|
moveByMatrix(t, matrix);
|
|
4050
4066
|
t.rotation = MathHelper.formatRotation(t.rotation + angle);
|
|
4051
4067
|
},
|
|
@@ -4072,11 +4088,24 @@ const LeafHelper = {
|
|
|
4072
4088
|
setTransform(t, transform, resize) {
|
|
4073
4089
|
const layout = getLayout(transform);
|
|
4074
4090
|
if (resize) {
|
|
4075
|
-
|
|
4091
|
+
const scaleX = layout.scaleX / t.scaleX;
|
|
4092
|
+
const scaleY = layout.scaleY / t.scaleY;
|
|
4076
4093
|
delete layout.scaleX;
|
|
4077
4094
|
delete layout.scaleY;
|
|
4095
|
+
t.set(layout);
|
|
4096
|
+
t.scaleResize(scaleX, scaleY, resize !== true);
|
|
4078
4097
|
}
|
|
4079
|
-
|
|
4098
|
+
else {
|
|
4099
|
+
t.set(layout);
|
|
4100
|
+
}
|
|
4101
|
+
},
|
|
4102
|
+
getLocalOrigin(t, origin) {
|
|
4103
|
+
return PointHelper.tempToOuterOf(L.getInnerOrigin(t, origin), t.localTransform);
|
|
4104
|
+
},
|
|
4105
|
+
getInnerOrigin(t, origin) {
|
|
4106
|
+
if (typeof origin === 'string')
|
|
4107
|
+
AroundHelper.toPoint(origin, t.boxBounds, origin = {});
|
|
4108
|
+
return origin;
|
|
4080
4109
|
},
|
|
4081
4110
|
getRelativeWorld(t, relative, temp) {
|
|
4082
4111
|
copy$6(matrix, t.worldTransform);
|
|
@@ -5072,8 +5101,8 @@ const BranchRender = {
|
|
|
5072
5101
|
const { LEAF, create } = IncrementId;
|
|
5073
5102
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5074
5103
|
const { toOuterOf } = BoundsHelper;
|
|
5075
|
-
const {
|
|
5076
|
-
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getRelativeWorld, drop } = LeafHelper;
|
|
5104
|
+
const { copy: copy$3 } = PointHelper;
|
|
5105
|
+
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5077
5106
|
let Leaf = class Leaf {
|
|
5078
5107
|
get tag() { return this.__tag; }
|
|
5079
5108
|
set tag(_value) { }
|
|
@@ -5160,12 +5189,18 @@ let Leaf = class Leaf {
|
|
|
5160
5189
|
}
|
|
5161
5190
|
set(_data) { }
|
|
5162
5191
|
get(_name) { return undefined; }
|
|
5192
|
+
setAttr(name, value) { this[name] = value; }
|
|
5193
|
+
getAttr(name) { return this[name]; }
|
|
5194
|
+
getComputedAttr(name) { return this.__[name]; }
|
|
5163
5195
|
toJSON() {
|
|
5164
5196
|
return this.__.__getInputData();
|
|
5165
5197
|
}
|
|
5166
5198
|
toString() {
|
|
5167
5199
|
return JSON.stringify(this.toJSON());
|
|
5168
5200
|
}
|
|
5201
|
+
toSVG() { return undefined; }
|
|
5202
|
+
__SVG(_data) { }
|
|
5203
|
+
toHTML() { return undefined; }
|
|
5169
5204
|
__setAttr(_attrName, _newValue) { return true; }
|
|
5170
5205
|
__getAttr(_attrName) { return undefined; }
|
|
5171
5206
|
setProxyAttr(_attrName, _newValue) { }
|
|
@@ -5331,13 +5366,13 @@ let Leaf = class Leaf {
|
|
|
5331
5366
|
moveLocal(this, x, y);
|
|
5332
5367
|
}
|
|
5333
5368
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5334
|
-
zoomOfLocal(this,
|
|
5369
|
+
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5335
5370
|
}
|
|
5336
5371
|
rotateOf(origin, rotation) {
|
|
5337
|
-
rotateOfLocal(this,
|
|
5372
|
+
rotateOfLocal(this, getLocalOrigin(this, origin), rotation);
|
|
5338
5373
|
}
|
|
5339
5374
|
skewOf(origin, skewX, skewY, resize) {
|
|
5340
|
-
skewOfLocal(this,
|
|
5375
|
+
skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize);
|
|
5341
5376
|
}
|
|
5342
5377
|
transformWorld(worldTransform, resize) {
|
|
5343
5378
|
transformWorld(this, worldTransform, resize);
|
|
@@ -5359,6 +5394,14 @@ let Leaf = class Leaf {
|
|
|
5359
5394
|
this.scaleY *= scaleY;
|
|
5360
5395
|
}
|
|
5361
5396
|
__scaleResize(_scaleX, _scaleY) { }
|
|
5397
|
+
resizeWidth(width) {
|
|
5398
|
+
const scale = width / this.__localBoxBounds.width;
|
|
5399
|
+
this.scaleResize(scale, this.__.lockRatio ? scale : 1);
|
|
5400
|
+
}
|
|
5401
|
+
resizeHeight(height) {
|
|
5402
|
+
const scale = height / this.__localBoxBounds.height;
|
|
5403
|
+
this.scaleResize(this.__.lockRatio ? scale : 1, scale);
|
|
5404
|
+
}
|
|
5362
5405
|
__hitWorld(_point) { return true; }
|
|
5363
5406
|
__hit(_local) { return true; }
|
|
5364
5407
|
__hitFill(_inner) { return true; }
|
|
@@ -5709,7 +5752,7 @@ class LeafLevelList {
|
|
|
5709
5752
|
}
|
|
5710
5753
|
}
|
|
5711
5754
|
|
|
5712
|
-
const version = "1.0.0-rc.
|
|
5755
|
+
const version = "1.0.0-rc.27";
|
|
5713
5756
|
const inviteCode = {};
|
|
5714
5757
|
|
|
5715
5758
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6779,6 +6822,8 @@ const UIRender = {
|
|
|
6779
6822
|
this.__drawRenderPath(canvas);
|
|
6780
6823
|
if (fill && !ignoreFill)
|
|
6781
6824
|
this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
6825
|
+
if (this.__.__isCanvas)
|
|
6826
|
+
this.__drawAfterFill(canvas, options);
|
|
6782
6827
|
if (stroke && !ignoreStroke)
|
|
6783
6828
|
this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
6784
6829
|
}
|
|
@@ -6983,7 +7028,7 @@ __decorate([
|
|
|
6983
7028
|
stateType(false)
|
|
6984
7029
|
], UI.prototype, "disabled", void 0);
|
|
6985
7030
|
__decorate([
|
|
6986
|
-
|
|
7031
|
+
surfaceType(false)
|
|
6987
7032
|
], UI.prototype, "locked", void 0);
|
|
6988
7033
|
__decorate([
|
|
6989
7034
|
sortType(0)
|
|
@@ -7081,6 +7126,9 @@ __decorate([
|
|
|
7081
7126
|
__decorate([
|
|
7082
7127
|
boundsType()
|
|
7083
7128
|
], UI.prototype, "autoHeight", void 0);
|
|
7129
|
+
__decorate([
|
|
7130
|
+
boundsType()
|
|
7131
|
+
], UI.prototype, "lockRatio", void 0);
|
|
7084
7132
|
__decorate([
|
|
7085
7133
|
boundsType()
|
|
7086
7134
|
], UI.prototype, "autoBox", void 0);
|
|
@@ -7198,6 +7246,9 @@ __decorate([
|
|
|
7198
7246
|
__decorate([
|
|
7199
7247
|
dataType()
|
|
7200
7248
|
], UI.prototype, "disabledStyle", void 0);
|
|
7249
|
+
__decorate([
|
|
7250
|
+
dataType({})
|
|
7251
|
+
], UI.prototype, "data", void 0);
|
|
7201
7252
|
__decorate([
|
|
7202
7253
|
rewrite(Leaf.prototype.reset)
|
|
7203
7254
|
], UI.prototype, "reset", null);
|
|
@@ -7670,9 +7721,9 @@ let Box = class Box extends Group {
|
|
|
7670
7721
|
if (!data.__autoSize) {
|
|
7671
7722
|
const b = this.__layout.boxBounds;
|
|
7672
7723
|
if (!data.__autoWidth)
|
|
7673
|
-
b.
|
|
7724
|
+
b.height += b.y, b.width = data.width, b.x = b.y = 0;
|
|
7674
7725
|
if (!data.__autoHeight)
|
|
7675
|
-
b.
|
|
7726
|
+
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
7676
7727
|
}
|
|
7677
7728
|
}
|
|
7678
7729
|
else {
|
|
@@ -7742,6 +7793,9 @@ let Box = class Box extends Group {
|
|
|
7742
7793
|
__decorate([
|
|
7743
7794
|
dataProcessor(BoxData)
|
|
7744
7795
|
], Box.prototype, "__", void 0);
|
|
7796
|
+
__decorate([
|
|
7797
|
+
dataType(false)
|
|
7798
|
+
], Box.prototype, "resizeChildren", void 0);
|
|
7745
7799
|
__decorate([
|
|
7746
7800
|
affectRenderBoundsType('show')
|
|
7747
7801
|
], Box.prototype, "overflow", void 0);
|
|
@@ -7851,7 +7905,7 @@ Ellipse = __decorate([
|
|
|
7851
7905
|
], Ellipse);
|
|
7852
7906
|
|
|
7853
7907
|
const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
|
|
7854
|
-
const { rotate: rotate$1, getAngle: getAngle$
|
|
7908
|
+
const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
|
|
7855
7909
|
const { toBounds: toBounds$1 } = PathBounds;
|
|
7856
7910
|
let Line = class Line extends UI {
|
|
7857
7911
|
get __tag() { return 'Line'; }
|
|
@@ -7866,7 +7920,7 @@ let Line = class Line extends UI {
|
|
|
7866
7920
|
}
|
|
7867
7921
|
set toPoint(value) {
|
|
7868
7922
|
this.width = getDistance$2(defaultPoint, value);
|
|
7869
|
-
this.rotation = getAngle$
|
|
7923
|
+
this.rotation = getAngle$1(defaultPoint, value);
|
|
7870
7924
|
if (this.height)
|
|
7871
7925
|
this.height = 0;
|
|
7872
7926
|
}
|
|
@@ -8037,7 +8091,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8037
8091
|
super(data);
|
|
8038
8092
|
this.canvas = Creator.canvas(this.__);
|
|
8039
8093
|
this.context = this.canvas.context;
|
|
8040
|
-
this.__.__drawAfterFill = true;
|
|
8094
|
+
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8041
8095
|
}
|
|
8042
8096
|
draw(ui, offset, scale, rotation) {
|
|
8043
8097
|
ui.__layout.update();
|
|
@@ -8105,9 +8159,6 @@ __decorate([
|
|
|
8105
8159
|
__decorate([
|
|
8106
8160
|
resizeType()
|
|
8107
8161
|
], Canvas.prototype, "contextSettings", void 0);
|
|
8108
|
-
__decorate([
|
|
8109
|
-
hitType('all')
|
|
8110
|
-
], Canvas.prototype, "hitFill", void 0);
|
|
8111
8162
|
Canvas = __decorate([
|
|
8112
8163
|
registerUI()
|
|
8113
8164
|
], Canvas);
|
|
@@ -8213,6 +8264,9 @@ __decorate([
|
|
|
8213
8264
|
__decorate([
|
|
8214
8265
|
boundsType(0)
|
|
8215
8266
|
], Text.prototype, "height", void 0);
|
|
8267
|
+
__decorate([
|
|
8268
|
+
dataType(false)
|
|
8269
|
+
], Text.prototype, "resizeFontSize", void 0);
|
|
8216
8270
|
__decorate([
|
|
8217
8271
|
surfaceType('#000000')
|
|
8218
8272
|
], Text.prototype, "fill", void 0);
|
|
@@ -8625,7 +8679,7 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
8625
8679
|
case 'angular':
|
|
8626
8680
|
return PaintGradient.conicGradient(paint, boxBounds);
|
|
8627
8681
|
default:
|
|
8628
|
-
return paint.r ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
|
|
8682
|
+
return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
|
|
8629
8683
|
}
|
|
8630
8684
|
}
|
|
8631
8685
|
|
|
@@ -8642,17 +8696,17 @@ const PaintModule = {
|
|
|
8642
8696
|
};
|
|
8643
8697
|
|
|
8644
8698
|
let origin = {};
|
|
8645
|
-
const { get: get$
|
|
8699
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
|
|
8646
8700
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
8647
|
-
const transform = get$
|
|
8701
|
+
const transform = get$3();
|
|
8648
8702
|
translate$1(transform, box.x + x, box.y + y);
|
|
8649
8703
|
scaleHelper(transform, scaleX, scaleY);
|
|
8650
8704
|
if (rotation)
|
|
8651
|
-
rotateOfOuter$
|
|
8705
|
+
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
8652
8706
|
data.transform = transform;
|
|
8653
8707
|
}
|
|
8654
8708
|
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
8655
|
-
const transform = get$
|
|
8709
|
+
const transform = get$3();
|
|
8656
8710
|
translate$1(transform, box.x + x, box.y + y);
|
|
8657
8711
|
if (scaleX)
|
|
8658
8712
|
scaleHelper(transform, scaleX, scaleY);
|
|
@@ -8661,10 +8715,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
8661
8715
|
data.transform = transform;
|
|
8662
8716
|
}
|
|
8663
8717
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
8664
|
-
const transform = get$
|
|
8718
|
+
const transform = get$3();
|
|
8665
8719
|
if (rotation) {
|
|
8666
8720
|
if (align === 'center') {
|
|
8667
|
-
rotateOfOuter$
|
|
8721
|
+
rotateOfOuter$1(transform, { x: width / 2, y: height / 2 }, rotation);
|
|
8668
8722
|
}
|
|
8669
8723
|
else {
|
|
8670
8724
|
rotate(transform, rotation);
|
|
@@ -8685,22 +8739,26 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
8685
8739
|
origin.y = box.y + y;
|
|
8686
8740
|
translate$1(transform, origin.x, origin.y);
|
|
8687
8741
|
if (scaleX)
|
|
8688
|
-
scaleOfOuter$
|
|
8742
|
+
scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
8689
8743
|
data.transform = transform;
|
|
8690
8744
|
}
|
|
8691
8745
|
|
|
8692
|
-
const { get: get$
|
|
8746
|
+
const { get: get$2, translate } = MatrixHelper;
|
|
8693
8747
|
const tempBox = new Bounds();
|
|
8694
8748
|
const tempPoint = {};
|
|
8695
8749
|
function createData(leafPaint, image, paint, box) {
|
|
8750
|
+
const { blendMode } = paint;
|
|
8751
|
+
if (blendMode)
|
|
8752
|
+
leafPaint.blendMode = blendMode;
|
|
8753
|
+
leafPaint.data = getPatternData(paint, box, image);
|
|
8754
|
+
}
|
|
8755
|
+
function getPatternData(paint, box, image) {
|
|
8696
8756
|
let { width, height } = image;
|
|
8697
8757
|
if (paint.padding)
|
|
8698
8758
|
box = tempBox.set(box).shrink(paint.padding);
|
|
8699
|
-
const { opacity, mode, align, offset, scale, size, rotation,
|
|
8759
|
+
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
8700
8760
|
const sameBox = box.width === width && box.height === height;
|
|
8701
|
-
|
|
8702
|
-
leafPaint.blendMode = blendMode;
|
|
8703
|
-
const data = leafPaint.data = { mode };
|
|
8761
|
+
const data = { mode };
|
|
8704
8762
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
8705
8763
|
const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
|
|
8706
8764
|
let x = 0, y = 0, scaleX, scaleY;
|
|
@@ -8752,7 +8810,7 @@ function createData(leafPaint, image, paint, box) {
|
|
|
8752
8810
|
}
|
|
8753
8811
|
if (!data.transform) {
|
|
8754
8812
|
if (box.x || box.y) {
|
|
8755
|
-
data.transform = get$
|
|
8813
|
+
data.transform = get$2();
|
|
8756
8814
|
translate(data.transform, box.x, box.y);
|
|
8757
8815
|
}
|
|
8758
8816
|
}
|
|
@@ -8766,6 +8824,7 @@ function createData(leafPaint, image, paint, box) {
|
|
|
8766
8824
|
data.opacity = opacity;
|
|
8767
8825
|
if (repeat)
|
|
8768
8826
|
data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
|
|
8827
|
+
return data;
|
|
8769
8828
|
}
|
|
8770
8829
|
|
|
8771
8830
|
let cache, box = new Bounds();
|
|
@@ -8855,7 +8914,7 @@ function ignoreRender(ui, value) {
|
|
|
8855
8914
|
leafer.renderer.ignore = value;
|
|
8856
8915
|
}
|
|
8857
8916
|
|
|
8858
|
-
const { get: get$
|
|
8917
|
+
const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
|
|
8859
8918
|
const { ceil, abs: abs$1 } = Math;
|
|
8860
8919
|
function createPattern(ui, paint, pixelRatio) {
|
|
8861
8920
|
let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
@@ -8866,7 +8925,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
8866
8925
|
const { image, data } = paint;
|
|
8867
8926
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
|
|
8868
8927
|
if (sx) {
|
|
8869
|
-
imageMatrix = get$
|
|
8928
|
+
imageMatrix = get$1();
|
|
8870
8929
|
copy$1(imageMatrix, transform);
|
|
8871
8930
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
8872
8931
|
scaleX *= sx;
|
|
@@ -8901,7 +8960,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
8901
8960
|
}
|
|
8902
8961
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
8903
8962
|
if (!imageMatrix) {
|
|
8904
|
-
imageMatrix = get$
|
|
8963
|
+
imageMatrix = get$1();
|
|
8905
8964
|
if (transform)
|
|
8906
8965
|
copy$1(imageMatrix, transform);
|
|
8907
8966
|
}
|
|
@@ -9002,13 +9061,14 @@ function recycleImage(attrName, data) {
|
|
|
9002
9061
|
|
|
9003
9062
|
const PaintImageModule = {
|
|
9004
9063
|
image,
|
|
9064
|
+
checkImage,
|
|
9065
|
+
createPattern,
|
|
9066
|
+
recycleImage,
|
|
9005
9067
|
createData,
|
|
9068
|
+
getPatternData,
|
|
9006
9069
|
fillOrFitMode,
|
|
9007
9070
|
clipMode,
|
|
9008
|
-
repeatMode
|
|
9009
|
-
createPattern,
|
|
9010
|
-
checkImage,
|
|
9011
|
-
recycleImage
|
|
9071
|
+
repeatMode
|
|
9012
9072
|
};
|
|
9013
9073
|
|
|
9014
9074
|
const { toPoint: toPoint$2 } = AroundHelper;
|
|
@@ -9038,8 +9098,8 @@ function applyStops(gradient, stops, opacity) {
|
|
|
9038
9098
|
}
|
|
9039
9099
|
}
|
|
9040
9100
|
|
|
9041
|
-
const { getAngle
|
|
9042
|
-
const { get
|
|
9101
|
+
const { getAngle, getDistance: getDistance$1 } = PointHelper;
|
|
9102
|
+
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
|
|
9043
9103
|
const { toPoint: toPoint$1 } = AroundHelper;
|
|
9044
9104
|
const realFrom$1 = {};
|
|
9045
9105
|
const realTo$1 = {};
|
|
@@ -9047,23 +9107,35 @@ function radialGradient(paint, box) {
|
|
|
9047
9107
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
9048
9108
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
9049
9109
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
9050
|
-
const { width, height } = box;
|
|
9051
|
-
let transform;
|
|
9052
|
-
if (width !== height || stretch) {
|
|
9053
|
-
transform = get$1();
|
|
9054
|
-
scaleOfOuter$1(transform, realFrom$1, width / height * (stretch || 1), 1);
|
|
9055
|
-
rotateOfOuter$1(transform, realFrom$1, getAngle$1(realFrom$1, realTo$1) + 90);
|
|
9056
|
-
}
|
|
9057
9110
|
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
9058
9111
|
applyStops(style, paint.stops, opacity);
|
|
9059
|
-
const data = { type, style
|
|
9112
|
+
const data = { type, style };
|
|
9113
|
+
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
9114
|
+
if (transform)
|
|
9115
|
+
data.transform = transform;
|
|
9060
9116
|
if (blendMode)
|
|
9061
9117
|
data.blendMode = blendMode;
|
|
9062
9118
|
return data;
|
|
9063
9119
|
}
|
|
9120
|
+
function getTransform(box, from, to, stretch, rotate90) {
|
|
9121
|
+
let transform;
|
|
9122
|
+
const { width, height } = box;
|
|
9123
|
+
if (width !== height || stretch) {
|
|
9124
|
+
const angle = getAngle(from, to);
|
|
9125
|
+
transform = get();
|
|
9126
|
+
if (rotate90) {
|
|
9127
|
+
scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
|
|
9128
|
+
rotateOfOuter(transform, from, angle + 90);
|
|
9129
|
+
}
|
|
9130
|
+
else {
|
|
9131
|
+
scaleOfOuter(transform, from, 1, width / height * (stretch || 1));
|
|
9132
|
+
rotateOfOuter(transform, from, angle);
|
|
9133
|
+
}
|
|
9134
|
+
}
|
|
9135
|
+
return transform;
|
|
9136
|
+
}
|
|
9064
9137
|
|
|
9065
|
-
const {
|
|
9066
|
-
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
|
|
9138
|
+
const { getDistance } = PointHelper;
|
|
9067
9139
|
const { toPoint } = AroundHelper;
|
|
9068
9140
|
const realFrom = {};
|
|
9069
9141
|
const realTo = {};
|
|
@@ -9071,20 +9143,12 @@ function conicGradient(paint, box) {
|
|
|
9071
9143
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
9072
9144
|
toPoint(from || 'center', box, realFrom);
|
|
9073
9145
|
toPoint(to || 'bottom', box, realTo);
|
|
9074
|
-
const { width, height } = box;
|
|
9075
|
-
const transform = get();
|
|
9076
|
-
const angle = getAngle(realFrom, realTo);
|
|
9077
|
-
if (Platform.conicGradientRotate90) {
|
|
9078
|
-
scaleOfOuter(transform, realFrom, width / height * (stretch || 1), 1);
|
|
9079
|
-
rotateOfOuter(transform, realFrom, angle + 90);
|
|
9080
|
-
}
|
|
9081
|
-
else {
|
|
9082
|
-
scaleOfOuter(transform, realFrom, 1, width / height * (stretch || 1));
|
|
9083
|
-
rotateOfOuter(transform, realFrom, angle);
|
|
9084
|
-
}
|
|
9085
9146
|
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));
|
|
9086
9147
|
applyStops(style, paint.stops, opacity);
|
|
9087
|
-
const data = { type, style
|
|
9148
|
+
const data = { type, style };
|
|
9149
|
+
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
9150
|
+
if (transform)
|
|
9151
|
+
data.transform = transform;
|
|
9088
9152
|
if (blendMode)
|
|
9089
9153
|
data.blendMode = blendMode;
|
|
9090
9154
|
return data;
|
|
@@ -9093,7 +9157,8 @@ function conicGradient(paint, box) {
|
|
|
9093
9157
|
const PaintGradientModule = {
|
|
9094
9158
|
linearGradient,
|
|
9095
9159
|
radialGradient,
|
|
9096
|
-
conicGradient
|
|
9160
|
+
conicGradient,
|
|
9161
|
+
getTransform
|
|
9097
9162
|
};
|
|
9098
9163
|
|
|
9099
9164
|
const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
|
|
@@ -9819,11 +9884,21 @@ const ExportModule = {
|
|
|
9819
9884
|
resolve();
|
|
9820
9885
|
this.running = false;
|
|
9821
9886
|
};
|
|
9887
|
+
const { toURL } = Platform;
|
|
9888
|
+
const { download } = Platform.origin;
|
|
9889
|
+
const fileType = FileHelper.fileType(filename);
|
|
9822
9890
|
if (filename === 'json') {
|
|
9823
9891
|
return over({ data: leaf.toJSON() });
|
|
9824
9892
|
}
|
|
9825
|
-
else if (
|
|
9826
|
-
|
|
9893
|
+
else if (fileType === 'json') {
|
|
9894
|
+
download(toURL(JSON.stringify(leaf.toJSON()), 'text'), filename);
|
|
9895
|
+
return over({ data: true });
|
|
9896
|
+
}
|
|
9897
|
+
if (filename === 'svg') {
|
|
9898
|
+
return over({ data: leaf.toSVG() });
|
|
9899
|
+
}
|
|
9900
|
+
else if (fileType === 'svg') {
|
|
9901
|
+
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
9827
9902
|
return over({ data: true });
|
|
9828
9903
|
}
|
|
9829
9904
|
const { leafer } = leaf;
|