leafer-ui 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/README.md +4 -1
- package/dist/web.cjs +397 -394
- package/dist/web.esm.js +399 -396
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +523 -503
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +547 -521
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +11 -11
package/dist/web.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$a.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
|
const debug$5 = Debug.get("LeaferCanvas");
|
|
6825
6841
|
|
|
@@ -7800,6 +7816,7 @@ class Picker {
|
|
|
7800
7816
|
hit = child.__.hitRadius ? true : hitRadiusPoint$1(child.__world, point);
|
|
7801
7817
|
if (child.isBranch) {
|
|
7802
7818
|
if (hit || child.__ignoreHitWorld) {
|
|
7819
|
+
if (child.isBranchLeaf && child.__.__clipAfterFill && !child.__hitWorld(point)) continue;
|
|
7803
7820
|
if (child.topChildren) this.eachFind(child.topChildren, false);
|
|
7804
7821
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
7805
7822
|
if (child.isBranchLeaf) this.hitChild(child, point);
|
|
@@ -7992,7 +8009,7 @@ const Transition = {
|
|
|
7992
8009
|
|
|
7993
8010
|
const {parse: parse, objectToCanvasData: objectToCanvasData} = PathConvert;
|
|
7994
8011
|
|
|
7995
|
-
const {stintSet: stintSet$
|
|
8012
|
+
const {stintSet: stintSet$3} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
|
|
7996
8013
|
|
|
7997
8014
|
const emptyPaint = {};
|
|
7998
8015
|
|
|
@@ -8059,7 +8076,7 @@ class UIData extends LeafData {
|
|
|
8059
8076
|
setFill(value) {
|
|
8060
8077
|
if (this.__naturalWidth) this.__removeNaturalSize();
|
|
8061
8078
|
if (isString(value) || !value) {
|
|
8062
|
-
stintSet$
|
|
8079
|
+
stintSet$3(this, "__isTransparentFill", hasTransparent$2(value));
|
|
8063
8080
|
this.__isFills && this.__removePaint("fill", true);
|
|
8064
8081
|
this._fill = value;
|
|
8065
8082
|
} else if (isObject(value)) {
|
|
@@ -8068,7 +8085,7 @@ class UIData extends LeafData {
|
|
|
8068
8085
|
}
|
|
8069
8086
|
setStroke(value) {
|
|
8070
8087
|
if (isString(value) || !value) {
|
|
8071
|
-
stintSet$
|
|
8088
|
+
stintSet$3(this, "__isTransparentStroke", hasTransparent$2(value));
|
|
8072
8089
|
this.__isStrokes && this.__removePaint("stroke", true);
|
|
8073
8090
|
this._stroke = value;
|
|
8074
8091
|
} else if (isObject(value)) {
|
|
@@ -8126,11 +8143,11 @@ class UIData extends LeafData {
|
|
|
8126
8143
|
if (removeInput) this.__removeInput(attrName);
|
|
8127
8144
|
PaintImage.recycleImage(attrName, this);
|
|
8128
8145
|
if (attrName === "fill") {
|
|
8129
|
-
stintSet$
|
|
8146
|
+
stintSet$3(this, "__isAlphaPixelFill", undefined);
|
|
8130
8147
|
this._fill = this.__isFills = undefined;
|
|
8131
8148
|
} else {
|
|
8132
|
-
stintSet$
|
|
8133
|
-
stintSet$
|
|
8149
|
+
stintSet$3(this, "__isAlphaPixelStroke", undefined);
|
|
8150
|
+
stintSet$3(this, "__hasMultiStrokeStyle", undefined);
|
|
8134
8151
|
this._stroke = this.__isStrokes = undefined;
|
|
8135
8152
|
}
|
|
8136
8153
|
}
|
|
@@ -8279,7 +8296,7 @@ class CanvasData extends RectData {
|
|
|
8279
8296
|
}
|
|
8280
8297
|
}
|
|
8281
8298
|
|
|
8282
|
-
const {max: max$
|
|
8299
|
+
const {max: max$2, add: add$1} = FourNumberHelper;
|
|
8283
8300
|
|
|
8284
8301
|
const UIBounds = {
|
|
8285
8302
|
__updateStrokeSpread() {
|
|
@@ -8295,7 +8312,7 @@ const UIBounds = {
|
|
|
8295
8312
|
}
|
|
8296
8313
|
if (data.__useArrow) spread += strokeWidth * 5;
|
|
8297
8314
|
if (box) {
|
|
8298
|
-
spread = max$
|
|
8315
|
+
spread = max$2(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
|
|
8299
8316
|
boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
|
|
8300
8317
|
}
|
|
8301
8318
|
this.__layout.strokeBoxSpread = boxSpread;
|
|
@@ -8305,35 +8322,35 @@ const UIBounds = {
|
|
|
8305
8322
|
let spread = 0;
|
|
8306
8323
|
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
|
|
8307
8324
|
if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
|
|
8308
|
-
if (blur) spread = max$
|
|
8325
|
+
if (blur) spread = max$2(spread, blur);
|
|
8309
8326
|
if (filter) spread = add$1(spread, Filter.getSpread(filter));
|
|
8310
8327
|
if (renderSpread) spread = add$1(spread, renderSpread);
|
|
8311
8328
|
if (strokeSpread) spread = add$1(spread, strokeSpread);
|
|
8312
8329
|
let shapeSpread = spread;
|
|
8313
|
-
if (innerShadow) shapeSpread = max$
|
|
8314
|
-
if (backgroundBlur) shapeSpread = max$
|
|
8330
|
+
if (innerShadow) shapeSpread = max$2(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
|
|
8331
|
+
if (backgroundBlur) shapeSpread = max$2(shapeSpread, backgroundBlur);
|
|
8315
8332
|
this.__layout.renderShapeSpread = shapeSpread;
|
|
8316
|
-
return box ? max$
|
|
8333
|
+
return box ? max$2(box.__updateRenderSpread(), spread) : spread;
|
|
8317
8334
|
}
|
|
8318
8335
|
};
|
|
8319
8336
|
|
|
8320
|
-
const {stintSet: stintSet$
|
|
8337
|
+
const {stintSet: stintSet$2} = DataHelper;
|
|
8321
8338
|
|
|
8322
8339
|
const UIRender = {
|
|
8323
8340
|
__updateChange() {
|
|
8324
8341
|
const data = this.__;
|
|
8325
8342
|
if (data.__useStroke) {
|
|
8326
8343
|
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
8327
|
-
stintSet$
|
|
8328
|
-
stintSet$
|
|
8344
|
+
stintSet$2(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
|
|
8345
|
+
stintSet$2(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
|
|
8329
8346
|
}
|
|
8330
8347
|
if (data.__useEffect) {
|
|
8331
8348
|
const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
8332
|
-
stintSet$
|
|
8349
|
+
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"));
|
|
8333
8350
|
data.__useEffect = !!(shadow || otherEffect);
|
|
8334
8351
|
}
|
|
8335
8352
|
data.__checkSingle();
|
|
8336
|
-
stintSet$
|
|
8353
|
+
stintSet$2(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
8337
8354
|
},
|
|
8338
8355
|
__drawFast(canvas, options) {
|
|
8339
8356
|
drawFast(this, canvas, options);
|
|
@@ -8349,24 +8366,24 @@ const UIRender = {
|
|
|
8349
8366
|
this.__nowWorld = this.__getNowWorld(options);
|
|
8350
8367
|
const {shadow: shadow, innerShadow: innerShadow, filter: filter} = data;
|
|
8351
8368
|
if (shadow) Effect.shadow(this, canvas, shape);
|
|
8352
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8353
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
8369
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8370
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
8354
8371
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
8355
8372
|
if (innerShadow) Effect.innerShadow(this, canvas, shape);
|
|
8356
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8373
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8357
8374
|
if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
8358
8375
|
if (shape.worldCanvas) shape.worldCanvas.recycle();
|
|
8359
8376
|
shape.canvas.recycle();
|
|
8360
8377
|
} else {
|
|
8361
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8378
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8362
8379
|
if (__isFastShadow) {
|
|
8363
8380
|
const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
|
|
8364
8381
|
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
8365
8382
|
}
|
|
8366
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
8383
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
8367
8384
|
if (__isFastShadow) canvas.restore();
|
|
8368
8385
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
8369
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8386
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8370
8387
|
}
|
|
8371
8388
|
} else {
|
|
8372
8389
|
if (data.__pathInputed) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
|
|
@@ -8375,9 +8392,9 @@ const UIRender = {
|
|
|
8375
8392
|
__drawShape(canvas, options) {
|
|
8376
8393
|
this.__drawRenderPath(canvas);
|
|
8377
8394
|
const data = this.__, {fill: fill, stroke: stroke} = data;
|
|
8378
|
-
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill("#000000", this, canvas);
|
|
8395
|
+
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas, options) : Paint.fill("#000000", this, canvas, options);
|
|
8379
8396
|
if (data.__isCanvas) this.__drawAfterFill(canvas, options);
|
|
8380
|
-
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke("#000000", this, canvas);
|
|
8397
|
+
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke("#000000", this, canvas, options);
|
|
8381
8398
|
},
|
|
8382
8399
|
__drawAfterFill(canvas, options) {
|
|
8383
8400
|
if (this.__.__clipAfterFill) {
|
|
@@ -8392,10 +8409,10 @@ const UIRender = {
|
|
|
8392
8409
|
function drawFast(ui, canvas, options) {
|
|
8393
8410
|
const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke} = ui.__;
|
|
8394
8411
|
ui.__drawRenderPath(canvas);
|
|
8395
|
-
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
8396
|
-
if (fill) Paint.fill(fill, ui, canvas);
|
|
8412
|
+
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
8413
|
+
if (fill) Paint.fill(fill, ui, canvas, options);
|
|
8397
8414
|
if (__drawAfterFill) ui.__drawAfterFill(canvas, options);
|
|
8398
|
-
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
8415
|
+
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
8399
8416
|
}
|
|
8400
8417
|
|
|
8401
8418
|
const RectRender = {
|
|
@@ -8533,8 +8550,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8533
8550
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
8534
8551
|
} else drawer.rect(x, y, width, height);
|
|
8535
8552
|
}
|
|
8536
|
-
drawImagePlaceholder(canvas,
|
|
8537
|
-
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
8553
|
+
drawImagePlaceholder(_image, canvas, renderOptions) {
|
|
8554
|
+
Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
|
|
8538
8555
|
}
|
|
8539
8556
|
animate(keyframe, _options, _type, _isTemp) {
|
|
8540
8557
|
this.set(keyframe);
|
|
@@ -9556,7 +9573,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
|
|
|
9556
9573
|
|
|
9557
9574
|
Canvas = __decorate([ registerUI() ], Canvas);
|
|
9558
9575
|
|
|
9559
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
|
|
9576
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9560
9577
|
|
|
9561
9578
|
let Text = class Text extends UI {
|
|
9562
9579
|
get __tag() {
|
|
@@ -9568,13 +9585,14 @@ let Text = class Text extends UI {
|
|
|
9568
9585
|
}
|
|
9569
9586
|
__updateTextDrawData() {
|
|
9570
9587
|
const data = this.__;
|
|
9571
|
-
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
|
|
9588
|
+
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
|
|
9572
9589
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
9573
9590
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
9574
|
-
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
9575
9591
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
|
|
9576
9592
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
9577
|
-
data
|
|
9593
|
+
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
9594
|
+
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
9595
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
|
|
9578
9596
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
9579
9597
|
}
|
|
9580
9598
|
__updateBoxBounds() {
|
|
@@ -9982,7 +10000,7 @@ class UIEvent extends Event {
|
|
|
9982
10000
|
}
|
|
9983
10001
|
}
|
|
9984
10002
|
|
|
9985
|
-
const {min: min, max: max$
|
|
10003
|
+
const {min: min, max: max$1, abs: abs$2} = Math, {float: float, sign: sign} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
|
|
9986
10004
|
|
|
9987
10005
|
const tempContent = new Bounds, tempDragBounds = new Bounds;
|
|
9988
10006
|
|
|
@@ -10039,7 +10057,7 @@ const DragBoundsHelper = {
|
|
|
10039
10057
|
bSize = float(tempDragBounds.maxX - tempContent.maxX);
|
|
10040
10058
|
aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
|
|
10041
10059
|
bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
|
|
10042
|
-
correctScaleX *= max$
|
|
10060
|
+
correctScaleX *= max$1(aScale, bScale);
|
|
10043
10061
|
} else {
|
|
10044
10062
|
if (scale.x < 0) {
|
|
10045
10063
|
if (float(minX(content) - minX(dragBounds)) <= 0 || float(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
|
|
@@ -10057,9 +10075,9 @@ const DragBoundsHelper = {
|
|
|
10057
10075
|
bSize = float(tempDragBounds.maxY - tempContent.maxY);
|
|
10058
10076
|
aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
|
|
10059
10077
|
bScale = originBottomScale && bSize > 0 ? 1 + bSize / (originBottomScale * tempContent.height) : 1;
|
|
10060
|
-
correctScaleY *= max$
|
|
10078
|
+
correctScaleY *= max$1(aScale, bScale);
|
|
10061
10079
|
if (lockRatio) {
|
|
10062
|
-
aScale = max$
|
|
10080
|
+
aScale = max$1(abs$2(correctScaleX), abs$2(correctScaleY));
|
|
10063
10081
|
correctScaleX = sign(correctScaleX) * aScale;
|
|
10064
10082
|
correctScaleY = sign(correctScaleY) * aScale;
|
|
10065
10083
|
}
|
|
@@ -10225,6 +10243,12 @@ MoveEvent.END = "move.end";
|
|
|
10225
10243
|
|
|
10226
10244
|
MoveEvent = __decorate([ registerUIEvent() ], MoveEvent);
|
|
10227
10245
|
|
|
10246
|
+
let TouchEvent = class TouchEvent extends UIEvent {};
|
|
10247
|
+
|
|
10248
|
+
TouchEvent = __decorate([ registerUIEvent() ], TouchEvent);
|
|
10249
|
+
|
|
10250
|
+
const MyTouchEvent = TouchEvent;
|
|
10251
|
+
|
|
10228
10252
|
let RotateEvent = class RotateEvent extends PointerEvent$1 {};
|
|
10229
10253
|
|
|
10230
10254
|
RotateEvent.BEFORE_ROTATE = "rotate.before_rotate";
|
|
@@ -11601,36 +11625,19 @@ class Interaction extends InteractionBase {
|
|
|
11601
11625
|
}
|
|
11602
11626
|
}
|
|
11603
11627
|
|
|
11604
|
-
function
|
|
11605
|
-
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11606
|
-
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
11607
|
-
let row;
|
|
11608
|
-
for (let i = 0, len = rows.length; i < len; i++) {
|
|
11609
|
-
row = rows[i];
|
|
11610
|
-
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
11611
|
-
canvas.fillText(charData.char, charData.x, row.y);
|
|
11612
|
-
});
|
|
11613
|
-
}
|
|
11614
|
-
if (decorationY) {
|
|
11615
|
-
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
11616
|
-
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
11617
|
-
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
11618
|
-
}
|
|
11619
|
-
}
|
|
11620
|
-
|
|
11621
|
-
function fill(fill, ui, canvas) {
|
|
11628
|
+
function fill(fill, ui, canvas, renderOptions) {
|
|
11622
11629
|
canvas.fillStyle = fill;
|
|
11623
|
-
fillPathOrText(ui, canvas);
|
|
11630
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
11624
11631
|
}
|
|
11625
11632
|
|
|
11626
|
-
function fills(fills, ui, canvas) {
|
|
11633
|
+
function fills(fills, ui, canvas, renderOptions) {
|
|
11627
11634
|
let item;
|
|
11628
11635
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
11629
11636
|
item = fills[i];
|
|
11630
11637
|
if (item.image) {
|
|
11631
|
-
if (PaintImage.checkImage(
|
|
11638
|
+
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
11632
11639
|
if (!item.style) {
|
|
11633
|
-
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas,
|
|
11640
|
+
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
|
|
11634
11641
|
continue;
|
|
11635
11642
|
}
|
|
11636
11643
|
}
|
|
@@ -11643,60 +11650,137 @@ function fills(fills, ui, canvas) {
|
|
|
11643
11650
|
if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
11644
11651
|
}
|
|
11645
11652
|
if (item.blendMode) canvas.blendMode = item.blendMode;
|
|
11646
|
-
fillPathOrText(ui, canvas);
|
|
11653
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
11647
11654
|
canvas.restore();
|
|
11648
11655
|
} else {
|
|
11649
11656
|
if (item.blendMode) {
|
|
11650
11657
|
canvas.saveBlendMode(item.blendMode);
|
|
11651
|
-
fillPathOrText(ui, canvas);
|
|
11658
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
11652
11659
|
canvas.restoreBlendMode();
|
|
11653
|
-
} else fillPathOrText(ui, canvas);
|
|
11660
|
+
} else fillPathOrText(ui, canvas, renderOptions);
|
|
11661
|
+
}
|
|
11662
|
+
}
|
|
11663
|
+
}
|
|
11664
|
+
|
|
11665
|
+
function fillPathOrText(ui, canvas, renderOptions) {
|
|
11666
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
11667
|
+
}
|
|
11668
|
+
|
|
11669
|
+
function fillText(ui, canvas, _renderOptions) {
|
|
11670
|
+
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11671
|
+
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
11672
|
+
let row;
|
|
11673
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
11674
|
+
row = rows[i];
|
|
11675
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
11676
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
11677
|
+
});
|
|
11678
|
+
}
|
|
11679
|
+
if (decorationY) {
|
|
11680
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
11681
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
11682
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
11683
|
+
}
|
|
11684
|
+
}
|
|
11685
|
+
|
|
11686
|
+
function stroke(stroke, ui, canvas, renderOptions) {
|
|
11687
|
+
const data = ui.__;
|
|
11688
|
+
if (!data.__strokeWidth) return;
|
|
11689
|
+
if (data.__font) {
|
|
11690
|
+
Paint.strokeText(stroke, ui, canvas, renderOptions);
|
|
11691
|
+
} else {
|
|
11692
|
+
switch (data.strokeAlign) {
|
|
11693
|
+
case "center":
|
|
11694
|
+
drawCenter$1(stroke, 1, ui, canvas, renderOptions);
|
|
11695
|
+
break;
|
|
11696
|
+
|
|
11697
|
+
case "inside":
|
|
11698
|
+
drawInside(stroke, ui, canvas, renderOptions);
|
|
11699
|
+
break;
|
|
11700
|
+
|
|
11701
|
+
case "outside":
|
|
11702
|
+
drawOutside(stroke, ui, canvas, renderOptions);
|
|
11703
|
+
break;
|
|
11654
11704
|
}
|
|
11655
11705
|
}
|
|
11656
11706
|
}
|
|
11657
11707
|
|
|
11658
|
-
function
|
|
11659
|
-
|
|
11708
|
+
function strokes(strokes, ui, canvas, renderOptions) {
|
|
11709
|
+
Paint.stroke(strokes, ui, canvas, renderOptions);
|
|
11710
|
+
}
|
|
11711
|
+
|
|
11712
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
11713
|
+
const data = ui.__;
|
|
11714
|
+
if (isObject(stroke)) {
|
|
11715
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
|
|
11716
|
+
} else {
|
|
11717
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
11718
|
+
canvas.stroke();
|
|
11719
|
+
}
|
|
11720
|
+
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
|
|
11721
|
+
}
|
|
11722
|
+
|
|
11723
|
+
function drawInside(stroke, ui, canvas, renderOptions) {
|
|
11724
|
+
canvas.save();
|
|
11725
|
+
canvas.clipUI(ui);
|
|
11726
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
11727
|
+
canvas.restore();
|
|
11728
|
+
}
|
|
11729
|
+
|
|
11730
|
+
function drawOutside(stroke, ui, canvas, renderOptions) {
|
|
11731
|
+
const data = ui.__;
|
|
11732
|
+
if (data.__fillAfterStroke) {
|
|
11733
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
11734
|
+
} else {
|
|
11735
|
+
const {renderBounds: renderBounds} = ui.__layout;
|
|
11736
|
+
const out = canvas.getSameCanvas(true, true);
|
|
11737
|
+
ui.__drawRenderPath(out);
|
|
11738
|
+
drawCenter$1(stroke, 2, ui, out, renderOptions);
|
|
11739
|
+
out.clipUI(data);
|
|
11740
|
+
out.clearWorld(renderBounds);
|
|
11741
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
11742
|
+
out.recycle(ui.__nowWorld);
|
|
11743
|
+
}
|
|
11660
11744
|
}
|
|
11661
11745
|
|
|
11662
|
-
function strokeText(stroke, ui, canvas) {
|
|
11746
|
+
function strokeText(stroke, ui, canvas, renderOptions) {
|
|
11663
11747
|
switch (ui.__.strokeAlign) {
|
|
11664
11748
|
case "center":
|
|
11665
|
-
drawCenter
|
|
11749
|
+
drawCenter(stroke, 1, ui, canvas, renderOptions);
|
|
11666
11750
|
break;
|
|
11667
11751
|
|
|
11668
11752
|
case "inside":
|
|
11669
|
-
drawAlign(stroke, "inside", ui, canvas);
|
|
11753
|
+
drawAlign(stroke, "inside", ui, canvas, renderOptions);
|
|
11670
11754
|
break;
|
|
11671
11755
|
|
|
11672
11756
|
case "outside":
|
|
11673
|
-
ui.__.__fillAfterStroke ? drawCenter
|
|
11757
|
+
ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
|
|
11674
11758
|
break;
|
|
11675
11759
|
}
|
|
11676
11760
|
}
|
|
11677
11761
|
|
|
11678
|
-
function drawCenter
|
|
11762
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
11679
11763
|
const data = ui.__;
|
|
11680
11764
|
if (isObject(stroke)) {
|
|
11681
|
-
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
11765
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
|
|
11682
11766
|
} else {
|
|
11683
11767
|
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
11684
|
-
drawTextStroke(ui, canvas);
|
|
11768
|
+
Paint.drawTextStroke(ui, canvas, renderOptions);
|
|
11685
11769
|
}
|
|
11686
11770
|
}
|
|
11687
11771
|
|
|
11688
|
-
function drawAlign(stroke, align, ui, canvas) {
|
|
11772
|
+
function drawAlign(stroke, align, ui, canvas, renderOptions) {
|
|
11689
11773
|
const out = canvas.getSameCanvas(true, true);
|
|
11690
11774
|
out.font = ui.__.__font;
|
|
11691
|
-
drawCenter
|
|
11775
|
+
drawCenter(stroke, 2, ui, out, renderOptions);
|
|
11692
11776
|
out.blendMode = align === "outside" ? "destination-out" : "destination-in";
|
|
11693
|
-
fillText(ui, out);
|
|
11777
|
+
Paint.fillText(ui, out, renderOptions);
|
|
11694
11778
|
out.blendMode = "normal";
|
|
11695
11779
|
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
11696
11780
|
out.recycle(ui.__nowWorld);
|
|
11697
11781
|
}
|
|
11698
11782
|
|
|
11699
|
-
function drawTextStroke(ui, canvas) {
|
|
11783
|
+
function drawTextStroke(ui, canvas, _renderOptions) {
|
|
11700
11784
|
let row, data = ui.__.__textDrawData;
|
|
11701
11785
|
const {rows: rows, decorationY: decorationY} = data;
|
|
11702
11786
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
@@ -11711,13 +11795,13 @@ function drawTextStroke(ui, canvas) {
|
|
|
11711
11795
|
}
|
|
11712
11796
|
}
|
|
11713
11797
|
|
|
11714
|
-
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
11798
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
|
|
11715
11799
|
let item;
|
|
11716
11800
|
const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
|
|
11717
11801
|
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
11718
11802
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
11719
11803
|
item = strokes[i];
|
|
11720
|
-
if (item.image && PaintImage.checkImage(ui, canvas,
|
|
11804
|
+
if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
|
|
11721
11805
|
if (item.style) {
|
|
11722
11806
|
if (__hasMultiStrokeStyle) {
|
|
11723
11807
|
const {strokeStyle: strokeStyle} = item;
|
|
@@ -11725,75 +11809,15 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
|
11725
11809
|
} else canvas.strokeStyle = item.style;
|
|
11726
11810
|
if (item.blendMode) {
|
|
11727
11811
|
canvas.saveBlendMode(item.blendMode);
|
|
11728
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
11812
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
11729
11813
|
canvas.restoreBlendMode();
|
|
11730
11814
|
} else {
|
|
11731
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
11815
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
11732
11816
|
}
|
|
11733
11817
|
}
|
|
11734
11818
|
}
|
|
11735
11819
|
}
|
|
11736
11820
|
|
|
11737
|
-
function stroke(stroke, ui, canvas) {
|
|
11738
|
-
const data = ui.__;
|
|
11739
|
-
if (!data.__strokeWidth) return;
|
|
11740
|
-
if (data.__font) {
|
|
11741
|
-
strokeText(stroke, ui, canvas);
|
|
11742
|
-
} else {
|
|
11743
|
-
switch (data.strokeAlign) {
|
|
11744
|
-
case "center":
|
|
11745
|
-
drawCenter(stroke, 1, ui, canvas);
|
|
11746
|
-
break;
|
|
11747
|
-
|
|
11748
|
-
case "inside":
|
|
11749
|
-
drawInside(stroke, ui, canvas);
|
|
11750
|
-
break;
|
|
11751
|
-
|
|
11752
|
-
case "outside":
|
|
11753
|
-
drawOutside(stroke, ui, canvas);
|
|
11754
|
-
break;
|
|
11755
|
-
}
|
|
11756
|
-
}
|
|
11757
|
-
}
|
|
11758
|
-
|
|
11759
|
-
function strokes(strokes, ui, canvas) {
|
|
11760
|
-
stroke(strokes, ui, canvas);
|
|
11761
|
-
}
|
|
11762
|
-
|
|
11763
|
-
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
11764
|
-
const data = ui.__;
|
|
11765
|
-
if (isObject(stroke)) {
|
|
11766
|
-
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
11767
|
-
} else {
|
|
11768
|
-
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
11769
|
-
canvas.stroke();
|
|
11770
|
-
}
|
|
11771
|
-
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas);
|
|
11772
|
-
}
|
|
11773
|
-
|
|
11774
|
-
function drawInside(stroke, ui, canvas) {
|
|
11775
|
-
canvas.save();
|
|
11776
|
-
canvas.clipUI(ui);
|
|
11777
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
11778
|
-
canvas.restore();
|
|
11779
|
-
}
|
|
11780
|
-
|
|
11781
|
-
function drawOutside(stroke, ui, canvas) {
|
|
11782
|
-
const data = ui.__;
|
|
11783
|
-
if (data.__fillAfterStroke) {
|
|
11784
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
11785
|
-
} else {
|
|
11786
|
-
const {renderBounds: renderBounds} = ui.__layout;
|
|
11787
|
-
const out = canvas.getSameCanvas(true, true);
|
|
11788
|
-
ui.__drawRenderPath(out);
|
|
11789
|
-
drawCenter(stroke, 2, ui, out);
|
|
11790
|
-
out.clipUI(data);
|
|
11791
|
-
out.clearWorld(renderBounds);
|
|
11792
|
-
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
11793
|
-
out.recycle(ui.__nowWorld);
|
|
11794
|
-
}
|
|
11795
|
-
}
|
|
11796
|
-
|
|
11797
11821
|
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
11798
11822
|
|
|
11799
11823
|
const tempBounds$1 = {};
|
|
@@ -11949,88 +11973,118 @@ const PaintModule = {
|
|
|
11949
11973
|
strokes: strokes,
|
|
11950
11974
|
strokeText: strokeText,
|
|
11951
11975
|
drawTextStroke: drawTextStroke,
|
|
11976
|
+
drawStrokesStyle: drawStrokesStyle,
|
|
11952
11977
|
shape: shape
|
|
11953
11978
|
};
|
|
11954
11979
|
|
|
11955
|
-
let
|
|
11956
|
-
|
|
11957
|
-
const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
11958
|
-
|
|
11959
|
-
function stretchMode(data, box, scaleX, scaleY) {
|
|
11960
|
-
const transform = get$3();
|
|
11961
|
-
translate$1(transform, box.x, box.y);
|
|
11962
|
-
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
11963
|
-
data.transform = transform;
|
|
11964
|
-
}
|
|
11965
|
-
|
|
11966
|
-
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
11967
|
-
const transform = get$3();
|
|
11968
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
11969
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
11970
|
-
if (rotation) rotateOfOuter$1(transform, {
|
|
11971
|
-
x: box.x + box.width / 2,
|
|
11972
|
-
y: box.y + box.height / 2
|
|
11973
|
-
}, rotation);
|
|
11974
|
-
data.transform = transform;
|
|
11975
|
-
}
|
|
11980
|
+
let cache, box = new Bounds;
|
|
11976
11981
|
|
|
11977
|
-
|
|
11978
|
-
const transform = get$3();
|
|
11979
|
-
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
11980
|
-
if (clipScaleX) {
|
|
11981
|
-
if (rotation || skew) {
|
|
11982
|
-
set(tempMatrix$1);
|
|
11983
|
-
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
11984
|
-
multiplyParent(transform, tempMatrix$1);
|
|
11985
|
-
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
11986
|
-
}
|
|
11987
|
-
data.transform = transform;
|
|
11988
|
-
}
|
|
11982
|
+
const {isSame: isSame} = BoundsHelper;
|
|
11989
11983
|
|
|
11990
|
-
function
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11984
|
+
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
11985
|
+
let leafPaint, event;
|
|
11986
|
+
const image = ImageManager.get(paint);
|
|
11987
|
+
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
11988
|
+
leafPaint = cache.leafPaint;
|
|
11994
11989
|
} else {
|
|
11995
|
-
|
|
11996
|
-
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
|
|
12000
|
-
|
|
12001
|
-
|
|
12002
|
-
|
|
12003
|
-
|
|
12004
|
-
|
|
12005
|
-
|
|
12006
|
-
|
|
12007
|
-
|
|
12008
|
-
|
|
12009
|
-
|
|
12010
|
-
|
|
12011
|
-
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
|
|
11990
|
+
leafPaint = {
|
|
11991
|
+
type: paint.type,
|
|
11992
|
+
image: image
|
|
11993
|
+
};
|
|
11994
|
+
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
11995
|
+
cache = image.use > 1 ? {
|
|
11996
|
+
leafPaint: leafPaint,
|
|
11997
|
+
paint: paint,
|
|
11998
|
+
boxBounds: box.set(boxBounds)
|
|
11999
|
+
} : null;
|
|
12000
|
+
}
|
|
12001
|
+
if (firstUse || image.loading) event = {
|
|
12002
|
+
image: image,
|
|
12003
|
+
attrName: attrName,
|
|
12004
|
+
attrValue: paint
|
|
12005
|
+
};
|
|
12006
|
+
if (image.ready) {
|
|
12007
|
+
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
12008
|
+
if (firstUse) {
|
|
12009
|
+
onLoad(ui, event);
|
|
12010
|
+
onLoadSuccess(ui, event);
|
|
12011
|
+
}
|
|
12012
|
+
} else if (image.error) {
|
|
12013
|
+
if (firstUse) onLoadError(ui, event, image.error);
|
|
12014
|
+
} else {
|
|
12015
|
+
if (firstUse) {
|
|
12016
|
+
ignoreRender(ui, true);
|
|
12017
|
+
onLoad(ui, event);
|
|
12018
|
+
}
|
|
12019
|
+
leafPaint.loadId = image.load(() => {
|
|
12020
|
+
ignoreRender(ui, false);
|
|
12021
|
+
if (!ui.destroyed) {
|
|
12022
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
12023
|
+
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
12024
|
+
ui.forceUpdate("surface");
|
|
12015
12025
|
}
|
|
12026
|
+
onLoadSuccess(ui, event);
|
|
12016
12027
|
}
|
|
12028
|
+
leafPaint.loadId = undefined;
|
|
12029
|
+
}, error => {
|
|
12030
|
+
ignoreRender(ui, false);
|
|
12031
|
+
onLoadError(ui, event, error);
|
|
12032
|
+
leafPaint.loadId = undefined;
|
|
12033
|
+
});
|
|
12034
|
+
if (ui.placeholderColor) {
|
|
12035
|
+
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
12036
|
+
if (!image.ready) {
|
|
12037
|
+
image.isPlacehold = true;
|
|
12038
|
+
ui.forceUpdate("surface");
|
|
12039
|
+
}
|
|
12040
|
+
}, ui.placeholderDelay);
|
|
12017
12041
|
}
|
|
12018
|
-
origin.x = box.x + x;
|
|
12019
|
-
origin.y = box.y + y;
|
|
12020
|
-
translate$1(transform, origin.x, origin.y);
|
|
12021
|
-
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
12022
12042
|
}
|
|
12023
|
-
|
|
12043
|
+
return leafPaint;
|
|
12024
12044
|
}
|
|
12025
12045
|
|
|
12026
|
-
function
|
|
12027
|
-
if (
|
|
12028
|
-
|
|
12029
|
-
|
|
12030
|
-
|
|
12046
|
+
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
12047
|
+
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
12048
|
+
const data = ui.__;
|
|
12049
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
12050
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
12051
|
+
if (data.__autoSide) {
|
|
12052
|
+
ui.forceUpdate("width");
|
|
12053
|
+
if (ui.__proxyData) {
|
|
12054
|
+
ui.setProxyAttr("width", data.width);
|
|
12055
|
+
ui.setProxyAttr("height", data.height);
|
|
12056
|
+
}
|
|
12057
|
+
return false;
|
|
12058
|
+
}
|
|
12059
|
+
}
|
|
12060
|
+
if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
12061
|
+
return true;
|
|
12062
|
+
}
|
|
12063
|
+
|
|
12064
|
+
function onLoad(ui, event) {
|
|
12065
|
+
emit(ui, ImageEvent.LOAD, event);
|
|
12066
|
+
}
|
|
12067
|
+
|
|
12068
|
+
function onLoadSuccess(ui, event) {
|
|
12069
|
+
emit(ui, ImageEvent.LOADED, event);
|
|
12031
12070
|
}
|
|
12032
12071
|
|
|
12033
|
-
|
|
12072
|
+
function onLoadError(ui, event, error) {
|
|
12073
|
+
event.error = error;
|
|
12074
|
+
ui.forceUpdate("surface");
|
|
12075
|
+
emit(ui, ImageEvent.ERROR, event);
|
|
12076
|
+
}
|
|
12077
|
+
|
|
12078
|
+
function emit(ui, type, data) {
|
|
12079
|
+
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
12080
|
+
}
|
|
12081
|
+
|
|
12082
|
+
function ignoreRender(ui, value) {
|
|
12083
|
+
const {leafer: leafer} = ui;
|
|
12084
|
+
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
12085
|
+
}
|
|
12086
|
+
|
|
12087
|
+
const {get: get$3, translate: translate$1} = MatrixHelper;
|
|
12034
12088
|
|
|
12035
12089
|
const tempBox = new Bounds;
|
|
12036
12090
|
|
|
@@ -12043,13 +12097,13 @@ function createData(leafPaint, image, paint, box) {
|
|
|
12043
12097
|
if (changeful) leafPaint.changeful = changeful;
|
|
12044
12098
|
if (sync) leafPaint.sync = sync;
|
|
12045
12099
|
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
12046
|
-
leafPaint.data = getPatternData(paint, box, image);
|
|
12100
|
+
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
12047
12101
|
}
|
|
12048
12102
|
|
|
12049
12103
|
function getPatternData(paint, box, image) {
|
|
12050
12104
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
12051
12105
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
12052
|
-
|
|
12106
|
+
const {width: width, height: height} = image;
|
|
12053
12107
|
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;
|
|
12054
12108
|
const sameBox = box.width === width && box.height === height;
|
|
12055
12109
|
const data = {
|
|
@@ -12080,8 +12134,8 @@ function getPatternData(paint, box, image) {
|
|
|
12080
12134
|
case "stretch":
|
|
12081
12135
|
if (!sameBox) {
|
|
12082
12136
|
scaleX = box.width / width, scaleY = box.height / height;
|
|
12083
|
-
stretchMode(data, box, scaleX, scaleY);
|
|
12084
|
-
}
|
|
12137
|
+
PaintImage.stretchMode(data, box, scaleX, scaleY);
|
|
12138
|
+
} else if (scaleX) scaleX = scaleY = undefined;
|
|
12085
12139
|
break;
|
|
12086
12140
|
|
|
12087
12141
|
case "normal":
|
|
@@ -12089,13 +12143,13 @@ function getPatternData(paint, box, image) {
|
|
|
12089
12143
|
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
12090
12144
|
let clipScaleX, clipScaleY;
|
|
12091
12145
|
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
|
|
12092
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
12146
|
+
PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
12093
12147
|
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
12094
12148
|
}
|
|
12095
12149
|
break;
|
|
12096
12150
|
|
|
12097
12151
|
case "repeat":
|
|
12098
|
-
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
12152
|
+
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
12099
12153
|
if (!repeat) data.repeat = "repeat";
|
|
12100
12154
|
const count = isObject(repeat);
|
|
12101
12155
|
if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
|
|
@@ -12104,18 +12158,16 @@ function getPatternData(paint, box, image) {
|
|
|
12104
12158
|
case "fit":
|
|
12105
12159
|
case "cover":
|
|
12106
12160
|
default:
|
|
12107
|
-
if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
12161
|
+
if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
12108
12162
|
}
|
|
12109
12163
|
if (!data.transform) {
|
|
12110
|
-
if (box.x || box.y) translate(data.transform = get$
|
|
12164
|
+
if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
|
|
12111
12165
|
}
|
|
12112
|
-
data.width = width;
|
|
12113
|
-
data.height = height;
|
|
12114
12166
|
if (scaleX) {
|
|
12115
12167
|
data.scaleX = scaleX;
|
|
12116
12168
|
data.scaleY = scaleY;
|
|
12117
12169
|
}
|
|
12118
|
-
if (opacity) data.opacity = opacity;
|
|
12170
|
+
if (opacity && opacity < 1) data.opacity = opacity;
|
|
12119
12171
|
if (filters) data.filters = filters;
|
|
12120
12172
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
12121
12173
|
return data;
|
|
@@ -12137,234 +12189,194 @@ function getGapValue(gap, size, totalSize, rows) {
|
|
|
12137
12189
|
return gap === "auto" ? value < 0 ? 0 : value : value;
|
|
12138
12190
|
}
|
|
12139
12191
|
|
|
12140
|
-
let
|
|
12192
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
12141
12193
|
|
|
12142
|
-
const {
|
|
12194
|
+
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
12143
12195
|
|
|
12144
|
-
function
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
} else {
|
|
12150
|
-
leafPaint = {
|
|
12151
|
-
type: paint.type,
|
|
12152
|
-
image: image
|
|
12153
|
-
};
|
|
12154
|
-
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
12155
|
-
cache = image.use > 1 ? {
|
|
12156
|
-
leafPaint: leafPaint,
|
|
12157
|
-
paint: paint,
|
|
12158
|
-
boxBounds: box.set(boxBounds)
|
|
12159
|
-
} : null;
|
|
12160
|
-
}
|
|
12161
|
-
if (firstUse || image.loading) event = {
|
|
12162
|
-
image: image,
|
|
12163
|
-
attrName: attrName,
|
|
12164
|
-
attrValue: paint
|
|
12165
|
-
};
|
|
12166
|
-
if (image.ready) {
|
|
12167
|
-
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
12168
|
-
if (firstUse) {
|
|
12169
|
-
onLoad(ui, event);
|
|
12170
|
-
onLoadSuccess(ui, event);
|
|
12171
|
-
}
|
|
12172
|
-
} else if (image.error) {
|
|
12173
|
-
if (firstUse) onLoadError(ui, event, image.error);
|
|
12174
|
-
} else {
|
|
12175
|
-
if (firstUse) {
|
|
12176
|
-
ignoreRender(ui, true);
|
|
12177
|
-
onLoad(ui, event);
|
|
12178
|
-
}
|
|
12179
|
-
leafPaint.loadId = image.load(() => {
|
|
12180
|
-
ignoreRender(ui, false);
|
|
12181
|
-
if (!ui.destroyed) {
|
|
12182
|
-
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
12183
|
-
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
12184
|
-
ui.forceUpdate("surface");
|
|
12185
|
-
}
|
|
12186
|
-
onLoadSuccess(ui, event);
|
|
12187
|
-
}
|
|
12188
|
-
leafPaint.loadId = undefined;
|
|
12189
|
-
}, error => {
|
|
12190
|
-
ignoreRender(ui, false);
|
|
12191
|
-
onLoadError(ui, event, error);
|
|
12192
|
-
leafPaint.loadId = undefined;
|
|
12193
|
-
});
|
|
12194
|
-
if (ui.placeholderColor) {
|
|
12195
|
-
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
12196
|
-
if (!image.ready) {
|
|
12197
|
-
image.isPlacehold = true;
|
|
12198
|
-
ui.forceUpdate("surface");
|
|
12199
|
-
}
|
|
12200
|
-
}, ui.placeholderDelay);
|
|
12201
|
-
}
|
|
12202
|
-
}
|
|
12203
|
-
return leafPaint;
|
|
12196
|
+
function stretchMode(data, box, scaleX, scaleY) {
|
|
12197
|
+
const transform = get$2(), {x: x, y: y} = box;
|
|
12198
|
+
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
12199
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
12200
|
+
data.transform = transform;
|
|
12204
12201
|
}
|
|
12205
12202
|
|
|
12206
|
-
function
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
ui.setProxyAttr("height", data.height);
|
|
12216
|
-
}
|
|
12217
|
-
return false;
|
|
12218
|
-
}
|
|
12219
|
-
}
|
|
12220
|
-
if (!leafPaint.data) createData(leafPaint, image, paint, boxBounds);
|
|
12221
|
-
return true;
|
|
12203
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
12204
|
+
const transform = get$2();
|
|
12205
|
+
translate(transform, box.x + x, box.y + y);
|
|
12206
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
12207
|
+
if (rotation) rotateOfOuter$1(transform, {
|
|
12208
|
+
x: box.x + box.width / 2,
|
|
12209
|
+
y: box.y + box.height / 2
|
|
12210
|
+
}, rotation);
|
|
12211
|
+
data.transform = transform;
|
|
12222
12212
|
}
|
|
12223
12213
|
|
|
12224
|
-
function
|
|
12225
|
-
|
|
12214
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
12215
|
+
const transform = get$2();
|
|
12216
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
12217
|
+
if (clipScaleX) {
|
|
12218
|
+
if (rotation || skew) {
|
|
12219
|
+
set(tempMatrix$1);
|
|
12220
|
+
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
12221
|
+
multiplyParent(transform, tempMatrix$1);
|
|
12222
|
+
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
12223
|
+
}
|
|
12224
|
+
data.transform = transform;
|
|
12226
12225
|
}
|
|
12227
12226
|
|
|
12228
|
-
function
|
|
12229
|
-
|
|
12230
|
-
|
|
12227
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
12228
|
+
const transform = get$2();
|
|
12229
|
+
if (freeTransform) {
|
|
12230
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
12231
|
+
} else {
|
|
12232
|
+
if (rotation) {
|
|
12233
|
+
if (align === "center") {
|
|
12234
|
+
rotateOfOuter$1(transform, {
|
|
12235
|
+
x: width / 2,
|
|
12236
|
+
y: height / 2
|
|
12237
|
+
}, rotation);
|
|
12238
|
+
} else {
|
|
12239
|
+
rotate(transform, rotation);
|
|
12240
|
+
switch (rotation) {
|
|
12241
|
+
case 90:
|
|
12242
|
+
translate(transform, height, 0);
|
|
12243
|
+
break;
|
|
12231
12244
|
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
emit(ui, ImageEvent.ERROR, event);
|
|
12236
|
-
}
|
|
12245
|
+
case 180:
|
|
12246
|
+
translate(transform, width, height);
|
|
12247
|
+
break;
|
|
12237
12248
|
|
|
12238
|
-
|
|
12239
|
-
|
|
12249
|
+
case 270:
|
|
12250
|
+
translate(transform, 0, width);
|
|
12251
|
+
break;
|
|
12252
|
+
}
|
|
12253
|
+
}
|
|
12254
|
+
}
|
|
12255
|
+
origin.x = box.x + x;
|
|
12256
|
+
origin.y = box.y + y;
|
|
12257
|
+
translate(transform, origin.x, origin.y);
|
|
12258
|
+
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
12259
|
+
}
|
|
12260
|
+
data.transform = transform;
|
|
12240
12261
|
}
|
|
12241
12262
|
|
|
12242
|
-
function
|
|
12243
|
-
|
|
12244
|
-
if (
|
|
12263
|
+
function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
12264
|
+
if (rotation) rotate(transform, rotation);
|
|
12265
|
+
if (skew) skewHelper(transform, skew.x, skew.y);
|
|
12266
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
12267
|
+
translate(transform, box.x + x, box.y + y);
|
|
12245
12268
|
}
|
|
12246
12269
|
|
|
12247
12270
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
12248
12271
|
|
|
12249
|
-
const {
|
|
12272
|
+
const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
12273
|
+
|
|
12274
|
+
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
12275
|
+
if (!paint.patternTask) {
|
|
12276
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
12277
|
+
paint.patternTask = null;
|
|
12278
|
+
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
12279
|
+
ui.forceUpdate("surface");
|
|
12280
|
+
}), 300);
|
|
12281
|
+
}
|
|
12282
|
+
}
|
|
12250
12283
|
|
|
12251
|
-
function createPattern(ui,
|
|
12252
|
-
let {scaleX: scaleX, scaleY: scaleY} =
|
|
12253
|
-
const id = scaleX + "-" + scaleY + "-" + pixelRatio;
|
|
12284
|
+
function createPattern(paint, ui, canvas, renderOptions) {
|
|
12285
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
12254
12286
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
12255
|
-
|
|
12256
|
-
|
|
12257
|
-
|
|
12258
|
-
|
|
12259
|
-
|
|
12260
|
-
|
|
12261
|
-
|
|
12262
|
-
|
|
12263
|
-
|
|
12264
|
-
|
|
12265
|
-
scaleX
|
|
12266
|
-
|
|
12267
|
-
|
|
12268
|
-
width *= scaleX;
|
|
12269
|
-
height *= scaleY;
|
|
12270
|
-
const size = width * height;
|
|
12271
|
-
if (!repeat) {
|
|
12272
|
-
if (size > Platform.image.maxCacheSize) return false;
|
|
12273
|
-
}
|
|
12274
|
-
let maxSize = Platform.image.maxPatternSize;
|
|
12275
|
-
if (image.isSVG) {
|
|
12276
|
-
const ws = width / image.width;
|
|
12277
|
-
if (ws > 1) imageScale = ws / ceil(ws);
|
|
12278
|
-
} else {
|
|
12279
|
-
const imageSize = image.width * image.height;
|
|
12280
|
-
if (maxSize > imageSize) maxSize = imageSize;
|
|
12281
|
-
}
|
|
12282
|
-
if (size > maxSize) imageScale = Math.sqrt(size / maxSize);
|
|
12283
|
-
if (imageScale) {
|
|
12284
|
-
scaleX /= imageScale;
|
|
12285
|
-
scaleY /= imageScale;
|
|
12286
|
-
width /= imageScale;
|
|
12287
|
-
height /= imageScale;
|
|
12288
|
-
}
|
|
12289
|
-
if (sx) {
|
|
12290
|
-
scaleX /= sx;
|
|
12291
|
-
scaleY /= sy;
|
|
12292
|
-
}
|
|
12293
|
-
const xGap = gap && gap.x * scaleX;
|
|
12294
|
-
const yGap = gap && gap.y * scaleY;
|
|
12295
|
-
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
12296
|
-
const canvasWidth = width + (xGap || 0);
|
|
12297
|
-
const canvasHeight = height + (yGap || 0);
|
|
12298
|
-
scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
|
|
12299
|
-
scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
|
|
12300
|
-
if (!imageMatrix) {
|
|
12287
|
+
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
12288
|
+
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
12289
|
+
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
12290
|
+
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
12291
|
+
width *= scaleX;
|
|
12292
|
+
height *= scaleY;
|
|
12293
|
+
if (gap) {
|
|
12294
|
+
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
12295
|
+
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
12296
|
+
}
|
|
12297
|
+
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
12298
|
+
scaleX *= getFloorScale(width + (xGap || 0));
|
|
12299
|
+
scaleY *= getFloorScale(height + (yGap || 0));
|
|
12301
12300
|
imageMatrix = get$1();
|
|
12302
12301
|
if (transform) copy$1(imageMatrix, transform);
|
|
12302
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
12303
12303
|
}
|
|
12304
|
-
|
|
12304
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
12305
|
+
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
12306
|
+
paint.style = pattern;
|
|
12307
|
+
paint.patternId = id;
|
|
12305
12308
|
}
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12309
|
+
}
|
|
12310
|
+
}
|
|
12311
|
+
|
|
12312
|
+
function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
12313
|
+
const {image: image} = paint;
|
|
12314
|
+
let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
|
|
12315
|
+
if (image.isSVG) {
|
|
12316
|
+
if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
|
|
12311
12317
|
} else {
|
|
12312
|
-
|
|
12318
|
+
if (maxSize > imageSize) maxSize = imageSize;
|
|
12313
12319
|
}
|
|
12320
|
+
if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
|
|
12321
|
+
return fixScale;
|
|
12314
12322
|
}
|
|
12315
12323
|
|
|
12316
|
-
function checkImage(ui, canvas,
|
|
12317
|
-
const {scaleX: scaleX, scaleY: scaleY} =
|
|
12318
|
-
const {
|
|
12319
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY
|
|
12324
|
+
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
12325
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
12326
|
+
const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
|
|
12327
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
12320
12328
|
return false;
|
|
12321
12329
|
} else {
|
|
12322
|
-
if (
|
|
12330
|
+
if (drawImage) {
|
|
12323
12331
|
if (data.repeat) {
|
|
12324
|
-
|
|
12325
|
-
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) ||
|
|
12326
|
-
|
|
12327
|
-
width *= scaleX * pixelRatio;
|
|
12328
|
-
height *= scaleY * pixelRatio;
|
|
12329
|
-
if (data.scaleX) {
|
|
12330
|
-
width *= data.scaleX;
|
|
12331
|
-
height *= data.scaleY;
|
|
12332
|
-
}
|
|
12333
|
-
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
12332
|
+
drawImage = false;
|
|
12333
|
+
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
12334
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
12334
12335
|
}
|
|
12335
12336
|
}
|
|
12336
|
-
if (
|
|
12337
|
+
if (drawImage) {
|
|
12337
12338
|
if (ui.__.__isFastShadow) {
|
|
12338
12339
|
canvas.fillStyle = paint.style || "#000";
|
|
12339
12340
|
canvas.fill();
|
|
12340
12341
|
}
|
|
12341
|
-
drawImage(ui, canvas,
|
|
12342
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
12342
12343
|
return true;
|
|
12343
12344
|
} else {
|
|
12344
|
-
if (!paint.style || paint.sync ||
|
|
12345
|
-
createPattern(ui, paint, pixelRatio);
|
|
12346
|
-
} else {
|
|
12347
|
-
if (!paint.patternTask) {
|
|
12348
|
-
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
12349
|
-
paint.patternTask = null;
|
|
12350
|
-
if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio);
|
|
12351
|
-
ui.forceUpdate("surface");
|
|
12352
|
-
}), 300);
|
|
12353
|
-
}
|
|
12354
|
-
}
|
|
12345
|
+
if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
12355
12346
|
return false;
|
|
12356
12347
|
}
|
|
12357
12348
|
}
|
|
12358
12349
|
}
|
|
12359
12350
|
|
|
12360
|
-
function drawImage(ui, canvas,
|
|
12361
|
-
|
|
12362
|
-
|
|
12363
|
-
if (
|
|
12364
|
-
|
|
12365
|
-
|
|
12366
|
-
|
|
12367
|
-
|
|
12351
|
+
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
12352
|
+
const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
12353
|
+
let {width: width, height: height} = image, clipUI;
|
|
12354
|
+
if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
|
|
12355
|
+
canvas.save();
|
|
12356
|
+
clipUI && canvas.clipUI(ui);
|
|
12357
|
+
blendMode && (canvas.blendMode = blendMode);
|
|
12358
|
+
opacity && (canvas.opacity *= opacity);
|
|
12359
|
+
transform && canvas.transform(transform);
|
|
12360
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
12361
|
+
canvas.restore();
|
|
12362
|
+
} else {
|
|
12363
|
+
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
12364
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
12365
|
+
}
|
|
12366
|
+
}
|
|
12367
|
+
|
|
12368
|
+
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
12369
|
+
const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
|
|
12370
|
+
if (canvas) {
|
|
12371
|
+
const {pixelRatio: pixelRatio} = canvas;
|
|
12372
|
+
scaleData.scaleX *= pixelRatio;
|
|
12373
|
+
scaleData.scaleY *= pixelRatio;
|
|
12374
|
+
}
|
|
12375
|
+
if (data && data.scaleX) {
|
|
12376
|
+
scaleData.scaleX *= Math.abs(data.scaleX);
|
|
12377
|
+
scaleData.scaleY *= Math.abs(data.scaleY);
|
|
12378
|
+
}
|
|
12379
|
+
return scaleData;
|
|
12368
12380
|
}
|
|
12369
12381
|
|
|
12370
12382
|
function recycleImage(attrName, data) {
|
|
@@ -12396,8 +12408,12 @@ function recycleImage(attrName, data) {
|
|
|
12396
12408
|
const PaintImageModule = {
|
|
12397
12409
|
image: image,
|
|
12398
12410
|
checkImage: checkImage,
|
|
12399
|
-
|
|
12411
|
+
drawImage: drawImage,
|
|
12412
|
+
getImageRenderScaleData: getImageRenderScaleData,
|
|
12400
12413
|
recycleImage: recycleImage,
|
|
12414
|
+
createPatternTask: createPatternTask,
|
|
12415
|
+
createPattern: createPattern,
|
|
12416
|
+
getPatternFixScale: getPatternFixScale,
|
|
12401
12417
|
createData: createData,
|
|
12402
12418
|
getPatternData: getPatternData,
|
|
12403
12419
|
stretchMode: stretchMode,
|
|
@@ -12853,10 +12869,8 @@ function createRows(drawData, content, style) {
|
|
|
12853
12869
|
bounds = drawData.bounds;
|
|
12854
12870
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
12855
12871
|
const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
|
|
12856
|
-
const {canvas: canvas} = Platform;
|
|
12857
|
-
|
|
12858
|
-
const charMode = width || height || __letterSpacing || textCase !== "none";
|
|
12859
|
-
if (charMode) {
|
|
12872
|
+
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
12873
|
+
if (style.__isCharMode) {
|
|
12860
12874
|
const wrap = style.textWrap !== "none";
|
|
12861
12875
|
const breakAll = style.textWrap === "break";
|
|
12862
12876
|
paraStart = true;
|
|
@@ -12985,12 +12999,19 @@ const TextMode = 2;
|
|
|
12985
12999
|
function layoutChar(drawData, style, width, _height) {
|
|
12986
13000
|
const {rows: rows} = drawData;
|
|
12987
13001
|
const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
|
|
12988
|
-
|
|
13002
|
+
const justifyLast = width && textAlign.includes("both");
|
|
13003
|
+
const justify = justifyLast || width && textAlign.includes("justify");
|
|
13004
|
+
const justifyLetter = justify && textAlign.includes("letter");
|
|
13005
|
+
let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
|
|
12989
13006
|
rows.forEach(row => {
|
|
12990
13007
|
if (row.words) {
|
|
12991
13008
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
12992
|
-
|
|
12993
|
-
|
|
13009
|
+
if (justify) {
|
|
13010
|
+
canJustify = !row.paraEnd || justifyLast;
|
|
13011
|
+
remainingWidth = width - row.width - indentWidth;
|
|
13012
|
+
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
13013
|
+
}
|
|
13014
|
+
mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
12994
13015
|
if (row.isOverflow && !letterSpacing) row.textMode = true;
|
|
12995
13016
|
if (mode === TextMode) {
|
|
12996
13017
|
row.x += indentWidth;
|
|
@@ -13008,11 +13029,15 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
13008
13029
|
charX = toWordChar(word.data, charX, wordChar);
|
|
13009
13030
|
if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
|
|
13010
13031
|
} else {
|
|
13011
|
-
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
13032
|
+
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
13012
13033
|
}
|
|
13013
|
-
if (
|
|
13014
|
-
|
|
13015
|
-
|
|
13034
|
+
if (canJustify) {
|
|
13035
|
+
isLastWord = index === wordsLength - 1;
|
|
13036
|
+
if (addWordWidth) {
|
|
13037
|
+
if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
|
|
13038
|
+
} else if (addLetterWidth) {
|
|
13039
|
+
row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
|
|
13040
|
+
}
|
|
13016
13041
|
}
|
|
13017
13042
|
});
|
|
13018
13043
|
}
|
|
@@ -13038,13 +13063,14 @@ function toWordChar(data, charX, wordChar) {
|
|
|
13038
13063
|
return charX;
|
|
13039
13064
|
}
|
|
13040
13065
|
|
|
13041
|
-
function toChar(data, charX, rowData, isOverflow) {
|
|
13066
|
+
function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
|
|
13042
13067
|
data.forEach(char => {
|
|
13043
13068
|
if (isOverflow || char.char !== " ") {
|
|
13044
13069
|
char.x = charX;
|
|
13045
13070
|
rowData.push(char);
|
|
13046
13071
|
}
|
|
13047
13072
|
charX += char.width;
|
|
13073
|
+
addLetterWidth && (charX += addLetterWidth);
|
|
13048
13074
|
});
|
|
13049
13075
|
return charX;
|
|
13050
13076
|
}
|
|
@@ -13186,10 +13212,10 @@ function getDrawData(content, style) {
|
|
|
13186
13212
|
let x = 0, y = 0;
|
|
13187
13213
|
let width = style.__getInput("width") || 0;
|
|
13188
13214
|
let height = style.__getInput("height") || 0;
|
|
13189
|
-
const {
|
|
13215
|
+
const {__padding: padding} = style;
|
|
13190
13216
|
if (padding) {
|
|
13191
|
-
if (width) x = padding[left], width -= padding[right] + padding[left]; else if (!style.autoSizeAlign) x = padding[left];
|
|
13192
|
-
if (height) y = padding[top], height -= padding[top] + padding[bottom]; else if (!style.autoSizeAlign) y = padding[top];
|
|
13217
|
+
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
13218
|
+
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
13193
13219
|
}
|
|
13194
13220
|
const drawData = {
|
|
13195
13221
|
bounds: {
|
|
@@ -13200,14 +13226,14 @@ function getDrawData(content, style) {
|
|
|
13200
13226
|
},
|
|
13201
13227
|
rows: [],
|
|
13202
13228
|
paraNumber: 0,
|
|
13203
|
-
font: Platform.canvas.font = __font
|
|
13229
|
+
font: Platform.canvas.font = style.__font
|
|
13204
13230
|
};
|
|
13205
13231
|
createRows(drawData, content, style);
|
|
13206
13232
|
if (padding) padAutoText(padding, drawData, style, width, height);
|
|
13207
13233
|
layoutText(drawData, style);
|
|
13208
|
-
layoutChar(drawData, style, width);
|
|
13234
|
+
if (style.__isCharMode) layoutChar(drawData, style, width);
|
|
13209
13235
|
if (drawData.overflow) clipText(drawData, style, x, width);
|
|
13210
|
-
if (textDecoration !== "none") decorationText(drawData, style);
|
|
13236
|
+
if (style.textDecoration !== "none") decorationText(drawData, style);
|
|
13211
13237
|
return drawData;
|
|
13212
13238
|
}
|
|
13213
13239
|
|
|
@@ -13280,4 +13306,4 @@ Object.assign(Creator, {
|
|
|
13280
13306
|
|
|
13281
13307
|
useCanvas();
|
|
13282
13308
|
|
|
13283
|
-
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$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as 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$1 as 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 };
|
|
13309
|
+
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$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as 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$1 as 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 };
|