@leafer-ui/miniapp 1.9.12 → 1.10.0
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.cjs +397 -394
- package/dist/miniapp.esm.js +399 -396
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +548 -522
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +12 -12
package/dist/miniapp.module.js
CHANGED
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
const Platform = {
|
|
2
|
-
toURL(text, fileType) {
|
|
3
|
-
let url = encodeURIComponent(text);
|
|
4
|
-
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
5
|
-
return url;
|
|
6
|
-
},
|
|
7
|
-
image: {
|
|
8
|
-
hitCanvasSize: 100,
|
|
9
|
-
maxCacheSize: 2560 * 1600,
|
|
10
|
-
maxPatternSize: 4096 * 2160,
|
|
11
|
-
crossOrigin: "anonymous",
|
|
12
|
-
getRealURL(url) {
|
|
13
|
-
const {prefix: prefix, suffix: suffix} = Platform.image;
|
|
14
|
-
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
15
|
-
if (prefix && url[0] === "/") url = prefix + url;
|
|
16
|
-
return url;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const IncrementId = {
|
|
22
|
-
RUNTIME: "runtime",
|
|
23
|
-
LEAF: "leaf",
|
|
24
|
-
TASK: "task",
|
|
25
|
-
CNAVAS: "canvas",
|
|
26
|
-
IMAGE: "image",
|
|
27
|
-
types: {},
|
|
28
|
-
create(typeName) {
|
|
29
|
-
const {types: types} = I$2;
|
|
30
|
-
if (types[typeName]) {
|
|
31
|
-
return types[typeName]++;
|
|
32
|
-
} else {
|
|
33
|
-
types[typeName] = 1;
|
|
34
|
-
return 0;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const I$2 = IncrementId;
|
|
40
|
-
|
|
41
1
|
var Answer;
|
|
42
2
|
|
|
43
3
|
(function(Answer) {
|
|
@@ -247,9 +207,80 @@ class LeafData {
|
|
|
247
207
|
}
|
|
248
208
|
}
|
|
249
209
|
|
|
210
|
+
const {floor: floor$2, max: max$5} = Math;
|
|
211
|
+
|
|
212
|
+
const Platform = {
|
|
213
|
+
toURL(text, fileType) {
|
|
214
|
+
let url = encodeURIComponent(text);
|
|
215
|
+
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
216
|
+
return url;
|
|
217
|
+
},
|
|
218
|
+
image: {
|
|
219
|
+
hitCanvasSize: 100,
|
|
220
|
+
maxCacheSize: 2560 * 1600,
|
|
221
|
+
maxPatternSize: 4096 * 2160,
|
|
222
|
+
crossOrigin: "anonymous",
|
|
223
|
+
isLarge(size, scaleX, scaleY, largeSize) {
|
|
224
|
+
return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image$1.maxCacheSize);
|
|
225
|
+
},
|
|
226
|
+
isSuperLarge(size, scaleX, scaleY) {
|
|
227
|
+
return image$1.isLarge(size, scaleX, scaleY, image$1.maxPatternSize);
|
|
228
|
+
},
|
|
229
|
+
getRealURL(url) {
|
|
230
|
+
const {prefix: prefix, suffix: suffix} = Platform.image;
|
|
231
|
+
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
232
|
+
if (prefix && url[0] === "/") url = prefix + url;
|
|
233
|
+
return url;
|
|
234
|
+
},
|
|
235
|
+
resize(image, width, height, xGap, yGap, clip, smooth, opacity, _filters) {
|
|
236
|
+
const canvas = Platform.origin.createCanvas(max$5(floor$2(width + (xGap || 0)), 1), max$5(floor$2(height + (yGap || 0)), 1));
|
|
237
|
+
const ctx = canvas.getContext("2d");
|
|
238
|
+
if (opacity) ctx.globalAlpha = opacity;
|
|
239
|
+
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
240
|
+
if (clip) {
|
|
241
|
+
const scaleX = width / clip.width, scaleY = height / clip.height;
|
|
242
|
+
ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
|
|
243
|
+
ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
244
|
+
} else ctx.drawImage(image, 0, 0, width, height);
|
|
245
|
+
return canvas;
|
|
246
|
+
},
|
|
247
|
+
setPatternTransform(pattern, transform, paint) {
|
|
248
|
+
try {
|
|
249
|
+
if (transform && pattern.setTransform) {
|
|
250
|
+
pattern.setTransform(transform);
|
|
251
|
+
transform = undefined;
|
|
252
|
+
}
|
|
253
|
+
} catch (_a) {}
|
|
254
|
+
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const {image: image$1} = Platform;
|
|
260
|
+
|
|
261
|
+
const IncrementId = {
|
|
262
|
+
RUNTIME: "runtime",
|
|
263
|
+
LEAF: "leaf",
|
|
264
|
+
TASK: "task",
|
|
265
|
+
CNAVAS: "canvas",
|
|
266
|
+
IMAGE: "image",
|
|
267
|
+
types: {},
|
|
268
|
+
create(typeName) {
|
|
269
|
+
const {types: types} = I$2;
|
|
270
|
+
if (types[typeName]) {
|
|
271
|
+
return types[typeName]++;
|
|
272
|
+
} else {
|
|
273
|
+
types[typeName] = 1;
|
|
274
|
+
return 0;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const I$2 = IncrementId;
|
|
280
|
+
|
|
250
281
|
let tempA, tempB, tempTo;
|
|
251
282
|
|
|
252
|
-
const {max: max$
|
|
283
|
+
const {max: max$4} = Math, tempFour = [ 0, 0, 0, 0 ];
|
|
253
284
|
|
|
254
285
|
const FourNumberHelper = {
|
|
255
286
|
zero: [ ...tempFour ],
|
|
@@ -301,9 +332,9 @@ const FourNumberHelper = {
|
|
|
301
332
|
return data;
|
|
302
333
|
},
|
|
303
334
|
max(t, other, change) {
|
|
304
|
-
if (isNumber(t) && isNumber(other)) return max$
|
|
335
|
+
if (isNumber(t) && isNumber(other)) return max$4(t, other);
|
|
305
336
|
toTempAB(t, other, change);
|
|
306
|
-
return set$2(tempTo, max$
|
|
337
|
+
return set$2(tempTo, max$4(tempA[0], tempB[0]), max$4(tempA[1], tempB[1]), max$4(tempA[2], tempB[2]), max$4(tempA[3], tempB[3]));
|
|
307
338
|
},
|
|
308
339
|
add(t, other, change) {
|
|
309
340
|
if (isNumber(t) && isNumber(other)) return t + other;
|
|
@@ -320,7 +351,7 @@ const FourNumberHelper = {
|
|
|
320
351
|
|
|
321
352
|
const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
|
|
322
353
|
|
|
323
|
-
const {round: round$3, pow: pow$1, PI: PI$3} = Math;
|
|
354
|
+
const {round: round$3, pow: pow$1, max: max$3, floor: floor$1, PI: PI$3} = Math;
|
|
324
355
|
|
|
325
356
|
const MathHelper = {
|
|
326
357
|
within(value, min, max) {
|
|
@@ -373,6 +404,9 @@ const MathHelper = {
|
|
|
373
404
|
scaleData.scaleY = scale.y;
|
|
374
405
|
}
|
|
375
406
|
},
|
|
407
|
+
getFloorScale(num, min = 1) {
|
|
408
|
+
return max$3(floor$1(num), min) / num;
|
|
409
|
+
},
|
|
376
410
|
randInt: randInt,
|
|
377
411
|
randColor(opacity) {
|
|
378
412
|
return `rgba(${randInt(255)},${randInt(255)},${randInt(255)},${opacity || 1})`;
|
|
@@ -1202,7 +1236,7 @@ const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
|
|
|
1202
1236
|
|
|
1203
1237
|
const {float: float$1, fourNumber: fourNumber} = MathHelper;
|
|
1204
1238
|
|
|
1205
|
-
const {floor: floor
|
|
1239
|
+
const {floor: floor, ceil: ceil$1} = Math;
|
|
1206
1240
|
|
|
1207
1241
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
1208
1242
|
|
|
@@ -1294,20 +1328,20 @@ const BoundsHelper = {
|
|
|
1294
1328
|
toOuterOf(t, matrix, to) {
|
|
1295
1329
|
to || (to = t);
|
|
1296
1330
|
if (matrix.b === 0 && matrix.c === 0) {
|
|
1297
|
-
const {a: a, d: d} = matrix;
|
|
1331
|
+
const {a: a, d: d, e: e, f: f} = matrix;
|
|
1298
1332
|
if (a > 0) {
|
|
1299
1333
|
to.width = t.width * a;
|
|
1300
|
-
to.x =
|
|
1334
|
+
to.x = e + t.x * a;
|
|
1301
1335
|
} else {
|
|
1302
1336
|
to.width = t.width * -a;
|
|
1303
|
-
to.x =
|
|
1337
|
+
to.x = e + t.x * a - to.width;
|
|
1304
1338
|
}
|
|
1305
1339
|
if (d > 0) {
|
|
1306
1340
|
to.height = t.height * d;
|
|
1307
|
-
to.y =
|
|
1341
|
+
to.y = f + t.y * d;
|
|
1308
1342
|
} else {
|
|
1309
1343
|
to.height = t.height * -d;
|
|
1310
|
-
to.y =
|
|
1344
|
+
to.y = f + t.y * d - to.height;
|
|
1311
1345
|
}
|
|
1312
1346
|
} else {
|
|
1313
1347
|
point.x = t.x;
|
|
@@ -1359,10 +1393,10 @@ const BoundsHelper = {
|
|
|
1359
1393
|
},
|
|
1360
1394
|
ceil(t) {
|
|
1361
1395
|
const {x: x, y: y} = t;
|
|
1362
|
-
t.x = floor
|
|
1363
|
-
t.y = floor
|
|
1364
|
-
t.width = x > t.x ? ceil$
|
|
1365
|
-
t.height = y > t.y ? ceil$
|
|
1396
|
+
t.x = floor(t.x);
|
|
1397
|
+
t.y = floor(t.y);
|
|
1398
|
+
t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
|
|
1399
|
+
t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
|
|
1366
1400
|
},
|
|
1367
1401
|
unsign(t) {
|
|
1368
1402
|
if (t.width < 0) {
|
|
@@ -2592,7 +2626,7 @@ const RectHelper = {
|
|
|
2592
2626
|
}
|
|
2593
2627
|
};
|
|
2594
2628
|
|
|
2595
|
-
const {sin: sin$3, cos: cos$3, hypot: hypot, atan2: atan2$1, ceil: ceil
|
|
2629
|
+
const {sin: sin$3, cos: cos$3, hypot: hypot, atan2: atan2$1, ceil: ceil, abs: abs$4, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
|
|
2596
2630
|
|
|
2597
2631
|
const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
|
|
2598
2632
|
|
|
@@ -2700,7 +2734,7 @@ const BezierHelper = {
|
|
|
2700
2734
|
let totalRadian = endRadian - startRadian;
|
|
2701
2735
|
if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
|
|
2702
2736
|
if (anticlockwise) totalRadian -= PI2;
|
|
2703
|
-
const parts = ceil
|
|
2737
|
+
const parts = ceil(abs$4(totalRadian / PI_2));
|
|
2704
2738
|
const partRadian = totalRadian / parts;
|
|
2705
2739
|
const partRadian4Sin = sin$3(partRadian / 4);
|
|
2706
2740
|
const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
|
|
@@ -3708,7 +3742,9 @@ class TaskItem {
|
|
|
3708
3742
|
run() {
|
|
3709
3743
|
return __awaiter(this, void 0, void 0, function*() {
|
|
3710
3744
|
try {
|
|
3711
|
-
if (this.
|
|
3745
|
+
if (this.isComplete) return;
|
|
3746
|
+
if (this.canUse && !this.canUse()) return this.cancel();
|
|
3747
|
+
if (this.task && this.parent.running) yield this.task();
|
|
3712
3748
|
} catch (error) {
|
|
3713
3749
|
debug$9.error(error);
|
|
3714
3750
|
}
|
|
@@ -3716,8 +3752,7 @@ class TaskItem {
|
|
|
3716
3752
|
}
|
|
3717
3753
|
complete() {
|
|
3718
3754
|
this.isComplete = true;
|
|
3719
|
-
this.parent = null;
|
|
3720
|
-
this.task = null;
|
|
3755
|
+
this.parent = this.task = this.canUse = null;
|
|
3721
3756
|
}
|
|
3722
3757
|
cancel() {
|
|
3723
3758
|
this.isCancel = true;
|
|
@@ -3760,7 +3795,7 @@ class TaskProcessor {
|
|
|
3760
3795
|
if (config) DataHelper.assign(this.config, config);
|
|
3761
3796
|
this.empty();
|
|
3762
3797
|
}
|
|
3763
|
-
add(taskCallback, options) {
|
|
3798
|
+
add(taskCallback, options, canUse) {
|
|
3764
3799
|
let start, parallel, time, delay;
|
|
3765
3800
|
const task = new TaskItem(taskCallback);
|
|
3766
3801
|
task.parent = this;
|
|
@@ -3771,9 +3806,11 @@ class TaskProcessor {
|
|
|
3771
3806
|
start = options.start;
|
|
3772
3807
|
time = options.time;
|
|
3773
3808
|
delay = options.delay;
|
|
3809
|
+
if (!canUse) canUse = options.canUse;
|
|
3774
3810
|
}
|
|
3775
3811
|
if (time) task.time = time;
|
|
3776
3812
|
if (parallel === false) task.parallel = false;
|
|
3813
|
+
if (canUse) task.canUse = canUse;
|
|
3777
3814
|
if (isUndefined(delay)) {
|
|
3778
3815
|
this.push(task, start);
|
|
3779
3816
|
} else {
|
|
@@ -3843,15 +3880,10 @@ class TaskProcessor {
|
|
|
3843
3880
|
this.timer = setTimeout(() => this.nextTask());
|
|
3844
3881
|
return;
|
|
3845
3882
|
}
|
|
3846
|
-
if (task.isCancel) {
|
|
3847
|
-
this.index++;
|
|
3848
|
-
this.runTask();
|
|
3849
|
-
return;
|
|
3850
|
-
}
|
|
3851
3883
|
task.run().then(() => {
|
|
3852
3884
|
this.onTask(task);
|
|
3853
3885
|
this.index++;
|
|
3854
|
-
this.nextTask();
|
|
3886
|
+
task.isCancel ? this.runTask() : this.nextTask();
|
|
3855
3887
|
}).catch(error => {
|
|
3856
3888
|
this.onError(error);
|
|
3857
3889
|
});
|
|
@@ -4027,8 +4059,6 @@ const I$1 = ImageManager;
|
|
|
4027
4059
|
|
|
4028
4060
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
4029
4061
|
|
|
4030
|
-
const {floor: floor$1, max: max$4} = Math;
|
|
4031
|
-
|
|
4032
4062
|
class LeaferImage {
|
|
4033
4063
|
get url() {
|
|
4034
4064
|
return this.config.url;
|
|
@@ -4053,10 +4083,9 @@ class LeaferImage {
|
|
|
4053
4083
|
load(onSuccess, onError) {
|
|
4054
4084
|
if (!this.loading) {
|
|
4055
4085
|
this.loading = true;
|
|
4056
|
-
|
|
4057
|
-
if (onProgress) loadImage = loadImageWithProgress;
|
|
4086
|
+
const {crossOrigin: crossOrigin} = this.config;
|
|
4058
4087
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
4059
|
-
return yield loadImage(this.url,
|
|
4088
|
+
return yield Platform.origin.loadImage(this.url, isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin, this).then(img => this.setView(img)).catch(e => {
|
|
4060
4089
|
this.error = e;
|
|
4061
4090
|
this.onComplete(false);
|
|
4062
4091
|
});
|
|
@@ -4082,9 +4111,6 @@ class LeaferImage {
|
|
|
4082
4111
|
this.view = img;
|
|
4083
4112
|
this.onComplete(true);
|
|
4084
4113
|
}
|
|
4085
|
-
onProgress(progress) {
|
|
4086
|
-
this.progress = progress;
|
|
4087
|
-
}
|
|
4088
4114
|
onComplete(isSuccess) {
|
|
4089
4115
|
let odd;
|
|
4090
4116
|
this.waitComplete.forEach((item, index) => {
|
|
@@ -4103,7 +4129,7 @@ class LeaferImage {
|
|
|
4103
4129
|
getFull(_filters) {
|
|
4104
4130
|
return this.view;
|
|
4105
4131
|
}
|
|
4106
|
-
getCanvas(width, height, opacity,
|
|
4132
|
+
getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
|
|
4107
4133
|
width || (width = this.width);
|
|
4108
4134
|
height || (height = this.height);
|
|
4109
4135
|
if (this.cache) {
|
|
@@ -4116,11 +4142,7 @@ class LeaferImage {
|
|
|
4116
4142
|
}
|
|
4117
4143
|
if (data) return data;
|
|
4118
4144
|
}
|
|
4119
|
-
const canvas = Platform.
|
|
4120
|
-
const ctx = canvas.getContext("2d");
|
|
4121
|
-
if (opacity) ctx.globalAlpha = opacity;
|
|
4122
|
-
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
4123
|
-
ctx.drawImage(this.view, 0, 0, width, height);
|
|
4145
|
+
const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
|
|
4124
4146
|
this.cache = this.use > 1 ? {
|
|
4125
4147
|
data: canvas,
|
|
4126
4148
|
params: arguments
|
|
@@ -4129,13 +4151,7 @@ class LeaferImage {
|
|
|
4129
4151
|
}
|
|
4130
4152
|
getPattern(canvas, repeat, transform, paint) {
|
|
4131
4153
|
const pattern = Platform.canvas.createPattern(canvas, repeat);
|
|
4132
|
-
|
|
4133
|
-
if (transform && pattern.setTransform) {
|
|
4134
|
-
pattern.setTransform(transform);
|
|
4135
|
-
transform = undefined;
|
|
4136
|
-
}
|
|
4137
|
-
} catch (_a) {}
|
|
4138
|
-
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
4154
|
+
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
4139
4155
|
return pattern;
|
|
4140
4156
|
}
|
|
4141
4157
|
destroy() {
|
|
@@ -5809,12 +5825,12 @@ const {toBounds: toBounds} = PathBounds;
|
|
|
5809
5825
|
|
|
5810
5826
|
const LeafBounds = {
|
|
5811
5827
|
__updateWorldBounds() {
|
|
5812
|
-
const
|
|
5813
|
-
toOuterOf$2(
|
|
5814
|
-
if (
|
|
5815
|
-
if (
|
|
5828
|
+
const {__layout: __layout, __world: __world} = this;
|
|
5829
|
+
toOuterOf$2(__layout.renderBounds, __world, __world);
|
|
5830
|
+
if (__layout.resized) {
|
|
5831
|
+
if (__layout.resized === "inner") this.__onUpdateSize();
|
|
5816
5832
|
if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
|
|
5817
|
-
|
|
5833
|
+
__layout.resized = undefined;
|
|
5818
5834
|
}
|
|
5819
5835
|
if (this.__hasWorldEvent) BoundsEvent.emitWorld(this);
|
|
5820
5836
|
},
|
|
@@ -6012,7 +6028,7 @@ const tempScaleData$1 = {};
|
|
|
6012
6028
|
|
|
6013
6029
|
const {LEAF: LEAF, create: create} = IncrementId;
|
|
6014
6030
|
|
|
6015
|
-
const {stintSet: stintSet$
|
|
6031
|
+
const {stintSet: stintSet$4} = DataHelper;
|
|
6016
6032
|
|
|
6017
6033
|
const {toInnerPoint: toInnerPoint, toOuterPoint: toOuterPoint, multiplyParent: multiplyParent$1} = MatrixHelper;
|
|
6018
6034
|
|
|
@@ -6295,8 +6311,8 @@ let Leaf = class Leaf {
|
|
|
6295
6311
|
const cameraWorld = this.__cameraWorld, world = this.__world;
|
|
6296
6312
|
multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
|
|
6297
6313
|
toOuterOf$1(this.__layout.renderBounds, cameraWorld, cameraWorld);
|
|
6298
|
-
stintSet$
|
|
6299
|
-
stintSet$
|
|
6314
|
+
stintSet$4(cameraWorld, "half", world.half);
|
|
6315
|
+
stintSet$4(cameraWorld, "ignorePixelSnap", world.ignorePixelSnap);
|
|
6300
6316
|
return cameraWorld;
|
|
6301
6317
|
} else {
|
|
6302
6318
|
return this.__world;
|
|
@@ -6819,7 +6835,7 @@ class LeafLevelList {
|
|
|
6819
6835
|
}
|
|
6820
6836
|
}
|
|
6821
6837
|
|
|
6822
|
-
const version = "1.
|
|
6838
|
+
const version = "1.10.0";
|
|
6823
6839
|
|
|
6824
6840
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6825
6841
|
get allowBackgroundColor() {
|
|
@@ -7747,6 +7763,7 @@ class Picker {
|
|
|
7747
7763
|
hit = child.__.hitRadius ? true : hitRadiusPoint$1(child.__world, point);
|
|
7748
7764
|
if (child.isBranch) {
|
|
7749
7765
|
if (hit || child.__ignoreHitWorld) {
|
|
7766
|
+
if (child.isBranchLeaf && child.__.__clipAfterFill && !child.__hitWorld(point)) continue;
|
|
7750
7767
|
if (child.topChildren) this.eachFind(child.topChildren, false);
|
|
7751
7768
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
7752
7769
|
if (child.isBranchLeaf) this.hitChild(child, point);
|
|
@@ -7939,7 +7956,7 @@ const Transition = {
|
|
|
7939
7956
|
|
|
7940
7957
|
const {parse: parse, objectToCanvasData: objectToCanvasData} = PathConvert;
|
|
7941
7958
|
|
|
7942
|
-
const {stintSet: stintSet$
|
|
7959
|
+
const {stintSet: stintSet$3} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
|
|
7943
7960
|
|
|
7944
7961
|
const emptyPaint = {};
|
|
7945
7962
|
|
|
@@ -8006,7 +8023,7 @@ class UIData extends LeafData {
|
|
|
8006
8023
|
setFill(value) {
|
|
8007
8024
|
if (this.__naturalWidth) this.__removeNaturalSize();
|
|
8008
8025
|
if (isString(value) || !value) {
|
|
8009
|
-
stintSet$
|
|
8026
|
+
stintSet$3(this, "__isTransparentFill", hasTransparent$2(value));
|
|
8010
8027
|
this.__isFills && this.__removePaint("fill", true);
|
|
8011
8028
|
this._fill = value;
|
|
8012
8029
|
} else if (isObject(value)) {
|
|
@@ -8015,7 +8032,7 @@ class UIData extends LeafData {
|
|
|
8015
8032
|
}
|
|
8016
8033
|
setStroke(value) {
|
|
8017
8034
|
if (isString(value) || !value) {
|
|
8018
|
-
stintSet$
|
|
8035
|
+
stintSet$3(this, "__isTransparentStroke", hasTransparent$2(value));
|
|
8019
8036
|
this.__isStrokes && this.__removePaint("stroke", true);
|
|
8020
8037
|
this._stroke = value;
|
|
8021
8038
|
} else if (isObject(value)) {
|
|
@@ -8073,11 +8090,11 @@ class UIData extends LeafData {
|
|
|
8073
8090
|
if (removeInput) this.__removeInput(attrName);
|
|
8074
8091
|
PaintImage.recycleImage(attrName, this);
|
|
8075
8092
|
if (attrName === "fill") {
|
|
8076
|
-
stintSet$
|
|
8093
|
+
stintSet$3(this, "__isAlphaPixelFill", undefined);
|
|
8077
8094
|
this._fill = this.__isFills = undefined;
|
|
8078
8095
|
} else {
|
|
8079
|
-
stintSet$
|
|
8080
|
-
stintSet$
|
|
8096
|
+
stintSet$3(this, "__isAlphaPixelStroke", undefined);
|
|
8097
|
+
stintSet$3(this, "__hasMultiStrokeStyle", undefined);
|
|
8081
8098
|
this._stroke = this.__isStrokes = undefined;
|
|
8082
8099
|
}
|
|
8083
8100
|
}
|
|
@@ -8226,7 +8243,7 @@ class CanvasData extends RectData {
|
|
|
8226
8243
|
}
|
|
8227
8244
|
}
|
|
8228
8245
|
|
|
8229
|
-
const {max: max$
|
|
8246
|
+
const {max: max$2, add: add$1} = FourNumberHelper;
|
|
8230
8247
|
|
|
8231
8248
|
const UIBounds = {
|
|
8232
8249
|
__updateStrokeSpread() {
|
|
@@ -8242,7 +8259,7 @@ const UIBounds = {
|
|
|
8242
8259
|
}
|
|
8243
8260
|
if (data.__useArrow) spread += strokeWidth * 5;
|
|
8244
8261
|
if (box) {
|
|
8245
|
-
spread = max$
|
|
8262
|
+
spread = max$2(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
|
|
8246
8263
|
boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
|
|
8247
8264
|
}
|
|
8248
8265
|
this.__layout.strokeBoxSpread = boxSpread;
|
|
@@ -8252,35 +8269,35 @@ const UIBounds = {
|
|
|
8252
8269
|
let spread = 0;
|
|
8253
8270
|
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
|
|
8254
8271
|
if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
|
|
8255
|
-
if (blur) spread = max$
|
|
8272
|
+
if (blur) spread = max$2(spread, blur);
|
|
8256
8273
|
if (filter) spread = add$1(spread, Filter.getSpread(filter));
|
|
8257
8274
|
if (renderSpread) spread = add$1(spread, renderSpread);
|
|
8258
8275
|
if (strokeSpread) spread = add$1(spread, strokeSpread);
|
|
8259
8276
|
let shapeSpread = spread;
|
|
8260
|
-
if (innerShadow) shapeSpread = max$
|
|
8261
|
-
if (backgroundBlur) shapeSpread = max$
|
|
8277
|
+
if (innerShadow) shapeSpread = max$2(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
|
|
8278
|
+
if (backgroundBlur) shapeSpread = max$2(shapeSpread, backgroundBlur);
|
|
8262
8279
|
this.__layout.renderShapeSpread = shapeSpread;
|
|
8263
|
-
return box ? max$
|
|
8280
|
+
return box ? max$2(box.__updateRenderSpread(), spread) : spread;
|
|
8264
8281
|
}
|
|
8265
8282
|
};
|
|
8266
8283
|
|
|
8267
|
-
const {stintSet: stintSet$
|
|
8284
|
+
const {stintSet: stintSet$2} = DataHelper;
|
|
8268
8285
|
|
|
8269
8286
|
const UIRender = {
|
|
8270
8287
|
__updateChange() {
|
|
8271
8288
|
const data = this.__;
|
|
8272
8289
|
if (data.__useStroke) {
|
|
8273
8290
|
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
8274
|
-
stintSet$
|
|
8275
|
-
stintSet$
|
|
8291
|
+
stintSet$2(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
|
|
8292
|
+
stintSet$2(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
|
|
8276
8293
|
}
|
|
8277
8294
|
if (data.__useEffect) {
|
|
8278
8295
|
const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
8279
|
-
stintSet$
|
|
8296
|
+
stintSet$2(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !Effect.isTransformShadow(shadow[0]) && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
|
|
8280
8297
|
data.__useEffect = !!(shadow || otherEffect);
|
|
8281
8298
|
}
|
|
8282
8299
|
data.__checkSingle();
|
|
8283
|
-
stintSet$
|
|
8300
|
+
stintSet$2(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
8284
8301
|
},
|
|
8285
8302
|
__drawFast(canvas, options) {
|
|
8286
8303
|
drawFast(this, canvas, options);
|
|
@@ -8296,24 +8313,24 @@ const UIRender = {
|
|
|
8296
8313
|
this.__nowWorld = this.__getNowWorld(options);
|
|
8297
8314
|
const {shadow: shadow, innerShadow: innerShadow, filter: filter} = data;
|
|
8298
8315
|
if (shadow) Effect.shadow(this, canvas, shape);
|
|
8299
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8300
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
8316
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8317
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
8301
8318
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
8302
8319
|
if (innerShadow) Effect.innerShadow(this, canvas, shape);
|
|
8303
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8320
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8304
8321
|
if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
8305
8322
|
if (shape.worldCanvas) shape.worldCanvas.recycle();
|
|
8306
8323
|
shape.canvas.recycle();
|
|
8307
8324
|
} else {
|
|
8308
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8325
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8309
8326
|
if (__isFastShadow) {
|
|
8310
8327
|
const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
|
|
8311
8328
|
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
8312
8329
|
}
|
|
8313
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
8330
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
8314
8331
|
if (__isFastShadow) canvas.restore();
|
|
8315
8332
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
8316
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8333
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8317
8334
|
}
|
|
8318
8335
|
} else {
|
|
8319
8336
|
if (data.__pathInputed) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
|
|
@@ -8322,9 +8339,9 @@ const UIRender = {
|
|
|
8322
8339
|
__drawShape(canvas, options) {
|
|
8323
8340
|
this.__drawRenderPath(canvas);
|
|
8324
8341
|
const data = this.__, {fill: fill, stroke: stroke} = data;
|
|
8325
|
-
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill("#000000", this, canvas);
|
|
8342
|
+
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas, options) : Paint.fill("#000000", this, canvas, options);
|
|
8326
8343
|
if (data.__isCanvas) this.__drawAfterFill(canvas, options);
|
|
8327
|
-
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke("#000000", this, canvas);
|
|
8344
|
+
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke("#000000", this, canvas, options);
|
|
8328
8345
|
},
|
|
8329
8346
|
__drawAfterFill(canvas, options) {
|
|
8330
8347
|
if (this.__.__clipAfterFill) {
|
|
@@ -8339,10 +8356,10 @@ const UIRender = {
|
|
|
8339
8356
|
function drawFast(ui, canvas, options) {
|
|
8340
8357
|
const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke} = ui.__;
|
|
8341
8358
|
ui.__drawRenderPath(canvas);
|
|
8342
|
-
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
8343
|
-
if (fill) Paint.fill(fill, ui, canvas);
|
|
8359
|
+
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
8360
|
+
if (fill) Paint.fill(fill, ui, canvas, options);
|
|
8344
8361
|
if (__drawAfterFill) ui.__drawAfterFill(canvas, options);
|
|
8345
|
-
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
8362
|
+
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
8346
8363
|
}
|
|
8347
8364
|
|
|
8348
8365
|
const RectRender = {
|
|
@@ -8480,8 +8497,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8480
8497
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
8481
8498
|
} else drawer.rect(x, y, width, height);
|
|
8482
8499
|
}
|
|
8483
|
-
drawImagePlaceholder(canvas,
|
|
8484
|
-
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
8500
|
+
drawImagePlaceholder(_image, canvas, renderOptions) {
|
|
8501
|
+
Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
|
|
8485
8502
|
}
|
|
8486
8503
|
animate(keyframe, _options, _type, _isTemp) {
|
|
8487
8504
|
this.set(keyframe);
|
|
@@ -9503,7 +9520,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
|
|
|
9503
9520
|
|
|
9504
9521
|
Canvas = __decorate([ registerUI() ], Canvas);
|
|
9505
9522
|
|
|
9506
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
|
|
9523
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9507
9524
|
|
|
9508
9525
|
let Text = class Text extends UI {
|
|
9509
9526
|
get __tag() {
|
|
@@ -9515,13 +9532,14 @@ let Text = class Text extends UI {
|
|
|
9515
9532
|
}
|
|
9516
9533
|
__updateTextDrawData() {
|
|
9517
9534
|
const data = this.__;
|
|
9518
|
-
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
|
|
9535
|
+
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
|
|
9519
9536
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
9520
9537
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
9521
|
-
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
9522
9538
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
|
|
9523
9539
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
9524
|
-
data
|
|
9540
|
+
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
9541
|
+
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
9542
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
|
|
9525
9543
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
9526
9544
|
}
|
|
9527
9545
|
__updateBoxBounds() {
|
|
@@ -9929,7 +9947,7 @@ class UIEvent extends Event {
|
|
|
9929
9947
|
}
|
|
9930
9948
|
}
|
|
9931
9949
|
|
|
9932
|
-
const {min: min, max: max$
|
|
9950
|
+
const {min: min, max: max$1, abs: abs$2} = Math, {float: float, sign: sign} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
|
|
9933
9951
|
|
|
9934
9952
|
const tempContent = new Bounds, tempDragBounds = new Bounds;
|
|
9935
9953
|
|
|
@@ -9986,7 +10004,7 @@ const DragBoundsHelper = {
|
|
|
9986
10004
|
bSize = float(tempDragBounds.maxX - tempContent.maxX);
|
|
9987
10005
|
aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
|
|
9988
10006
|
bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
|
|
9989
|
-
correctScaleX *= max$
|
|
10007
|
+
correctScaleX *= max$1(aScale, bScale);
|
|
9990
10008
|
} else {
|
|
9991
10009
|
if (scale.x < 0) {
|
|
9992
10010
|
if (float(minX(content) - minX(dragBounds)) <= 0 || float(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
|
|
@@ -10004,9 +10022,9 @@ const DragBoundsHelper = {
|
|
|
10004
10022
|
bSize = float(tempDragBounds.maxY - tempContent.maxY);
|
|
10005
10023
|
aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
|
|
10006
10024
|
bScale = originBottomScale && bSize > 0 ? 1 + bSize / (originBottomScale * tempContent.height) : 1;
|
|
10007
|
-
correctScaleY *= max$
|
|
10025
|
+
correctScaleY *= max$1(aScale, bScale);
|
|
10008
10026
|
if (lockRatio) {
|
|
10009
|
-
aScale = max$
|
|
10027
|
+
aScale = max$1(abs$2(correctScaleX), abs$2(correctScaleY));
|
|
10010
10028
|
correctScaleX = sign(correctScaleX) * aScale;
|
|
10011
10029
|
correctScaleY = sign(correctScaleY) * aScale;
|
|
10012
10030
|
}
|
|
@@ -10172,6 +10190,12 @@ MoveEvent.END = "move.end";
|
|
|
10172
10190
|
|
|
10173
10191
|
MoveEvent = __decorate([ registerUIEvent() ], MoveEvent);
|
|
10174
10192
|
|
|
10193
|
+
let TouchEvent = class TouchEvent extends UIEvent {};
|
|
10194
|
+
|
|
10195
|
+
TouchEvent = __decorate([ registerUIEvent() ], TouchEvent);
|
|
10196
|
+
|
|
10197
|
+
const MyTouchEvent = TouchEvent;
|
|
10198
|
+
|
|
10175
10199
|
let RotateEvent = class RotateEvent extends PointerEvent {};
|
|
10176
10200
|
|
|
10177
10201
|
RotateEvent.BEFORE_ROTATE = "rotate.before_rotate";
|
|
@@ -11332,36 +11356,19 @@ class Interaction extends InteractionBase {
|
|
|
11332
11356
|
}
|
|
11333
11357
|
}
|
|
11334
11358
|
|
|
11335
|
-
function
|
|
11336
|
-
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11337
|
-
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
11338
|
-
let row;
|
|
11339
|
-
for (let i = 0, len = rows.length; i < len; i++) {
|
|
11340
|
-
row = rows[i];
|
|
11341
|
-
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
11342
|
-
canvas.fillText(charData.char, charData.x, row.y);
|
|
11343
|
-
});
|
|
11344
|
-
}
|
|
11345
|
-
if (decorationY) {
|
|
11346
|
-
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
11347
|
-
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
11348
|
-
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
11349
|
-
}
|
|
11350
|
-
}
|
|
11351
|
-
|
|
11352
|
-
function fill(fill, ui, canvas) {
|
|
11359
|
+
function fill(fill, ui, canvas, renderOptions) {
|
|
11353
11360
|
canvas.fillStyle = fill;
|
|
11354
|
-
fillPathOrText(ui, canvas);
|
|
11361
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
11355
11362
|
}
|
|
11356
11363
|
|
|
11357
|
-
function fills(fills, ui, canvas) {
|
|
11364
|
+
function fills(fills, ui, canvas, renderOptions) {
|
|
11358
11365
|
let item;
|
|
11359
11366
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
11360
11367
|
item = fills[i];
|
|
11361
11368
|
if (item.image) {
|
|
11362
|
-
if (PaintImage.checkImage(
|
|
11369
|
+
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
11363
11370
|
if (!item.style) {
|
|
11364
|
-
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas,
|
|
11371
|
+
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
|
|
11365
11372
|
continue;
|
|
11366
11373
|
}
|
|
11367
11374
|
}
|
|
@@ -11374,60 +11381,137 @@ function fills(fills, ui, canvas) {
|
|
|
11374
11381
|
if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
11375
11382
|
}
|
|
11376
11383
|
if (item.blendMode) canvas.blendMode = item.blendMode;
|
|
11377
|
-
fillPathOrText(ui, canvas);
|
|
11384
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
11378
11385
|
canvas.restore();
|
|
11379
11386
|
} else {
|
|
11380
11387
|
if (item.blendMode) {
|
|
11381
11388
|
canvas.saveBlendMode(item.blendMode);
|
|
11382
|
-
fillPathOrText(ui, canvas);
|
|
11389
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
11383
11390
|
canvas.restoreBlendMode();
|
|
11384
|
-
} else fillPathOrText(ui, canvas);
|
|
11391
|
+
} else fillPathOrText(ui, canvas, renderOptions);
|
|
11392
|
+
}
|
|
11393
|
+
}
|
|
11394
|
+
}
|
|
11395
|
+
|
|
11396
|
+
function fillPathOrText(ui, canvas, renderOptions) {
|
|
11397
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
11398
|
+
}
|
|
11399
|
+
|
|
11400
|
+
function fillText(ui, canvas, _renderOptions) {
|
|
11401
|
+
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11402
|
+
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
11403
|
+
let row;
|
|
11404
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
11405
|
+
row = rows[i];
|
|
11406
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
11407
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
11408
|
+
});
|
|
11409
|
+
}
|
|
11410
|
+
if (decorationY) {
|
|
11411
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
11412
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
11413
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
11414
|
+
}
|
|
11415
|
+
}
|
|
11416
|
+
|
|
11417
|
+
function stroke(stroke, ui, canvas, renderOptions) {
|
|
11418
|
+
const data = ui.__;
|
|
11419
|
+
if (!data.__strokeWidth) return;
|
|
11420
|
+
if (data.__font) {
|
|
11421
|
+
Paint.strokeText(stroke, ui, canvas, renderOptions);
|
|
11422
|
+
} else {
|
|
11423
|
+
switch (data.strokeAlign) {
|
|
11424
|
+
case "center":
|
|
11425
|
+
drawCenter$1(stroke, 1, ui, canvas, renderOptions);
|
|
11426
|
+
break;
|
|
11427
|
+
|
|
11428
|
+
case "inside":
|
|
11429
|
+
drawInside(stroke, ui, canvas, renderOptions);
|
|
11430
|
+
break;
|
|
11431
|
+
|
|
11432
|
+
case "outside":
|
|
11433
|
+
drawOutside(stroke, ui, canvas, renderOptions);
|
|
11434
|
+
break;
|
|
11385
11435
|
}
|
|
11386
11436
|
}
|
|
11387
11437
|
}
|
|
11388
11438
|
|
|
11389
|
-
function
|
|
11390
|
-
|
|
11439
|
+
function strokes(strokes, ui, canvas, renderOptions) {
|
|
11440
|
+
Paint.stroke(strokes, ui, canvas, renderOptions);
|
|
11441
|
+
}
|
|
11442
|
+
|
|
11443
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
11444
|
+
const data = ui.__;
|
|
11445
|
+
if (isObject(stroke)) {
|
|
11446
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
|
|
11447
|
+
} else {
|
|
11448
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
11449
|
+
canvas.stroke();
|
|
11450
|
+
}
|
|
11451
|
+
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
|
|
11452
|
+
}
|
|
11453
|
+
|
|
11454
|
+
function drawInside(stroke, ui, canvas, renderOptions) {
|
|
11455
|
+
canvas.save();
|
|
11456
|
+
canvas.clipUI(ui);
|
|
11457
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
11458
|
+
canvas.restore();
|
|
11459
|
+
}
|
|
11460
|
+
|
|
11461
|
+
function drawOutside(stroke, ui, canvas, renderOptions) {
|
|
11462
|
+
const data = ui.__;
|
|
11463
|
+
if (data.__fillAfterStroke) {
|
|
11464
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
11465
|
+
} else {
|
|
11466
|
+
const {renderBounds: renderBounds} = ui.__layout;
|
|
11467
|
+
const out = canvas.getSameCanvas(true, true);
|
|
11468
|
+
ui.__drawRenderPath(out);
|
|
11469
|
+
drawCenter$1(stroke, 2, ui, out, renderOptions);
|
|
11470
|
+
out.clipUI(data);
|
|
11471
|
+
out.clearWorld(renderBounds);
|
|
11472
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
11473
|
+
out.recycle(ui.__nowWorld);
|
|
11474
|
+
}
|
|
11391
11475
|
}
|
|
11392
11476
|
|
|
11393
|
-
function strokeText(stroke, ui, canvas) {
|
|
11477
|
+
function strokeText(stroke, ui, canvas, renderOptions) {
|
|
11394
11478
|
switch (ui.__.strokeAlign) {
|
|
11395
11479
|
case "center":
|
|
11396
|
-
drawCenter
|
|
11480
|
+
drawCenter(stroke, 1, ui, canvas, renderOptions);
|
|
11397
11481
|
break;
|
|
11398
11482
|
|
|
11399
11483
|
case "inside":
|
|
11400
|
-
drawAlign(stroke, "inside", ui, canvas);
|
|
11484
|
+
drawAlign(stroke, "inside", ui, canvas, renderOptions);
|
|
11401
11485
|
break;
|
|
11402
11486
|
|
|
11403
11487
|
case "outside":
|
|
11404
|
-
ui.__.__fillAfterStroke ? drawCenter
|
|
11488
|
+
ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
|
|
11405
11489
|
break;
|
|
11406
11490
|
}
|
|
11407
11491
|
}
|
|
11408
11492
|
|
|
11409
|
-
function drawCenter
|
|
11493
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
11410
11494
|
const data = ui.__;
|
|
11411
11495
|
if (isObject(stroke)) {
|
|
11412
|
-
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
11496
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
|
|
11413
11497
|
} else {
|
|
11414
11498
|
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
11415
|
-
drawTextStroke(ui, canvas);
|
|
11499
|
+
Paint.drawTextStroke(ui, canvas, renderOptions);
|
|
11416
11500
|
}
|
|
11417
11501
|
}
|
|
11418
11502
|
|
|
11419
|
-
function drawAlign(stroke, align, ui, canvas) {
|
|
11503
|
+
function drawAlign(stroke, align, ui, canvas, renderOptions) {
|
|
11420
11504
|
const out = canvas.getSameCanvas(true, true);
|
|
11421
11505
|
out.font = ui.__.__font;
|
|
11422
|
-
drawCenter
|
|
11506
|
+
drawCenter(stroke, 2, ui, out, renderOptions);
|
|
11423
11507
|
out.blendMode = align === "outside" ? "destination-out" : "destination-in";
|
|
11424
|
-
fillText(ui, out);
|
|
11508
|
+
Paint.fillText(ui, out, renderOptions);
|
|
11425
11509
|
out.blendMode = "normal";
|
|
11426
11510
|
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
11427
11511
|
out.recycle(ui.__nowWorld);
|
|
11428
11512
|
}
|
|
11429
11513
|
|
|
11430
|
-
function drawTextStroke(ui, canvas) {
|
|
11514
|
+
function drawTextStroke(ui, canvas, _renderOptions) {
|
|
11431
11515
|
let row, data = ui.__.__textDrawData;
|
|
11432
11516
|
const {rows: rows, decorationY: decorationY} = data;
|
|
11433
11517
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
@@ -11442,13 +11526,13 @@ function drawTextStroke(ui, canvas) {
|
|
|
11442
11526
|
}
|
|
11443
11527
|
}
|
|
11444
11528
|
|
|
11445
|
-
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
11529
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
|
|
11446
11530
|
let item;
|
|
11447
11531
|
const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
|
|
11448
11532
|
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
11449
11533
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
11450
11534
|
item = strokes[i];
|
|
11451
|
-
if (item.image && PaintImage.checkImage(ui, canvas,
|
|
11535
|
+
if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
|
|
11452
11536
|
if (item.style) {
|
|
11453
11537
|
if (__hasMultiStrokeStyle) {
|
|
11454
11538
|
const {strokeStyle: strokeStyle} = item;
|
|
@@ -11456,75 +11540,15 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
|
11456
11540
|
} else canvas.strokeStyle = item.style;
|
|
11457
11541
|
if (item.blendMode) {
|
|
11458
11542
|
canvas.saveBlendMode(item.blendMode);
|
|
11459
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
11543
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
11460
11544
|
canvas.restoreBlendMode();
|
|
11461
11545
|
} else {
|
|
11462
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
11546
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
11463
11547
|
}
|
|
11464
11548
|
}
|
|
11465
11549
|
}
|
|
11466
11550
|
}
|
|
11467
11551
|
|
|
11468
|
-
function stroke(stroke, ui, canvas) {
|
|
11469
|
-
const data = ui.__;
|
|
11470
|
-
if (!data.__strokeWidth) return;
|
|
11471
|
-
if (data.__font) {
|
|
11472
|
-
strokeText(stroke, ui, canvas);
|
|
11473
|
-
} else {
|
|
11474
|
-
switch (data.strokeAlign) {
|
|
11475
|
-
case "center":
|
|
11476
|
-
drawCenter(stroke, 1, ui, canvas);
|
|
11477
|
-
break;
|
|
11478
|
-
|
|
11479
|
-
case "inside":
|
|
11480
|
-
drawInside(stroke, ui, canvas);
|
|
11481
|
-
break;
|
|
11482
|
-
|
|
11483
|
-
case "outside":
|
|
11484
|
-
drawOutside(stroke, ui, canvas);
|
|
11485
|
-
break;
|
|
11486
|
-
}
|
|
11487
|
-
}
|
|
11488
|
-
}
|
|
11489
|
-
|
|
11490
|
-
function strokes(strokes, ui, canvas) {
|
|
11491
|
-
stroke(strokes, ui, canvas);
|
|
11492
|
-
}
|
|
11493
|
-
|
|
11494
|
-
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
11495
|
-
const data = ui.__;
|
|
11496
|
-
if (isObject(stroke)) {
|
|
11497
|
-
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
11498
|
-
} else {
|
|
11499
|
-
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
11500
|
-
canvas.stroke();
|
|
11501
|
-
}
|
|
11502
|
-
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas);
|
|
11503
|
-
}
|
|
11504
|
-
|
|
11505
|
-
function drawInside(stroke, ui, canvas) {
|
|
11506
|
-
canvas.save();
|
|
11507
|
-
canvas.clipUI(ui);
|
|
11508
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
11509
|
-
canvas.restore();
|
|
11510
|
-
}
|
|
11511
|
-
|
|
11512
|
-
function drawOutside(stroke, ui, canvas) {
|
|
11513
|
-
const data = ui.__;
|
|
11514
|
-
if (data.__fillAfterStroke) {
|
|
11515
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
11516
|
-
} else {
|
|
11517
|
-
const {renderBounds: renderBounds} = ui.__layout;
|
|
11518
|
-
const out = canvas.getSameCanvas(true, true);
|
|
11519
|
-
ui.__drawRenderPath(out);
|
|
11520
|
-
drawCenter(stroke, 2, ui, out);
|
|
11521
|
-
out.clipUI(data);
|
|
11522
|
-
out.clearWorld(renderBounds);
|
|
11523
|
-
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
11524
|
-
out.recycle(ui.__nowWorld);
|
|
11525
|
-
}
|
|
11526
|
-
}
|
|
11527
|
-
|
|
11528
11552
|
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
11529
11553
|
|
|
11530
11554
|
const tempBounds$1 = {};
|
|
@@ -11680,88 +11704,118 @@ const PaintModule = {
|
|
|
11680
11704
|
strokes: strokes,
|
|
11681
11705
|
strokeText: strokeText,
|
|
11682
11706
|
drawTextStroke: drawTextStroke,
|
|
11707
|
+
drawStrokesStyle: drawStrokesStyle,
|
|
11683
11708
|
shape: shape
|
|
11684
11709
|
};
|
|
11685
11710
|
|
|
11686
|
-
let
|
|
11687
|
-
|
|
11688
|
-
const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
11689
|
-
|
|
11690
|
-
function stretchMode(data, box, scaleX, scaleY) {
|
|
11691
|
-
const transform = get$3();
|
|
11692
|
-
translate$1(transform, box.x, box.y);
|
|
11693
|
-
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
11694
|
-
data.transform = transform;
|
|
11695
|
-
}
|
|
11696
|
-
|
|
11697
|
-
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
11698
|
-
const transform = get$3();
|
|
11699
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
11700
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
11701
|
-
if (rotation) rotateOfOuter$1(transform, {
|
|
11702
|
-
x: box.x + box.width / 2,
|
|
11703
|
-
y: box.y + box.height / 2
|
|
11704
|
-
}, rotation);
|
|
11705
|
-
data.transform = transform;
|
|
11706
|
-
}
|
|
11711
|
+
let cache, box = new Bounds;
|
|
11707
11712
|
|
|
11708
|
-
|
|
11709
|
-
const transform = get$3();
|
|
11710
|
-
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
11711
|
-
if (clipScaleX) {
|
|
11712
|
-
if (rotation || skew) {
|
|
11713
|
-
set(tempMatrix$1);
|
|
11714
|
-
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
11715
|
-
multiplyParent(transform, tempMatrix$1);
|
|
11716
|
-
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
11717
|
-
}
|
|
11718
|
-
data.transform = transform;
|
|
11719
|
-
}
|
|
11713
|
+
const {isSame: isSame} = BoundsHelper;
|
|
11720
11714
|
|
|
11721
|
-
function
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11715
|
+
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
11716
|
+
let leafPaint, event;
|
|
11717
|
+
const image = ImageManager.get(paint);
|
|
11718
|
+
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
11719
|
+
leafPaint = cache.leafPaint;
|
|
11720
|
+
} else {
|
|
11721
|
+
leafPaint = {
|
|
11722
|
+
type: paint.type,
|
|
11723
|
+
image: image
|
|
11724
|
+
};
|
|
11725
|
+
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
11726
|
+
cache = image.use > 1 ? {
|
|
11727
|
+
leafPaint: leafPaint,
|
|
11728
|
+
paint: paint,
|
|
11729
|
+
boxBounds: box.set(boxBounds)
|
|
11730
|
+
} : null;
|
|
11731
|
+
}
|
|
11732
|
+
if (firstUse || image.loading) event = {
|
|
11733
|
+
image: image,
|
|
11734
|
+
attrName: attrName,
|
|
11735
|
+
attrValue: paint
|
|
11736
|
+
};
|
|
11737
|
+
if (image.ready) {
|
|
11738
|
+
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
11739
|
+
if (firstUse) {
|
|
11740
|
+
onLoad(ui, event);
|
|
11741
|
+
onLoadSuccess(ui, event);
|
|
11742
|
+
}
|
|
11743
|
+
} else if (image.error) {
|
|
11744
|
+
if (firstUse) onLoadError(ui, event, image.error);
|
|
11745
|
+
} else {
|
|
11746
|
+
if (firstUse) {
|
|
11747
|
+
ignoreRender(ui, true);
|
|
11748
|
+
onLoad(ui, event);
|
|
11749
|
+
}
|
|
11750
|
+
leafPaint.loadId = image.load(() => {
|
|
11751
|
+
ignoreRender(ui, false);
|
|
11752
|
+
if (!ui.destroyed) {
|
|
11753
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
11754
|
+
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
11755
|
+
ui.forceUpdate("surface");
|
|
11746
11756
|
}
|
|
11757
|
+
onLoadSuccess(ui, event);
|
|
11747
11758
|
}
|
|
11759
|
+
leafPaint.loadId = undefined;
|
|
11760
|
+
}, error => {
|
|
11761
|
+
ignoreRender(ui, false);
|
|
11762
|
+
onLoadError(ui, event, error);
|
|
11763
|
+
leafPaint.loadId = undefined;
|
|
11764
|
+
});
|
|
11765
|
+
if (ui.placeholderColor) {
|
|
11766
|
+
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
11767
|
+
if (!image.ready) {
|
|
11768
|
+
image.isPlacehold = true;
|
|
11769
|
+
ui.forceUpdate("surface");
|
|
11770
|
+
}
|
|
11771
|
+
}, ui.placeholderDelay);
|
|
11748
11772
|
}
|
|
11749
|
-
origin.x = box.x + x;
|
|
11750
|
-
origin.y = box.y + y;
|
|
11751
|
-
translate$1(transform, origin.x, origin.y);
|
|
11752
|
-
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
11753
11773
|
}
|
|
11754
|
-
|
|
11774
|
+
return leafPaint;
|
|
11755
11775
|
}
|
|
11756
11776
|
|
|
11757
|
-
function
|
|
11758
|
-
if (
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11777
|
+
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
11778
|
+
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
11779
|
+
const data = ui.__;
|
|
11780
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
11781
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
11782
|
+
if (data.__autoSide) {
|
|
11783
|
+
ui.forceUpdate("width");
|
|
11784
|
+
if (ui.__proxyData) {
|
|
11785
|
+
ui.setProxyAttr("width", data.width);
|
|
11786
|
+
ui.setProxyAttr("height", data.height);
|
|
11787
|
+
}
|
|
11788
|
+
return false;
|
|
11789
|
+
}
|
|
11790
|
+
}
|
|
11791
|
+
if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
11792
|
+
return true;
|
|
11793
|
+
}
|
|
11794
|
+
|
|
11795
|
+
function onLoad(ui, event) {
|
|
11796
|
+
emit(ui, ImageEvent.LOAD, event);
|
|
11797
|
+
}
|
|
11798
|
+
|
|
11799
|
+
function onLoadSuccess(ui, event) {
|
|
11800
|
+
emit(ui, ImageEvent.LOADED, event);
|
|
11762
11801
|
}
|
|
11763
11802
|
|
|
11764
|
-
|
|
11803
|
+
function onLoadError(ui, event, error) {
|
|
11804
|
+
event.error = error;
|
|
11805
|
+
ui.forceUpdate("surface");
|
|
11806
|
+
emit(ui, ImageEvent.ERROR, event);
|
|
11807
|
+
}
|
|
11808
|
+
|
|
11809
|
+
function emit(ui, type, data) {
|
|
11810
|
+
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
11811
|
+
}
|
|
11812
|
+
|
|
11813
|
+
function ignoreRender(ui, value) {
|
|
11814
|
+
const {leafer: leafer} = ui;
|
|
11815
|
+
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
11816
|
+
}
|
|
11817
|
+
|
|
11818
|
+
const {get: get$3, translate: translate$1} = MatrixHelper;
|
|
11765
11819
|
|
|
11766
11820
|
const tempBox = new Bounds;
|
|
11767
11821
|
|
|
@@ -11774,13 +11828,13 @@ function createData(leafPaint, image, paint, box) {
|
|
|
11774
11828
|
if (changeful) leafPaint.changeful = changeful;
|
|
11775
11829
|
if (sync) leafPaint.sync = sync;
|
|
11776
11830
|
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
11777
|
-
leafPaint.data = getPatternData(paint, box, image);
|
|
11831
|
+
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
11778
11832
|
}
|
|
11779
11833
|
|
|
11780
11834
|
function getPatternData(paint, box, image) {
|
|
11781
11835
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
11782
11836
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
11783
|
-
|
|
11837
|
+
const {width: width, height: height} = image;
|
|
11784
11838
|
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;
|
|
11785
11839
|
const sameBox = box.width === width && box.height === height;
|
|
11786
11840
|
const data = {
|
|
@@ -11811,8 +11865,8 @@ function getPatternData(paint, box, image) {
|
|
|
11811
11865
|
case "stretch":
|
|
11812
11866
|
if (!sameBox) {
|
|
11813
11867
|
scaleX = box.width / width, scaleY = box.height / height;
|
|
11814
|
-
stretchMode(data, box, scaleX, scaleY);
|
|
11815
|
-
}
|
|
11868
|
+
PaintImage.stretchMode(data, box, scaleX, scaleY);
|
|
11869
|
+
} else if (scaleX) scaleX = scaleY = undefined;
|
|
11816
11870
|
break;
|
|
11817
11871
|
|
|
11818
11872
|
case "normal":
|
|
@@ -11820,13 +11874,13 @@ function getPatternData(paint, box, image) {
|
|
|
11820
11874
|
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
11821
11875
|
let clipScaleX, clipScaleY;
|
|
11822
11876
|
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
|
|
11823
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
11877
|
+
PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
11824
11878
|
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
11825
11879
|
}
|
|
11826
11880
|
break;
|
|
11827
11881
|
|
|
11828
11882
|
case "repeat":
|
|
11829
|
-
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
11883
|
+
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
11830
11884
|
if (!repeat) data.repeat = "repeat";
|
|
11831
11885
|
const count = isObject(repeat);
|
|
11832
11886
|
if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
|
|
@@ -11835,18 +11889,16 @@ function getPatternData(paint, box, image) {
|
|
|
11835
11889
|
case "fit":
|
|
11836
11890
|
case "cover":
|
|
11837
11891
|
default:
|
|
11838
|
-
if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
11892
|
+
if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
11839
11893
|
}
|
|
11840
11894
|
if (!data.transform) {
|
|
11841
|
-
if (box.x || box.y) translate(data.transform = get$
|
|
11895
|
+
if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
|
|
11842
11896
|
}
|
|
11843
|
-
data.width = width;
|
|
11844
|
-
data.height = height;
|
|
11845
11897
|
if (scaleX) {
|
|
11846
11898
|
data.scaleX = scaleX;
|
|
11847
11899
|
data.scaleY = scaleY;
|
|
11848
11900
|
}
|
|
11849
|
-
if (opacity) data.opacity = opacity;
|
|
11901
|
+
if (opacity && opacity < 1) data.opacity = opacity;
|
|
11850
11902
|
if (filters) data.filters = filters;
|
|
11851
11903
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
11852
11904
|
return data;
|
|
@@ -11868,234 +11920,194 @@ function getGapValue(gap, size, totalSize, rows) {
|
|
|
11868
11920
|
return gap === "auto" ? value < 0 ? 0 : value : value;
|
|
11869
11921
|
}
|
|
11870
11922
|
|
|
11871
|
-
let
|
|
11923
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
11872
11924
|
|
|
11873
|
-
const {
|
|
11925
|
+
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
11874
11926
|
|
|
11875
|
-
function
|
|
11876
|
-
|
|
11877
|
-
|
|
11878
|
-
|
|
11879
|
-
|
|
11880
|
-
} else {
|
|
11881
|
-
leafPaint = {
|
|
11882
|
-
type: paint.type,
|
|
11883
|
-
image: image
|
|
11884
|
-
};
|
|
11885
|
-
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
11886
|
-
cache = image.use > 1 ? {
|
|
11887
|
-
leafPaint: leafPaint,
|
|
11888
|
-
paint: paint,
|
|
11889
|
-
boxBounds: box.set(boxBounds)
|
|
11890
|
-
} : null;
|
|
11891
|
-
}
|
|
11892
|
-
if (firstUse || image.loading) event = {
|
|
11893
|
-
image: image,
|
|
11894
|
-
attrName: attrName,
|
|
11895
|
-
attrValue: paint
|
|
11896
|
-
};
|
|
11897
|
-
if (image.ready) {
|
|
11898
|
-
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
11899
|
-
if (firstUse) {
|
|
11900
|
-
onLoad(ui, event);
|
|
11901
|
-
onLoadSuccess(ui, event);
|
|
11902
|
-
}
|
|
11903
|
-
} else if (image.error) {
|
|
11904
|
-
if (firstUse) onLoadError(ui, event, image.error);
|
|
11905
|
-
} else {
|
|
11906
|
-
if (firstUse) {
|
|
11907
|
-
ignoreRender(ui, true);
|
|
11908
|
-
onLoad(ui, event);
|
|
11909
|
-
}
|
|
11910
|
-
leafPaint.loadId = image.load(() => {
|
|
11911
|
-
ignoreRender(ui, false);
|
|
11912
|
-
if (!ui.destroyed) {
|
|
11913
|
-
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
11914
|
-
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
11915
|
-
ui.forceUpdate("surface");
|
|
11916
|
-
}
|
|
11917
|
-
onLoadSuccess(ui, event);
|
|
11918
|
-
}
|
|
11919
|
-
leafPaint.loadId = undefined;
|
|
11920
|
-
}, error => {
|
|
11921
|
-
ignoreRender(ui, false);
|
|
11922
|
-
onLoadError(ui, event, error);
|
|
11923
|
-
leafPaint.loadId = undefined;
|
|
11924
|
-
});
|
|
11925
|
-
if (ui.placeholderColor) {
|
|
11926
|
-
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
11927
|
-
if (!image.ready) {
|
|
11928
|
-
image.isPlacehold = true;
|
|
11929
|
-
ui.forceUpdate("surface");
|
|
11930
|
-
}
|
|
11931
|
-
}, ui.placeholderDelay);
|
|
11932
|
-
}
|
|
11933
|
-
}
|
|
11934
|
-
return leafPaint;
|
|
11927
|
+
function stretchMode(data, box, scaleX, scaleY) {
|
|
11928
|
+
const transform = get$2(), {x: x, y: y} = box;
|
|
11929
|
+
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
11930
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
11931
|
+
data.transform = transform;
|
|
11935
11932
|
}
|
|
11936
11933
|
|
|
11937
|
-
function
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
|
|
11942
|
-
|
|
11943
|
-
|
|
11944
|
-
|
|
11945
|
-
|
|
11946
|
-
ui.setProxyAttr("height", data.height);
|
|
11947
|
-
}
|
|
11948
|
-
return false;
|
|
11949
|
-
}
|
|
11950
|
-
}
|
|
11951
|
-
if (!leafPaint.data) createData(leafPaint, image, paint, boxBounds);
|
|
11952
|
-
return true;
|
|
11934
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
11935
|
+
const transform = get$2();
|
|
11936
|
+
translate(transform, box.x + x, box.y + y);
|
|
11937
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
11938
|
+
if (rotation) rotateOfOuter$1(transform, {
|
|
11939
|
+
x: box.x + box.width / 2,
|
|
11940
|
+
y: box.y + box.height / 2
|
|
11941
|
+
}, rotation);
|
|
11942
|
+
data.transform = transform;
|
|
11953
11943
|
}
|
|
11954
11944
|
|
|
11955
|
-
function
|
|
11956
|
-
|
|
11945
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
11946
|
+
const transform = get$2();
|
|
11947
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
11948
|
+
if (clipScaleX) {
|
|
11949
|
+
if (rotation || skew) {
|
|
11950
|
+
set(tempMatrix$1);
|
|
11951
|
+
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
11952
|
+
multiplyParent(transform, tempMatrix$1);
|
|
11953
|
+
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
11954
|
+
}
|
|
11955
|
+
data.transform = transform;
|
|
11957
11956
|
}
|
|
11958
11957
|
|
|
11959
|
-
function
|
|
11960
|
-
|
|
11961
|
-
|
|
11958
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
11959
|
+
const transform = get$2();
|
|
11960
|
+
if (freeTransform) {
|
|
11961
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
11962
|
+
} else {
|
|
11963
|
+
if (rotation) {
|
|
11964
|
+
if (align === "center") {
|
|
11965
|
+
rotateOfOuter$1(transform, {
|
|
11966
|
+
x: width / 2,
|
|
11967
|
+
y: height / 2
|
|
11968
|
+
}, rotation);
|
|
11969
|
+
} else {
|
|
11970
|
+
rotate(transform, rotation);
|
|
11971
|
+
switch (rotation) {
|
|
11972
|
+
case 90:
|
|
11973
|
+
translate(transform, height, 0);
|
|
11974
|
+
break;
|
|
11962
11975
|
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
|
|
11966
|
-
emit(ui, ImageEvent.ERROR, event);
|
|
11967
|
-
}
|
|
11976
|
+
case 180:
|
|
11977
|
+
translate(transform, width, height);
|
|
11978
|
+
break;
|
|
11968
11979
|
|
|
11969
|
-
|
|
11970
|
-
|
|
11980
|
+
case 270:
|
|
11981
|
+
translate(transform, 0, width);
|
|
11982
|
+
break;
|
|
11983
|
+
}
|
|
11984
|
+
}
|
|
11985
|
+
}
|
|
11986
|
+
origin.x = box.x + x;
|
|
11987
|
+
origin.y = box.y + y;
|
|
11988
|
+
translate(transform, origin.x, origin.y);
|
|
11989
|
+
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
11990
|
+
}
|
|
11991
|
+
data.transform = transform;
|
|
11971
11992
|
}
|
|
11972
11993
|
|
|
11973
|
-
function
|
|
11974
|
-
|
|
11975
|
-
if (
|
|
11994
|
+
function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
11995
|
+
if (rotation) rotate(transform, rotation);
|
|
11996
|
+
if (skew) skewHelper(transform, skew.x, skew.y);
|
|
11997
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
11998
|
+
translate(transform, box.x + x, box.y + y);
|
|
11976
11999
|
}
|
|
11977
12000
|
|
|
11978
12001
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
11979
12002
|
|
|
11980
|
-
const {
|
|
12003
|
+
const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
12004
|
+
|
|
12005
|
+
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
12006
|
+
if (!paint.patternTask) {
|
|
12007
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
12008
|
+
paint.patternTask = null;
|
|
12009
|
+
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
12010
|
+
ui.forceUpdate("surface");
|
|
12011
|
+
}), 300);
|
|
12012
|
+
}
|
|
12013
|
+
}
|
|
11981
12014
|
|
|
11982
|
-
function createPattern(ui,
|
|
11983
|
-
let {scaleX: scaleX, scaleY: scaleY} =
|
|
11984
|
-
const id = scaleX + "-" + scaleY + "-" + pixelRatio;
|
|
12015
|
+
function createPattern(paint, ui, canvas, renderOptions) {
|
|
12016
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
11985
12017
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
11986
|
-
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
|
|
11995
|
-
|
|
11996
|
-
scaleX
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
width *= scaleX;
|
|
12000
|
-
height *= scaleY;
|
|
12001
|
-
const size = width * height;
|
|
12002
|
-
if (!repeat) {
|
|
12003
|
-
if (size > Platform.image.maxCacheSize) return false;
|
|
12004
|
-
}
|
|
12005
|
-
let maxSize = Platform.image.maxPatternSize;
|
|
12006
|
-
if (image.isSVG) {
|
|
12007
|
-
const ws = width / image.width;
|
|
12008
|
-
if (ws > 1) imageScale = ws / ceil(ws);
|
|
12009
|
-
} else {
|
|
12010
|
-
const imageSize = image.width * image.height;
|
|
12011
|
-
if (maxSize > imageSize) maxSize = imageSize;
|
|
12012
|
-
}
|
|
12013
|
-
if (size > maxSize) imageScale = Math.sqrt(size / maxSize);
|
|
12014
|
-
if (imageScale) {
|
|
12015
|
-
scaleX /= imageScale;
|
|
12016
|
-
scaleY /= imageScale;
|
|
12017
|
-
width /= imageScale;
|
|
12018
|
-
height /= imageScale;
|
|
12019
|
-
}
|
|
12020
|
-
if (sx) {
|
|
12021
|
-
scaleX /= sx;
|
|
12022
|
-
scaleY /= sy;
|
|
12023
|
-
}
|
|
12024
|
-
const xGap = gap && gap.x * scaleX;
|
|
12025
|
-
const yGap = gap && gap.y * scaleY;
|
|
12026
|
-
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
12027
|
-
const canvasWidth = width + (xGap || 0);
|
|
12028
|
-
const canvasHeight = height + (yGap || 0);
|
|
12029
|
-
scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
|
|
12030
|
-
scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
|
|
12031
|
-
if (!imageMatrix) {
|
|
12018
|
+
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
12019
|
+
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
12020
|
+
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
12021
|
+
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
12022
|
+
width *= scaleX;
|
|
12023
|
+
height *= scaleY;
|
|
12024
|
+
if (gap) {
|
|
12025
|
+
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
12026
|
+
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
12027
|
+
}
|
|
12028
|
+
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
12029
|
+
scaleX *= getFloorScale(width + (xGap || 0));
|
|
12030
|
+
scaleY *= getFloorScale(height + (yGap || 0));
|
|
12032
12031
|
imageMatrix = get$1();
|
|
12033
12032
|
if (transform) copy$1(imageMatrix, transform);
|
|
12033
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
12034
12034
|
}
|
|
12035
|
-
|
|
12035
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
12036
|
+
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
12037
|
+
paint.style = pattern;
|
|
12038
|
+
paint.patternId = id;
|
|
12036
12039
|
}
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12041
|
-
|
|
12040
|
+
}
|
|
12041
|
+
}
|
|
12042
|
+
|
|
12043
|
+
function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
12044
|
+
const {image: image} = paint;
|
|
12045
|
+
let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
|
|
12046
|
+
if (image.isSVG) {
|
|
12047
|
+
if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
|
|
12042
12048
|
} else {
|
|
12043
|
-
|
|
12049
|
+
if (maxSize > imageSize) maxSize = imageSize;
|
|
12044
12050
|
}
|
|
12051
|
+
if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
|
|
12052
|
+
return fixScale;
|
|
12045
12053
|
}
|
|
12046
12054
|
|
|
12047
|
-
function checkImage(ui, canvas,
|
|
12048
|
-
const {scaleX: scaleX, scaleY: scaleY} =
|
|
12049
|
-
const {
|
|
12050
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY
|
|
12055
|
+
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
12056
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
12057
|
+
const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
|
|
12058
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
12051
12059
|
return false;
|
|
12052
12060
|
} else {
|
|
12053
|
-
if (
|
|
12061
|
+
if (drawImage) {
|
|
12054
12062
|
if (data.repeat) {
|
|
12055
|
-
|
|
12056
|
-
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) ||
|
|
12057
|
-
|
|
12058
|
-
width *= scaleX * pixelRatio;
|
|
12059
|
-
height *= scaleY * pixelRatio;
|
|
12060
|
-
if (data.scaleX) {
|
|
12061
|
-
width *= data.scaleX;
|
|
12062
|
-
height *= data.scaleY;
|
|
12063
|
-
}
|
|
12064
|
-
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
12063
|
+
drawImage = false;
|
|
12064
|
+
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
12065
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
12065
12066
|
}
|
|
12066
12067
|
}
|
|
12067
|
-
if (
|
|
12068
|
+
if (drawImage) {
|
|
12068
12069
|
if (ui.__.__isFastShadow) {
|
|
12069
12070
|
canvas.fillStyle = paint.style || "#000";
|
|
12070
12071
|
canvas.fill();
|
|
12071
12072
|
}
|
|
12072
|
-
drawImage(ui, canvas,
|
|
12073
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
12073
12074
|
return true;
|
|
12074
12075
|
} else {
|
|
12075
|
-
if (!paint.style || paint.sync ||
|
|
12076
|
-
createPattern(ui, paint, pixelRatio);
|
|
12077
|
-
} else {
|
|
12078
|
-
if (!paint.patternTask) {
|
|
12079
|
-
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
12080
|
-
paint.patternTask = null;
|
|
12081
|
-
if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio);
|
|
12082
|
-
ui.forceUpdate("surface");
|
|
12083
|
-
}), 300);
|
|
12084
|
-
}
|
|
12085
|
-
}
|
|
12076
|
+
if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
12086
12077
|
return false;
|
|
12087
12078
|
}
|
|
12088
12079
|
}
|
|
12089
12080
|
}
|
|
12090
12081
|
|
|
12091
|
-
function drawImage(ui, canvas,
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
if (
|
|
12095
|
-
|
|
12096
|
-
|
|
12097
|
-
|
|
12098
|
-
|
|
12082
|
+
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
12083
|
+
const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
12084
|
+
let {width: width, height: height} = image, clipUI;
|
|
12085
|
+
if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
|
|
12086
|
+
canvas.save();
|
|
12087
|
+
clipUI && canvas.clipUI(ui);
|
|
12088
|
+
blendMode && (canvas.blendMode = blendMode);
|
|
12089
|
+
opacity && (canvas.opacity *= opacity);
|
|
12090
|
+
transform && canvas.transform(transform);
|
|
12091
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
12092
|
+
canvas.restore();
|
|
12093
|
+
} else {
|
|
12094
|
+
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
12095
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
12096
|
+
}
|
|
12097
|
+
}
|
|
12098
|
+
|
|
12099
|
+
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
12100
|
+
const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
|
|
12101
|
+
if (canvas) {
|
|
12102
|
+
const {pixelRatio: pixelRatio} = canvas;
|
|
12103
|
+
scaleData.scaleX *= pixelRatio;
|
|
12104
|
+
scaleData.scaleY *= pixelRatio;
|
|
12105
|
+
}
|
|
12106
|
+
if (data && data.scaleX) {
|
|
12107
|
+
scaleData.scaleX *= Math.abs(data.scaleX);
|
|
12108
|
+
scaleData.scaleY *= Math.abs(data.scaleY);
|
|
12109
|
+
}
|
|
12110
|
+
return scaleData;
|
|
12099
12111
|
}
|
|
12100
12112
|
|
|
12101
12113
|
function recycleImage(attrName, data) {
|
|
@@ -12127,8 +12139,12 @@ function recycleImage(attrName, data) {
|
|
|
12127
12139
|
const PaintImageModule = {
|
|
12128
12140
|
image: image,
|
|
12129
12141
|
checkImage: checkImage,
|
|
12130
|
-
|
|
12142
|
+
drawImage: drawImage,
|
|
12143
|
+
getImageRenderScaleData: getImageRenderScaleData,
|
|
12131
12144
|
recycleImage: recycleImage,
|
|
12145
|
+
createPatternTask: createPatternTask,
|
|
12146
|
+
createPattern: createPattern,
|
|
12147
|
+
getPatternFixScale: getPatternFixScale,
|
|
12132
12148
|
createData: createData,
|
|
12133
12149
|
getPatternData: getPatternData,
|
|
12134
12150
|
stretchMode: stretchMode,
|
|
@@ -12584,10 +12600,8 @@ function createRows(drawData, content, style) {
|
|
|
12584
12600
|
bounds = drawData.bounds;
|
|
12585
12601
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
12586
12602
|
const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
|
|
12587
|
-
const {canvas: canvas} = Platform;
|
|
12588
|
-
|
|
12589
|
-
const charMode = width || height || __letterSpacing || textCase !== "none";
|
|
12590
|
-
if (charMode) {
|
|
12603
|
+
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
12604
|
+
if (style.__isCharMode) {
|
|
12591
12605
|
const wrap = style.textWrap !== "none";
|
|
12592
12606
|
const breakAll = style.textWrap === "break";
|
|
12593
12607
|
paraStart = true;
|
|
@@ -12716,12 +12730,19 @@ const TextMode = 2;
|
|
|
12716
12730
|
function layoutChar(drawData, style, width, _height) {
|
|
12717
12731
|
const {rows: rows} = drawData;
|
|
12718
12732
|
const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
|
|
12719
|
-
|
|
12733
|
+
const justifyLast = width && textAlign.includes("both");
|
|
12734
|
+
const justify = justifyLast || width && textAlign.includes("justify");
|
|
12735
|
+
const justifyLetter = justify && textAlign.includes("letter");
|
|
12736
|
+
let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
|
|
12720
12737
|
rows.forEach(row => {
|
|
12721
12738
|
if (row.words) {
|
|
12722
12739
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
12723
|
-
|
|
12724
|
-
|
|
12740
|
+
if (justify) {
|
|
12741
|
+
canJustify = !row.paraEnd || justifyLast;
|
|
12742
|
+
remainingWidth = width - row.width - indentWidth;
|
|
12743
|
+
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
12744
|
+
}
|
|
12745
|
+
mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
12725
12746
|
if (row.isOverflow && !letterSpacing) row.textMode = true;
|
|
12726
12747
|
if (mode === TextMode) {
|
|
12727
12748
|
row.x += indentWidth;
|
|
@@ -12739,11 +12760,15 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
12739
12760
|
charX = toWordChar(word.data, charX, wordChar);
|
|
12740
12761
|
if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
|
|
12741
12762
|
} else {
|
|
12742
|
-
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
12763
|
+
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
12743
12764
|
}
|
|
12744
|
-
if (
|
|
12745
|
-
|
|
12746
|
-
|
|
12765
|
+
if (canJustify) {
|
|
12766
|
+
isLastWord = index === wordsLength - 1;
|
|
12767
|
+
if (addWordWidth) {
|
|
12768
|
+
if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
|
|
12769
|
+
} else if (addLetterWidth) {
|
|
12770
|
+
row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
|
|
12771
|
+
}
|
|
12747
12772
|
}
|
|
12748
12773
|
});
|
|
12749
12774
|
}
|
|
@@ -12769,13 +12794,14 @@ function toWordChar(data, charX, wordChar) {
|
|
|
12769
12794
|
return charX;
|
|
12770
12795
|
}
|
|
12771
12796
|
|
|
12772
|
-
function toChar(data, charX, rowData, isOverflow) {
|
|
12797
|
+
function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
|
|
12773
12798
|
data.forEach(char => {
|
|
12774
12799
|
if (isOverflow || char.char !== " ") {
|
|
12775
12800
|
char.x = charX;
|
|
12776
12801
|
rowData.push(char);
|
|
12777
12802
|
}
|
|
12778
12803
|
charX += char.width;
|
|
12804
|
+
addLetterWidth && (charX += addLetterWidth);
|
|
12779
12805
|
});
|
|
12780
12806
|
return charX;
|
|
12781
12807
|
}
|
|
@@ -12917,10 +12943,10 @@ function getDrawData(content, style) {
|
|
|
12917
12943
|
let x = 0, y = 0;
|
|
12918
12944
|
let width = style.__getInput("width") || 0;
|
|
12919
12945
|
let height = style.__getInput("height") || 0;
|
|
12920
|
-
const {
|
|
12946
|
+
const {__padding: padding} = style;
|
|
12921
12947
|
if (padding) {
|
|
12922
|
-
if (width) x = padding[left], width -= padding[right] + padding[left]; else if (!style.autoSizeAlign) x = padding[left];
|
|
12923
|
-
if (height) y = padding[top], height -= padding[top] + padding[bottom]; else if (!style.autoSizeAlign) y = padding[top];
|
|
12948
|
+
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
12949
|
+
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
12924
12950
|
}
|
|
12925
12951
|
const drawData = {
|
|
12926
12952
|
bounds: {
|
|
@@ -12931,14 +12957,14 @@ function getDrawData(content, style) {
|
|
|
12931
12957
|
},
|
|
12932
12958
|
rows: [],
|
|
12933
12959
|
paraNumber: 0,
|
|
12934
|
-
font: Platform.canvas.font = __font
|
|
12960
|
+
font: Platform.canvas.font = style.__font
|
|
12935
12961
|
};
|
|
12936
12962
|
createRows(drawData, content, style);
|
|
12937
12963
|
if (padding) padAutoText(padding, drawData, style, width, height);
|
|
12938
12964
|
layoutText(drawData, style);
|
|
12939
|
-
layoutChar(drawData, style, width);
|
|
12965
|
+
if (style.__isCharMode) layoutChar(drawData, style, width);
|
|
12940
12966
|
if (drawData.overflow) clipText(drawData, style, x, width);
|
|
12941
|
-
if (textDecoration !== "none") decorationText(drawData, style);
|
|
12967
|
+
if (style.textDecoration !== "none") decorationText(drawData, style);
|
|
12942
12968
|
return drawData;
|
|
12943
12969
|
}
|
|
12944
12970
|
|
|
@@ -13017,4 +13043,4 @@ try {
|
|
|
13017
13043
|
if (wx) useCanvas("miniapp", wx);
|
|
13018
13044
|
} catch (_a) {}
|
|
13019
13045
|
|
|
13020
|
-
export { AlignHelper, Answer, App, AroundHelper, 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, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, 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, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, 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, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
|
|
13046
|
+
export { AlignHelper, Answer, App, AroundHelper, 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, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, 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, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TouchEvent, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, 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, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
|