@leafer-ui/miniapp 1.9.12 → 1.10.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/miniapp.cjs +429 -428
- package/dist/miniapp.esm.js +431 -430
- 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 +578 -554
- 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.1";
|
|
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(_paint, 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,102 +11356,163 @@ 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) {
|
|
11358
|
-
let item;
|
|
11364
|
+
function fills(fills, ui, canvas, renderOptions) {
|
|
11365
|
+
let item, originPaint, countImage;
|
|
11359
11366
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
11360
|
-
item = fills[i];
|
|
11367
|
+
item = fills[i], originPaint = item.originPaint;
|
|
11361
11368
|
if (item.image) {
|
|
11362
|
-
|
|
11369
|
+
countImage ? countImage++ : countImage = 1;
|
|
11370
|
+
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
11363
11371
|
if (!item.style) {
|
|
11364
|
-
if (
|
|
11372
|
+
if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
|
|
11365
11373
|
continue;
|
|
11366
11374
|
}
|
|
11367
11375
|
}
|
|
11368
11376
|
canvas.fillStyle = item.style;
|
|
11369
|
-
if (item.transform ||
|
|
11377
|
+
if (item.transform || originPaint.scaleFixed) {
|
|
11370
11378
|
canvas.save();
|
|
11371
11379
|
if (item.transform) canvas.transform(item.transform);
|
|
11372
|
-
if (
|
|
11380
|
+
if (originPaint.scaleFixed) {
|
|
11373
11381
|
const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
11374
|
-
if (
|
|
11382
|
+
if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
11375
11383
|
}
|
|
11376
|
-
if (
|
|
11377
|
-
fillPathOrText(ui, canvas);
|
|
11384
|
+
if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
|
|
11385
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
11378
11386
|
canvas.restore();
|
|
11379
11387
|
} else {
|
|
11380
|
-
if (
|
|
11381
|
-
canvas.saveBlendMode(
|
|
11382
|
-
fillPathOrText(ui, canvas);
|
|
11388
|
+
if (originPaint.blendMode) {
|
|
11389
|
+
canvas.saveBlendMode(originPaint.blendMode);
|
|
11390
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
11383
11391
|
canvas.restoreBlendMode();
|
|
11384
|
-
} else fillPathOrText(ui, canvas);
|
|
11392
|
+
} else fillPathOrText(ui, canvas, renderOptions);
|
|
11393
|
+
}
|
|
11394
|
+
}
|
|
11395
|
+
}
|
|
11396
|
+
|
|
11397
|
+
function fillPathOrText(ui, canvas, renderOptions) {
|
|
11398
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
11399
|
+
}
|
|
11400
|
+
|
|
11401
|
+
function fillText(ui, canvas, _renderOptions) {
|
|
11402
|
+
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11403
|
+
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
11404
|
+
let row;
|
|
11405
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
11406
|
+
row = rows[i];
|
|
11407
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
11408
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
11409
|
+
});
|
|
11410
|
+
}
|
|
11411
|
+
if (decorationY) {
|
|
11412
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
11413
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
11414
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
11415
|
+
}
|
|
11416
|
+
}
|
|
11417
|
+
|
|
11418
|
+
function stroke(stroke, ui, canvas, renderOptions) {
|
|
11419
|
+
const data = ui.__;
|
|
11420
|
+
if (!data.__strokeWidth) return;
|
|
11421
|
+
if (data.__font) {
|
|
11422
|
+
Paint.strokeText(stroke, ui, canvas, renderOptions);
|
|
11423
|
+
} else {
|
|
11424
|
+
switch (data.strokeAlign) {
|
|
11425
|
+
case "center":
|
|
11426
|
+
drawCenter$1(stroke, 1, ui, canvas, renderOptions);
|
|
11427
|
+
break;
|
|
11428
|
+
|
|
11429
|
+
case "inside":
|
|
11430
|
+
drawInside(stroke, ui, canvas, renderOptions);
|
|
11431
|
+
break;
|
|
11432
|
+
|
|
11433
|
+
case "outside":
|
|
11434
|
+
drawOutside(stroke, ui, canvas, renderOptions);
|
|
11435
|
+
break;
|
|
11385
11436
|
}
|
|
11386
11437
|
}
|
|
11387
11438
|
}
|
|
11388
11439
|
|
|
11389
|
-
function
|
|
11390
|
-
|
|
11440
|
+
function strokes(strokes, ui, canvas, renderOptions) {
|
|
11441
|
+
Paint.stroke(strokes, ui, canvas, renderOptions);
|
|
11442
|
+
}
|
|
11443
|
+
|
|
11444
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
11445
|
+
const data = ui.__;
|
|
11446
|
+
if (isObject(stroke)) {
|
|
11447
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
|
|
11448
|
+
} else {
|
|
11449
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
11450
|
+
canvas.stroke();
|
|
11451
|
+
}
|
|
11452
|
+
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
|
|
11453
|
+
}
|
|
11454
|
+
|
|
11455
|
+
function drawInside(stroke, ui, canvas, renderOptions) {
|
|
11456
|
+
canvas.save();
|
|
11457
|
+
canvas.clipUI(ui);
|
|
11458
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
11459
|
+
canvas.restore();
|
|
11460
|
+
}
|
|
11461
|
+
|
|
11462
|
+
function drawOutside(stroke, ui, canvas, renderOptions) {
|
|
11463
|
+
const data = ui.__;
|
|
11464
|
+
if (data.__fillAfterStroke) {
|
|
11465
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
11466
|
+
} else {
|
|
11467
|
+
const {renderBounds: renderBounds} = ui.__layout;
|
|
11468
|
+
const out = canvas.getSameCanvas(true, true);
|
|
11469
|
+
ui.__drawRenderPath(out);
|
|
11470
|
+
drawCenter$1(stroke, 2, ui, out, renderOptions);
|
|
11471
|
+
out.clipUI(data);
|
|
11472
|
+
out.clearWorld(renderBounds);
|
|
11473
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
11474
|
+
out.recycle(ui.__nowWorld);
|
|
11475
|
+
}
|
|
11391
11476
|
}
|
|
11392
11477
|
|
|
11393
|
-
function strokeText(stroke, ui, canvas) {
|
|
11478
|
+
function strokeText(stroke, ui, canvas, renderOptions) {
|
|
11394
11479
|
switch (ui.__.strokeAlign) {
|
|
11395
11480
|
case "center":
|
|
11396
|
-
drawCenter
|
|
11481
|
+
drawCenter(stroke, 1, ui, canvas, renderOptions);
|
|
11397
11482
|
break;
|
|
11398
11483
|
|
|
11399
11484
|
case "inside":
|
|
11400
|
-
drawAlign(stroke, "inside", ui, canvas);
|
|
11485
|
+
drawAlign(stroke, "inside", ui, canvas, renderOptions);
|
|
11401
11486
|
break;
|
|
11402
11487
|
|
|
11403
11488
|
case "outside":
|
|
11404
|
-
ui.__.__fillAfterStroke ? drawCenter
|
|
11489
|
+
ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
|
|
11405
11490
|
break;
|
|
11406
11491
|
}
|
|
11407
11492
|
}
|
|
11408
11493
|
|
|
11409
|
-
function drawCenter
|
|
11494
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
11410
11495
|
const data = ui.__;
|
|
11411
11496
|
if (isObject(stroke)) {
|
|
11412
|
-
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
11497
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
|
|
11413
11498
|
} else {
|
|
11414
11499
|
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
11415
|
-
drawTextStroke(ui, canvas);
|
|
11500
|
+
Paint.drawTextStroke(ui, canvas, renderOptions);
|
|
11416
11501
|
}
|
|
11417
11502
|
}
|
|
11418
11503
|
|
|
11419
|
-
function drawAlign(stroke, align, ui, canvas) {
|
|
11504
|
+
function drawAlign(stroke, align, ui, canvas, renderOptions) {
|
|
11420
11505
|
const out = canvas.getSameCanvas(true, true);
|
|
11421
11506
|
out.font = ui.__.__font;
|
|
11422
|
-
drawCenter
|
|
11507
|
+
drawCenter(stroke, 2, ui, out, renderOptions);
|
|
11423
11508
|
out.blendMode = align === "outside" ? "destination-out" : "destination-in";
|
|
11424
|
-
fillText(ui, out);
|
|
11509
|
+
Paint.fillText(ui, out, renderOptions);
|
|
11425
11510
|
out.blendMode = "normal";
|
|
11426
11511
|
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
11427
11512
|
out.recycle(ui.__nowWorld);
|
|
11428
11513
|
}
|
|
11429
11514
|
|
|
11430
|
-
function drawTextStroke(ui, canvas) {
|
|
11515
|
+
function drawTextStroke(ui, canvas, _renderOptions) {
|
|
11431
11516
|
let row, data = ui.__.__textDrawData;
|
|
11432
11517
|
const {rows: rows, decorationY: decorationY} = data;
|
|
11433
11518
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
@@ -11442,89 +11527,29 @@ function drawTextStroke(ui, canvas) {
|
|
|
11442
11527
|
}
|
|
11443
11528
|
}
|
|
11444
11529
|
|
|
11445
|
-
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
11530
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
|
|
11446
11531
|
let item;
|
|
11447
11532
|
const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
|
|
11448
11533
|
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
11449
11534
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
11450
11535
|
item = strokes[i];
|
|
11451
|
-
if (item.image && PaintImage.checkImage(ui, canvas,
|
|
11536
|
+
if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
|
|
11452
11537
|
if (item.style) {
|
|
11453
11538
|
if (__hasMultiStrokeStyle) {
|
|
11454
11539
|
const {strokeStyle: strokeStyle} = item;
|
|
11455
11540
|
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
11456
11541
|
} else canvas.strokeStyle = item.style;
|
|
11457
|
-
if (item.blendMode) {
|
|
11458
|
-
canvas.saveBlendMode(item.blendMode);
|
|
11459
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
11542
|
+
if (item.originPaint.blendMode) {
|
|
11543
|
+
canvas.saveBlendMode(item.originPaint.blendMode);
|
|
11544
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
11460
11545
|
canvas.restoreBlendMode();
|
|
11461
11546
|
} else {
|
|
11462
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
11547
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
11463
11548
|
}
|
|
11464
11549
|
}
|
|
11465
11550
|
}
|
|
11466
11551
|
}
|
|
11467
11552
|
|
|
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
11553
|
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
11529
11554
|
|
|
11530
11555
|
const tempBounds$1 = {};
|
|
@@ -11612,62 +11637,63 @@ function compute(attrName, ui) {
|
|
|
11612
11637
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
11613
11638
|
isTransparent = true;
|
|
11614
11639
|
}
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11640
|
+
if (attrName === "fill") {
|
|
11641
|
+
stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
|
|
11642
|
+
stintSet(data, "__isTransparentFill", isTransparent);
|
|
11643
|
+
} else {
|
|
11644
|
+
stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
|
|
11645
|
+
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
11646
|
+
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
11647
|
+
}
|
|
11619
11648
|
} else {
|
|
11620
|
-
|
|
11621
|
-
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
11622
|
-
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
11649
|
+
data.__removePaint(attrName, false);
|
|
11623
11650
|
}
|
|
11624
11651
|
}
|
|
11625
11652
|
|
|
11626
11653
|
function getLeafPaint(attrName, paint, ui) {
|
|
11627
11654
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
11628
|
-
let
|
|
11655
|
+
let leafPaint;
|
|
11629
11656
|
const {boxBounds: boxBounds} = ui.__layout;
|
|
11630
11657
|
switch (paint.type) {
|
|
11631
11658
|
case "image":
|
|
11632
|
-
|
|
11659
|
+
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
11633
11660
|
break;
|
|
11634
11661
|
|
|
11635
11662
|
case "linear":
|
|
11636
|
-
|
|
11663
|
+
leafPaint = PaintGradient.linearGradient(paint, boxBounds);
|
|
11637
11664
|
break;
|
|
11638
11665
|
|
|
11639
11666
|
case "radial":
|
|
11640
|
-
|
|
11667
|
+
leafPaint = PaintGradient.radialGradient(paint, boxBounds);
|
|
11641
11668
|
break;
|
|
11642
11669
|
|
|
11643
11670
|
case "angular":
|
|
11644
|
-
|
|
11671
|
+
leafPaint = PaintGradient.conicGradient(paint, boxBounds);
|
|
11645
11672
|
break;
|
|
11646
11673
|
|
|
11647
11674
|
case "solid":
|
|
11648
11675
|
const {type: type, color: color, opacity: opacity} = paint;
|
|
11649
|
-
|
|
11676
|
+
leafPaint = {
|
|
11650
11677
|
type: type,
|
|
11651
11678
|
style: ColorConvert.string(color, opacity)
|
|
11652
11679
|
};
|
|
11653
11680
|
break;
|
|
11654
11681
|
|
|
11655
11682
|
default:
|
|
11656
|
-
if (!isUndefined(paint.r))
|
|
11683
|
+
if (!isUndefined(paint.r)) leafPaint = {
|
|
11657
11684
|
type: "solid",
|
|
11658
11685
|
style: ColorConvert.string(paint)
|
|
11659
11686
|
};
|
|
11660
11687
|
}
|
|
11661
|
-
if (
|
|
11662
|
-
|
|
11688
|
+
if (leafPaint) {
|
|
11689
|
+
leafPaint.originPaint = paint;
|
|
11690
|
+
if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
|
|
11663
11691
|
if (paint.style) {
|
|
11664
11692
|
if (paint.style.strokeWidth === 0) return undefined;
|
|
11665
|
-
|
|
11693
|
+
leafPaint.strokeStyle = paint.style;
|
|
11666
11694
|
}
|
|
11667
|
-
if (paint.editing) data.editing = paint.editing;
|
|
11668
|
-
if (paint.blendMode) data.blendMode = paint.blendMode;
|
|
11669
11695
|
}
|
|
11670
|
-
return
|
|
11696
|
+
return leafPaint;
|
|
11671
11697
|
}
|
|
11672
11698
|
|
|
11673
11699
|
const PaintModule = {
|
|
@@ -11680,88 +11706,118 @@ const PaintModule = {
|
|
|
11680
11706
|
strokes: strokes,
|
|
11681
11707
|
strokeText: strokeText,
|
|
11682
11708
|
drawTextStroke: drawTextStroke,
|
|
11709
|
+
drawStrokesStyle: drawStrokesStyle,
|
|
11683
11710
|
shape: shape
|
|
11684
11711
|
};
|
|
11685
11712
|
|
|
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
|
-
}
|
|
11713
|
+
let cache, box = new Bounds;
|
|
11696
11714
|
|
|
11697
|
-
|
|
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
|
-
}
|
|
11715
|
+
const {isSame: isSame} = BoundsHelper;
|
|
11707
11716
|
|
|
11708
|
-
function
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
if (
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
+
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
11718
|
+
let leafPaint, event;
|
|
11719
|
+
const image = ImageManager.get(paint);
|
|
11720
|
+
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
11721
|
+
leafPaint = cache.leafPaint;
|
|
11722
|
+
} else {
|
|
11723
|
+
leafPaint = {
|
|
11724
|
+
type: paint.type,
|
|
11725
|
+
image: image
|
|
11726
|
+
};
|
|
11727
|
+
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
11728
|
+
cache = image.use > 1 ? {
|
|
11729
|
+
leafPaint: leafPaint,
|
|
11730
|
+
paint: paint,
|
|
11731
|
+
boxBounds: box.set(boxBounds)
|
|
11732
|
+
} : null;
|
|
11717
11733
|
}
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
if (
|
|
11724
|
-
|
|
11734
|
+
if (firstUse || image.loading) event = {
|
|
11735
|
+
image: image,
|
|
11736
|
+
attrName: attrName,
|
|
11737
|
+
attrValue: paint
|
|
11738
|
+
};
|
|
11739
|
+
if (image.ready) {
|
|
11740
|
+
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
11741
|
+
if (firstUse) {
|
|
11742
|
+
onLoad(ui, event);
|
|
11743
|
+
onLoadSuccess(ui, event);
|
|
11744
|
+
}
|
|
11745
|
+
} else if (image.error) {
|
|
11746
|
+
if (firstUse) onLoadError(ui, event, image.error);
|
|
11725
11747
|
} else {
|
|
11726
|
-
if (
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11748
|
+
if (firstUse) {
|
|
11749
|
+
ignoreRender(ui, true);
|
|
11750
|
+
onLoad(ui, event);
|
|
11751
|
+
}
|
|
11752
|
+
leafPaint.loadId = image.load(() => {
|
|
11753
|
+
ignoreRender(ui, false);
|
|
11754
|
+
if (!ui.destroyed) {
|
|
11755
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
11756
|
+
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
11757
|
+
ui.forceUpdate("surface");
|
|
11758
|
+
}
|
|
11759
|
+
onLoadSuccess(ui, event);
|
|
11760
|
+
}
|
|
11761
|
+
leafPaint.loadId = undefined;
|
|
11762
|
+
}, error => {
|
|
11763
|
+
ignoreRender(ui, false);
|
|
11764
|
+
onLoadError(ui, event, error);
|
|
11765
|
+
leafPaint.loadId = undefined;
|
|
11766
|
+
});
|
|
11767
|
+
if (ui.placeholderColor) {
|
|
11768
|
+
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
11769
|
+
if (!image.ready) {
|
|
11770
|
+
image.isPlacehold = true;
|
|
11771
|
+
ui.forceUpdate("surface");
|
|
11746
11772
|
}
|
|
11773
|
+
}, ui.placeholderDelay);
|
|
11774
|
+
}
|
|
11775
|
+
}
|
|
11776
|
+
return leafPaint;
|
|
11777
|
+
}
|
|
11778
|
+
|
|
11779
|
+
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
11780
|
+
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
11781
|
+
const data = ui.__;
|
|
11782
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
11783
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
11784
|
+
if (data.__autoSide) {
|
|
11785
|
+
ui.forceUpdate("width");
|
|
11786
|
+
if (ui.__proxyData) {
|
|
11787
|
+
ui.setProxyAttr("width", data.width);
|
|
11788
|
+
ui.setProxyAttr("height", data.height);
|
|
11747
11789
|
}
|
|
11790
|
+
return false;
|
|
11748
11791
|
}
|
|
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
11792
|
}
|
|
11754
|
-
data.
|
|
11793
|
+
if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
11794
|
+
return true;
|
|
11755
11795
|
}
|
|
11756
11796
|
|
|
11757
|
-
function
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11797
|
+
function onLoad(ui, event) {
|
|
11798
|
+
emit(ui, ImageEvent.LOAD, event);
|
|
11799
|
+
}
|
|
11800
|
+
|
|
11801
|
+
function onLoadSuccess(ui, event) {
|
|
11802
|
+
emit(ui, ImageEvent.LOADED, event);
|
|
11803
|
+
}
|
|
11804
|
+
|
|
11805
|
+
function onLoadError(ui, event, error) {
|
|
11806
|
+
event.error = error;
|
|
11807
|
+
ui.forceUpdate("surface");
|
|
11808
|
+
emit(ui, ImageEvent.ERROR, event);
|
|
11762
11809
|
}
|
|
11763
11810
|
|
|
11764
|
-
|
|
11811
|
+
function emit(ui, type, data) {
|
|
11812
|
+
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
11813
|
+
}
|
|
11814
|
+
|
|
11815
|
+
function ignoreRender(ui, value) {
|
|
11816
|
+
const {leafer: leafer} = ui;
|
|
11817
|
+
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
11818
|
+
}
|
|
11819
|
+
|
|
11820
|
+
const {get: get$3, translate: translate$1} = MatrixHelper;
|
|
11765
11821
|
|
|
11766
11822
|
const tempBox = new Bounds;
|
|
11767
11823
|
|
|
@@ -11770,17 +11826,13 @@ const tempScaleData = {};
|
|
|
11770
11826
|
const tempImage = {};
|
|
11771
11827
|
|
|
11772
11828
|
function createData(leafPaint, image, paint, box) {
|
|
11773
|
-
|
|
11774
|
-
if (changeful) leafPaint.changeful = changeful;
|
|
11775
|
-
if (sync) leafPaint.sync = sync;
|
|
11776
|
-
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
11777
|
-
leafPaint.data = getPatternData(paint, box, image);
|
|
11829
|
+
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
11778
11830
|
}
|
|
11779
11831
|
|
|
11780
11832
|
function getPatternData(paint, box, image) {
|
|
11781
11833
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
11782
11834
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
11783
|
-
|
|
11835
|
+
const {width: width, height: height} = image;
|
|
11784
11836
|
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
11837
|
const sameBox = box.width === width && box.height === height;
|
|
11786
11838
|
const data = {
|
|
@@ -11811,8 +11863,8 @@ function getPatternData(paint, box, image) {
|
|
|
11811
11863
|
case "stretch":
|
|
11812
11864
|
if (!sameBox) {
|
|
11813
11865
|
scaleX = box.width / width, scaleY = box.height / height;
|
|
11814
|
-
stretchMode(data, box, scaleX, scaleY);
|
|
11815
|
-
}
|
|
11866
|
+
PaintImage.stretchMode(data, box, scaleX, scaleY);
|
|
11867
|
+
} else if (scaleX) scaleX = scaleY = undefined;
|
|
11816
11868
|
break;
|
|
11817
11869
|
|
|
11818
11870
|
case "normal":
|
|
@@ -11820,13 +11872,13 @@ function getPatternData(paint, box, image) {
|
|
|
11820
11872
|
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
11821
11873
|
let clipScaleX, clipScaleY;
|
|
11822
11874
|
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);
|
|
11875
|
+
PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
11824
11876
|
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
11825
11877
|
}
|
|
11826
11878
|
break;
|
|
11827
11879
|
|
|
11828
11880
|
case "repeat":
|
|
11829
|
-
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
11881
|
+
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
11830
11882
|
if (!repeat) data.repeat = "repeat";
|
|
11831
11883
|
const count = isObject(repeat);
|
|
11832
11884
|
if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
|
|
@@ -11835,18 +11887,16 @@ function getPatternData(paint, box, image) {
|
|
|
11835
11887
|
case "fit":
|
|
11836
11888
|
case "cover":
|
|
11837
11889
|
default:
|
|
11838
|
-
if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
11890
|
+
if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
11839
11891
|
}
|
|
11840
11892
|
if (!data.transform) {
|
|
11841
|
-
if (box.x || box.y) translate(data.transform = get$
|
|
11893
|
+
if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
|
|
11842
11894
|
}
|
|
11843
|
-
data.width = width;
|
|
11844
|
-
data.height = height;
|
|
11845
11895
|
if (scaleX) {
|
|
11846
11896
|
data.scaleX = scaleX;
|
|
11847
11897
|
data.scaleY = scaleY;
|
|
11848
11898
|
}
|
|
11849
|
-
if (opacity) data.opacity = opacity;
|
|
11899
|
+
if (opacity && opacity < 1) data.opacity = opacity;
|
|
11850
11900
|
if (filters) data.filters = filters;
|
|
11851
11901
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
11852
11902
|
return data;
|
|
@@ -11868,234 +11918,194 @@ function getGapValue(gap, size, totalSize, rows) {
|
|
|
11868
11918
|
return gap === "auto" ? value < 0 ? 0 : value : value;
|
|
11869
11919
|
}
|
|
11870
11920
|
|
|
11871
|
-
let
|
|
11921
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
11872
11922
|
|
|
11873
|
-
const {
|
|
11923
|
+
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
11874
11924
|
|
|
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;
|
|
11925
|
+
function stretchMode(data, box, scaleX, scaleY) {
|
|
11926
|
+
const transform = get$2(), {x: x, y: y} = box;
|
|
11927
|
+
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
11928
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
11929
|
+
data.transform = transform;
|
|
11935
11930
|
}
|
|
11936
11931
|
|
|
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;
|
|
11932
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
11933
|
+
const transform = get$2();
|
|
11934
|
+
translate(transform, box.x + x, box.y + y);
|
|
11935
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
11936
|
+
if (rotation) rotateOfOuter$1(transform, {
|
|
11937
|
+
x: box.x + box.width / 2,
|
|
11938
|
+
y: box.y + box.height / 2
|
|
11939
|
+
}, rotation);
|
|
11940
|
+
data.transform = transform;
|
|
11953
11941
|
}
|
|
11954
11942
|
|
|
11955
|
-
function
|
|
11956
|
-
|
|
11943
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
11944
|
+
const transform = get$2();
|
|
11945
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
11946
|
+
if (clipScaleX) {
|
|
11947
|
+
if (rotation || skew) {
|
|
11948
|
+
set(tempMatrix$1);
|
|
11949
|
+
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
11950
|
+
multiplyParent(transform, tempMatrix$1);
|
|
11951
|
+
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
11952
|
+
}
|
|
11953
|
+
data.transform = transform;
|
|
11957
11954
|
}
|
|
11958
11955
|
|
|
11959
|
-
function
|
|
11960
|
-
|
|
11961
|
-
|
|
11956
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
11957
|
+
const transform = get$2();
|
|
11958
|
+
if (freeTransform) {
|
|
11959
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
11960
|
+
} else {
|
|
11961
|
+
if (rotation) {
|
|
11962
|
+
if (align === "center") {
|
|
11963
|
+
rotateOfOuter$1(transform, {
|
|
11964
|
+
x: width / 2,
|
|
11965
|
+
y: height / 2
|
|
11966
|
+
}, rotation);
|
|
11967
|
+
} else {
|
|
11968
|
+
rotate(transform, rotation);
|
|
11969
|
+
switch (rotation) {
|
|
11970
|
+
case 90:
|
|
11971
|
+
translate(transform, height, 0);
|
|
11972
|
+
break;
|
|
11962
11973
|
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
|
|
11966
|
-
emit(ui, ImageEvent.ERROR, event);
|
|
11967
|
-
}
|
|
11974
|
+
case 180:
|
|
11975
|
+
translate(transform, width, height);
|
|
11976
|
+
break;
|
|
11968
11977
|
|
|
11969
|
-
|
|
11970
|
-
|
|
11978
|
+
case 270:
|
|
11979
|
+
translate(transform, 0, width);
|
|
11980
|
+
break;
|
|
11981
|
+
}
|
|
11982
|
+
}
|
|
11983
|
+
}
|
|
11984
|
+
origin.x = box.x + x;
|
|
11985
|
+
origin.y = box.y + y;
|
|
11986
|
+
translate(transform, origin.x, origin.y);
|
|
11987
|
+
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
11988
|
+
}
|
|
11989
|
+
data.transform = transform;
|
|
11971
11990
|
}
|
|
11972
11991
|
|
|
11973
|
-
function
|
|
11974
|
-
|
|
11975
|
-
if (
|
|
11992
|
+
function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
11993
|
+
if (rotation) rotate(transform, rotation);
|
|
11994
|
+
if (skew) skewHelper(transform, skew.x, skew.y);
|
|
11995
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
11996
|
+
translate(transform, box.x + x, box.y + y);
|
|
11976
11997
|
}
|
|
11977
11998
|
|
|
11978
11999
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
11979
12000
|
|
|
11980
|
-
const {
|
|
12001
|
+
const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
11981
12002
|
|
|
11982
|
-
function
|
|
11983
|
-
|
|
11984
|
-
|
|
12003
|
+
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
12004
|
+
if (!paint.patternTask) {
|
|
12005
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
12006
|
+
paint.patternTask = null;
|
|
12007
|
+
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
12008
|
+
ui.forceUpdate("surface");
|
|
12009
|
+
}), 300);
|
|
12010
|
+
}
|
|
12011
|
+
}
|
|
12012
|
+
|
|
12013
|
+
function createPattern(paint, ui, canvas, renderOptions) {
|
|
12014
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
11985
12015
|
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) {
|
|
12016
|
+
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
12017
|
+
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
12018
|
+
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
12019
|
+
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
12020
|
+
width *= scaleX;
|
|
12021
|
+
height *= scaleY;
|
|
12022
|
+
if (gap) {
|
|
12023
|
+
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
12024
|
+
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
12025
|
+
}
|
|
12026
|
+
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
12027
|
+
scaleX *= getFloorScale(width + (xGap || 0));
|
|
12028
|
+
scaleY *= getFloorScale(height + (yGap || 0));
|
|
12032
12029
|
imageMatrix = get$1();
|
|
12033
12030
|
if (transform) copy$1(imageMatrix, transform);
|
|
12031
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
12034
12032
|
}
|
|
12035
|
-
|
|
12033
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
12034
|
+
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
12035
|
+
paint.style = pattern;
|
|
12036
|
+
paint.patternId = id;
|
|
12036
12037
|
}
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12041
|
-
|
|
12038
|
+
}
|
|
12039
|
+
}
|
|
12040
|
+
|
|
12041
|
+
function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
12042
|
+
const {image: image} = paint;
|
|
12043
|
+
let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
|
|
12044
|
+
if (image.isSVG) {
|
|
12045
|
+
if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
|
|
12042
12046
|
} else {
|
|
12043
|
-
|
|
12047
|
+
if (maxSize > imageSize) maxSize = imageSize;
|
|
12044
12048
|
}
|
|
12049
|
+
if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
|
|
12050
|
+
return fixScale;
|
|
12045
12051
|
}
|
|
12046
12052
|
|
|
12047
|
-
function checkImage(ui, canvas,
|
|
12048
|
-
const {scaleX: scaleX, scaleY: scaleY} =
|
|
12049
|
-
const {
|
|
12050
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY
|
|
12053
|
+
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
12054
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
12055
|
+
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
|
|
12056
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
12051
12057
|
return false;
|
|
12052
12058
|
} else {
|
|
12053
|
-
if (
|
|
12059
|
+
if (drawImage) {
|
|
12054
12060
|
if (data.repeat) {
|
|
12055
|
-
|
|
12056
|
-
} else if (!(
|
|
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;
|
|
12061
|
+
drawImage = false;
|
|
12062
|
+
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
12063
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
12065
12064
|
}
|
|
12066
12065
|
}
|
|
12067
|
-
if (
|
|
12066
|
+
if (drawImage) {
|
|
12068
12067
|
if (ui.__.__isFastShadow) {
|
|
12069
12068
|
canvas.fillStyle = paint.style || "#000";
|
|
12070
12069
|
canvas.fill();
|
|
12071
12070
|
}
|
|
12072
|
-
drawImage(ui, canvas,
|
|
12071
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
12073
12072
|
return true;
|
|
12074
12073
|
} else {
|
|
12075
|
-
if (!paint.style ||
|
|
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
|
-
}
|
|
12074
|
+
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
12086
12075
|
return false;
|
|
12087
12076
|
}
|
|
12088
12077
|
}
|
|
12089
12078
|
}
|
|
12090
12079
|
|
|
12091
|
-
function drawImage(ui, canvas,
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
if (
|
|
12095
|
-
|
|
12096
|
-
|
|
12097
|
-
|
|
12098
|
-
|
|
12080
|
+
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
12081
|
+
const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
12082
|
+
let {width: width, height: height} = image, clipUI;
|
|
12083
|
+
if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
|
|
12084
|
+
canvas.save();
|
|
12085
|
+
clipUI && canvas.clipUI(ui);
|
|
12086
|
+
blendMode && (canvas.blendMode = blendMode);
|
|
12087
|
+
opacity && (canvas.opacity *= opacity);
|
|
12088
|
+
transform && canvas.transform(transform);
|
|
12089
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
12090
|
+
canvas.restore();
|
|
12091
|
+
} else {
|
|
12092
|
+
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
12093
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
12094
|
+
}
|
|
12095
|
+
}
|
|
12096
|
+
|
|
12097
|
+
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
12098
|
+
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
12099
|
+
if (canvas) {
|
|
12100
|
+
const {pixelRatio: pixelRatio} = canvas;
|
|
12101
|
+
scaleData.scaleX *= pixelRatio;
|
|
12102
|
+
scaleData.scaleY *= pixelRatio;
|
|
12103
|
+
}
|
|
12104
|
+
if (data && data.scaleX) {
|
|
12105
|
+
scaleData.scaleX *= Math.abs(data.scaleX);
|
|
12106
|
+
scaleData.scaleY *= Math.abs(data.scaleY);
|
|
12107
|
+
}
|
|
12108
|
+
return scaleData;
|
|
12099
12109
|
}
|
|
12100
12110
|
|
|
12101
12111
|
function recycleImage(attrName, data) {
|
|
@@ -12127,8 +12137,12 @@ function recycleImage(attrName, data) {
|
|
|
12127
12137
|
const PaintImageModule = {
|
|
12128
12138
|
image: image,
|
|
12129
12139
|
checkImage: checkImage,
|
|
12130
|
-
|
|
12140
|
+
drawImage: drawImage,
|
|
12141
|
+
getImageRenderScaleData: getImageRenderScaleData,
|
|
12131
12142
|
recycleImage: recycleImage,
|
|
12143
|
+
createPatternTask: createPatternTask,
|
|
12144
|
+
createPattern: createPattern,
|
|
12145
|
+
getPatternFixScale: getPatternFixScale,
|
|
12132
12146
|
createData: createData,
|
|
12133
12147
|
getPatternData: getPatternData,
|
|
12134
12148
|
stretchMode: stretchMode,
|
|
@@ -12584,10 +12598,8 @@ function createRows(drawData, content, style) {
|
|
|
12584
12598
|
bounds = drawData.bounds;
|
|
12585
12599
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
12586
12600
|
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) {
|
|
12601
|
+
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
12602
|
+
if (style.__isCharMode) {
|
|
12591
12603
|
const wrap = style.textWrap !== "none";
|
|
12592
12604
|
const breakAll = style.textWrap === "break";
|
|
12593
12605
|
paraStart = true;
|
|
@@ -12716,12 +12728,19 @@ const TextMode = 2;
|
|
|
12716
12728
|
function layoutChar(drawData, style, width, _height) {
|
|
12717
12729
|
const {rows: rows} = drawData;
|
|
12718
12730
|
const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
|
|
12719
|
-
|
|
12731
|
+
const justifyLast = width && textAlign.includes("both");
|
|
12732
|
+
const justify = justifyLast || width && textAlign.includes("justify");
|
|
12733
|
+
const justifyLetter = justify && textAlign.includes("letter");
|
|
12734
|
+
let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
|
|
12720
12735
|
rows.forEach(row => {
|
|
12721
12736
|
if (row.words) {
|
|
12722
12737
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
12723
|
-
|
|
12724
|
-
|
|
12738
|
+
if (justify) {
|
|
12739
|
+
canJustify = !row.paraEnd || justifyLast;
|
|
12740
|
+
remainingWidth = width - row.width - indentWidth;
|
|
12741
|
+
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
12742
|
+
}
|
|
12743
|
+
mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
12725
12744
|
if (row.isOverflow && !letterSpacing) row.textMode = true;
|
|
12726
12745
|
if (mode === TextMode) {
|
|
12727
12746
|
row.x += indentWidth;
|
|
@@ -12739,11 +12758,15 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
12739
12758
|
charX = toWordChar(word.data, charX, wordChar);
|
|
12740
12759
|
if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
|
|
12741
12760
|
} else {
|
|
12742
|
-
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
12761
|
+
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
12743
12762
|
}
|
|
12744
|
-
if (
|
|
12745
|
-
|
|
12746
|
-
|
|
12763
|
+
if (canJustify) {
|
|
12764
|
+
isLastWord = index === wordsLength - 1;
|
|
12765
|
+
if (addWordWidth) {
|
|
12766
|
+
if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
|
|
12767
|
+
} else if (addLetterWidth) {
|
|
12768
|
+
row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
|
|
12769
|
+
}
|
|
12747
12770
|
}
|
|
12748
12771
|
});
|
|
12749
12772
|
}
|
|
@@ -12769,13 +12792,14 @@ function toWordChar(data, charX, wordChar) {
|
|
|
12769
12792
|
return charX;
|
|
12770
12793
|
}
|
|
12771
12794
|
|
|
12772
|
-
function toChar(data, charX, rowData, isOverflow) {
|
|
12795
|
+
function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
|
|
12773
12796
|
data.forEach(char => {
|
|
12774
12797
|
if (isOverflow || char.char !== " ") {
|
|
12775
12798
|
char.x = charX;
|
|
12776
12799
|
rowData.push(char);
|
|
12777
12800
|
}
|
|
12778
12801
|
charX += char.width;
|
|
12802
|
+
addLetterWidth && (charX += addLetterWidth);
|
|
12779
12803
|
});
|
|
12780
12804
|
return charX;
|
|
12781
12805
|
}
|
|
@@ -12917,10 +12941,10 @@ function getDrawData(content, style) {
|
|
|
12917
12941
|
let x = 0, y = 0;
|
|
12918
12942
|
let width = style.__getInput("width") || 0;
|
|
12919
12943
|
let height = style.__getInput("height") || 0;
|
|
12920
|
-
const {
|
|
12944
|
+
const {__padding: padding} = style;
|
|
12921
12945
|
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];
|
|
12946
|
+
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
12947
|
+
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
12924
12948
|
}
|
|
12925
12949
|
const drawData = {
|
|
12926
12950
|
bounds: {
|
|
@@ -12931,14 +12955,14 @@ function getDrawData(content, style) {
|
|
|
12931
12955
|
},
|
|
12932
12956
|
rows: [],
|
|
12933
12957
|
paraNumber: 0,
|
|
12934
|
-
font: Platform.canvas.font = __font
|
|
12958
|
+
font: Platform.canvas.font = style.__font
|
|
12935
12959
|
};
|
|
12936
12960
|
createRows(drawData, content, style);
|
|
12937
12961
|
if (padding) padAutoText(padding, drawData, style, width, height);
|
|
12938
12962
|
layoutText(drawData, style);
|
|
12939
|
-
layoutChar(drawData, style, width);
|
|
12963
|
+
if (style.__isCharMode) layoutChar(drawData, style, width);
|
|
12940
12964
|
if (drawData.overflow) clipText(drawData, style, x, width);
|
|
12941
|
-
if (textDecoration !== "none") decorationText(drawData, style);
|
|
12965
|
+
if (style.textDecoration !== "none") decorationText(drawData, style);
|
|
12942
12966
|
return drawData;
|
|
12943
12967
|
}
|
|
12944
12968
|
|
|
@@ -13017,4 +13041,4 @@ try {
|
|
|
13017
13041
|
if (wx) useCanvas("miniapp", wx);
|
|
13018
13042
|
} catch (_a) {}
|
|
13019
13043
|
|
|
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 };
|
|
13044
|
+
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 };
|