@leafer-editor/worker 1.12.4 → 2.0.1
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.js +141 -103
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +145 -107
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +17 -17
package/dist/worker.module.js
CHANGED
|
@@ -216,59 +216,6 @@ class LeafData {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
const {floor: floor$2, max: max$7} = Math;
|
|
220
|
-
|
|
221
|
-
const Platform = {
|
|
222
|
-
toURL(text, fileType) {
|
|
223
|
-
let url = encodeURIComponent(text);
|
|
224
|
-
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
225
|
-
return url;
|
|
226
|
-
},
|
|
227
|
-
image: {
|
|
228
|
-
hitCanvasSize: 100,
|
|
229
|
-
maxCacheSize: 2560 * 1600,
|
|
230
|
-
maxPatternSize: 4096 * 2160,
|
|
231
|
-
crossOrigin: "anonymous",
|
|
232
|
-
isLarge(size, scaleX, scaleY, largeSize) {
|
|
233
|
-
return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image$1.maxCacheSize);
|
|
234
|
-
},
|
|
235
|
-
isSuperLarge(size, scaleX, scaleY) {
|
|
236
|
-
return image$1.isLarge(size, scaleX, scaleY, image$1.maxPatternSize);
|
|
237
|
-
},
|
|
238
|
-
getRealURL(url) {
|
|
239
|
-
const {prefix: prefix, suffix: suffix} = Platform.image;
|
|
240
|
-
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
241
|
-
if (prefix && url[0] === "/") url = prefix + url;
|
|
242
|
-
return url;
|
|
243
|
-
},
|
|
244
|
-
resize(image, width, height, xGap, yGap, clip, smooth, opacity, _filters) {
|
|
245
|
-
const canvas = Platform.origin.createCanvas(max$7(floor$2(width + (xGap || 0)), 1), max$7(floor$2(height + (yGap || 0)), 1));
|
|
246
|
-
const ctx = canvas.getContext("2d");
|
|
247
|
-
if (opacity) ctx.globalAlpha = opacity;
|
|
248
|
-
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
249
|
-
if (image) {
|
|
250
|
-
if (clip) {
|
|
251
|
-
const scaleX = width / clip.width, scaleY = height / clip.height;
|
|
252
|
-
ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
|
|
253
|
-
ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
254
|
-
} else ctx.drawImage(image, 0, 0, width, height);
|
|
255
|
-
}
|
|
256
|
-
return canvas;
|
|
257
|
-
},
|
|
258
|
-
setPatternTransform(pattern, transform, paint) {
|
|
259
|
-
try {
|
|
260
|
-
if (transform && pattern.setTransform) {
|
|
261
|
-
pattern.setTransform(transform);
|
|
262
|
-
transform = undefined;
|
|
263
|
-
}
|
|
264
|
-
} catch (_a) {}
|
|
265
|
-
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
const {image: image$1} = Platform;
|
|
271
|
-
|
|
272
219
|
const IncrementId = {
|
|
273
220
|
RUNTIME: "runtime",
|
|
274
221
|
LEAF: "leaf",
|
|
@@ -291,7 +238,7 @@ const I$2 = IncrementId;
|
|
|
291
238
|
|
|
292
239
|
let tempA, tempB, tempTo;
|
|
293
240
|
|
|
294
|
-
const {max: max$
|
|
241
|
+
const {max: max$7} = Math, tempFour = [ 0, 0, 0, 0 ];
|
|
295
242
|
|
|
296
243
|
const FourNumberHelper = {
|
|
297
244
|
zero: [ ...tempFour ],
|
|
@@ -343,9 +290,9 @@ const FourNumberHelper = {
|
|
|
343
290
|
return data;
|
|
344
291
|
},
|
|
345
292
|
max(t, other, change) {
|
|
346
|
-
if (isNumber(t) && isNumber(other)) return max$
|
|
293
|
+
if (isNumber(t) && isNumber(other)) return max$7(t, other);
|
|
347
294
|
toTempAB(t, other, change);
|
|
348
|
-
return set$2(tempTo, max$
|
|
295
|
+
return set$2(tempTo, max$7(tempA[0], tempB[0]), max$7(tempA[1], tempB[1]), max$7(tempA[2], tempB[2]), max$7(tempA[3], tempB[3]));
|
|
349
296
|
},
|
|
350
297
|
add(t, other, change) {
|
|
351
298
|
if (isNumber(t) && isNumber(other)) return t + other;
|
|
@@ -362,7 +309,7 @@ const FourNumberHelper = {
|
|
|
362
309
|
|
|
363
310
|
const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
|
|
364
311
|
|
|
365
|
-
const {round: round$3, pow: pow$1, max: max$
|
|
312
|
+
const {round: round$3, pow: pow$1, max: max$6, floor: floor$2, PI: PI$3} = Math;
|
|
366
313
|
|
|
367
314
|
const MathHelper = {
|
|
368
315
|
within(value, min, max) {
|
|
@@ -416,7 +363,7 @@ const MathHelper = {
|
|
|
416
363
|
}
|
|
417
364
|
},
|
|
418
365
|
getFloorScale(num, min = 1) {
|
|
419
|
-
return max$
|
|
366
|
+
return max$6(floor$2(num), min) / num;
|
|
420
367
|
},
|
|
421
368
|
randInt: randInt,
|
|
422
369
|
randColor(opacity) {
|
|
@@ -1261,7 +1208,7 @@ const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
|
|
|
1261
1208
|
|
|
1262
1209
|
const {float: float$1, fourNumber: fourNumber} = MathHelper;
|
|
1263
1210
|
|
|
1264
|
-
const {floor: floor, ceil: ceil$1} = Math;
|
|
1211
|
+
const {floor: floor$1, ceil: ceil$1} = Math;
|
|
1265
1212
|
|
|
1266
1213
|
let right$4, bottom$3, boundsRight, boundsBottom;
|
|
1267
1214
|
|
|
@@ -1418,8 +1365,8 @@ const BoundsHelper = {
|
|
|
1418
1365
|
},
|
|
1419
1366
|
ceil(t) {
|
|
1420
1367
|
const {x: x, y: y} = t;
|
|
1421
|
-
t.x = floor(t.x);
|
|
1422
|
-
t.y = floor(t.y);
|
|
1368
|
+
t.x = floor$1(t.x);
|
|
1369
|
+
t.y = floor$1(t.y);
|
|
1423
1370
|
t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
|
|
1424
1371
|
t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
|
|
1425
1372
|
},
|
|
@@ -1551,6 +1498,9 @@ const BoundsHelper = {
|
|
|
1551
1498
|
isEmpty(t) {
|
|
1552
1499
|
return t.x === 0 && t.y === 0 && t.width === 0 && t.height === 0;
|
|
1553
1500
|
},
|
|
1501
|
+
hasSize(t) {
|
|
1502
|
+
return t.width && t.height;
|
|
1503
|
+
},
|
|
1554
1504
|
reset(t) {
|
|
1555
1505
|
B.set(t);
|
|
1556
1506
|
}
|
|
@@ -1727,6 +1677,12 @@ class AutoBounds {
|
|
|
1727
1677
|
}
|
|
1728
1678
|
}
|
|
1729
1679
|
|
|
1680
|
+
const UnitConvertHelper = {
|
|
1681
|
+
number(value, percentRefer) {
|
|
1682
|
+
return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1730
1686
|
const StringNumberMap = {
|
|
1731
1687
|
0: 1,
|
|
1732
1688
|
1: 1,
|
|
@@ -1743,6 +1699,69 @@ const StringNumberMap = {
|
|
|
1743
1699
|
E: 1
|
|
1744
1700
|
};
|
|
1745
1701
|
|
|
1702
|
+
const {floor: floor, max: max$5} = Math;
|
|
1703
|
+
|
|
1704
|
+
const Platform = {
|
|
1705
|
+
toURL(text, fileType) {
|
|
1706
|
+
let url = encodeURIComponent(text);
|
|
1707
|
+
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
1708
|
+
return url;
|
|
1709
|
+
},
|
|
1710
|
+
image: {
|
|
1711
|
+
hitCanvasSize: 100,
|
|
1712
|
+
maxCacheSize: 2560 * 1600,
|
|
1713
|
+
maxPatternSize: 4096 * 2160,
|
|
1714
|
+
crossOrigin: "anonymous",
|
|
1715
|
+
isLarge(size, scaleX, scaleY, largeSize) {
|
|
1716
|
+
return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image$1.maxCacheSize);
|
|
1717
|
+
},
|
|
1718
|
+
isSuperLarge(size, scaleX, scaleY) {
|
|
1719
|
+
return image$1.isLarge(size, scaleX, scaleY, image$1.maxPatternSize);
|
|
1720
|
+
},
|
|
1721
|
+
getRealURL(url) {
|
|
1722
|
+
const {prefix: prefix, suffix: suffix} = image$1;
|
|
1723
|
+
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
1724
|
+
if (prefix && url[0] === "/") url = prefix + url;
|
|
1725
|
+
return url;
|
|
1726
|
+
},
|
|
1727
|
+
resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
|
|
1728
|
+
const realWidth = max$5(floor(width + (xGap || 0)), 1), realHeight = max$5(floor(height + (yGap || 0)), 1);
|
|
1729
|
+
let interlaceX, interlaceY, interlaceOffset;
|
|
1730
|
+
if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, interlace.type === "x" ? width : height))) interlace.type === "x" ? interlaceX = true : interlaceY = true;
|
|
1731
|
+
const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
|
|
1732
|
+
const ctx = canvas.getContext("2d");
|
|
1733
|
+
if (opacity) ctx.globalAlpha = opacity;
|
|
1734
|
+
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
1735
|
+
if (image$1.canUse(view)) {
|
|
1736
|
+
if (clip) {
|
|
1737
|
+
const scaleX = width / clip.width, scaleY = height / clip.height;
|
|
1738
|
+
ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
|
|
1739
|
+
ctx.drawImage(view, 0, 0, view.width, view.height);
|
|
1740
|
+
} else ctx.drawImage(view, 0, 0, width, height);
|
|
1741
|
+
if (interlaceOffset) {
|
|
1742
|
+
ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset - realWidth : realWidth, interlaceX ? realHeight : interlaceOffset - realHeight, realWidth, realHeight);
|
|
1743
|
+
ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset : realWidth, interlaceX ? realHeight : interlaceOffset, realWidth, realHeight);
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
return canvas;
|
|
1747
|
+
},
|
|
1748
|
+
canUse(view) {
|
|
1749
|
+
return view && view.width && !view.__closed;
|
|
1750
|
+
},
|
|
1751
|
+
setPatternTransform(pattern, transform, paint) {
|
|
1752
|
+
try {
|
|
1753
|
+
if (transform && pattern.setTransform) {
|
|
1754
|
+
pattern.setTransform(transform);
|
|
1755
|
+
transform = undefined;
|
|
1756
|
+
}
|
|
1757
|
+
} catch (_a) {}
|
|
1758
|
+
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
|
|
1763
|
+
const {image: image$1} = Platform;
|
|
1764
|
+
|
|
1746
1765
|
const {randColor: randColor} = MathHelper;
|
|
1747
1766
|
|
|
1748
1767
|
class Debug {
|
|
@@ -3298,10 +3317,10 @@ const PathCommandDataHelper = {
|
|
|
3298
3317
|
data.push(O$5, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
|
|
3299
3318
|
}
|
|
3300
3319
|
},
|
|
3301
|
-
arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
|
|
3320
|
+
arcTo(data, x1, y1, x2, y2, radius, lastX, lastY, fullRadius) {
|
|
3302
3321
|
if (!isUndefined(lastX)) {
|
|
3303
|
-
const
|
|
3304
|
-
radius = min$2(radius, min$2(
|
|
3322
|
+
const r = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / (fullRadius ? 1 : 2);
|
|
3323
|
+
radius = min$2(radius, min$2(r, r * abs$7(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
|
|
3305
3324
|
}
|
|
3306
3325
|
data.push(U$4, x1, y1, x2, y2, radius);
|
|
3307
3326
|
},
|
|
@@ -3645,7 +3664,7 @@ const PathCorner = {
|
|
|
3645
3664
|
let command, lastCommand, commandLen;
|
|
3646
3665
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3647
3666
|
if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
|
|
3648
|
-
const len = data.length;
|
|
3667
|
+
const len = data.length, three = len === 9;
|
|
3649
3668
|
const smooth = [];
|
|
3650
3669
|
while (i < len) {
|
|
3651
3670
|
command = data[i];
|
|
@@ -3657,7 +3676,7 @@ const PathCorner = {
|
|
|
3657
3676
|
if (data[i] === L$4) {
|
|
3658
3677
|
secondX = data[i + 1];
|
|
3659
3678
|
secondY = data[i + 2];
|
|
3660
|
-
smooth.push(M$4, getCenterX(startX, secondX), getCenterY(startY, secondY));
|
|
3679
|
+
three ? smooth.push(M$4, startX, startY) : smooth.push(M$4, getCenterX(startX, secondX), getCenterY(startY, secondY));
|
|
3661
3680
|
} else {
|
|
3662
3681
|
smooth.push(M$4, startX, startY);
|
|
3663
3682
|
}
|
|
@@ -3669,11 +3688,11 @@ const PathCorner = {
|
|
|
3669
3688
|
i += 3;
|
|
3670
3689
|
switch (data[i]) {
|
|
3671
3690
|
case L$4:
|
|
3672
|
-
arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
|
|
3691
|
+
arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY, three);
|
|
3673
3692
|
break;
|
|
3674
3693
|
|
|
3675
3694
|
case Z$2:
|
|
3676
|
-
arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
|
|
3695
|
+
arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
|
|
3677
3696
|
break;
|
|
3678
3697
|
|
|
3679
3698
|
default:
|
|
@@ -3685,7 +3704,7 @@ const PathCorner = {
|
|
|
3685
3704
|
|
|
3686
3705
|
case Z$2:
|
|
3687
3706
|
if (lastCommand !== Z$2) {
|
|
3688
|
-
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
|
|
3707
|
+
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY, three);
|
|
3689
3708
|
smooth.push(Z$2);
|
|
3690
3709
|
}
|
|
3691
3710
|
i += 1;
|
|
@@ -3785,9 +3804,10 @@ class TaskItem {
|
|
|
3785
3804
|
run() {
|
|
3786
3805
|
return __awaiter(this, void 0, void 0, function*() {
|
|
3787
3806
|
try {
|
|
3788
|
-
if (this.isComplete) return;
|
|
3807
|
+
if (this.isComplete || this.runing) return;
|
|
3808
|
+
this.runing = true;
|
|
3789
3809
|
if (this.canUse && !this.canUse()) return this.cancel();
|
|
3790
|
-
if (this.task
|
|
3810
|
+
if (this.task) yield this.task();
|
|
3791
3811
|
} catch (error) {
|
|
3792
3812
|
debug$c.error(error);
|
|
3793
3813
|
}
|
|
@@ -3903,7 +3923,7 @@ class TaskProcessor {
|
|
|
3903
3923
|
stop() {
|
|
3904
3924
|
this.isComplete = true;
|
|
3905
3925
|
this.list.forEach(task => {
|
|
3906
|
-
if (!task.isComplete) task.
|
|
3926
|
+
if (!task.isComplete) task.run();
|
|
3907
3927
|
});
|
|
3908
3928
|
this.pause();
|
|
3909
3929
|
this.empty();
|
|
@@ -4193,7 +4213,7 @@ class LeaferImage {
|
|
|
4193
4213
|
getFull(_filters) {
|
|
4194
4214
|
return this.view;
|
|
4195
4215
|
}
|
|
4196
|
-
getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
|
|
4216
|
+
getCanvas(width, height, opacity, filters, xGap, yGap, smooth, interlace) {
|
|
4197
4217
|
width || (width = this.width);
|
|
4198
4218
|
height || (height = this.height);
|
|
4199
4219
|
if (this.cache) {
|
|
@@ -4206,7 +4226,7 @@ class LeaferImage {
|
|
|
4206
4226
|
}
|
|
4207
4227
|
if (data) return data;
|
|
4208
4228
|
}
|
|
4209
|
-
const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
|
|
4229
|
+
const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters, interlace);
|
|
4210
4230
|
this.cache = this.use > 1 ? {
|
|
4211
4231
|
data: canvas,
|
|
4212
4232
|
params: arguments
|
|
@@ -6098,7 +6118,7 @@ const LeafRender = {
|
|
|
6098
6118
|
}
|
|
6099
6119
|
};
|
|
6100
6120
|
|
|
6101
|
-
const {excludeRenderBounds: excludeRenderBounds$1} = LeafBoundsHelper;
|
|
6121
|
+
const {excludeRenderBounds: excludeRenderBounds$1} = LeafBoundsHelper, {hasSize: hasSize} = BoundsHelper;
|
|
6102
6122
|
|
|
6103
6123
|
const BranchRender = {
|
|
6104
6124
|
__updateChange() {
|
|
@@ -6110,8 +6130,8 @@ const BranchRender = {
|
|
|
6110
6130
|
this.__.__checkSingle();
|
|
6111
6131
|
},
|
|
6112
6132
|
__render(canvas, options) {
|
|
6113
|
-
this.__nowWorld = this.__getNowWorld(options);
|
|
6114
|
-
if (this.__worldOpacity) {
|
|
6133
|
+
const nowWorld = this.__nowWorld = this.__getNowWorld(options);
|
|
6134
|
+
if (this.__worldOpacity && hasSize(nowWorld)) {
|
|
6115
6135
|
const data = this.__;
|
|
6116
6136
|
if (data.__useDim) {
|
|
6117
6137
|
if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
|
|
@@ -6120,7 +6140,6 @@ const BranchRender = {
|
|
|
6120
6140
|
if (data.eraser === "path") return this.__renderEraser(canvas, options);
|
|
6121
6141
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
6122
6142
|
this.__renderBranch(tempCanvas, options);
|
|
6123
|
-
const nowWorld = this.__nowWorld;
|
|
6124
6143
|
canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
|
|
6125
6144
|
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
|
|
6126
6145
|
tempCanvas.recycle(nowWorld);
|
|
@@ -6960,7 +6979,7 @@ class LeafLevelList {
|
|
|
6960
6979
|
}
|
|
6961
6980
|
}
|
|
6962
6981
|
|
|
6963
|
-
const version = "
|
|
6982
|
+
const version = "2.0.1";
|
|
6964
6983
|
|
|
6965
6984
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6966
6985
|
get allowBackgroundColor() {
|
|
@@ -7387,6 +7406,7 @@ class Renderer {
|
|
|
7387
7406
|
this.times = 0;
|
|
7388
7407
|
this.config = {
|
|
7389
7408
|
usePartRender: true,
|
|
7409
|
+
ceilPartPixel: true,
|
|
7390
7410
|
maxFPS: 120
|
|
7391
7411
|
};
|
|
7392
7412
|
this.frames = [];
|
|
@@ -7495,8 +7515,9 @@ class Renderer {
|
|
|
7495
7515
|
const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
7496
7516
|
canvas.save();
|
|
7497
7517
|
bounds.spread(Renderer.clipSpread).ceil();
|
|
7498
|
-
|
|
7499
|
-
canvas.clipWorld(bounds);
|
|
7518
|
+
const {ceilPartPixel: ceilPartPixel} = this.config;
|
|
7519
|
+
canvas.clipWorld(bounds, ceilPartPixel);
|
|
7520
|
+
canvas.clearWorld(bounds, ceilPartPixel);
|
|
7500
7521
|
this.__render(bounds, realBounds);
|
|
7501
7522
|
canvas.restore();
|
|
7502
7523
|
Run.end(t);
|
|
@@ -7895,11 +7916,7 @@ const ColorConvert = {
|
|
|
7895
7916
|
hasTransparent: hasTransparent$3
|
|
7896
7917
|
};
|
|
7897
7918
|
|
|
7898
|
-
const UnitConvert =
|
|
7899
|
-
number(value, percentRefer) {
|
|
7900
|
-
return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
|
|
7901
|
-
}
|
|
7902
|
-
};
|
|
7919
|
+
const UnitConvert = UnitConvertHelper;
|
|
7903
7920
|
|
|
7904
7921
|
const PathArrow = {};
|
|
7905
7922
|
|
|
@@ -7976,16 +7993,16 @@ class UIData extends LeafData {
|
|
|
7976
7993
|
return t.fill || t.stroke;
|
|
7977
7994
|
}
|
|
7978
7995
|
get __autoWidth() {
|
|
7979
|
-
return
|
|
7996
|
+
return this._width == null;
|
|
7980
7997
|
}
|
|
7981
7998
|
get __autoHeight() {
|
|
7982
|
-
return
|
|
7999
|
+
return this._height == null;
|
|
7983
8000
|
}
|
|
7984
8001
|
get __autoSide() {
|
|
7985
|
-
return
|
|
8002
|
+
return this._width == null || this._height == null;
|
|
7986
8003
|
}
|
|
7987
8004
|
get __autoSize() {
|
|
7988
|
-
return
|
|
8005
|
+
return this._width == null && this._height == null;
|
|
7989
8006
|
}
|
|
7990
8007
|
setVisible(value) {
|
|
7991
8008
|
this._visible = value;
|
|
@@ -9269,9 +9286,10 @@ let Ellipse = class Ellipse extends UI {
|
|
|
9269
9286
|
const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
|
|
9270
9287
|
const rx = width / 2, ry = height / 2;
|
|
9271
9288
|
const path = this.__.path = [];
|
|
9289
|
+
let open;
|
|
9272
9290
|
if (innerRadius) {
|
|
9273
9291
|
if (startAngle || endAngle) {
|
|
9274
|
-
if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false);
|
|
9292
|
+
if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false); else open = true;
|
|
9275
9293
|
ellipse(path, rx, ry, rx, ry, 0, endAngle, startAngle, true);
|
|
9276
9294
|
} else {
|
|
9277
9295
|
if (innerRadius < 1) {
|
|
@@ -9288,7 +9306,7 @@ let Ellipse = class Ellipse extends UI {
|
|
|
9288
9306
|
ellipse(path, rx, ry, rx, ry);
|
|
9289
9307
|
}
|
|
9290
9308
|
}
|
|
9291
|
-
closePath$2(path);
|
|
9309
|
+
if (!open) closePath$2(path);
|
|
9292
9310
|
if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
|
|
9293
9311
|
}
|
|
9294
9312
|
};
|
|
@@ -11153,6 +11171,7 @@ ui$2.__updateHitCanvas = function() {
|
|
|
11153
11171
|
ImageManager.patternLocked = true;
|
|
11154
11172
|
this.__renderShape(h, {
|
|
11155
11173
|
matrix: matrix$2.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y),
|
|
11174
|
+
snapshot: true,
|
|
11156
11175
|
ignoreFill: !isHitPixelFill,
|
|
11157
11176
|
ignoreStroke: !isHitPixelStroke
|
|
11158
11177
|
});
|
|
@@ -11726,7 +11745,7 @@ function getPatternData(paint, box, image) {
|
|
|
11726
11745
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
11727
11746
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
11728
11747
|
const {width: width, height: height} = image;
|
|
11729
|
-
const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters} = paint;
|
|
11748
|
+
const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters, interlace: interlace} = paint;
|
|
11730
11749
|
const sameBox = box.width === width && box.height === height;
|
|
11731
11750
|
const data = {
|
|
11732
11751
|
mode: mode
|
|
@@ -11792,6 +11811,10 @@ function getPatternData(paint, box, image) {
|
|
|
11792
11811
|
if (opacity && opacity < 1) data.opacity = opacity;
|
|
11793
11812
|
if (filters) data.filters = filters;
|
|
11794
11813
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
11814
|
+
if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
|
|
11815
|
+
type: "x",
|
|
11816
|
+
offset: interlace
|
|
11817
|
+
} : interlace;
|
|
11795
11818
|
return data;
|
|
11796
11819
|
}
|
|
11797
11820
|
|
|
@@ -11925,7 +11948,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
11925
11948
|
if (transform) copy$4(imageMatrix, transform);
|
|
11926
11949
|
scale$1(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
11927
11950
|
}
|
|
11928
|
-
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
11951
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
11929
11952
|
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
11930
11953
|
paint.style = pattern;
|
|
11931
11954
|
paint.patternId = id;
|
|
@@ -11947,8 +11970,8 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
11947
11970
|
|
|
11948
11971
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
11949
11972
|
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
11950
|
-
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
|
|
11951
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
11973
|
+
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
11974
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
|
|
11952
11975
|
return false;
|
|
11953
11976
|
} else {
|
|
11954
11977
|
if (drawImage) {
|
|
@@ -12622,7 +12645,7 @@ const TextMode = 2;
|
|
|
12622
12645
|
|
|
12623
12646
|
function layoutChar(drawData, style, width, _height) {
|
|
12624
12647
|
const {rows: rows} = drawData;
|
|
12625
|
-
const {textAlign: textAlign, paraIndent: paraIndent,
|
|
12648
|
+
const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
|
|
12626
12649
|
const justifyLast = width && textAlign.includes("both");
|
|
12627
12650
|
const justify = justifyLast || width && textAlign.includes("justify");
|
|
12628
12651
|
const justifyLetter = justify && textAlign.includes("letter");
|
|
@@ -12635,8 +12658,8 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
12635
12658
|
remainingWidth = width - row.width - indentWidth;
|
|
12636
12659
|
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
12637
12660
|
}
|
|
12638
|
-
mode =
|
|
12639
|
-
if (row.isOverflow && !
|
|
12661
|
+
mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
12662
|
+
if (row.isOverflow && !__letterSpacing) row.textMode = true;
|
|
12640
12663
|
if (mode === TextMode) {
|
|
12641
12664
|
row.x += indentWidth;
|
|
12642
12665
|
toTextChar$1(row);
|
|
@@ -12705,7 +12728,7 @@ function layoutText(drawData, style) {
|
|
|
12705
12728
|
let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
12706
12729
|
let starY = __baseLine;
|
|
12707
12730
|
if (__clipText && realHeight > height) {
|
|
12708
|
-
realHeight = Math.max(height, __lineHeight);
|
|
12731
|
+
realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
|
|
12709
12732
|
if (countRows > 1) drawData.overflow = countRows;
|
|
12710
12733
|
} else if (height || autoSizeAlign) {
|
|
12711
12734
|
switch (verticalAlign) {
|
|
@@ -12762,10 +12785,10 @@ function layoutText(drawData, style) {
|
|
|
12762
12785
|
}
|
|
12763
12786
|
|
|
12764
12787
|
function clipText(drawData, style, x, width) {
|
|
12765
|
-
if (!width) return;
|
|
12766
12788
|
const {rows: rows, overflow: overflow} = drawData;
|
|
12767
12789
|
let {textOverflow: textOverflow} = style;
|
|
12768
|
-
rows.splice(overflow);
|
|
12790
|
+
if (overflow) rows.splice(overflow);
|
|
12791
|
+
if (!width) return;
|
|
12769
12792
|
if (textOverflow && textOverflow !== "show") {
|
|
12770
12793
|
if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
|
|
12771
12794
|
let char, charRight;
|
|
@@ -13084,8 +13107,13 @@ class Stroker extends UI {
|
|
|
13084
13107
|
if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
|
|
13085
13108
|
}
|
|
13086
13109
|
data.strokeWidth = strokeWidth / Math.max(aScaleX, aScaleY);
|
|
13110
|
+
if (data.shadow) {
|
|
13111
|
+
const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
|
|
13112
|
+
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
13113
|
+
}
|
|
13087
13114
|
if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas, options) : Paint.strokes(stroke, this, canvas, options);
|
|
13088
13115
|
if (fill) isString(fill) ? Paint.fill(fill, this, canvas, options) : Paint.fills(fill, this, canvas, options);
|
|
13116
|
+
if (data.shadow) canvas.restore();
|
|
13089
13117
|
}
|
|
13090
13118
|
}
|
|
13091
13119
|
data.strokeWidth = strokeWidth;
|
|
@@ -15176,7 +15204,10 @@ class InnerEditor {
|
|
|
15176
15204
|
return "focus";
|
|
15177
15205
|
}
|
|
15178
15206
|
get editBox() {
|
|
15179
|
-
return this.editor.editBox;
|
|
15207
|
+
return this._editBox || this.editor.editBox;
|
|
15208
|
+
}
|
|
15209
|
+
set editBox(value) {
|
|
15210
|
+
this._editBox = value;
|
|
15180
15211
|
}
|
|
15181
15212
|
constructor(editor) {
|
|
15182
15213
|
this.eventIds = [];
|
|
@@ -15367,7 +15398,7 @@ let LineEditTool = class LineEditTool extends EditTool {
|
|
|
15367
15398
|
onSkew(_e) {}
|
|
15368
15399
|
onUpdate() {
|
|
15369
15400
|
const {editBox: editBox} = this, {rotatePoints: rotatePoints, resizeLines: resizeLines, resizePoints: resizePoints, rect: rect} = editBox;
|
|
15370
|
-
const line =
|
|
15401
|
+
const line = editBox.target;
|
|
15371
15402
|
let fromTo, leftOrRight;
|
|
15372
15403
|
if (line.pathInputed) fromTo = this.getFromToByPath(line.__.path); else if (line.points) fromTo = this.getFromToByPoints(line.__.points);
|
|
15373
15404
|
if (fromTo) {
|
|
@@ -15984,13 +16015,14 @@ leafer.initType = function(type) {
|
|
|
15984
16015
|
};
|
|
15985
16016
|
|
|
15986
16017
|
leafer.getValidMove = function(moveX, moveY, checkLimit = true) {
|
|
15987
|
-
const {disabled: disabled} = this.app.config.move;
|
|
16018
|
+
const {disabled: disabled, scrollSpread: scrollSpread} = this.app.config.move;
|
|
15988
16019
|
move.set(moveX, moveY);
|
|
15989
16020
|
const scrollType = getScrollType(this);
|
|
15990
16021
|
if (scrollType) {
|
|
15991
16022
|
if (scrollType.includes("x")) move.y = 0; else if (scrollType.includes("y")) move.x = 0; else Math.abs(move.x) > Math.abs(move.y) ? move.y = 0 : move.x = 0;
|
|
15992
16023
|
if (checkLimit && scrollType.includes("limit")) {
|
|
15993
16024
|
bounds.set(this.__world).addPoint(this.zoomLayer);
|
|
16025
|
+
if (scrollSpread) bounds.spread(scrollSpread);
|
|
15994
16026
|
DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, "auto", move, true);
|
|
15995
16027
|
if (scrollType.includes("x")) move.y = 0; else if (scrollType.includes("y")) move.x = 0;
|
|
15996
16028
|
}
|
|
@@ -17068,7 +17100,13 @@ const ExportModule = {
|
|
|
17068
17100
|
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
17069
17101
|
let pixelRatio = options.pixelRatio || 1;
|
|
17070
17102
|
let {x: x, y: y, width: width, height: height} = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
17071
|
-
if (clip)
|
|
17103
|
+
if (clip) {
|
|
17104
|
+
x += clip.x, y += clip.y, width = clip.width, height = clip.height;
|
|
17105
|
+
if (clip.rotation) matrix.rotateOfInner({
|
|
17106
|
+
x: x,
|
|
17107
|
+
y: y
|
|
17108
|
+
}, -clip.rotation);
|
|
17109
|
+
}
|
|
17072
17110
|
const renderOptions = {
|
|
17073
17111
|
exporting: true,
|
|
17074
17112
|
matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY)
|
|
@@ -17622,4 +17660,4 @@ HTMLText = __decorate([ registerUI() ], HTMLText);
|
|
|
17622
17660
|
|
|
17623
17661
|
Plugin.add("html");
|
|
17624
17662
|
|
|
17625
|
-
export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, FourNumberHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
|
|
17663
|
+
export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, FourNumberHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
|