@leafer-draw/worker 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/worker.cjs +428 -428
- package/dist/worker.esm.js +430 -430
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +546 -533
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +567 -550
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/worker.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$1;
|
|
30
|
-
if (types[typeName]) {
|
|
31
|
-
return types[typeName]++;
|
|
32
|
-
} else {
|
|
33
|
-
types[typeName] = 1;
|
|
34
|
-
return 0;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const I$1 = 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$4} = 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$4(floor$2(width + (xGap || 0)), 1), max$4(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$1;
|
|
270
|
+
if (types[typeName]) {
|
|
271
|
+
return types[typeName]++;
|
|
272
|
+
} else {
|
|
273
|
+
types[typeName] = 1;
|
|
274
|
+
return 0;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const I$1 = IncrementId;
|
|
280
|
+
|
|
250
281
|
let tempA, tempB, tempTo;
|
|
251
282
|
|
|
252
|
-
const {max: max$
|
|
283
|
+
const {max: max$3} = 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$3(t, other);
|
|
305
336
|
toTempAB(t, other, change);
|
|
306
|
-
return set$2(tempTo, max$
|
|
337
|
+
return set$2(tempTo, max$3(tempA[0], tempB[0]), max$3(tempA[1], tempB[1]), max$3(tempA[2], tempB[2]), max$3(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$2, 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$2(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, 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$3, 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$3(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$8.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 = ImageManager;
|
|
|
4027
4059
|
|
|
4028
4060
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
4029
4061
|
|
|
4030
|
-
const {floor: floor$1, max: max$3} = 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() {
|
|
@@ -7591,7 +7607,7 @@ const Transition = {
|
|
|
7591
7607
|
|
|
7592
7608
|
const {parse: parse, objectToCanvasData: objectToCanvasData} = PathConvert;
|
|
7593
7609
|
|
|
7594
|
-
const {stintSet: stintSet$
|
|
7610
|
+
const {stintSet: stintSet$3} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
|
|
7595
7611
|
|
|
7596
7612
|
const emptyPaint = {};
|
|
7597
7613
|
|
|
@@ -7658,7 +7674,7 @@ class UIData extends LeafData {
|
|
|
7658
7674
|
setFill(value) {
|
|
7659
7675
|
if (this.__naturalWidth) this.__removeNaturalSize();
|
|
7660
7676
|
if (isString(value) || !value) {
|
|
7661
|
-
stintSet$
|
|
7677
|
+
stintSet$3(this, "__isTransparentFill", hasTransparent$2(value));
|
|
7662
7678
|
this.__isFills && this.__removePaint("fill", true);
|
|
7663
7679
|
this._fill = value;
|
|
7664
7680
|
} else if (isObject(value)) {
|
|
@@ -7667,7 +7683,7 @@ class UIData extends LeafData {
|
|
|
7667
7683
|
}
|
|
7668
7684
|
setStroke(value) {
|
|
7669
7685
|
if (isString(value) || !value) {
|
|
7670
|
-
stintSet$
|
|
7686
|
+
stintSet$3(this, "__isTransparentStroke", hasTransparent$2(value));
|
|
7671
7687
|
this.__isStrokes && this.__removePaint("stroke", true);
|
|
7672
7688
|
this._stroke = value;
|
|
7673
7689
|
} else if (isObject(value)) {
|
|
@@ -7725,11 +7741,11 @@ class UIData extends LeafData {
|
|
|
7725
7741
|
if (removeInput) this.__removeInput(attrName);
|
|
7726
7742
|
PaintImage.recycleImage(attrName, this);
|
|
7727
7743
|
if (attrName === "fill") {
|
|
7728
|
-
stintSet$
|
|
7744
|
+
stintSet$3(this, "__isAlphaPixelFill", undefined);
|
|
7729
7745
|
this._fill = this.__isFills = undefined;
|
|
7730
7746
|
} else {
|
|
7731
|
-
stintSet$
|
|
7732
|
-
stintSet$
|
|
7747
|
+
stintSet$3(this, "__isAlphaPixelStroke", undefined);
|
|
7748
|
+
stintSet$3(this, "__hasMultiStrokeStyle", undefined);
|
|
7733
7749
|
this._stroke = this.__isStrokes = undefined;
|
|
7734
7750
|
}
|
|
7735
7751
|
}
|
|
@@ -7878,7 +7894,7 @@ class CanvasData extends RectData {
|
|
|
7878
7894
|
}
|
|
7879
7895
|
}
|
|
7880
7896
|
|
|
7881
|
-
const {max: max$
|
|
7897
|
+
const {max: max$1, add: add$1} = FourNumberHelper;
|
|
7882
7898
|
|
|
7883
7899
|
const UIBounds = {
|
|
7884
7900
|
__updateStrokeSpread() {
|
|
@@ -7894,7 +7910,7 @@ const UIBounds = {
|
|
|
7894
7910
|
}
|
|
7895
7911
|
if (data.__useArrow) spread += strokeWidth * 5;
|
|
7896
7912
|
if (box) {
|
|
7897
|
-
spread = max$
|
|
7913
|
+
spread = max$1(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
|
|
7898
7914
|
boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
|
|
7899
7915
|
}
|
|
7900
7916
|
this.__layout.strokeBoxSpread = boxSpread;
|
|
@@ -7904,35 +7920,35 @@ const UIBounds = {
|
|
|
7904
7920
|
let spread = 0;
|
|
7905
7921
|
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
|
|
7906
7922
|
if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
|
|
7907
|
-
if (blur) spread = max$
|
|
7923
|
+
if (blur) spread = max$1(spread, blur);
|
|
7908
7924
|
if (filter) spread = add$1(spread, Filter.getSpread(filter));
|
|
7909
7925
|
if (renderSpread) spread = add$1(spread, renderSpread);
|
|
7910
7926
|
if (strokeSpread) spread = add$1(spread, strokeSpread);
|
|
7911
7927
|
let shapeSpread = spread;
|
|
7912
|
-
if (innerShadow) shapeSpread = max$
|
|
7913
|
-
if (backgroundBlur) shapeSpread = max$
|
|
7928
|
+
if (innerShadow) shapeSpread = max$1(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
|
|
7929
|
+
if (backgroundBlur) shapeSpread = max$1(shapeSpread, backgroundBlur);
|
|
7914
7930
|
this.__layout.renderShapeSpread = shapeSpread;
|
|
7915
|
-
return box ? max$
|
|
7931
|
+
return box ? max$1(box.__updateRenderSpread(), spread) : spread;
|
|
7916
7932
|
}
|
|
7917
7933
|
};
|
|
7918
7934
|
|
|
7919
|
-
const {stintSet: stintSet$
|
|
7935
|
+
const {stintSet: stintSet$2} = DataHelper;
|
|
7920
7936
|
|
|
7921
7937
|
const UIRender = {
|
|
7922
7938
|
__updateChange() {
|
|
7923
7939
|
const data = this.__;
|
|
7924
7940
|
if (data.__useStroke) {
|
|
7925
7941
|
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
7926
|
-
stintSet$
|
|
7927
|
-
stintSet$
|
|
7942
|
+
stintSet$2(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
|
|
7943
|
+
stintSet$2(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
|
|
7928
7944
|
}
|
|
7929
7945
|
if (data.__useEffect) {
|
|
7930
7946
|
const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7931
|
-
stintSet$
|
|
7947
|
+
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"));
|
|
7932
7948
|
data.__useEffect = !!(shadow || otherEffect);
|
|
7933
7949
|
}
|
|
7934
7950
|
data.__checkSingle();
|
|
7935
|
-
stintSet$
|
|
7951
|
+
stintSet$2(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
7936
7952
|
},
|
|
7937
7953
|
__drawFast(canvas, options) {
|
|
7938
7954
|
drawFast(this, canvas, options);
|
|
@@ -7948,24 +7964,24 @@ const UIRender = {
|
|
|
7948
7964
|
this.__nowWorld = this.__getNowWorld(options);
|
|
7949
7965
|
const {shadow: shadow, innerShadow: innerShadow, filter: filter} = data;
|
|
7950
7966
|
if (shadow) Effect.shadow(this, canvas, shape);
|
|
7951
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7952
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7967
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7968
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
7953
7969
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
7954
7970
|
if (innerShadow) Effect.innerShadow(this, canvas, shape);
|
|
7955
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7971
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7956
7972
|
if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
7957
7973
|
if (shape.worldCanvas) shape.worldCanvas.recycle();
|
|
7958
7974
|
shape.canvas.recycle();
|
|
7959
7975
|
} else {
|
|
7960
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7976
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7961
7977
|
if (__isFastShadow) {
|
|
7962
7978
|
const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
|
|
7963
7979
|
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
7964
7980
|
}
|
|
7965
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7981
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
7966
7982
|
if (__isFastShadow) canvas.restore();
|
|
7967
7983
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
7968
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7984
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7969
7985
|
}
|
|
7970
7986
|
} else {
|
|
7971
7987
|
if (data.__pathInputed) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
|
|
@@ -7974,9 +7990,9 @@ const UIRender = {
|
|
|
7974
7990
|
__drawShape(canvas, options) {
|
|
7975
7991
|
this.__drawRenderPath(canvas);
|
|
7976
7992
|
const data = this.__, {fill: fill, stroke: stroke} = data;
|
|
7977
|
-
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill("#000000", this, canvas);
|
|
7993
|
+
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas, options) : Paint.fill("#000000", this, canvas, options);
|
|
7978
7994
|
if (data.__isCanvas) this.__drawAfterFill(canvas, options);
|
|
7979
|
-
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke("#000000", this, canvas);
|
|
7995
|
+
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke("#000000", this, canvas, options);
|
|
7980
7996
|
},
|
|
7981
7997
|
__drawAfterFill(canvas, options) {
|
|
7982
7998
|
if (this.__.__clipAfterFill) {
|
|
@@ -7991,10 +8007,10 @@ const UIRender = {
|
|
|
7991
8007
|
function drawFast(ui, canvas, options) {
|
|
7992
8008
|
const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke} = ui.__;
|
|
7993
8009
|
ui.__drawRenderPath(canvas);
|
|
7994
|
-
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
7995
|
-
if (fill) Paint.fill(fill, ui, canvas);
|
|
8010
|
+
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
8011
|
+
if (fill) Paint.fill(fill, ui, canvas, options);
|
|
7996
8012
|
if (__drawAfterFill) ui.__drawAfterFill(canvas, options);
|
|
7997
|
-
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
8013
|
+
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
7998
8014
|
}
|
|
7999
8015
|
|
|
8000
8016
|
const RectRender = {
|
|
@@ -8132,8 +8148,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8132
8148
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
8133
8149
|
} else drawer.rect(x, y, width, height);
|
|
8134
8150
|
}
|
|
8135
|
-
drawImagePlaceholder(canvas,
|
|
8136
|
-
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
8151
|
+
drawImagePlaceholder(_paint, canvas, renderOptions) {
|
|
8152
|
+
Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
|
|
8137
8153
|
}
|
|
8138
8154
|
animate(keyframe, _options, _type, _isTemp) {
|
|
8139
8155
|
this.set(keyframe);
|
|
@@ -9155,7 +9171,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
|
|
|
9155
9171
|
|
|
9156
9172
|
Canvas = __decorate([ registerUI() ], Canvas);
|
|
9157
9173
|
|
|
9158
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
|
|
9174
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9159
9175
|
|
|
9160
9176
|
let Text = class Text extends UI {
|
|
9161
9177
|
get __tag() {
|
|
@@ -9167,13 +9183,14 @@ let Text = class Text extends UI {
|
|
|
9167
9183
|
}
|
|
9168
9184
|
__updateTextDrawData() {
|
|
9169
9185
|
const data = this.__;
|
|
9170
|
-
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
|
|
9186
|
+
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
|
|
9171
9187
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
9172
9188
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
9173
|
-
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
9174
9189
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
|
|
9175
9190
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
9176
|
-
data
|
|
9191
|
+
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
9192
|
+
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
9193
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
|
|
9177
9194
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
9178
9195
|
}
|
|
9179
9196
|
__updateBoxBounds() {
|
|
@@ -9383,102 +9400,163 @@ function penPathType() {
|
|
|
9383
9400
|
};
|
|
9384
9401
|
}
|
|
9385
9402
|
|
|
9386
|
-
function
|
|
9387
|
-
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
9388
|
-
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
9389
|
-
let row;
|
|
9390
|
-
for (let i = 0, len = rows.length; i < len; i++) {
|
|
9391
|
-
row = rows[i];
|
|
9392
|
-
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
9393
|
-
canvas.fillText(charData.char, charData.x, row.y);
|
|
9394
|
-
});
|
|
9395
|
-
}
|
|
9396
|
-
if (decorationY) {
|
|
9397
|
-
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
9398
|
-
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
9399
|
-
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
9400
|
-
}
|
|
9401
|
-
}
|
|
9402
|
-
|
|
9403
|
-
function fill(fill, ui, canvas) {
|
|
9403
|
+
function fill(fill, ui, canvas, renderOptions) {
|
|
9404
9404
|
canvas.fillStyle = fill;
|
|
9405
|
-
fillPathOrText(ui, canvas);
|
|
9405
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9406
9406
|
}
|
|
9407
9407
|
|
|
9408
|
-
function fills(fills, ui, canvas) {
|
|
9409
|
-
let item;
|
|
9408
|
+
function fills(fills, ui, canvas, renderOptions) {
|
|
9409
|
+
let item, originPaint, countImage;
|
|
9410
9410
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
9411
|
-
item = fills[i];
|
|
9411
|
+
item = fills[i], originPaint = item.originPaint;
|
|
9412
9412
|
if (item.image) {
|
|
9413
|
-
|
|
9413
|
+
countImage ? countImage++ : countImage = 1;
|
|
9414
|
+
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
9414
9415
|
if (!item.style) {
|
|
9415
|
-
if (
|
|
9416
|
+
if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
|
|
9416
9417
|
continue;
|
|
9417
9418
|
}
|
|
9418
9419
|
}
|
|
9419
9420
|
canvas.fillStyle = item.style;
|
|
9420
|
-
if (item.transform ||
|
|
9421
|
+
if (item.transform || originPaint.scaleFixed) {
|
|
9421
9422
|
canvas.save();
|
|
9422
9423
|
if (item.transform) canvas.transform(item.transform);
|
|
9423
|
-
if (
|
|
9424
|
+
if (originPaint.scaleFixed) {
|
|
9424
9425
|
const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
9425
|
-
if (
|
|
9426
|
+
if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
9426
9427
|
}
|
|
9427
|
-
if (
|
|
9428
|
-
fillPathOrText(ui, canvas);
|
|
9428
|
+
if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
|
|
9429
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9429
9430
|
canvas.restore();
|
|
9430
9431
|
} else {
|
|
9431
|
-
if (
|
|
9432
|
-
canvas.saveBlendMode(
|
|
9433
|
-
fillPathOrText(ui, canvas);
|
|
9432
|
+
if (originPaint.blendMode) {
|
|
9433
|
+
canvas.saveBlendMode(originPaint.blendMode);
|
|
9434
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9434
9435
|
canvas.restoreBlendMode();
|
|
9435
|
-
} else fillPathOrText(ui, canvas);
|
|
9436
|
+
} else fillPathOrText(ui, canvas, renderOptions);
|
|
9437
|
+
}
|
|
9438
|
+
}
|
|
9439
|
+
}
|
|
9440
|
+
|
|
9441
|
+
function fillPathOrText(ui, canvas, renderOptions) {
|
|
9442
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
9443
|
+
}
|
|
9444
|
+
|
|
9445
|
+
function fillText(ui, canvas, _renderOptions) {
|
|
9446
|
+
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
9447
|
+
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
9448
|
+
let row;
|
|
9449
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
9450
|
+
row = rows[i];
|
|
9451
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
9452
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
9453
|
+
});
|
|
9454
|
+
}
|
|
9455
|
+
if (decorationY) {
|
|
9456
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
9457
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
9458
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
9459
|
+
}
|
|
9460
|
+
}
|
|
9461
|
+
|
|
9462
|
+
function stroke(stroke, ui, canvas, renderOptions) {
|
|
9463
|
+
const data = ui.__;
|
|
9464
|
+
if (!data.__strokeWidth) return;
|
|
9465
|
+
if (data.__font) {
|
|
9466
|
+
Paint.strokeText(stroke, ui, canvas, renderOptions);
|
|
9467
|
+
} else {
|
|
9468
|
+
switch (data.strokeAlign) {
|
|
9469
|
+
case "center":
|
|
9470
|
+
drawCenter$1(stroke, 1, ui, canvas, renderOptions);
|
|
9471
|
+
break;
|
|
9472
|
+
|
|
9473
|
+
case "inside":
|
|
9474
|
+
drawInside(stroke, ui, canvas, renderOptions);
|
|
9475
|
+
break;
|
|
9476
|
+
|
|
9477
|
+
case "outside":
|
|
9478
|
+
drawOutside(stroke, ui, canvas, renderOptions);
|
|
9479
|
+
break;
|
|
9436
9480
|
}
|
|
9437
9481
|
}
|
|
9438
9482
|
}
|
|
9439
9483
|
|
|
9440
|
-
function
|
|
9441
|
-
|
|
9484
|
+
function strokes(strokes, ui, canvas, renderOptions) {
|
|
9485
|
+
Paint.stroke(strokes, ui, canvas, renderOptions);
|
|
9486
|
+
}
|
|
9487
|
+
|
|
9488
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9489
|
+
const data = ui.__;
|
|
9490
|
+
if (isObject(stroke)) {
|
|
9491
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
|
|
9492
|
+
} else {
|
|
9493
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9494
|
+
canvas.stroke();
|
|
9495
|
+
}
|
|
9496
|
+
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
|
|
9497
|
+
}
|
|
9498
|
+
|
|
9499
|
+
function drawInside(stroke, ui, canvas, renderOptions) {
|
|
9500
|
+
canvas.save();
|
|
9501
|
+
canvas.clipUI(ui);
|
|
9502
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9503
|
+
canvas.restore();
|
|
9504
|
+
}
|
|
9505
|
+
|
|
9506
|
+
function drawOutside(stroke, ui, canvas, renderOptions) {
|
|
9507
|
+
const data = ui.__;
|
|
9508
|
+
if (data.__fillAfterStroke) {
|
|
9509
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9510
|
+
} else {
|
|
9511
|
+
const {renderBounds: renderBounds} = ui.__layout;
|
|
9512
|
+
const out = canvas.getSameCanvas(true, true);
|
|
9513
|
+
ui.__drawRenderPath(out);
|
|
9514
|
+
drawCenter$1(stroke, 2, ui, out, renderOptions);
|
|
9515
|
+
out.clipUI(data);
|
|
9516
|
+
out.clearWorld(renderBounds);
|
|
9517
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9518
|
+
out.recycle(ui.__nowWorld);
|
|
9519
|
+
}
|
|
9442
9520
|
}
|
|
9443
9521
|
|
|
9444
|
-
function strokeText(stroke, ui, canvas) {
|
|
9522
|
+
function strokeText(stroke, ui, canvas, renderOptions) {
|
|
9445
9523
|
switch (ui.__.strokeAlign) {
|
|
9446
9524
|
case "center":
|
|
9447
|
-
drawCenter
|
|
9525
|
+
drawCenter(stroke, 1, ui, canvas, renderOptions);
|
|
9448
9526
|
break;
|
|
9449
9527
|
|
|
9450
9528
|
case "inside":
|
|
9451
|
-
drawAlign(stroke, "inside", ui, canvas);
|
|
9529
|
+
drawAlign(stroke, "inside", ui, canvas, renderOptions);
|
|
9452
9530
|
break;
|
|
9453
9531
|
|
|
9454
9532
|
case "outside":
|
|
9455
|
-
ui.__.__fillAfterStroke ? drawCenter
|
|
9533
|
+
ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
|
|
9456
9534
|
break;
|
|
9457
9535
|
}
|
|
9458
9536
|
}
|
|
9459
9537
|
|
|
9460
|
-
function drawCenter
|
|
9538
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9461
9539
|
const data = ui.__;
|
|
9462
9540
|
if (isObject(stroke)) {
|
|
9463
|
-
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
9541
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
|
|
9464
9542
|
} else {
|
|
9465
9543
|
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9466
|
-
drawTextStroke(ui, canvas);
|
|
9544
|
+
Paint.drawTextStroke(ui, canvas, renderOptions);
|
|
9467
9545
|
}
|
|
9468
9546
|
}
|
|
9469
9547
|
|
|
9470
|
-
function drawAlign(stroke, align, ui, canvas) {
|
|
9548
|
+
function drawAlign(stroke, align, ui, canvas, renderOptions) {
|
|
9471
9549
|
const out = canvas.getSameCanvas(true, true);
|
|
9472
9550
|
out.font = ui.__.__font;
|
|
9473
|
-
drawCenter
|
|
9551
|
+
drawCenter(stroke, 2, ui, out, renderOptions);
|
|
9474
9552
|
out.blendMode = align === "outside" ? "destination-out" : "destination-in";
|
|
9475
|
-
fillText(ui, out);
|
|
9553
|
+
Paint.fillText(ui, out, renderOptions);
|
|
9476
9554
|
out.blendMode = "normal";
|
|
9477
9555
|
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9478
9556
|
out.recycle(ui.__nowWorld);
|
|
9479
9557
|
}
|
|
9480
9558
|
|
|
9481
|
-
function drawTextStroke(ui, canvas) {
|
|
9559
|
+
function drawTextStroke(ui, canvas, _renderOptions) {
|
|
9482
9560
|
let row, data = ui.__.__textDrawData;
|
|
9483
9561
|
const {rows: rows, decorationY: decorationY} = data;
|
|
9484
9562
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
@@ -9493,89 +9571,29 @@ function drawTextStroke(ui, canvas) {
|
|
|
9493
9571
|
}
|
|
9494
9572
|
}
|
|
9495
9573
|
|
|
9496
|
-
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
9574
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
|
|
9497
9575
|
let item;
|
|
9498
9576
|
const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
|
|
9499
9577
|
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
9500
9578
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
9501
9579
|
item = strokes[i];
|
|
9502
|
-
if (item.image && PaintImage.checkImage(ui, canvas,
|
|
9580
|
+
if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
|
|
9503
9581
|
if (item.style) {
|
|
9504
9582
|
if (__hasMultiStrokeStyle) {
|
|
9505
9583
|
const {strokeStyle: strokeStyle} = item;
|
|
9506
9584
|
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
9507
9585
|
} else canvas.strokeStyle = item.style;
|
|
9508
|
-
if (item.blendMode) {
|
|
9509
|
-
canvas.saveBlendMode(item.blendMode);
|
|
9510
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9586
|
+
if (item.originPaint.blendMode) {
|
|
9587
|
+
canvas.saveBlendMode(item.originPaint.blendMode);
|
|
9588
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9511
9589
|
canvas.restoreBlendMode();
|
|
9512
9590
|
} else {
|
|
9513
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9591
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9514
9592
|
}
|
|
9515
9593
|
}
|
|
9516
9594
|
}
|
|
9517
9595
|
}
|
|
9518
9596
|
|
|
9519
|
-
function stroke(stroke, ui, canvas) {
|
|
9520
|
-
const data = ui.__;
|
|
9521
|
-
if (!data.__strokeWidth) return;
|
|
9522
|
-
if (data.__font) {
|
|
9523
|
-
strokeText(stroke, ui, canvas);
|
|
9524
|
-
} else {
|
|
9525
|
-
switch (data.strokeAlign) {
|
|
9526
|
-
case "center":
|
|
9527
|
-
drawCenter(stroke, 1, ui, canvas);
|
|
9528
|
-
break;
|
|
9529
|
-
|
|
9530
|
-
case "inside":
|
|
9531
|
-
drawInside(stroke, ui, canvas);
|
|
9532
|
-
break;
|
|
9533
|
-
|
|
9534
|
-
case "outside":
|
|
9535
|
-
drawOutside(stroke, ui, canvas);
|
|
9536
|
-
break;
|
|
9537
|
-
}
|
|
9538
|
-
}
|
|
9539
|
-
}
|
|
9540
|
-
|
|
9541
|
-
function strokes(strokes, ui, canvas) {
|
|
9542
|
-
stroke(strokes, ui, canvas);
|
|
9543
|
-
}
|
|
9544
|
-
|
|
9545
|
-
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
9546
|
-
const data = ui.__;
|
|
9547
|
-
if (isObject(stroke)) {
|
|
9548
|
-
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
9549
|
-
} else {
|
|
9550
|
-
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9551
|
-
canvas.stroke();
|
|
9552
|
-
}
|
|
9553
|
-
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas);
|
|
9554
|
-
}
|
|
9555
|
-
|
|
9556
|
-
function drawInside(stroke, ui, canvas) {
|
|
9557
|
-
canvas.save();
|
|
9558
|
-
canvas.clipUI(ui);
|
|
9559
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
9560
|
-
canvas.restore();
|
|
9561
|
-
}
|
|
9562
|
-
|
|
9563
|
-
function drawOutside(stroke, ui, canvas) {
|
|
9564
|
-
const data = ui.__;
|
|
9565
|
-
if (data.__fillAfterStroke) {
|
|
9566
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
9567
|
-
} else {
|
|
9568
|
-
const {renderBounds: renderBounds} = ui.__layout;
|
|
9569
|
-
const out = canvas.getSameCanvas(true, true);
|
|
9570
|
-
ui.__drawRenderPath(out);
|
|
9571
|
-
drawCenter(stroke, 2, ui, out);
|
|
9572
|
-
out.clipUI(data);
|
|
9573
|
-
out.clearWorld(renderBounds);
|
|
9574
|
-
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9575
|
-
out.recycle(ui.__nowWorld);
|
|
9576
|
-
}
|
|
9577
|
-
}
|
|
9578
|
-
|
|
9579
9597
|
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
9580
9598
|
|
|
9581
9599
|
const tempBounds$1 = {};
|
|
@@ -9663,62 +9681,63 @@ function compute(attrName, ui) {
|
|
|
9663
9681
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
9664
9682
|
isTransparent = true;
|
|
9665
9683
|
}
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
|
|
9684
|
+
if (attrName === "fill") {
|
|
9685
|
+
stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
|
|
9686
|
+
stintSet(data, "__isTransparentFill", isTransparent);
|
|
9687
|
+
} else {
|
|
9688
|
+
stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
|
|
9689
|
+
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
9690
|
+
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
9691
|
+
}
|
|
9670
9692
|
} else {
|
|
9671
|
-
|
|
9672
|
-
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
9673
|
-
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
9693
|
+
data.__removePaint(attrName, false);
|
|
9674
9694
|
}
|
|
9675
9695
|
}
|
|
9676
9696
|
|
|
9677
9697
|
function getLeafPaint(attrName, paint, ui) {
|
|
9678
9698
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
9679
|
-
let
|
|
9699
|
+
let leafPaint;
|
|
9680
9700
|
const {boxBounds: boxBounds} = ui.__layout;
|
|
9681
9701
|
switch (paint.type) {
|
|
9682
9702
|
case "image":
|
|
9683
|
-
|
|
9703
|
+
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
9684
9704
|
break;
|
|
9685
9705
|
|
|
9686
9706
|
case "linear":
|
|
9687
|
-
|
|
9707
|
+
leafPaint = PaintGradient.linearGradient(paint, boxBounds);
|
|
9688
9708
|
break;
|
|
9689
9709
|
|
|
9690
9710
|
case "radial":
|
|
9691
|
-
|
|
9711
|
+
leafPaint = PaintGradient.radialGradient(paint, boxBounds);
|
|
9692
9712
|
break;
|
|
9693
9713
|
|
|
9694
9714
|
case "angular":
|
|
9695
|
-
|
|
9715
|
+
leafPaint = PaintGradient.conicGradient(paint, boxBounds);
|
|
9696
9716
|
break;
|
|
9697
9717
|
|
|
9698
9718
|
case "solid":
|
|
9699
9719
|
const {type: type, color: color, opacity: opacity} = paint;
|
|
9700
|
-
|
|
9720
|
+
leafPaint = {
|
|
9701
9721
|
type: type,
|
|
9702
9722
|
style: ColorConvert.string(color, opacity)
|
|
9703
9723
|
};
|
|
9704
9724
|
break;
|
|
9705
9725
|
|
|
9706
9726
|
default:
|
|
9707
|
-
if (!isUndefined(paint.r))
|
|
9727
|
+
if (!isUndefined(paint.r)) leafPaint = {
|
|
9708
9728
|
type: "solid",
|
|
9709
9729
|
style: ColorConvert.string(paint)
|
|
9710
9730
|
};
|
|
9711
9731
|
}
|
|
9712
|
-
if (
|
|
9713
|
-
|
|
9732
|
+
if (leafPaint) {
|
|
9733
|
+
leafPaint.originPaint = paint;
|
|
9734
|
+
if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
|
|
9714
9735
|
if (paint.style) {
|
|
9715
9736
|
if (paint.style.strokeWidth === 0) return undefined;
|
|
9716
|
-
|
|
9737
|
+
leafPaint.strokeStyle = paint.style;
|
|
9717
9738
|
}
|
|
9718
|
-
if (paint.editing) data.editing = paint.editing;
|
|
9719
|
-
if (paint.blendMode) data.blendMode = paint.blendMode;
|
|
9720
9739
|
}
|
|
9721
|
-
return
|
|
9740
|
+
return leafPaint;
|
|
9722
9741
|
}
|
|
9723
9742
|
|
|
9724
9743
|
const PaintModule = {
|
|
@@ -9731,88 +9750,118 @@ const PaintModule = {
|
|
|
9731
9750
|
strokes: strokes,
|
|
9732
9751
|
strokeText: strokeText,
|
|
9733
9752
|
drawTextStroke: drawTextStroke,
|
|
9753
|
+
drawStrokesStyle: drawStrokesStyle,
|
|
9734
9754
|
shape: shape
|
|
9735
9755
|
};
|
|
9736
9756
|
|
|
9737
|
-
let
|
|
9738
|
-
|
|
9739
|
-
const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
9740
|
-
|
|
9741
|
-
function stretchMode(data, box, scaleX, scaleY) {
|
|
9742
|
-
const transform = get$3();
|
|
9743
|
-
translate$1(transform, box.x, box.y);
|
|
9744
|
-
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
9745
|
-
data.transform = transform;
|
|
9746
|
-
}
|
|
9757
|
+
let cache, box = new Bounds;
|
|
9747
9758
|
|
|
9748
|
-
|
|
9749
|
-
const transform = get$3();
|
|
9750
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
9751
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
9752
|
-
if (rotation) rotateOfOuter$1(transform, {
|
|
9753
|
-
x: box.x + box.width / 2,
|
|
9754
|
-
y: box.y + box.height / 2
|
|
9755
|
-
}, rotation);
|
|
9756
|
-
data.transform = transform;
|
|
9757
|
-
}
|
|
9759
|
+
const {isSame: isSame} = BoundsHelper;
|
|
9758
9760
|
|
|
9759
|
-
function
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
if (
|
|
9763
|
-
|
|
9764
|
-
set(tempMatrix$1);
|
|
9765
|
-
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
9766
|
-
multiplyParent(transform, tempMatrix$1);
|
|
9767
|
-
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
9768
|
-
}
|
|
9769
|
-
data.transform = transform;
|
|
9770
|
-
}
|
|
9771
|
-
|
|
9772
|
-
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
9773
|
-
const transform = get$3();
|
|
9774
|
-
if (freeTransform) {
|
|
9775
|
-
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9761
|
+
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
9762
|
+
let leafPaint, event;
|
|
9763
|
+
const image = ImageManager.get(paint);
|
|
9764
|
+
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
9765
|
+
leafPaint = cache.leafPaint;
|
|
9776
9766
|
} else {
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
9767
|
+
leafPaint = {
|
|
9768
|
+
type: paint.type,
|
|
9769
|
+
image: image
|
|
9770
|
+
};
|
|
9771
|
+
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
9772
|
+
cache = image.use > 1 ? {
|
|
9773
|
+
leafPaint: leafPaint,
|
|
9774
|
+
paint: paint,
|
|
9775
|
+
boxBounds: box.set(boxBounds)
|
|
9776
|
+
} : null;
|
|
9777
|
+
}
|
|
9778
|
+
if (firstUse || image.loading) event = {
|
|
9779
|
+
image: image,
|
|
9780
|
+
attrName: attrName,
|
|
9781
|
+
attrValue: paint
|
|
9782
|
+
};
|
|
9783
|
+
if (image.ready) {
|
|
9784
|
+
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
9785
|
+
if (firstUse) {
|
|
9786
|
+
onLoad(ui, event);
|
|
9787
|
+
onLoadSuccess(ui, event);
|
|
9788
|
+
}
|
|
9789
|
+
} else if (image.error) {
|
|
9790
|
+
if (firstUse) onLoadError(ui, event, image.error);
|
|
9791
|
+
} else {
|
|
9792
|
+
if (firstUse) {
|
|
9793
|
+
ignoreRender(ui, true);
|
|
9794
|
+
onLoad(ui, event);
|
|
9795
|
+
}
|
|
9796
|
+
leafPaint.loadId = image.load(() => {
|
|
9797
|
+
ignoreRender(ui, false);
|
|
9798
|
+
if (!ui.destroyed) {
|
|
9799
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
9800
|
+
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
9801
|
+
ui.forceUpdate("surface");
|
|
9802
|
+
}
|
|
9803
|
+
onLoadSuccess(ui, event);
|
|
9804
|
+
}
|
|
9805
|
+
leafPaint.loadId = undefined;
|
|
9806
|
+
}, error => {
|
|
9807
|
+
ignoreRender(ui, false);
|
|
9808
|
+
onLoadError(ui, event, error);
|
|
9809
|
+
leafPaint.loadId = undefined;
|
|
9810
|
+
});
|
|
9811
|
+
if (ui.placeholderColor) {
|
|
9812
|
+
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
9813
|
+
if (!image.ready) {
|
|
9814
|
+
image.isPlacehold = true;
|
|
9815
|
+
ui.forceUpdate("surface");
|
|
9797
9816
|
}
|
|
9817
|
+
}, ui.placeholderDelay);
|
|
9818
|
+
}
|
|
9819
|
+
}
|
|
9820
|
+
return leafPaint;
|
|
9821
|
+
}
|
|
9822
|
+
|
|
9823
|
+
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
9824
|
+
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
9825
|
+
const data = ui.__;
|
|
9826
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
9827
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
9828
|
+
if (data.__autoSide) {
|
|
9829
|
+
ui.forceUpdate("width");
|
|
9830
|
+
if (ui.__proxyData) {
|
|
9831
|
+
ui.setProxyAttr("width", data.width);
|
|
9832
|
+
ui.setProxyAttr("height", data.height);
|
|
9798
9833
|
}
|
|
9834
|
+
return false;
|
|
9799
9835
|
}
|
|
9800
|
-
origin.x = box.x + x;
|
|
9801
|
-
origin.y = box.y + y;
|
|
9802
|
-
translate$1(transform, origin.x, origin.y);
|
|
9803
|
-
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
9804
9836
|
}
|
|
9805
|
-
data.
|
|
9837
|
+
if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
9838
|
+
return true;
|
|
9806
9839
|
}
|
|
9807
9840
|
|
|
9808
|
-
function
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9841
|
+
function onLoad(ui, event) {
|
|
9842
|
+
emit(ui, ImageEvent.LOAD, event);
|
|
9843
|
+
}
|
|
9844
|
+
|
|
9845
|
+
function onLoadSuccess(ui, event) {
|
|
9846
|
+
emit(ui, ImageEvent.LOADED, event);
|
|
9847
|
+
}
|
|
9848
|
+
|
|
9849
|
+
function onLoadError(ui, event, error) {
|
|
9850
|
+
event.error = error;
|
|
9851
|
+
ui.forceUpdate("surface");
|
|
9852
|
+
emit(ui, ImageEvent.ERROR, event);
|
|
9853
|
+
}
|
|
9854
|
+
|
|
9855
|
+
function emit(ui, type, data) {
|
|
9856
|
+
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
9813
9857
|
}
|
|
9814
9858
|
|
|
9815
|
-
|
|
9859
|
+
function ignoreRender(ui, value) {
|
|
9860
|
+
const {leafer: leafer} = ui;
|
|
9861
|
+
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
9862
|
+
}
|
|
9863
|
+
|
|
9864
|
+
const {get: get$3, translate: translate$1} = MatrixHelper;
|
|
9816
9865
|
|
|
9817
9866
|
const tempBox = new Bounds;
|
|
9818
9867
|
|
|
@@ -9821,17 +9870,13 @@ const tempScaleData = {};
|
|
|
9821
9870
|
const tempImage = {};
|
|
9822
9871
|
|
|
9823
9872
|
function createData(leafPaint, image, paint, box) {
|
|
9824
|
-
|
|
9825
|
-
if (changeful) leafPaint.changeful = changeful;
|
|
9826
|
-
if (sync) leafPaint.sync = sync;
|
|
9827
|
-
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
9828
|
-
leafPaint.data = getPatternData(paint, box, image);
|
|
9873
|
+
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
9829
9874
|
}
|
|
9830
9875
|
|
|
9831
9876
|
function getPatternData(paint, box, image) {
|
|
9832
9877
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
9833
9878
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
9834
|
-
|
|
9879
|
+
const {width: width, height: height} = image;
|
|
9835
9880
|
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;
|
|
9836
9881
|
const sameBox = box.width === width && box.height === height;
|
|
9837
9882
|
const data = {
|
|
@@ -9862,8 +9907,8 @@ function getPatternData(paint, box, image) {
|
|
|
9862
9907
|
case "stretch":
|
|
9863
9908
|
if (!sameBox) {
|
|
9864
9909
|
scaleX = box.width / width, scaleY = box.height / height;
|
|
9865
|
-
stretchMode(data, box, scaleX, scaleY);
|
|
9866
|
-
}
|
|
9910
|
+
PaintImage.stretchMode(data, box, scaleX, scaleY);
|
|
9911
|
+
} else if (scaleX) scaleX = scaleY = undefined;
|
|
9867
9912
|
break;
|
|
9868
9913
|
|
|
9869
9914
|
case "normal":
|
|
@@ -9871,13 +9916,13 @@ function getPatternData(paint, box, image) {
|
|
|
9871
9916
|
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
9872
9917
|
let clipScaleX, clipScaleY;
|
|
9873
9918
|
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
|
|
9874
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
9919
|
+
PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
9875
9920
|
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
9876
9921
|
}
|
|
9877
9922
|
break;
|
|
9878
9923
|
|
|
9879
9924
|
case "repeat":
|
|
9880
|
-
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
9925
|
+
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
9881
9926
|
if (!repeat) data.repeat = "repeat";
|
|
9882
9927
|
const count = isObject(repeat);
|
|
9883
9928
|
if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
|
|
@@ -9886,18 +9931,16 @@ function getPatternData(paint, box, image) {
|
|
|
9886
9931
|
case "fit":
|
|
9887
9932
|
case "cover":
|
|
9888
9933
|
default:
|
|
9889
|
-
if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9934
|
+
if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9890
9935
|
}
|
|
9891
9936
|
if (!data.transform) {
|
|
9892
|
-
if (box.x || box.y) translate(data.transform = get$
|
|
9937
|
+
if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
|
|
9893
9938
|
}
|
|
9894
|
-
data.width = width;
|
|
9895
|
-
data.height = height;
|
|
9896
9939
|
if (scaleX) {
|
|
9897
9940
|
data.scaleX = scaleX;
|
|
9898
9941
|
data.scaleY = scaleY;
|
|
9899
9942
|
}
|
|
9900
|
-
if (opacity) data.opacity = opacity;
|
|
9943
|
+
if (opacity && opacity < 1) data.opacity = opacity;
|
|
9901
9944
|
if (filters) data.filters = filters;
|
|
9902
9945
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
9903
9946
|
return data;
|
|
@@ -9919,234 +9962,194 @@ function getGapValue(gap, size, totalSize, rows) {
|
|
|
9919
9962
|
return gap === "auto" ? value < 0 ? 0 : value : value;
|
|
9920
9963
|
}
|
|
9921
9964
|
|
|
9922
|
-
let
|
|
9965
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
9923
9966
|
|
|
9924
|
-
const {
|
|
9967
|
+
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
9925
9968
|
|
|
9926
|
-
function
|
|
9927
|
-
|
|
9928
|
-
|
|
9929
|
-
|
|
9930
|
-
|
|
9931
|
-
} else {
|
|
9932
|
-
leafPaint = {
|
|
9933
|
-
type: paint.type,
|
|
9934
|
-
image: image
|
|
9935
|
-
};
|
|
9936
|
-
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
9937
|
-
cache = image.use > 1 ? {
|
|
9938
|
-
leafPaint: leafPaint,
|
|
9939
|
-
paint: paint,
|
|
9940
|
-
boxBounds: box.set(boxBounds)
|
|
9941
|
-
} : null;
|
|
9942
|
-
}
|
|
9943
|
-
if (firstUse || image.loading) event = {
|
|
9944
|
-
image: image,
|
|
9945
|
-
attrName: attrName,
|
|
9946
|
-
attrValue: paint
|
|
9947
|
-
};
|
|
9948
|
-
if (image.ready) {
|
|
9949
|
-
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
9950
|
-
if (firstUse) {
|
|
9951
|
-
onLoad(ui, event);
|
|
9952
|
-
onLoadSuccess(ui, event);
|
|
9953
|
-
}
|
|
9954
|
-
} else if (image.error) {
|
|
9955
|
-
if (firstUse) onLoadError(ui, event, image.error);
|
|
9956
|
-
} else {
|
|
9957
|
-
if (firstUse) {
|
|
9958
|
-
ignoreRender(ui, true);
|
|
9959
|
-
onLoad(ui, event);
|
|
9960
|
-
}
|
|
9961
|
-
leafPaint.loadId = image.load(() => {
|
|
9962
|
-
ignoreRender(ui, false);
|
|
9963
|
-
if (!ui.destroyed) {
|
|
9964
|
-
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
9965
|
-
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
9966
|
-
ui.forceUpdate("surface");
|
|
9967
|
-
}
|
|
9968
|
-
onLoadSuccess(ui, event);
|
|
9969
|
-
}
|
|
9970
|
-
leafPaint.loadId = undefined;
|
|
9971
|
-
}, error => {
|
|
9972
|
-
ignoreRender(ui, false);
|
|
9973
|
-
onLoadError(ui, event, error);
|
|
9974
|
-
leafPaint.loadId = undefined;
|
|
9975
|
-
});
|
|
9976
|
-
if (ui.placeholderColor) {
|
|
9977
|
-
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
9978
|
-
if (!image.ready) {
|
|
9979
|
-
image.isPlacehold = true;
|
|
9980
|
-
ui.forceUpdate("surface");
|
|
9981
|
-
}
|
|
9982
|
-
}, ui.placeholderDelay);
|
|
9983
|
-
}
|
|
9984
|
-
}
|
|
9985
|
-
return leafPaint;
|
|
9969
|
+
function stretchMode(data, box, scaleX, scaleY) {
|
|
9970
|
+
const transform = get$2(), {x: x, y: y} = box;
|
|
9971
|
+
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
9972
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
9973
|
+
data.transform = transform;
|
|
9986
9974
|
}
|
|
9987
9975
|
|
|
9988
|
-
function
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
ui.setProxyAttr("height", data.height);
|
|
9998
|
-
}
|
|
9999
|
-
return false;
|
|
10000
|
-
}
|
|
10001
|
-
}
|
|
10002
|
-
if (!leafPaint.data) createData(leafPaint, image, paint, boxBounds);
|
|
10003
|
-
return true;
|
|
9976
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
9977
|
+
const transform = get$2();
|
|
9978
|
+
translate(transform, box.x + x, box.y + y);
|
|
9979
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
9980
|
+
if (rotation) rotateOfOuter$1(transform, {
|
|
9981
|
+
x: box.x + box.width / 2,
|
|
9982
|
+
y: box.y + box.height / 2
|
|
9983
|
+
}, rotation);
|
|
9984
|
+
data.transform = transform;
|
|
10004
9985
|
}
|
|
10005
9986
|
|
|
10006
|
-
function
|
|
10007
|
-
|
|
9987
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
9988
|
+
const transform = get$2();
|
|
9989
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9990
|
+
if (clipScaleX) {
|
|
9991
|
+
if (rotation || skew) {
|
|
9992
|
+
set(tempMatrix$1);
|
|
9993
|
+
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
9994
|
+
multiplyParent(transform, tempMatrix$1);
|
|
9995
|
+
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
9996
|
+
}
|
|
9997
|
+
data.transform = transform;
|
|
10008
9998
|
}
|
|
10009
9999
|
|
|
10010
|
-
function
|
|
10011
|
-
|
|
10012
|
-
|
|
10000
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
10001
|
+
const transform = get$2();
|
|
10002
|
+
if (freeTransform) {
|
|
10003
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
10004
|
+
} else {
|
|
10005
|
+
if (rotation) {
|
|
10006
|
+
if (align === "center") {
|
|
10007
|
+
rotateOfOuter$1(transform, {
|
|
10008
|
+
x: width / 2,
|
|
10009
|
+
y: height / 2
|
|
10010
|
+
}, rotation);
|
|
10011
|
+
} else {
|
|
10012
|
+
rotate(transform, rotation);
|
|
10013
|
+
switch (rotation) {
|
|
10014
|
+
case 90:
|
|
10015
|
+
translate(transform, height, 0);
|
|
10016
|
+
break;
|
|
10013
10017
|
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
emit(ui, ImageEvent.ERROR, event);
|
|
10018
|
-
}
|
|
10018
|
+
case 180:
|
|
10019
|
+
translate(transform, width, height);
|
|
10020
|
+
break;
|
|
10019
10021
|
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
+
case 270:
|
|
10023
|
+
translate(transform, 0, width);
|
|
10024
|
+
break;
|
|
10025
|
+
}
|
|
10026
|
+
}
|
|
10027
|
+
}
|
|
10028
|
+
origin.x = box.x + x;
|
|
10029
|
+
origin.y = box.y + y;
|
|
10030
|
+
translate(transform, origin.x, origin.y);
|
|
10031
|
+
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
10032
|
+
}
|
|
10033
|
+
data.transform = transform;
|
|
10022
10034
|
}
|
|
10023
10035
|
|
|
10024
|
-
function
|
|
10025
|
-
|
|
10026
|
-
if (
|
|
10036
|
+
function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
10037
|
+
if (rotation) rotate(transform, rotation);
|
|
10038
|
+
if (skew) skewHelper(transform, skew.x, skew.y);
|
|
10039
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
10040
|
+
translate(transform, box.x + x, box.y + y);
|
|
10027
10041
|
}
|
|
10028
10042
|
|
|
10029
10043
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
10030
10044
|
|
|
10031
|
-
const {
|
|
10045
|
+
const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
10046
|
+
|
|
10047
|
+
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
10048
|
+
if (!paint.patternTask) {
|
|
10049
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
10050
|
+
paint.patternTask = null;
|
|
10051
|
+
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
10052
|
+
ui.forceUpdate("surface");
|
|
10053
|
+
}), 300);
|
|
10054
|
+
}
|
|
10055
|
+
}
|
|
10032
10056
|
|
|
10033
|
-
function createPattern(ui,
|
|
10034
|
-
let {scaleX: scaleX, scaleY: scaleY} =
|
|
10035
|
-
const id = scaleX + "-" + scaleY + "-" + pixelRatio;
|
|
10057
|
+
function createPattern(paint, ui, canvas, renderOptions) {
|
|
10058
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
10036
10059
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
scaleX
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
width *= scaleX;
|
|
10051
|
-
height *= scaleY;
|
|
10052
|
-
const size = width * height;
|
|
10053
|
-
if (!repeat) {
|
|
10054
|
-
if (size > Platform.image.maxCacheSize) return false;
|
|
10055
|
-
}
|
|
10056
|
-
let maxSize = Platform.image.maxPatternSize;
|
|
10057
|
-
if (image.isSVG) {
|
|
10058
|
-
const ws = width / image.width;
|
|
10059
|
-
if (ws > 1) imageScale = ws / ceil(ws);
|
|
10060
|
-
} else {
|
|
10061
|
-
const imageSize = image.width * image.height;
|
|
10062
|
-
if (maxSize > imageSize) maxSize = imageSize;
|
|
10063
|
-
}
|
|
10064
|
-
if (size > maxSize) imageScale = Math.sqrt(size / maxSize);
|
|
10065
|
-
if (imageScale) {
|
|
10066
|
-
scaleX /= imageScale;
|
|
10067
|
-
scaleY /= imageScale;
|
|
10068
|
-
width /= imageScale;
|
|
10069
|
-
height /= imageScale;
|
|
10070
|
-
}
|
|
10071
|
-
if (sx) {
|
|
10072
|
-
scaleX /= sx;
|
|
10073
|
-
scaleY /= sy;
|
|
10074
|
-
}
|
|
10075
|
-
const xGap = gap && gap.x * scaleX;
|
|
10076
|
-
const yGap = gap && gap.y * scaleY;
|
|
10077
|
-
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10078
|
-
const canvasWidth = width + (xGap || 0);
|
|
10079
|
-
const canvasHeight = height + (yGap || 0);
|
|
10080
|
-
scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
|
|
10081
|
-
scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
|
|
10082
|
-
if (!imageMatrix) {
|
|
10060
|
+
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
10061
|
+
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
10062
|
+
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
10063
|
+
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
10064
|
+
width *= scaleX;
|
|
10065
|
+
height *= scaleY;
|
|
10066
|
+
if (gap) {
|
|
10067
|
+
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
10068
|
+
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
10069
|
+
}
|
|
10070
|
+
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10071
|
+
scaleX *= getFloorScale(width + (xGap || 0));
|
|
10072
|
+
scaleY *= getFloorScale(height + (yGap || 0));
|
|
10083
10073
|
imageMatrix = get$1();
|
|
10084
10074
|
if (transform) copy$1(imageMatrix, transform);
|
|
10075
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10085
10076
|
}
|
|
10086
|
-
|
|
10077
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
10078
|
+
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10079
|
+
paint.style = pattern;
|
|
10080
|
+
paint.patternId = id;
|
|
10087
10081
|
}
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10082
|
+
}
|
|
10083
|
+
}
|
|
10084
|
+
|
|
10085
|
+
function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
10086
|
+
const {image: image} = paint;
|
|
10087
|
+
let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
|
|
10088
|
+
if (image.isSVG) {
|
|
10089
|
+
if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
|
|
10093
10090
|
} else {
|
|
10094
|
-
|
|
10091
|
+
if (maxSize > imageSize) maxSize = imageSize;
|
|
10095
10092
|
}
|
|
10093
|
+
if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
|
|
10094
|
+
return fixScale;
|
|
10096
10095
|
}
|
|
10097
10096
|
|
|
10098
|
-
function checkImage(ui, canvas,
|
|
10099
|
-
const {scaleX: scaleX, scaleY: scaleY} =
|
|
10100
|
-
const {
|
|
10101
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY
|
|
10097
|
+
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
10098
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
10099
|
+
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
|
|
10100
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
10102
10101
|
return false;
|
|
10103
10102
|
} else {
|
|
10104
|
-
if (
|
|
10103
|
+
if (drawImage) {
|
|
10105
10104
|
if (data.repeat) {
|
|
10106
|
-
|
|
10107
|
-
} else if (!(
|
|
10108
|
-
|
|
10109
|
-
width *= scaleX * pixelRatio;
|
|
10110
|
-
height *= scaleY * pixelRatio;
|
|
10111
|
-
if (data.scaleX) {
|
|
10112
|
-
width *= data.scaleX;
|
|
10113
|
-
height *= data.scaleY;
|
|
10114
|
-
}
|
|
10115
|
-
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
10105
|
+
drawImage = false;
|
|
10106
|
+
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
10107
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
10116
10108
|
}
|
|
10117
10109
|
}
|
|
10118
|
-
if (
|
|
10110
|
+
if (drawImage) {
|
|
10119
10111
|
if (ui.__.__isFastShadow) {
|
|
10120
10112
|
canvas.fillStyle = paint.style || "#000";
|
|
10121
10113
|
canvas.fill();
|
|
10122
10114
|
}
|
|
10123
|
-
drawImage(ui, canvas,
|
|
10115
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
10124
10116
|
return true;
|
|
10125
10117
|
} else {
|
|
10126
|
-
if (!paint.style ||
|
|
10127
|
-
createPattern(ui, paint, pixelRatio);
|
|
10128
|
-
} else {
|
|
10129
|
-
if (!paint.patternTask) {
|
|
10130
|
-
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
10131
|
-
paint.patternTask = null;
|
|
10132
|
-
if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio);
|
|
10133
|
-
ui.forceUpdate("surface");
|
|
10134
|
-
}), 300);
|
|
10135
|
-
}
|
|
10136
|
-
}
|
|
10118
|
+
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
10137
10119
|
return false;
|
|
10138
10120
|
}
|
|
10139
10121
|
}
|
|
10140
10122
|
}
|
|
10141
10123
|
|
|
10142
|
-
function drawImage(ui, canvas,
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
if (
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10124
|
+
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
10125
|
+
const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
10126
|
+
let {width: width, height: height} = image, clipUI;
|
|
10127
|
+
if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
|
|
10128
|
+
canvas.save();
|
|
10129
|
+
clipUI && canvas.clipUI(ui);
|
|
10130
|
+
blendMode && (canvas.blendMode = blendMode);
|
|
10131
|
+
opacity && (canvas.opacity *= opacity);
|
|
10132
|
+
transform && canvas.transform(transform);
|
|
10133
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
10134
|
+
canvas.restore();
|
|
10135
|
+
} else {
|
|
10136
|
+
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
10137
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
10138
|
+
}
|
|
10139
|
+
}
|
|
10140
|
+
|
|
10141
|
+
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
10142
|
+
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
10143
|
+
if (canvas) {
|
|
10144
|
+
const {pixelRatio: pixelRatio} = canvas;
|
|
10145
|
+
scaleData.scaleX *= pixelRatio;
|
|
10146
|
+
scaleData.scaleY *= pixelRatio;
|
|
10147
|
+
}
|
|
10148
|
+
if (data && data.scaleX) {
|
|
10149
|
+
scaleData.scaleX *= Math.abs(data.scaleX);
|
|
10150
|
+
scaleData.scaleY *= Math.abs(data.scaleY);
|
|
10151
|
+
}
|
|
10152
|
+
return scaleData;
|
|
10150
10153
|
}
|
|
10151
10154
|
|
|
10152
10155
|
function recycleImage(attrName, data) {
|
|
@@ -10178,8 +10181,12 @@ function recycleImage(attrName, data) {
|
|
|
10178
10181
|
const PaintImageModule = {
|
|
10179
10182
|
image: image,
|
|
10180
10183
|
checkImage: checkImage,
|
|
10181
|
-
|
|
10184
|
+
drawImage: drawImage,
|
|
10185
|
+
getImageRenderScaleData: getImageRenderScaleData,
|
|
10182
10186
|
recycleImage: recycleImage,
|
|
10187
|
+
createPatternTask: createPatternTask,
|
|
10188
|
+
createPattern: createPattern,
|
|
10189
|
+
getPatternFixScale: getPatternFixScale,
|
|
10183
10190
|
createData: createData,
|
|
10184
10191
|
getPatternData: getPatternData,
|
|
10185
10192
|
stretchMode: stretchMode,
|
|
@@ -10635,10 +10642,8 @@ function createRows(drawData, content, style) {
|
|
|
10635
10642
|
bounds = drawData.bounds;
|
|
10636
10643
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
10637
10644
|
const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
|
|
10638
|
-
const {canvas: canvas} = Platform;
|
|
10639
|
-
|
|
10640
|
-
const charMode = width || height || __letterSpacing || textCase !== "none";
|
|
10641
|
-
if (charMode) {
|
|
10645
|
+
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
10646
|
+
if (style.__isCharMode) {
|
|
10642
10647
|
const wrap = style.textWrap !== "none";
|
|
10643
10648
|
const breakAll = style.textWrap === "break";
|
|
10644
10649
|
paraStart = true;
|
|
@@ -10767,12 +10772,19 @@ const TextMode = 2;
|
|
|
10767
10772
|
function layoutChar(drawData, style, width, _height) {
|
|
10768
10773
|
const {rows: rows} = drawData;
|
|
10769
10774
|
const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
|
|
10770
|
-
|
|
10775
|
+
const justifyLast = width && textAlign.includes("both");
|
|
10776
|
+
const justify = justifyLast || width && textAlign.includes("justify");
|
|
10777
|
+
const justifyLetter = justify && textAlign.includes("letter");
|
|
10778
|
+
let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
|
|
10771
10779
|
rows.forEach(row => {
|
|
10772
10780
|
if (row.words) {
|
|
10773
10781
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
10774
|
-
|
|
10775
|
-
|
|
10782
|
+
if (justify) {
|
|
10783
|
+
canJustify = !row.paraEnd || justifyLast;
|
|
10784
|
+
remainingWidth = width - row.width - indentWidth;
|
|
10785
|
+
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
10786
|
+
}
|
|
10787
|
+
mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
10776
10788
|
if (row.isOverflow && !letterSpacing) row.textMode = true;
|
|
10777
10789
|
if (mode === TextMode) {
|
|
10778
10790
|
row.x += indentWidth;
|
|
@@ -10790,11 +10802,15 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
10790
10802
|
charX = toWordChar(word.data, charX, wordChar);
|
|
10791
10803
|
if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
|
|
10792
10804
|
} else {
|
|
10793
|
-
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
10805
|
+
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
10794
10806
|
}
|
|
10795
|
-
if (
|
|
10796
|
-
|
|
10797
|
-
|
|
10807
|
+
if (canJustify) {
|
|
10808
|
+
isLastWord = index === wordsLength - 1;
|
|
10809
|
+
if (addWordWidth) {
|
|
10810
|
+
if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
|
|
10811
|
+
} else if (addLetterWidth) {
|
|
10812
|
+
row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
|
|
10813
|
+
}
|
|
10798
10814
|
}
|
|
10799
10815
|
});
|
|
10800
10816
|
}
|
|
@@ -10820,13 +10836,14 @@ function toWordChar(data, charX, wordChar) {
|
|
|
10820
10836
|
return charX;
|
|
10821
10837
|
}
|
|
10822
10838
|
|
|
10823
|
-
function toChar(data, charX, rowData, isOverflow) {
|
|
10839
|
+
function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
|
|
10824
10840
|
data.forEach(char => {
|
|
10825
10841
|
if (isOverflow || char.char !== " ") {
|
|
10826
10842
|
char.x = charX;
|
|
10827
10843
|
rowData.push(char);
|
|
10828
10844
|
}
|
|
10829
10845
|
charX += char.width;
|
|
10846
|
+
addLetterWidth && (charX += addLetterWidth);
|
|
10830
10847
|
});
|
|
10831
10848
|
return charX;
|
|
10832
10849
|
}
|
|
@@ -10968,10 +10985,10 @@ function getDrawData(content, style) {
|
|
|
10968
10985
|
let x = 0, y = 0;
|
|
10969
10986
|
let width = style.__getInput("width") || 0;
|
|
10970
10987
|
let height = style.__getInput("height") || 0;
|
|
10971
|
-
const {
|
|
10988
|
+
const {__padding: padding} = style;
|
|
10972
10989
|
if (padding) {
|
|
10973
|
-
if (width) x = padding[left], width -= padding[right] + padding[left]; else if (!style.autoSizeAlign) x = padding[left];
|
|
10974
|
-
if (height) y = padding[top], height -= padding[top] + padding[bottom]; else if (!style.autoSizeAlign) y = padding[top];
|
|
10990
|
+
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
10991
|
+
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
10975
10992
|
}
|
|
10976
10993
|
const drawData = {
|
|
10977
10994
|
bounds: {
|
|
@@ -10982,14 +10999,14 @@ function getDrawData(content, style) {
|
|
|
10982
10999
|
},
|
|
10983
11000
|
rows: [],
|
|
10984
11001
|
paraNumber: 0,
|
|
10985
|
-
font: Platform.canvas.font = __font
|
|
11002
|
+
font: Platform.canvas.font = style.__font
|
|
10986
11003
|
};
|
|
10987
11004
|
createRows(drawData, content, style);
|
|
10988
11005
|
if (padding) padAutoText(padding, drawData, style, width, height);
|
|
10989
11006
|
layoutText(drawData, style);
|
|
10990
|
-
layoutChar(drawData, style, width);
|
|
11007
|
+
if (style.__isCharMode) layoutChar(drawData, style, width);
|
|
10991
11008
|
if (drawData.overflow) clipText(drawData, style, x, width);
|
|
10992
|
-
if (textDecoration !== "none") decorationText(drawData, style);
|
|
11009
|
+
if (style.textDecoration !== "none") decorationText(drawData, style);
|
|
10993
11010
|
return drawData;
|
|
10994
11011
|
}
|
|
10995
11012
|
|