@leafer-draw/miniapp 1.0.0-rc.24 → 1.0.0-rc.26
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/miniapp.esm.js +73 -49
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.module.js +143 -70
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +7 -7
package/dist/miniapp.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) { }
|
|
@@ -5166,6 +5195,9 @@ let Leaf = class Leaf {
|
|
|
5166
5195
|
toString() {
|
|
5167
5196
|
return JSON.stringify(this.toJSON());
|
|
5168
5197
|
}
|
|
5198
|
+
toSVG() { return undefined; }
|
|
5199
|
+
__SVG(_data) { }
|
|
5200
|
+
toHTML() { return undefined; }
|
|
5169
5201
|
__setAttr(_attrName, _newValue) { return true; }
|
|
5170
5202
|
__getAttr(_attrName) { return undefined; }
|
|
5171
5203
|
setProxyAttr(_attrName, _newValue) { }
|
|
@@ -5331,13 +5363,13 @@ let Leaf = class Leaf {
|
|
|
5331
5363
|
moveLocal(this, x, y);
|
|
5332
5364
|
}
|
|
5333
5365
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5334
|
-
zoomOfLocal(this,
|
|
5366
|
+
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5335
5367
|
}
|
|
5336
5368
|
rotateOf(origin, rotation) {
|
|
5337
|
-
rotateOfLocal(this,
|
|
5369
|
+
rotateOfLocal(this, getLocalOrigin(this, origin), rotation);
|
|
5338
5370
|
}
|
|
5339
5371
|
skewOf(origin, skewX, skewY, resize) {
|
|
5340
|
-
skewOfLocal(this,
|
|
5372
|
+
skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize);
|
|
5341
5373
|
}
|
|
5342
5374
|
transformWorld(worldTransform, resize) {
|
|
5343
5375
|
transformWorld(this, worldTransform, resize);
|
|
@@ -5359,6 +5391,14 @@ let Leaf = class Leaf {
|
|
|
5359
5391
|
this.scaleY *= scaleY;
|
|
5360
5392
|
}
|
|
5361
5393
|
__scaleResize(_scaleX, _scaleY) { }
|
|
5394
|
+
resizeWidth(width) {
|
|
5395
|
+
const scale = width / this.__localBoxBounds.width;
|
|
5396
|
+
this.scaleResize(scale, this.__.lockRatio ? scale : 1);
|
|
5397
|
+
}
|
|
5398
|
+
resizeHeight(height) {
|
|
5399
|
+
const scale = height / this.__localBoxBounds.height;
|
|
5400
|
+
this.scaleResize(this.__.lockRatio ? scale : 1, scale);
|
|
5401
|
+
}
|
|
5362
5402
|
__hitWorld(_point) { return true; }
|
|
5363
5403
|
__hit(_local) { return true; }
|
|
5364
5404
|
__hitFill(_inner) { return true; }
|
|
@@ -5709,7 +5749,7 @@ class LeafLevelList {
|
|
|
5709
5749
|
}
|
|
5710
5750
|
}
|
|
5711
5751
|
|
|
5712
|
-
const version = "1.0.0-rc.
|
|
5752
|
+
const version = "1.0.0-rc.26";
|
|
5713
5753
|
const inviteCode = {};
|
|
5714
5754
|
|
|
5715
5755
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -5834,9 +5874,12 @@ function useCanvas(_canvasType, app) {
|
|
|
5834
5874
|
if (toAlbum) {
|
|
5835
5875
|
Platform.miniapp.saveToAlbum(filePath).then(() => {
|
|
5836
5876
|
fs.unlink({ filePath });
|
|
5877
|
+
resolve();
|
|
5837
5878
|
});
|
|
5838
5879
|
}
|
|
5839
|
-
|
|
5880
|
+
else {
|
|
5881
|
+
resolve();
|
|
5882
|
+
}
|
|
5840
5883
|
},
|
|
5841
5884
|
fail(error) {
|
|
5842
5885
|
reject(error);
|
|
@@ -7102,7 +7145,7 @@ __decorate([
|
|
|
7102
7145
|
stateType(false)
|
|
7103
7146
|
], UI.prototype, "disabled", void 0);
|
|
7104
7147
|
__decorate([
|
|
7105
|
-
|
|
7148
|
+
surfaceType(false)
|
|
7106
7149
|
], UI.prototype, "locked", void 0);
|
|
7107
7150
|
__decorate([
|
|
7108
7151
|
sortType(0)
|
|
@@ -7184,10 +7227,10 @@ __decorate([
|
|
|
7184
7227
|
], UI.prototype, "gap", void 0);
|
|
7185
7228
|
__decorate([
|
|
7186
7229
|
boundsType('top-left')
|
|
7187
|
-
], UI.prototype, "
|
|
7230
|
+
], UI.prototype, "flowAlign", void 0);
|
|
7188
7231
|
__decorate([
|
|
7189
7232
|
boundsType(false)
|
|
7190
|
-
], UI.prototype, "
|
|
7233
|
+
], UI.prototype, "flowWrap", void 0);
|
|
7191
7234
|
__decorate([
|
|
7192
7235
|
boundsType('box')
|
|
7193
7236
|
], UI.prototype, "itemBox", void 0);
|
|
@@ -7200,6 +7243,9 @@ __decorate([
|
|
|
7200
7243
|
__decorate([
|
|
7201
7244
|
boundsType()
|
|
7202
7245
|
], UI.prototype, "autoHeight", void 0);
|
|
7246
|
+
__decorate([
|
|
7247
|
+
boundsType()
|
|
7248
|
+
], UI.prototype, "lockRatio", void 0);
|
|
7203
7249
|
__decorate([
|
|
7204
7250
|
boundsType()
|
|
7205
7251
|
], UI.prototype, "autoBox", void 0);
|
|
@@ -7789,9 +7835,9 @@ let Box = class Box extends Group {
|
|
|
7789
7835
|
if (!data.__autoSize) {
|
|
7790
7836
|
const b = this.__layout.boxBounds;
|
|
7791
7837
|
if (!data.__autoWidth)
|
|
7792
|
-
b.
|
|
7838
|
+
b.height += b.y, b.width = data.width, b.x = b.y = 0;
|
|
7793
7839
|
if (!data.__autoHeight)
|
|
7794
|
-
b.
|
|
7840
|
+
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
7795
7841
|
}
|
|
7796
7842
|
}
|
|
7797
7843
|
else {
|
|
@@ -7861,6 +7907,9 @@ let Box = class Box extends Group {
|
|
|
7861
7907
|
__decorate([
|
|
7862
7908
|
dataProcessor(BoxData)
|
|
7863
7909
|
], Box.prototype, "__", void 0);
|
|
7910
|
+
__decorate([
|
|
7911
|
+
dataType(false)
|
|
7912
|
+
], Box.prototype, "resizeChildren", void 0);
|
|
7864
7913
|
__decorate([
|
|
7865
7914
|
affectRenderBoundsType('show')
|
|
7866
7915
|
], Box.prototype, "overflow", void 0);
|
|
@@ -7970,7 +8019,7 @@ Ellipse = __decorate([
|
|
|
7970
8019
|
], Ellipse);
|
|
7971
8020
|
|
|
7972
8021
|
const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
|
|
7973
|
-
const { rotate: rotate$1, getAngle: getAngle$
|
|
8022
|
+
const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
|
|
7974
8023
|
const { toBounds: toBounds$1 } = PathBounds;
|
|
7975
8024
|
let Line = class Line extends UI {
|
|
7976
8025
|
get __tag() { return 'Line'; }
|
|
@@ -7985,7 +8034,7 @@ let Line = class Line extends UI {
|
|
|
7985
8034
|
}
|
|
7986
8035
|
set toPoint(value) {
|
|
7987
8036
|
this.width = getDistance$2(defaultPoint, value);
|
|
7988
|
-
this.rotation = getAngle$
|
|
8037
|
+
this.rotation = getAngle$1(defaultPoint, value);
|
|
7989
8038
|
if (this.height)
|
|
7990
8039
|
this.height = 0;
|
|
7991
8040
|
}
|
|
@@ -8332,6 +8381,9 @@ __decorate([
|
|
|
8332
8381
|
__decorate([
|
|
8333
8382
|
boundsType(0)
|
|
8334
8383
|
], Text.prototype, "height", void 0);
|
|
8384
|
+
__decorate([
|
|
8385
|
+
dataType(false)
|
|
8386
|
+
], Text.prototype, "resizeFontSize", void 0);
|
|
8335
8387
|
__decorate([
|
|
8336
8388
|
surfaceType('#000000')
|
|
8337
8389
|
], Text.prototype, "fill", void 0);
|
|
@@ -8744,7 +8796,7 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
8744
8796
|
case 'angular':
|
|
8745
8797
|
return PaintGradient.conicGradient(paint, boxBounds);
|
|
8746
8798
|
default:
|
|
8747
|
-
return paint.r ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
|
|
8799
|
+
return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
|
|
8748
8800
|
}
|
|
8749
8801
|
}
|
|
8750
8802
|
|
|
@@ -8761,17 +8813,17 @@ const PaintModule = {
|
|
|
8761
8813
|
};
|
|
8762
8814
|
|
|
8763
8815
|
let origin = {};
|
|
8764
|
-
const { get: get$
|
|
8816
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
|
|
8765
8817
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
8766
|
-
const transform = get$
|
|
8818
|
+
const transform = get$3();
|
|
8767
8819
|
translate$1(transform, box.x + x, box.y + y);
|
|
8768
8820
|
scaleHelper(transform, scaleX, scaleY);
|
|
8769
8821
|
if (rotation)
|
|
8770
|
-
rotateOfOuter$
|
|
8822
|
+
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
8771
8823
|
data.transform = transform;
|
|
8772
8824
|
}
|
|
8773
8825
|
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
8774
|
-
const transform = get$
|
|
8826
|
+
const transform = get$3();
|
|
8775
8827
|
translate$1(transform, box.x + x, box.y + y);
|
|
8776
8828
|
if (scaleX)
|
|
8777
8829
|
scaleHelper(transform, scaleX, scaleY);
|
|
@@ -8780,10 +8832,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
8780
8832
|
data.transform = transform;
|
|
8781
8833
|
}
|
|
8782
8834
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
8783
|
-
const transform = get$
|
|
8835
|
+
const transform = get$3();
|
|
8784
8836
|
if (rotation) {
|
|
8785
8837
|
if (align === 'center') {
|
|
8786
|
-
rotateOfOuter$
|
|
8838
|
+
rotateOfOuter$1(transform, { x: width / 2, y: height / 2 }, rotation);
|
|
8787
8839
|
}
|
|
8788
8840
|
else {
|
|
8789
8841
|
rotate(transform, rotation);
|
|
@@ -8804,22 +8856,26 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
8804
8856
|
origin.y = box.y + y;
|
|
8805
8857
|
translate$1(transform, origin.x, origin.y);
|
|
8806
8858
|
if (scaleX)
|
|
8807
|
-
scaleOfOuter$
|
|
8859
|
+
scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
8808
8860
|
data.transform = transform;
|
|
8809
8861
|
}
|
|
8810
8862
|
|
|
8811
|
-
const { get: get$
|
|
8863
|
+
const { get: get$2, translate } = MatrixHelper;
|
|
8812
8864
|
const tempBox = new Bounds();
|
|
8813
8865
|
const tempPoint = {};
|
|
8814
8866
|
function createData(leafPaint, image, paint, box) {
|
|
8867
|
+
const { blendMode } = paint;
|
|
8868
|
+
if (blendMode)
|
|
8869
|
+
leafPaint.blendMode = blendMode;
|
|
8870
|
+
leafPaint.data = getPatternData(paint, box, image);
|
|
8871
|
+
}
|
|
8872
|
+
function getPatternData(paint, box, image) {
|
|
8815
8873
|
let { width, height } = image;
|
|
8816
8874
|
if (paint.padding)
|
|
8817
8875
|
box = tempBox.set(box).shrink(paint.padding);
|
|
8818
|
-
const { opacity, mode, align, offset, scale, size, rotation,
|
|
8876
|
+
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
8819
8877
|
const sameBox = box.width === width && box.height === height;
|
|
8820
|
-
|
|
8821
|
-
leafPaint.blendMode = blendMode;
|
|
8822
|
-
const data = leafPaint.data = { mode };
|
|
8878
|
+
const data = { mode };
|
|
8823
8879
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
8824
8880
|
const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
|
|
8825
8881
|
let x = 0, y = 0, scaleX, scaleY;
|
|
@@ -8871,7 +8927,7 @@ function createData(leafPaint, image, paint, box) {
|
|
|
8871
8927
|
}
|
|
8872
8928
|
if (!data.transform) {
|
|
8873
8929
|
if (box.x || box.y) {
|
|
8874
|
-
data.transform = get$
|
|
8930
|
+
data.transform = get$2();
|
|
8875
8931
|
translate(data.transform, box.x, box.y);
|
|
8876
8932
|
}
|
|
8877
8933
|
}
|
|
@@ -8885,6 +8941,7 @@ function createData(leafPaint, image, paint, box) {
|
|
|
8885
8941
|
data.opacity = opacity;
|
|
8886
8942
|
if (repeat)
|
|
8887
8943
|
data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
|
|
8944
|
+
return data;
|
|
8888
8945
|
}
|
|
8889
8946
|
|
|
8890
8947
|
let cache, box = new Bounds();
|
|
@@ -8974,7 +9031,7 @@ function ignoreRender(ui, value) {
|
|
|
8974
9031
|
leafer.renderer.ignore = value;
|
|
8975
9032
|
}
|
|
8976
9033
|
|
|
8977
|
-
const { get: get$
|
|
9034
|
+
const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
|
|
8978
9035
|
const { ceil, abs: abs$1 } = Math;
|
|
8979
9036
|
function createPattern(ui, paint, pixelRatio) {
|
|
8980
9037
|
let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
@@ -8985,7 +9042,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
8985
9042
|
const { image, data } = paint;
|
|
8986
9043
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
|
|
8987
9044
|
if (sx) {
|
|
8988
|
-
imageMatrix = get$
|
|
9045
|
+
imageMatrix = get$1();
|
|
8989
9046
|
copy$1(imageMatrix, transform);
|
|
8990
9047
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
8991
9048
|
scaleX *= sx;
|
|
@@ -9020,7 +9077,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
9020
9077
|
}
|
|
9021
9078
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
9022
9079
|
if (!imageMatrix) {
|
|
9023
|
-
imageMatrix = get$
|
|
9080
|
+
imageMatrix = get$1();
|
|
9024
9081
|
if (transform)
|
|
9025
9082
|
copy$1(imageMatrix, transform);
|
|
9026
9083
|
}
|
|
@@ -9121,13 +9178,14 @@ function recycleImage(attrName, data) {
|
|
|
9121
9178
|
|
|
9122
9179
|
const PaintImageModule = {
|
|
9123
9180
|
image,
|
|
9181
|
+
checkImage,
|
|
9182
|
+
createPattern,
|
|
9183
|
+
recycleImage,
|
|
9124
9184
|
createData,
|
|
9185
|
+
getPatternData,
|
|
9125
9186
|
fillOrFitMode,
|
|
9126
9187
|
clipMode,
|
|
9127
|
-
repeatMode
|
|
9128
|
-
createPattern,
|
|
9129
|
-
checkImage,
|
|
9130
|
-
recycleImage
|
|
9188
|
+
repeatMode
|
|
9131
9189
|
};
|
|
9132
9190
|
|
|
9133
9191
|
const { toPoint: toPoint$2 } = AroundHelper;
|
|
@@ -9157,8 +9215,8 @@ function applyStops(gradient, stops, opacity) {
|
|
|
9157
9215
|
}
|
|
9158
9216
|
}
|
|
9159
9217
|
|
|
9160
|
-
const { getAngle
|
|
9161
|
-
const { get
|
|
9218
|
+
const { getAngle, getDistance: getDistance$1 } = PointHelper;
|
|
9219
|
+
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
|
|
9162
9220
|
const { toPoint: toPoint$1 } = AroundHelper;
|
|
9163
9221
|
const realFrom$1 = {};
|
|
9164
9222
|
const realTo$1 = {};
|
|
@@ -9166,23 +9224,35 @@ function radialGradient(paint, box) {
|
|
|
9166
9224
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
9167
9225
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
9168
9226
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
9169
|
-
const { width, height } = box;
|
|
9170
|
-
let transform;
|
|
9171
|
-
if (width !== height || stretch) {
|
|
9172
|
-
transform = get$1();
|
|
9173
|
-
scaleOfOuter$1(transform, realFrom$1, width / height * (stretch || 1), 1);
|
|
9174
|
-
rotateOfOuter$1(transform, realFrom$1, getAngle$1(realFrom$1, realTo$1) + 90);
|
|
9175
|
-
}
|
|
9176
9227
|
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
9177
9228
|
applyStops(style, paint.stops, opacity);
|
|
9178
|
-
const data = { type, style
|
|
9229
|
+
const data = { type, style };
|
|
9230
|
+
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
9231
|
+
if (transform)
|
|
9232
|
+
data.transform = transform;
|
|
9179
9233
|
if (blendMode)
|
|
9180
9234
|
data.blendMode = blendMode;
|
|
9181
9235
|
return data;
|
|
9182
9236
|
}
|
|
9237
|
+
function getTransform(box, from, to, stretch, rotate90) {
|
|
9238
|
+
let transform;
|
|
9239
|
+
const { width, height } = box;
|
|
9240
|
+
if (width !== height || stretch) {
|
|
9241
|
+
const angle = getAngle(from, to);
|
|
9242
|
+
transform = get();
|
|
9243
|
+
if (rotate90) {
|
|
9244
|
+
scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
|
|
9245
|
+
rotateOfOuter(transform, from, angle + 90);
|
|
9246
|
+
}
|
|
9247
|
+
else {
|
|
9248
|
+
scaleOfOuter(transform, from, 1, width / height * (stretch || 1));
|
|
9249
|
+
rotateOfOuter(transform, from, angle);
|
|
9250
|
+
}
|
|
9251
|
+
}
|
|
9252
|
+
return transform;
|
|
9253
|
+
}
|
|
9183
9254
|
|
|
9184
|
-
const {
|
|
9185
|
-
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
|
|
9255
|
+
const { getDistance } = PointHelper;
|
|
9186
9256
|
const { toPoint } = AroundHelper;
|
|
9187
9257
|
const realFrom = {};
|
|
9188
9258
|
const realTo = {};
|
|
@@ -9190,20 +9260,12 @@ function conicGradient(paint, box) {
|
|
|
9190
9260
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
9191
9261
|
toPoint(from || 'center', box, realFrom);
|
|
9192
9262
|
toPoint(to || 'bottom', box, realTo);
|
|
9193
|
-
const { width, height } = box;
|
|
9194
|
-
const transform = get();
|
|
9195
|
-
const angle = getAngle(realFrom, realTo);
|
|
9196
|
-
if (Platform.conicGradientRotate90) {
|
|
9197
|
-
scaleOfOuter(transform, realFrom, width / height * (stretch || 1), 1);
|
|
9198
|
-
rotateOfOuter(transform, realFrom, angle + 90);
|
|
9199
|
-
}
|
|
9200
|
-
else {
|
|
9201
|
-
scaleOfOuter(transform, realFrom, 1, width / height * (stretch || 1));
|
|
9202
|
-
rotateOfOuter(transform, realFrom, angle);
|
|
9203
|
-
}
|
|
9204
9263
|
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));
|
|
9205
9264
|
applyStops(style, paint.stops, opacity);
|
|
9206
|
-
const data = { type, style
|
|
9265
|
+
const data = { type, style };
|
|
9266
|
+
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
9267
|
+
if (transform)
|
|
9268
|
+
data.transform = transform;
|
|
9207
9269
|
if (blendMode)
|
|
9208
9270
|
data.blendMode = blendMode;
|
|
9209
9271
|
return data;
|
|
@@ -9212,7 +9274,8 @@ function conicGradient(paint, box) {
|
|
|
9212
9274
|
const PaintGradientModule = {
|
|
9213
9275
|
linearGradient,
|
|
9214
9276
|
radialGradient,
|
|
9215
|
-
conicGradient
|
|
9277
|
+
conicGradient,
|
|
9278
|
+
getTransform
|
|
9216
9279
|
};
|
|
9217
9280
|
|
|
9218
9281
|
const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
|
|
@@ -9938,11 +10001,21 @@ const ExportModule = {
|
|
|
9938
10001
|
resolve();
|
|
9939
10002
|
this.running = false;
|
|
9940
10003
|
};
|
|
10004
|
+
const { toURL } = Platform;
|
|
10005
|
+
const { download } = Platform.origin;
|
|
10006
|
+
const fileType = FileHelper.fileType(filename);
|
|
9941
10007
|
if (filename === 'json') {
|
|
9942
10008
|
return over({ data: leaf.toJSON() });
|
|
9943
10009
|
}
|
|
9944
|
-
else if (
|
|
9945
|
-
|
|
10010
|
+
else if (fileType === 'json') {
|
|
10011
|
+
download(toURL(JSON.stringify(leaf.toJSON()), 'text'), filename);
|
|
10012
|
+
return over({ data: true });
|
|
10013
|
+
}
|
|
10014
|
+
if (filename === 'svg') {
|
|
10015
|
+
return over({ data: leaf.toSVG() });
|
|
10016
|
+
}
|
|
10017
|
+
else if (fileType === 'svg') {
|
|
10018
|
+
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
9946
10019
|
return over({ data: true });
|
|
9947
10020
|
}
|
|
9948
10021
|
const { leafer } = leaf;
|