@leafer-draw/miniapp 1.9.12 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniapp.cjs +428 -428
- package/dist/miniapp.esm.js +430 -430
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +567 -550
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/miniapp.module.js
CHANGED
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
const Platform = {
|
|
2
|
-
toURL(text, fileType) {
|
|
3
|
-
let url = encodeURIComponent(text);
|
|
4
|
-
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
5
|
-
return url;
|
|
6
|
-
},
|
|
7
|
-
image: {
|
|
8
|
-
hitCanvasSize: 100,
|
|
9
|
-
maxCacheSize: 2560 * 1600,
|
|
10
|
-
maxPatternSize: 4096 * 2160,
|
|
11
|
-
crossOrigin: "anonymous",
|
|
12
|
-
getRealURL(url) {
|
|
13
|
-
const {prefix: prefix, suffix: suffix} = Platform.image;
|
|
14
|
-
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
15
|
-
if (prefix && url[0] === "/") url = prefix + url;
|
|
16
|
-
return url;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const IncrementId = {
|
|
22
|
-
RUNTIME: "runtime",
|
|
23
|
-
LEAF: "leaf",
|
|
24
|
-
TASK: "task",
|
|
25
|
-
CNAVAS: "canvas",
|
|
26
|
-
IMAGE: "image",
|
|
27
|
-
types: {},
|
|
28
|
-
create(typeName) {
|
|
29
|
-
const {types: types} = I$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() {
|
|
@@ -7744,7 +7760,7 @@ const Transition = {
|
|
|
7744
7760
|
|
|
7745
7761
|
const {parse: parse, objectToCanvasData: objectToCanvasData} = PathConvert;
|
|
7746
7762
|
|
|
7747
|
-
const {stintSet: stintSet$
|
|
7763
|
+
const {stintSet: stintSet$3} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
|
|
7748
7764
|
|
|
7749
7765
|
const emptyPaint = {};
|
|
7750
7766
|
|
|
@@ -7811,7 +7827,7 @@ class UIData extends LeafData {
|
|
|
7811
7827
|
setFill(value) {
|
|
7812
7828
|
if (this.__naturalWidth) this.__removeNaturalSize();
|
|
7813
7829
|
if (isString(value) || !value) {
|
|
7814
|
-
stintSet$
|
|
7830
|
+
stintSet$3(this, "__isTransparentFill", hasTransparent$2(value));
|
|
7815
7831
|
this.__isFills && this.__removePaint("fill", true);
|
|
7816
7832
|
this._fill = value;
|
|
7817
7833
|
} else if (isObject(value)) {
|
|
@@ -7820,7 +7836,7 @@ class UIData extends LeafData {
|
|
|
7820
7836
|
}
|
|
7821
7837
|
setStroke(value) {
|
|
7822
7838
|
if (isString(value) || !value) {
|
|
7823
|
-
stintSet$
|
|
7839
|
+
stintSet$3(this, "__isTransparentStroke", hasTransparent$2(value));
|
|
7824
7840
|
this.__isStrokes && this.__removePaint("stroke", true);
|
|
7825
7841
|
this._stroke = value;
|
|
7826
7842
|
} else if (isObject(value)) {
|
|
@@ -7878,11 +7894,11 @@ class UIData extends LeafData {
|
|
|
7878
7894
|
if (removeInput) this.__removeInput(attrName);
|
|
7879
7895
|
PaintImage.recycleImage(attrName, this);
|
|
7880
7896
|
if (attrName === "fill") {
|
|
7881
|
-
stintSet$
|
|
7897
|
+
stintSet$3(this, "__isAlphaPixelFill", undefined);
|
|
7882
7898
|
this._fill = this.__isFills = undefined;
|
|
7883
7899
|
} else {
|
|
7884
|
-
stintSet$
|
|
7885
|
-
stintSet$
|
|
7900
|
+
stintSet$3(this, "__isAlphaPixelStroke", undefined);
|
|
7901
|
+
stintSet$3(this, "__hasMultiStrokeStyle", undefined);
|
|
7886
7902
|
this._stroke = this.__isStrokes = undefined;
|
|
7887
7903
|
}
|
|
7888
7904
|
}
|
|
@@ -8031,7 +8047,7 @@ class CanvasData extends RectData {
|
|
|
8031
8047
|
}
|
|
8032
8048
|
}
|
|
8033
8049
|
|
|
8034
|
-
const {max: max$
|
|
8050
|
+
const {max: max$1, add: add$1} = FourNumberHelper;
|
|
8035
8051
|
|
|
8036
8052
|
const UIBounds = {
|
|
8037
8053
|
__updateStrokeSpread() {
|
|
@@ -8047,7 +8063,7 @@ const UIBounds = {
|
|
|
8047
8063
|
}
|
|
8048
8064
|
if (data.__useArrow) spread += strokeWidth * 5;
|
|
8049
8065
|
if (box) {
|
|
8050
|
-
spread = max$
|
|
8066
|
+
spread = max$1(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
|
|
8051
8067
|
boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
|
|
8052
8068
|
}
|
|
8053
8069
|
this.__layout.strokeBoxSpread = boxSpread;
|
|
@@ -8057,35 +8073,35 @@ const UIBounds = {
|
|
|
8057
8073
|
let spread = 0;
|
|
8058
8074
|
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
|
|
8059
8075
|
if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
|
|
8060
|
-
if (blur) spread = max$
|
|
8076
|
+
if (blur) spread = max$1(spread, blur);
|
|
8061
8077
|
if (filter) spread = add$1(spread, Filter.getSpread(filter));
|
|
8062
8078
|
if (renderSpread) spread = add$1(spread, renderSpread);
|
|
8063
8079
|
if (strokeSpread) spread = add$1(spread, strokeSpread);
|
|
8064
8080
|
let shapeSpread = spread;
|
|
8065
|
-
if (innerShadow) shapeSpread = max$
|
|
8066
|
-
if (backgroundBlur) shapeSpread = max$
|
|
8081
|
+
if (innerShadow) shapeSpread = max$1(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
|
|
8082
|
+
if (backgroundBlur) shapeSpread = max$1(shapeSpread, backgroundBlur);
|
|
8067
8083
|
this.__layout.renderShapeSpread = shapeSpread;
|
|
8068
|
-
return box ? max$
|
|
8084
|
+
return box ? max$1(box.__updateRenderSpread(), spread) : spread;
|
|
8069
8085
|
}
|
|
8070
8086
|
};
|
|
8071
8087
|
|
|
8072
|
-
const {stintSet: stintSet$
|
|
8088
|
+
const {stintSet: stintSet$2} = DataHelper;
|
|
8073
8089
|
|
|
8074
8090
|
const UIRender = {
|
|
8075
8091
|
__updateChange() {
|
|
8076
8092
|
const data = this.__;
|
|
8077
8093
|
if (data.__useStroke) {
|
|
8078
8094
|
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
8079
|
-
stintSet$
|
|
8080
|
-
stintSet$
|
|
8095
|
+
stintSet$2(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
|
|
8096
|
+
stintSet$2(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
|
|
8081
8097
|
}
|
|
8082
8098
|
if (data.__useEffect) {
|
|
8083
8099
|
const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
8084
|
-
stintSet$
|
|
8100
|
+
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"));
|
|
8085
8101
|
data.__useEffect = !!(shadow || otherEffect);
|
|
8086
8102
|
}
|
|
8087
8103
|
data.__checkSingle();
|
|
8088
|
-
stintSet$
|
|
8104
|
+
stintSet$2(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
8089
8105
|
},
|
|
8090
8106
|
__drawFast(canvas, options) {
|
|
8091
8107
|
drawFast(this, canvas, options);
|
|
@@ -8101,24 +8117,24 @@ const UIRender = {
|
|
|
8101
8117
|
this.__nowWorld = this.__getNowWorld(options);
|
|
8102
8118
|
const {shadow: shadow, innerShadow: innerShadow, filter: filter} = data;
|
|
8103
8119
|
if (shadow) Effect.shadow(this, canvas, shape);
|
|
8104
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8105
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
8120
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8121
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
8106
8122
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
8107
8123
|
if (innerShadow) Effect.innerShadow(this, canvas, shape);
|
|
8108
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8124
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8109
8125
|
if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
8110
8126
|
if (shape.worldCanvas) shape.worldCanvas.recycle();
|
|
8111
8127
|
shape.canvas.recycle();
|
|
8112
8128
|
} else {
|
|
8113
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8129
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8114
8130
|
if (__isFastShadow) {
|
|
8115
8131
|
const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
|
|
8116
8132
|
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
8117
8133
|
}
|
|
8118
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
8134
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
8119
8135
|
if (__isFastShadow) canvas.restore();
|
|
8120
8136
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
8121
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8137
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8122
8138
|
}
|
|
8123
8139
|
} else {
|
|
8124
8140
|
if (data.__pathInputed) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
|
|
@@ -8127,9 +8143,9 @@ const UIRender = {
|
|
|
8127
8143
|
__drawShape(canvas, options) {
|
|
8128
8144
|
this.__drawRenderPath(canvas);
|
|
8129
8145
|
const data = this.__, {fill: fill, stroke: stroke} = data;
|
|
8130
|
-
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill("#000000", this, canvas);
|
|
8146
|
+
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas, options) : Paint.fill("#000000", this, canvas, options);
|
|
8131
8147
|
if (data.__isCanvas) this.__drawAfterFill(canvas, options);
|
|
8132
|
-
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke("#000000", this, canvas);
|
|
8148
|
+
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke("#000000", this, canvas, options);
|
|
8133
8149
|
},
|
|
8134
8150
|
__drawAfterFill(canvas, options) {
|
|
8135
8151
|
if (this.__.__clipAfterFill) {
|
|
@@ -8144,10 +8160,10 @@ const UIRender = {
|
|
|
8144
8160
|
function drawFast(ui, canvas, options) {
|
|
8145
8161
|
const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke} = ui.__;
|
|
8146
8162
|
ui.__drawRenderPath(canvas);
|
|
8147
|
-
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
8148
|
-
if (fill) Paint.fill(fill, ui, canvas);
|
|
8163
|
+
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
8164
|
+
if (fill) Paint.fill(fill, ui, canvas, options);
|
|
8149
8165
|
if (__drawAfterFill) ui.__drawAfterFill(canvas, options);
|
|
8150
|
-
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
8166
|
+
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
8151
8167
|
}
|
|
8152
8168
|
|
|
8153
8169
|
const RectRender = {
|
|
@@ -8285,8 +8301,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8285
8301
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
8286
8302
|
} else drawer.rect(x, y, width, height);
|
|
8287
8303
|
}
|
|
8288
|
-
drawImagePlaceholder(canvas,
|
|
8289
|
-
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
8304
|
+
drawImagePlaceholder(_paint, canvas, renderOptions) {
|
|
8305
|
+
Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
|
|
8290
8306
|
}
|
|
8291
8307
|
animate(keyframe, _options, _type, _isTemp) {
|
|
8292
8308
|
this.set(keyframe);
|
|
@@ -9308,7 +9324,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
|
|
|
9308
9324
|
|
|
9309
9325
|
Canvas = __decorate([ registerUI() ], Canvas);
|
|
9310
9326
|
|
|
9311
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
|
|
9327
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9312
9328
|
|
|
9313
9329
|
let Text = class Text extends UI {
|
|
9314
9330
|
get __tag() {
|
|
@@ -9320,13 +9336,14 @@ let Text = class Text extends UI {
|
|
|
9320
9336
|
}
|
|
9321
9337
|
__updateTextDrawData() {
|
|
9322
9338
|
const data = this.__;
|
|
9323
|
-
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
|
|
9339
|
+
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
|
|
9324
9340
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
9325
9341
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
9326
|
-
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
9327
9342
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
|
|
9328
9343
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
9329
|
-
data
|
|
9344
|
+
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
9345
|
+
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
9346
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
|
|
9330
9347
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
9331
9348
|
}
|
|
9332
9349
|
__updateBoxBounds() {
|
|
@@ -9536,102 +9553,163 @@ function penPathType() {
|
|
|
9536
9553
|
};
|
|
9537
9554
|
}
|
|
9538
9555
|
|
|
9539
|
-
function
|
|
9540
|
-
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
9541
|
-
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
9542
|
-
let row;
|
|
9543
|
-
for (let i = 0, len = rows.length; i < len; i++) {
|
|
9544
|
-
row = rows[i];
|
|
9545
|
-
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
9546
|
-
canvas.fillText(charData.char, charData.x, row.y);
|
|
9547
|
-
});
|
|
9548
|
-
}
|
|
9549
|
-
if (decorationY) {
|
|
9550
|
-
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
9551
|
-
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
9552
|
-
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
9553
|
-
}
|
|
9554
|
-
}
|
|
9555
|
-
|
|
9556
|
-
function fill(fill, ui, canvas) {
|
|
9556
|
+
function fill(fill, ui, canvas, renderOptions) {
|
|
9557
9557
|
canvas.fillStyle = fill;
|
|
9558
|
-
fillPathOrText(ui, canvas);
|
|
9558
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9559
9559
|
}
|
|
9560
9560
|
|
|
9561
|
-
function fills(fills, ui, canvas) {
|
|
9562
|
-
let item;
|
|
9561
|
+
function fills(fills, ui, canvas, renderOptions) {
|
|
9562
|
+
let item, originPaint, countImage;
|
|
9563
9563
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
9564
|
-
item = fills[i];
|
|
9564
|
+
item = fills[i], originPaint = item.originPaint;
|
|
9565
9565
|
if (item.image) {
|
|
9566
|
-
|
|
9566
|
+
countImage ? countImage++ : countImage = 1;
|
|
9567
|
+
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
9567
9568
|
if (!item.style) {
|
|
9568
|
-
if (
|
|
9569
|
+
if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
|
|
9569
9570
|
continue;
|
|
9570
9571
|
}
|
|
9571
9572
|
}
|
|
9572
9573
|
canvas.fillStyle = item.style;
|
|
9573
|
-
if (item.transform ||
|
|
9574
|
+
if (item.transform || originPaint.scaleFixed) {
|
|
9574
9575
|
canvas.save();
|
|
9575
9576
|
if (item.transform) canvas.transform(item.transform);
|
|
9576
|
-
if (
|
|
9577
|
+
if (originPaint.scaleFixed) {
|
|
9577
9578
|
const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
9578
|
-
if (
|
|
9579
|
+
if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
9579
9580
|
}
|
|
9580
|
-
if (
|
|
9581
|
-
fillPathOrText(ui, canvas);
|
|
9581
|
+
if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
|
|
9582
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9582
9583
|
canvas.restore();
|
|
9583
9584
|
} else {
|
|
9584
|
-
if (
|
|
9585
|
-
canvas.saveBlendMode(
|
|
9586
|
-
fillPathOrText(ui, canvas);
|
|
9585
|
+
if (originPaint.blendMode) {
|
|
9586
|
+
canvas.saveBlendMode(originPaint.blendMode);
|
|
9587
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9587
9588
|
canvas.restoreBlendMode();
|
|
9588
|
-
} else fillPathOrText(ui, canvas);
|
|
9589
|
+
} else fillPathOrText(ui, canvas, renderOptions);
|
|
9590
|
+
}
|
|
9591
|
+
}
|
|
9592
|
+
}
|
|
9593
|
+
|
|
9594
|
+
function fillPathOrText(ui, canvas, renderOptions) {
|
|
9595
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
9596
|
+
}
|
|
9597
|
+
|
|
9598
|
+
function fillText(ui, canvas, _renderOptions) {
|
|
9599
|
+
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
9600
|
+
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
9601
|
+
let row;
|
|
9602
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
9603
|
+
row = rows[i];
|
|
9604
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
9605
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
9606
|
+
});
|
|
9607
|
+
}
|
|
9608
|
+
if (decorationY) {
|
|
9609
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
9610
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
9611
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
9612
|
+
}
|
|
9613
|
+
}
|
|
9614
|
+
|
|
9615
|
+
function stroke(stroke, ui, canvas, renderOptions) {
|
|
9616
|
+
const data = ui.__;
|
|
9617
|
+
if (!data.__strokeWidth) return;
|
|
9618
|
+
if (data.__font) {
|
|
9619
|
+
Paint.strokeText(stroke, ui, canvas, renderOptions);
|
|
9620
|
+
} else {
|
|
9621
|
+
switch (data.strokeAlign) {
|
|
9622
|
+
case "center":
|
|
9623
|
+
drawCenter$1(stroke, 1, ui, canvas, renderOptions);
|
|
9624
|
+
break;
|
|
9625
|
+
|
|
9626
|
+
case "inside":
|
|
9627
|
+
drawInside(stroke, ui, canvas, renderOptions);
|
|
9628
|
+
break;
|
|
9629
|
+
|
|
9630
|
+
case "outside":
|
|
9631
|
+
drawOutside(stroke, ui, canvas, renderOptions);
|
|
9632
|
+
break;
|
|
9589
9633
|
}
|
|
9590
9634
|
}
|
|
9591
9635
|
}
|
|
9592
9636
|
|
|
9593
|
-
function
|
|
9594
|
-
|
|
9637
|
+
function strokes(strokes, ui, canvas, renderOptions) {
|
|
9638
|
+
Paint.stroke(strokes, ui, canvas, renderOptions);
|
|
9639
|
+
}
|
|
9640
|
+
|
|
9641
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9642
|
+
const data = ui.__;
|
|
9643
|
+
if (isObject(stroke)) {
|
|
9644
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
|
|
9645
|
+
} else {
|
|
9646
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9647
|
+
canvas.stroke();
|
|
9648
|
+
}
|
|
9649
|
+
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
|
|
9650
|
+
}
|
|
9651
|
+
|
|
9652
|
+
function drawInside(stroke, ui, canvas, renderOptions) {
|
|
9653
|
+
canvas.save();
|
|
9654
|
+
canvas.clipUI(ui);
|
|
9655
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9656
|
+
canvas.restore();
|
|
9657
|
+
}
|
|
9658
|
+
|
|
9659
|
+
function drawOutside(stroke, ui, canvas, renderOptions) {
|
|
9660
|
+
const data = ui.__;
|
|
9661
|
+
if (data.__fillAfterStroke) {
|
|
9662
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9663
|
+
} else {
|
|
9664
|
+
const {renderBounds: renderBounds} = ui.__layout;
|
|
9665
|
+
const out = canvas.getSameCanvas(true, true);
|
|
9666
|
+
ui.__drawRenderPath(out);
|
|
9667
|
+
drawCenter$1(stroke, 2, ui, out, renderOptions);
|
|
9668
|
+
out.clipUI(data);
|
|
9669
|
+
out.clearWorld(renderBounds);
|
|
9670
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9671
|
+
out.recycle(ui.__nowWorld);
|
|
9672
|
+
}
|
|
9595
9673
|
}
|
|
9596
9674
|
|
|
9597
|
-
function strokeText(stroke, ui, canvas) {
|
|
9675
|
+
function strokeText(stroke, ui, canvas, renderOptions) {
|
|
9598
9676
|
switch (ui.__.strokeAlign) {
|
|
9599
9677
|
case "center":
|
|
9600
|
-
drawCenter
|
|
9678
|
+
drawCenter(stroke, 1, ui, canvas, renderOptions);
|
|
9601
9679
|
break;
|
|
9602
9680
|
|
|
9603
9681
|
case "inside":
|
|
9604
|
-
drawAlign(stroke, "inside", ui, canvas);
|
|
9682
|
+
drawAlign(stroke, "inside", ui, canvas, renderOptions);
|
|
9605
9683
|
break;
|
|
9606
9684
|
|
|
9607
9685
|
case "outside":
|
|
9608
|
-
ui.__.__fillAfterStroke ? drawCenter
|
|
9686
|
+
ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
|
|
9609
9687
|
break;
|
|
9610
9688
|
}
|
|
9611
9689
|
}
|
|
9612
9690
|
|
|
9613
|
-
function drawCenter
|
|
9691
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9614
9692
|
const data = ui.__;
|
|
9615
9693
|
if (isObject(stroke)) {
|
|
9616
|
-
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
9694
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
|
|
9617
9695
|
} else {
|
|
9618
9696
|
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9619
|
-
drawTextStroke(ui, canvas);
|
|
9697
|
+
Paint.drawTextStroke(ui, canvas, renderOptions);
|
|
9620
9698
|
}
|
|
9621
9699
|
}
|
|
9622
9700
|
|
|
9623
|
-
function drawAlign(stroke, align, ui, canvas) {
|
|
9701
|
+
function drawAlign(stroke, align, ui, canvas, renderOptions) {
|
|
9624
9702
|
const out = canvas.getSameCanvas(true, true);
|
|
9625
9703
|
out.font = ui.__.__font;
|
|
9626
|
-
drawCenter
|
|
9704
|
+
drawCenter(stroke, 2, ui, out, renderOptions);
|
|
9627
9705
|
out.blendMode = align === "outside" ? "destination-out" : "destination-in";
|
|
9628
|
-
fillText(ui, out);
|
|
9706
|
+
Paint.fillText(ui, out, renderOptions);
|
|
9629
9707
|
out.blendMode = "normal";
|
|
9630
9708
|
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9631
9709
|
out.recycle(ui.__nowWorld);
|
|
9632
9710
|
}
|
|
9633
9711
|
|
|
9634
|
-
function drawTextStroke(ui, canvas) {
|
|
9712
|
+
function drawTextStroke(ui, canvas, _renderOptions) {
|
|
9635
9713
|
let row, data = ui.__.__textDrawData;
|
|
9636
9714
|
const {rows: rows, decorationY: decorationY} = data;
|
|
9637
9715
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
@@ -9646,89 +9724,29 @@ function drawTextStroke(ui, canvas) {
|
|
|
9646
9724
|
}
|
|
9647
9725
|
}
|
|
9648
9726
|
|
|
9649
|
-
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
9727
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
|
|
9650
9728
|
let item;
|
|
9651
9729
|
const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
|
|
9652
9730
|
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
9653
9731
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
9654
9732
|
item = strokes[i];
|
|
9655
|
-
if (item.image && PaintImage.checkImage(ui, canvas,
|
|
9733
|
+
if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
|
|
9656
9734
|
if (item.style) {
|
|
9657
9735
|
if (__hasMultiStrokeStyle) {
|
|
9658
9736
|
const {strokeStyle: strokeStyle} = item;
|
|
9659
9737
|
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
9660
9738
|
} else canvas.strokeStyle = item.style;
|
|
9661
|
-
if (item.blendMode) {
|
|
9662
|
-
canvas.saveBlendMode(item.blendMode);
|
|
9663
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9739
|
+
if (item.originPaint.blendMode) {
|
|
9740
|
+
canvas.saveBlendMode(item.originPaint.blendMode);
|
|
9741
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9664
9742
|
canvas.restoreBlendMode();
|
|
9665
9743
|
} else {
|
|
9666
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9744
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9667
9745
|
}
|
|
9668
9746
|
}
|
|
9669
9747
|
}
|
|
9670
9748
|
}
|
|
9671
9749
|
|
|
9672
|
-
function stroke(stroke, ui, canvas) {
|
|
9673
|
-
const data = ui.__;
|
|
9674
|
-
if (!data.__strokeWidth) return;
|
|
9675
|
-
if (data.__font) {
|
|
9676
|
-
strokeText(stroke, ui, canvas);
|
|
9677
|
-
} else {
|
|
9678
|
-
switch (data.strokeAlign) {
|
|
9679
|
-
case "center":
|
|
9680
|
-
drawCenter(stroke, 1, ui, canvas);
|
|
9681
|
-
break;
|
|
9682
|
-
|
|
9683
|
-
case "inside":
|
|
9684
|
-
drawInside(stroke, ui, canvas);
|
|
9685
|
-
break;
|
|
9686
|
-
|
|
9687
|
-
case "outside":
|
|
9688
|
-
drawOutside(stroke, ui, canvas);
|
|
9689
|
-
break;
|
|
9690
|
-
}
|
|
9691
|
-
}
|
|
9692
|
-
}
|
|
9693
|
-
|
|
9694
|
-
function strokes(strokes, ui, canvas) {
|
|
9695
|
-
stroke(strokes, ui, canvas);
|
|
9696
|
-
}
|
|
9697
|
-
|
|
9698
|
-
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
9699
|
-
const data = ui.__;
|
|
9700
|
-
if (isObject(stroke)) {
|
|
9701
|
-
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
9702
|
-
} else {
|
|
9703
|
-
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9704
|
-
canvas.stroke();
|
|
9705
|
-
}
|
|
9706
|
-
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas);
|
|
9707
|
-
}
|
|
9708
|
-
|
|
9709
|
-
function drawInside(stroke, ui, canvas) {
|
|
9710
|
-
canvas.save();
|
|
9711
|
-
canvas.clipUI(ui);
|
|
9712
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
9713
|
-
canvas.restore();
|
|
9714
|
-
}
|
|
9715
|
-
|
|
9716
|
-
function drawOutside(stroke, ui, canvas) {
|
|
9717
|
-
const data = ui.__;
|
|
9718
|
-
if (data.__fillAfterStroke) {
|
|
9719
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
9720
|
-
} else {
|
|
9721
|
-
const {renderBounds: renderBounds} = ui.__layout;
|
|
9722
|
-
const out = canvas.getSameCanvas(true, true);
|
|
9723
|
-
ui.__drawRenderPath(out);
|
|
9724
|
-
drawCenter(stroke, 2, ui, out);
|
|
9725
|
-
out.clipUI(data);
|
|
9726
|
-
out.clearWorld(renderBounds);
|
|
9727
|
-
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9728
|
-
out.recycle(ui.__nowWorld);
|
|
9729
|
-
}
|
|
9730
|
-
}
|
|
9731
|
-
|
|
9732
9750
|
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
9733
9751
|
|
|
9734
9752
|
const tempBounds$1 = {};
|
|
@@ -9816,62 +9834,63 @@ function compute(attrName, ui) {
|
|
|
9816
9834
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
9817
9835
|
isTransparent = true;
|
|
9818
9836
|
}
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9837
|
+
if (attrName === "fill") {
|
|
9838
|
+
stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
|
|
9839
|
+
stintSet(data, "__isTransparentFill", isTransparent);
|
|
9840
|
+
} else {
|
|
9841
|
+
stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
|
|
9842
|
+
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
9843
|
+
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
9844
|
+
}
|
|
9823
9845
|
} else {
|
|
9824
|
-
|
|
9825
|
-
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
9826
|
-
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
9846
|
+
data.__removePaint(attrName, false);
|
|
9827
9847
|
}
|
|
9828
9848
|
}
|
|
9829
9849
|
|
|
9830
9850
|
function getLeafPaint(attrName, paint, ui) {
|
|
9831
9851
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
9832
|
-
let
|
|
9852
|
+
let leafPaint;
|
|
9833
9853
|
const {boxBounds: boxBounds} = ui.__layout;
|
|
9834
9854
|
switch (paint.type) {
|
|
9835
9855
|
case "image":
|
|
9836
|
-
|
|
9856
|
+
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
9837
9857
|
break;
|
|
9838
9858
|
|
|
9839
9859
|
case "linear":
|
|
9840
|
-
|
|
9860
|
+
leafPaint = PaintGradient.linearGradient(paint, boxBounds);
|
|
9841
9861
|
break;
|
|
9842
9862
|
|
|
9843
9863
|
case "radial":
|
|
9844
|
-
|
|
9864
|
+
leafPaint = PaintGradient.radialGradient(paint, boxBounds);
|
|
9845
9865
|
break;
|
|
9846
9866
|
|
|
9847
9867
|
case "angular":
|
|
9848
|
-
|
|
9868
|
+
leafPaint = PaintGradient.conicGradient(paint, boxBounds);
|
|
9849
9869
|
break;
|
|
9850
9870
|
|
|
9851
9871
|
case "solid":
|
|
9852
9872
|
const {type: type, color: color, opacity: opacity} = paint;
|
|
9853
|
-
|
|
9873
|
+
leafPaint = {
|
|
9854
9874
|
type: type,
|
|
9855
9875
|
style: ColorConvert.string(color, opacity)
|
|
9856
9876
|
};
|
|
9857
9877
|
break;
|
|
9858
9878
|
|
|
9859
9879
|
default:
|
|
9860
|
-
if (!isUndefined(paint.r))
|
|
9880
|
+
if (!isUndefined(paint.r)) leafPaint = {
|
|
9861
9881
|
type: "solid",
|
|
9862
9882
|
style: ColorConvert.string(paint)
|
|
9863
9883
|
};
|
|
9864
9884
|
}
|
|
9865
|
-
if (
|
|
9866
|
-
|
|
9885
|
+
if (leafPaint) {
|
|
9886
|
+
leafPaint.originPaint = paint;
|
|
9887
|
+
if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
|
|
9867
9888
|
if (paint.style) {
|
|
9868
9889
|
if (paint.style.strokeWidth === 0) return undefined;
|
|
9869
|
-
|
|
9890
|
+
leafPaint.strokeStyle = paint.style;
|
|
9870
9891
|
}
|
|
9871
|
-
if (paint.editing) data.editing = paint.editing;
|
|
9872
|
-
if (paint.blendMode) data.blendMode = paint.blendMode;
|
|
9873
9892
|
}
|
|
9874
|
-
return
|
|
9893
|
+
return leafPaint;
|
|
9875
9894
|
}
|
|
9876
9895
|
|
|
9877
9896
|
const PaintModule = {
|
|
@@ -9884,88 +9903,118 @@ const PaintModule = {
|
|
|
9884
9903
|
strokes: strokes,
|
|
9885
9904
|
strokeText: strokeText,
|
|
9886
9905
|
drawTextStroke: drawTextStroke,
|
|
9906
|
+
drawStrokesStyle: drawStrokesStyle,
|
|
9887
9907
|
shape: shape
|
|
9888
9908
|
};
|
|
9889
9909
|
|
|
9890
|
-
let
|
|
9891
|
-
|
|
9892
|
-
const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
9893
|
-
|
|
9894
|
-
function stretchMode(data, box, scaleX, scaleY) {
|
|
9895
|
-
const transform = get$3();
|
|
9896
|
-
translate$1(transform, box.x, box.y);
|
|
9897
|
-
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
9898
|
-
data.transform = transform;
|
|
9899
|
-
}
|
|
9910
|
+
let cache, box = new Bounds;
|
|
9900
9911
|
|
|
9901
|
-
|
|
9902
|
-
const transform = get$3();
|
|
9903
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
9904
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
9905
|
-
if (rotation) rotateOfOuter$1(transform, {
|
|
9906
|
-
x: box.x + box.width / 2,
|
|
9907
|
-
y: box.y + box.height / 2
|
|
9908
|
-
}, rotation);
|
|
9909
|
-
data.transform = transform;
|
|
9910
|
-
}
|
|
9912
|
+
const {isSame: isSame} = BoundsHelper;
|
|
9911
9913
|
|
|
9912
|
-
function
|
|
9913
|
-
|
|
9914
|
-
|
|
9915
|
-
if (
|
|
9916
|
-
|
|
9917
|
-
set(tempMatrix$1);
|
|
9918
|
-
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
9919
|
-
multiplyParent(transform, tempMatrix$1);
|
|
9920
|
-
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
9921
|
-
}
|
|
9922
|
-
data.transform = transform;
|
|
9923
|
-
}
|
|
9924
|
-
|
|
9925
|
-
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
9926
|
-
const transform = get$3();
|
|
9927
|
-
if (freeTransform) {
|
|
9928
|
-
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9914
|
+
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
9915
|
+
let leafPaint, event;
|
|
9916
|
+
const image = ImageManager.get(paint);
|
|
9917
|
+
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
9918
|
+
leafPaint = cache.leafPaint;
|
|
9929
9919
|
} else {
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9920
|
+
leafPaint = {
|
|
9921
|
+
type: paint.type,
|
|
9922
|
+
image: image
|
|
9923
|
+
};
|
|
9924
|
+
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
9925
|
+
cache = image.use > 1 ? {
|
|
9926
|
+
leafPaint: leafPaint,
|
|
9927
|
+
paint: paint,
|
|
9928
|
+
boxBounds: box.set(boxBounds)
|
|
9929
|
+
} : null;
|
|
9930
|
+
}
|
|
9931
|
+
if (firstUse || image.loading) event = {
|
|
9932
|
+
image: image,
|
|
9933
|
+
attrName: attrName,
|
|
9934
|
+
attrValue: paint
|
|
9935
|
+
};
|
|
9936
|
+
if (image.ready) {
|
|
9937
|
+
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
9938
|
+
if (firstUse) {
|
|
9939
|
+
onLoad(ui, event);
|
|
9940
|
+
onLoadSuccess(ui, event);
|
|
9941
|
+
}
|
|
9942
|
+
} else if (image.error) {
|
|
9943
|
+
if (firstUse) onLoadError(ui, event, image.error);
|
|
9944
|
+
} else {
|
|
9945
|
+
if (firstUse) {
|
|
9946
|
+
ignoreRender(ui, true);
|
|
9947
|
+
onLoad(ui, event);
|
|
9948
|
+
}
|
|
9949
|
+
leafPaint.loadId = image.load(() => {
|
|
9950
|
+
ignoreRender(ui, false);
|
|
9951
|
+
if (!ui.destroyed) {
|
|
9952
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
9953
|
+
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
9954
|
+
ui.forceUpdate("surface");
|
|
9955
|
+
}
|
|
9956
|
+
onLoadSuccess(ui, event);
|
|
9957
|
+
}
|
|
9958
|
+
leafPaint.loadId = undefined;
|
|
9959
|
+
}, error => {
|
|
9960
|
+
ignoreRender(ui, false);
|
|
9961
|
+
onLoadError(ui, event, error);
|
|
9962
|
+
leafPaint.loadId = undefined;
|
|
9963
|
+
});
|
|
9964
|
+
if (ui.placeholderColor) {
|
|
9965
|
+
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
9966
|
+
if (!image.ready) {
|
|
9967
|
+
image.isPlacehold = true;
|
|
9968
|
+
ui.forceUpdate("surface");
|
|
9950
9969
|
}
|
|
9970
|
+
}, ui.placeholderDelay);
|
|
9971
|
+
}
|
|
9972
|
+
}
|
|
9973
|
+
return leafPaint;
|
|
9974
|
+
}
|
|
9975
|
+
|
|
9976
|
+
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
9977
|
+
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
9978
|
+
const data = ui.__;
|
|
9979
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
9980
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
9981
|
+
if (data.__autoSide) {
|
|
9982
|
+
ui.forceUpdate("width");
|
|
9983
|
+
if (ui.__proxyData) {
|
|
9984
|
+
ui.setProxyAttr("width", data.width);
|
|
9985
|
+
ui.setProxyAttr("height", data.height);
|
|
9951
9986
|
}
|
|
9987
|
+
return false;
|
|
9952
9988
|
}
|
|
9953
|
-
origin.x = box.x + x;
|
|
9954
|
-
origin.y = box.y + y;
|
|
9955
|
-
translate$1(transform, origin.x, origin.y);
|
|
9956
|
-
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
9957
9989
|
}
|
|
9958
|
-
data.
|
|
9990
|
+
if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
9991
|
+
return true;
|
|
9959
9992
|
}
|
|
9960
9993
|
|
|
9961
|
-
function
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9994
|
+
function onLoad(ui, event) {
|
|
9995
|
+
emit(ui, ImageEvent.LOAD, event);
|
|
9996
|
+
}
|
|
9997
|
+
|
|
9998
|
+
function onLoadSuccess(ui, event) {
|
|
9999
|
+
emit(ui, ImageEvent.LOADED, event);
|
|
10000
|
+
}
|
|
10001
|
+
|
|
10002
|
+
function onLoadError(ui, event, error) {
|
|
10003
|
+
event.error = error;
|
|
10004
|
+
ui.forceUpdate("surface");
|
|
10005
|
+
emit(ui, ImageEvent.ERROR, event);
|
|
10006
|
+
}
|
|
10007
|
+
|
|
10008
|
+
function emit(ui, type, data) {
|
|
10009
|
+
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
9966
10010
|
}
|
|
9967
10011
|
|
|
9968
|
-
|
|
10012
|
+
function ignoreRender(ui, value) {
|
|
10013
|
+
const {leafer: leafer} = ui;
|
|
10014
|
+
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
10015
|
+
}
|
|
10016
|
+
|
|
10017
|
+
const {get: get$3, translate: translate$1} = MatrixHelper;
|
|
9969
10018
|
|
|
9970
10019
|
const tempBox = new Bounds;
|
|
9971
10020
|
|
|
@@ -9974,17 +10023,13 @@ const tempScaleData = {};
|
|
|
9974
10023
|
const tempImage = {};
|
|
9975
10024
|
|
|
9976
10025
|
function createData(leafPaint, image, paint, box) {
|
|
9977
|
-
|
|
9978
|
-
if (changeful) leafPaint.changeful = changeful;
|
|
9979
|
-
if (sync) leafPaint.sync = sync;
|
|
9980
|
-
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
9981
|
-
leafPaint.data = getPatternData(paint, box, image);
|
|
10026
|
+
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
9982
10027
|
}
|
|
9983
10028
|
|
|
9984
10029
|
function getPatternData(paint, box, image) {
|
|
9985
10030
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
9986
10031
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
9987
|
-
|
|
10032
|
+
const {width: width, height: height} = image;
|
|
9988
10033
|
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;
|
|
9989
10034
|
const sameBox = box.width === width && box.height === height;
|
|
9990
10035
|
const data = {
|
|
@@ -10015,8 +10060,8 @@ function getPatternData(paint, box, image) {
|
|
|
10015
10060
|
case "stretch":
|
|
10016
10061
|
if (!sameBox) {
|
|
10017
10062
|
scaleX = box.width / width, scaleY = box.height / height;
|
|
10018
|
-
stretchMode(data, box, scaleX, scaleY);
|
|
10019
|
-
}
|
|
10063
|
+
PaintImage.stretchMode(data, box, scaleX, scaleY);
|
|
10064
|
+
} else if (scaleX) scaleX = scaleY = undefined;
|
|
10020
10065
|
break;
|
|
10021
10066
|
|
|
10022
10067
|
case "normal":
|
|
@@ -10024,13 +10069,13 @@ function getPatternData(paint, box, image) {
|
|
|
10024
10069
|
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
10025
10070
|
let clipScaleX, clipScaleY;
|
|
10026
10071
|
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
|
|
10027
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
10072
|
+
PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
10028
10073
|
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
10029
10074
|
}
|
|
10030
10075
|
break;
|
|
10031
10076
|
|
|
10032
10077
|
case "repeat":
|
|
10033
|
-
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
10078
|
+
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
10034
10079
|
if (!repeat) data.repeat = "repeat";
|
|
10035
10080
|
const count = isObject(repeat);
|
|
10036
10081
|
if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
|
|
@@ -10039,18 +10084,16 @@ function getPatternData(paint, box, image) {
|
|
|
10039
10084
|
case "fit":
|
|
10040
10085
|
case "cover":
|
|
10041
10086
|
default:
|
|
10042
|
-
if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
10087
|
+
if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
10043
10088
|
}
|
|
10044
10089
|
if (!data.transform) {
|
|
10045
|
-
if (box.x || box.y) translate(data.transform = get$
|
|
10090
|
+
if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
|
|
10046
10091
|
}
|
|
10047
|
-
data.width = width;
|
|
10048
|
-
data.height = height;
|
|
10049
10092
|
if (scaleX) {
|
|
10050
10093
|
data.scaleX = scaleX;
|
|
10051
10094
|
data.scaleY = scaleY;
|
|
10052
10095
|
}
|
|
10053
|
-
if (opacity) data.opacity = opacity;
|
|
10096
|
+
if (opacity && opacity < 1) data.opacity = opacity;
|
|
10054
10097
|
if (filters) data.filters = filters;
|
|
10055
10098
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
10056
10099
|
return data;
|
|
@@ -10072,234 +10115,194 @@ function getGapValue(gap, size, totalSize, rows) {
|
|
|
10072
10115
|
return gap === "auto" ? value < 0 ? 0 : value : value;
|
|
10073
10116
|
}
|
|
10074
10117
|
|
|
10075
|
-
let
|
|
10118
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
10076
10119
|
|
|
10077
|
-
const {
|
|
10120
|
+
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
10078
10121
|
|
|
10079
|
-
function
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
} else {
|
|
10085
|
-
leafPaint = {
|
|
10086
|
-
type: paint.type,
|
|
10087
|
-
image: image
|
|
10088
|
-
};
|
|
10089
|
-
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
10090
|
-
cache = image.use > 1 ? {
|
|
10091
|
-
leafPaint: leafPaint,
|
|
10092
|
-
paint: paint,
|
|
10093
|
-
boxBounds: box.set(boxBounds)
|
|
10094
|
-
} : null;
|
|
10095
|
-
}
|
|
10096
|
-
if (firstUse || image.loading) event = {
|
|
10097
|
-
image: image,
|
|
10098
|
-
attrName: attrName,
|
|
10099
|
-
attrValue: paint
|
|
10100
|
-
};
|
|
10101
|
-
if (image.ready) {
|
|
10102
|
-
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
10103
|
-
if (firstUse) {
|
|
10104
|
-
onLoad(ui, event);
|
|
10105
|
-
onLoadSuccess(ui, event);
|
|
10106
|
-
}
|
|
10107
|
-
} else if (image.error) {
|
|
10108
|
-
if (firstUse) onLoadError(ui, event, image.error);
|
|
10109
|
-
} else {
|
|
10110
|
-
if (firstUse) {
|
|
10111
|
-
ignoreRender(ui, true);
|
|
10112
|
-
onLoad(ui, event);
|
|
10113
|
-
}
|
|
10114
|
-
leafPaint.loadId = image.load(() => {
|
|
10115
|
-
ignoreRender(ui, false);
|
|
10116
|
-
if (!ui.destroyed) {
|
|
10117
|
-
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
10118
|
-
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
10119
|
-
ui.forceUpdate("surface");
|
|
10120
|
-
}
|
|
10121
|
-
onLoadSuccess(ui, event);
|
|
10122
|
-
}
|
|
10123
|
-
leafPaint.loadId = undefined;
|
|
10124
|
-
}, error => {
|
|
10125
|
-
ignoreRender(ui, false);
|
|
10126
|
-
onLoadError(ui, event, error);
|
|
10127
|
-
leafPaint.loadId = undefined;
|
|
10128
|
-
});
|
|
10129
|
-
if (ui.placeholderColor) {
|
|
10130
|
-
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
10131
|
-
if (!image.ready) {
|
|
10132
|
-
image.isPlacehold = true;
|
|
10133
|
-
ui.forceUpdate("surface");
|
|
10134
|
-
}
|
|
10135
|
-
}, ui.placeholderDelay);
|
|
10136
|
-
}
|
|
10137
|
-
}
|
|
10138
|
-
return leafPaint;
|
|
10122
|
+
function stretchMode(data, box, scaleX, scaleY) {
|
|
10123
|
+
const transform = get$2(), {x: x, y: y} = box;
|
|
10124
|
+
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
10125
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
10126
|
+
data.transform = transform;
|
|
10139
10127
|
}
|
|
10140
10128
|
|
|
10141
|
-
function
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
ui.setProxyAttr("height", data.height);
|
|
10151
|
-
}
|
|
10152
|
-
return false;
|
|
10153
|
-
}
|
|
10154
|
-
}
|
|
10155
|
-
if (!leafPaint.data) createData(leafPaint, image, paint, boxBounds);
|
|
10156
|
-
return true;
|
|
10129
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10130
|
+
const transform = get$2();
|
|
10131
|
+
translate(transform, box.x + x, box.y + y);
|
|
10132
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
10133
|
+
if (rotation) rotateOfOuter$1(transform, {
|
|
10134
|
+
x: box.x + box.width / 2,
|
|
10135
|
+
y: box.y + box.height / 2
|
|
10136
|
+
}, rotation);
|
|
10137
|
+
data.transform = transform;
|
|
10157
10138
|
}
|
|
10158
10139
|
|
|
10159
|
-
function
|
|
10160
|
-
|
|
10140
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
10141
|
+
const transform = get$2();
|
|
10142
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
10143
|
+
if (clipScaleX) {
|
|
10144
|
+
if (rotation || skew) {
|
|
10145
|
+
set(tempMatrix$1);
|
|
10146
|
+
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
10147
|
+
multiplyParent(transform, tempMatrix$1);
|
|
10148
|
+
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
10149
|
+
}
|
|
10150
|
+
data.transform = transform;
|
|
10161
10151
|
}
|
|
10162
10152
|
|
|
10163
|
-
function
|
|
10164
|
-
|
|
10165
|
-
|
|
10153
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
10154
|
+
const transform = get$2();
|
|
10155
|
+
if (freeTransform) {
|
|
10156
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
10157
|
+
} else {
|
|
10158
|
+
if (rotation) {
|
|
10159
|
+
if (align === "center") {
|
|
10160
|
+
rotateOfOuter$1(transform, {
|
|
10161
|
+
x: width / 2,
|
|
10162
|
+
y: height / 2
|
|
10163
|
+
}, rotation);
|
|
10164
|
+
} else {
|
|
10165
|
+
rotate(transform, rotation);
|
|
10166
|
+
switch (rotation) {
|
|
10167
|
+
case 90:
|
|
10168
|
+
translate(transform, height, 0);
|
|
10169
|
+
break;
|
|
10166
10170
|
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
emit(ui, ImageEvent.ERROR, event);
|
|
10171
|
-
}
|
|
10171
|
+
case 180:
|
|
10172
|
+
translate(transform, width, height);
|
|
10173
|
+
break;
|
|
10172
10174
|
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
+
case 270:
|
|
10176
|
+
translate(transform, 0, width);
|
|
10177
|
+
break;
|
|
10178
|
+
}
|
|
10179
|
+
}
|
|
10180
|
+
}
|
|
10181
|
+
origin.x = box.x + x;
|
|
10182
|
+
origin.y = box.y + y;
|
|
10183
|
+
translate(transform, origin.x, origin.y);
|
|
10184
|
+
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
10185
|
+
}
|
|
10186
|
+
data.transform = transform;
|
|
10175
10187
|
}
|
|
10176
10188
|
|
|
10177
|
-
function
|
|
10178
|
-
|
|
10179
|
-
if (
|
|
10189
|
+
function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
10190
|
+
if (rotation) rotate(transform, rotation);
|
|
10191
|
+
if (skew) skewHelper(transform, skew.x, skew.y);
|
|
10192
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
10193
|
+
translate(transform, box.x + x, box.y + y);
|
|
10180
10194
|
}
|
|
10181
10195
|
|
|
10182
10196
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
10183
10197
|
|
|
10184
|
-
const {
|
|
10198
|
+
const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
10199
|
+
|
|
10200
|
+
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
10201
|
+
if (!paint.patternTask) {
|
|
10202
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
10203
|
+
paint.patternTask = null;
|
|
10204
|
+
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
10205
|
+
ui.forceUpdate("surface");
|
|
10206
|
+
}), 300);
|
|
10207
|
+
}
|
|
10208
|
+
}
|
|
10185
10209
|
|
|
10186
|
-
function createPattern(ui,
|
|
10187
|
-
let {scaleX: scaleX, scaleY: scaleY} =
|
|
10188
|
-
const id = scaleX + "-" + scaleY + "-" + pixelRatio;
|
|
10210
|
+
function createPattern(paint, ui, canvas, renderOptions) {
|
|
10211
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
10189
10212
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
|
|
10200
|
-
scaleX
|
|
10201
|
-
|
|
10202
|
-
|
|
10203
|
-
width *= scaleX;
|
|
10204
|
-
height *= scaleY;
|
|
10205
|
-
const size = width * height;
|
|
10206
|
-
if (!repeat) {
|
|
10207
|
-
if (size > Platform.image.maxCacheSize) return false;
|
|
10208
|
-
}
|
|
10209
|
-
let maxSize = Platform.image.maxPatternSize;
|
|
10210
|
-
if (image.isSVG) {
|
|
10211
|
-
const ws = width / image.width;
|
|
10212
|
-
if (ws > 1) imageScale = ws / ceil(ws);
|
|
10213
|
-
} else {
|
|
10214
|
-
const imageSize = image.width * image.height;
|
|
10215
|
-
if (maxSize > imageSize) maxSize = imageSize;
|
|
10216
|
-
}
|
|
10217
|
-
if (size > maxSize) imageScale = Math.sqrt(size / maxSize);
|
|
10218
|
-
if (imageScale) {
|
|
10219
|
-
scaleX /= imageScale;
|
|
10220
|
-
scaleY /= imageScale;
|
|
10221
|
-
width /= imageScale;
|
|
10222
|
-
height /= imageScale;
|
|
10223
|
-
}
|
|
10224
|
-
if (sx) {
|
|
10225
|
-
scaleX /= sx;
|
|
10226
|
-
scaleY /= sy;
|
|
10227
|
-
}
|
|
10228
|
-
const xGap = gap && gap.x * scaleX;
|
|
10229
|
-
const yGap = gap && gap.y * scaleY;
|
|
10230
|
-
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10231
|
-
const canvasWidth = width + (xGap || 0);
|
|
10232
|
-
const canvasHeight = height + (yGap || 0);
|
|
10233
|
-
scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
|
|
10234
|
-
scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
|
|
10235
|
-
if (!imageMatrix) {
|
|
10213
|
+
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
10214
|
+
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
10215
|
+
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
10216
|
+
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
10217
|
+
width *= scaleX;
|
|
10218
|
+
height *= scaleY;
|
|
10219
|
+
if (gap) {
|
|
10220
|
+
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
10221
|
+
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
10222
|
+
}
|
|
10223
|
+
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10224
|
+
scaleX *= getFloorScale(width + (xGap || 0));
|
|
10225
|
+
scaleY *= getFloorScale(height + (yGap || 0));
|
|
10236
10226
|
imageMatrix = get$1();
|
|
10237
10227
|
if (transform) copy$1(imageMatrix, transform);
|
|
10228
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10238
10229
|
}
|
|
10239
|
-
|
|
10230
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
10231
|
+
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10232
|
+
paint.style = pattern;
|
|
10233
|
+
paint.patternId = id;
|
|
10240
10234
|
}
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10235
|
+
}
|
|
10236
|
+
}
|
|
10237
|
+
|
|
10238
|
+
function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
10239
|
+
const {image: image} = paint;
|
|
10240
|
+
let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
|
|
10241
|
+
if (image.isSVG) {
|
|
10242
|
+
if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
|
|
10246
10243
|
} else {
|
|
10247
|
-
|
|
10244
|
+
if (maxSize > imageSize) maxSize = imageSize;
|
|
10248
10245
|
}
|
|
10246
|
+
if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
|
|
10247
|
+
return fixScale;
|
|
10249
10248
|
}
|
|
10250
10249
|
|
|
10251
|
-
function checkImage(ui, canvas,
|
|
10252
|
-
const {scaleX: scaleX, scaleY: scaleY} =
|
|
10253
|
-
const {
|
|
10254
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY
|
|
10250
|
+
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
10251
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
10252
|
+
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
|
|
10253
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
10255
10254
|
return false;
|
|
10256
10255
|
} else {
|
|
10257
|
-
if (
|
|
10256
|
+
if (drawImage) {
|
|
10258
10257
|
if (data.repeat) {
|
|
10259
|
-
|
|
10260
|
-
} else if (!(
|
|
10261
|
-
|
|
10262
|
-
width *= scaleX * pixelRatio;
|
|
10263
|
-
height *= scaleY * pixelRatio;
|
|
10264
|
-
if (data.scaleX) {
|
|
10265
|
-
width *= data.scaleX;
|
|
10266
|
-
height *= data.scaleY;
|
|
10267
|
-
}
|
|
10268
|
-
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
10258
|
+
drawImage = false;
|
|
10259
|
+
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
10260
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
10269
10261
|
}
|
|
10270
10262
|
}
|
|
10271
|
-
if (
|
|
10263
|
+
if (drawImage) {
|
|
10272
10264
|
if (ui.__.__isFastShadow) {
|
|
10273
10265
|
canvas.fillStyle = paint.style || "#000";
|
|
10274
10266
|
canvas.fill();
|
|
10275
10267
|
}
|
|
10276
|
-
drawImage(ui, canvas,
|
|
10268
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
10277
10269
|
return true;
|
|
10278
10270
|
} else {
|
|
10279
|
-
if (!paint.style ||
|
|
10280
|
-
createPattern(ui, paint, pixelRatio);
|
|
10281
|
-
} else {
|
|
10282
|
-
if (!paint.patternTask) {
|
|
10283
|
-
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
10284
|
-
paint.patternTask = null;
|
|
10285
|
-
if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio);
|
|
10286
|
-
ui.forceUpdate("surface");
|
|
10287
|
-
}), 300);
|
|
10288
|
-
}
|
|
10289
|
-
}
|
|
10271
|
+
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
10290
10272
|
return false;
|
|
10291
10273
|
}
|
|
10292
10274
|
}
|
|
10293
10275
|
}
|
|
10294
10276
|
|
|
10295
|
-
function drawImage(ui, canvas,
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
if (
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10277
|
+
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
10278
|
+
const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
10279
|
+
let {width: width, height: height} = image, clipUI;
|
|
10280
|
+
if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
|
|
10281
|
+
canvas.save();
|
|
10282
|
+
clipUI && canvas.clipUI(ui);
|
|
10283
|
+
blendMode && (canvas.blendMode = blendMode);
|
|
10284
|
+
opacity && (canvas.opacity *= opacity);
|
|
10285
|
+
transform && canvas.transform(transform);
|
|
10286
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
10287
|
+
canvas.restore();
|
|
10288
|
+
} else {
|
|
10289
|
+
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
10290
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
10291
|
+
}
|
|
10292
|
+
}
|
|
10293
|
+
|
|
10294
|
+
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
10295
|
+
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
10296
|
+
if (canvas) {
|
|
10297
|
+
const {pixelRatio: pixelRatio} = canvas;
|
|
10298
|
+
scaleData.scaleX *= pixelRatio;
|
|
10299
|
+
scaleData.scaleY *= pixelRatio;
|
|
10300
|
+
}
|
|
10301
|
+
if (data && data.scaleX) {
|
|
10302
|
+
scaleData.scaleX *= Math.abs(data.scaleX);
|
|
10303
|
+
scaleData.scaleY *= Math.abs(data.scaleY);
|
|
10304
|
+
}
|
|
10305
|
+
return scaleData;
|
|
10303
10306
|
}
|
|
10304
10307
|
|
|
10305
10308
|
function recycleImage(attrName, data) {
|
|
@@ -10331,8 +10334,12 @@ function recycleImage(attrName, data) {
|
|
|
10331
10334
|
const PaintImageModule = {
|
|
10332
10335
|
image: image,
|
|
10333
10336
|
checkImage: checkImage,
|
|
10334
|
-
|
|
10337
|
+
drawImage: drawImage,
|
|
10338
|
+
getImageRenderScaleData: getImageRenderScaleData,
|
|
10335
10339
|
recycleImage: recycleImage,
|
|
10340
|
+
createPatternTask: createPatternTask,
|
|
10341
|
+
createPattern: createPattern,
|
|
10342
|
+
getPatternFixScale: getPatternFixScale,
|
|
10336
10343
|
createData: createData,
|
|
10337
10344
|
getPatternData: getPatternData,
|
|
10338
10345
|
stretchMode: stretchMode,
|
|
@@ -10788,10 +10795,8 @@ function createRows(drawData, content, style) {
|
|
|
10788
10795
|
bounds = drawData.bounds;
|
|
10789
10796
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
10790
10797
|
const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
|
|
10791
|
-
const {canvas: canvas} = Platform;
|
|
10792
|
-
|
|
10793
|
-
const charMode = width || height || __letterSpacing || textCase !== "none";
|
|
10794
|
-
if (charMode) {
|
|
10798
|
+
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
10799
|
+
if (style.__isCharMode) {
|
|
10795
10800
|
const wrap = style.textWrap !== "none";
|
|
10796
10801
|
const breakAll = style.textWrap === "break";
|
|
10797
10802
|
paraStart = true;
|
|
@@ -10920,12 +10925,19 @@ const TextMode = 2;
|
|
|
10920
10925
|
function layoutChar(drawData, style, width, _height) {
|
|
10921
10926
|
const {rows: rows} = drawData;
|
|
10922
10927
|
const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
|
|
10923
|
-
|
|
10928
|
+
const justifyLast = width && textAlign.includes("both");
|
|
10929
|
+
const justify = justifyLast || width && textAlign.includes("justify");
|
|
10930
|
+
const justifyLetter = justify && textAlign.includes("letter");
|
|
10931
|
+
let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
|
|
10924
10932
|
rows.forEach(row => {
|
|
10925
10933
|
if (row.words) {
|
|
10926
10934
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
10927
|
-
|
|
10928
|
-
|
|
10935
|
+
if (justify) {
|
|
10936
|
+
canJustify = !row.paraEnd || justifyLast;
|
|
10937
|
+
remainingWidth = width - row.width - indentWidth;
|
|
10938
|
+
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
10939
|
+
}
|
|
10940
|
+
mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
10929
10941
|
if (row.isOverflow && !letterSpacing) row.textMode = true;
|
|
10930
10942
|
if (mode === TextMode) {
|
|
10931
10943
|
row.x += indentWidth;
|
|
@@ -10943,11 +10955,15 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
10943
10955
|
charX = toWordChar(word.data, charX, wordChar);
|
|
10944
10956
|
if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
|
|
10945
10957
|
} else {
|
|
10946
|
-
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
10958
|
+
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
10947
10959
|
}
|
|
10948
|
-
if (
|
|
10949
|
-
|
|
10950
|
-
|
|
10960
|
+
if (canJustify) {
|
|
10961
|
+
isLastWord = index === wordsLength - 1;
|
|
10962
|
+
if (addWordWidth) {
|
|
10963
|
+
if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
|
|
10964
|
+
} else if (addLetterWidth) {
|
|
10965
|
+
row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
|
|
10966
|
+
}
|
|
10951
10967
|
}
|
|
10952
10968
|
});
|
|
10953
10969
|
}
|
|
@@ -10973,13 +10989,14 @@ function toWordChar(data, charX, wordChar) {
|
|
|
10973
10989
|
return charX;
|
|
10974
10990
|
}
|
|
10975
10991
|
|
|
10976
|
-
function toChar(data, charX, rowData, isOverflow) {
|
|
10992
|
+
function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
|
|
10977
10993
|
data.forEach(char => {
|
|
10978
10994
|
if (isOverflow || char.char !== " ") {
|
|
10979
10995
|
char.x = charX;
|
|
10980
10996
|
rowData.push(char);
|
|
10981
10997
|
}
|
|
10982
10998
|
charX += char.width;
|
|
10999
|
+
addLetterWidth && (charX += addLetterWidth);
|
|
10983
11000
|
});
|
|
10984
11001
|
return charX;
|
|
10985
11002
|
}
|
|
@@ -11121,10 +11138,10 @@ function getDrawData(content, style) {
|
|
|
11121
11138
|
let x = 0, y = 0;
|
|
11122
11139
|
let width = style.__getInput("width") || 0;
|
|
11123
11140
|
let height = style.__getInput("height") || 0;
|
|
11124
|
-
const {
|
|
11141
|
+
const {__padding: padding} = style;
|
|
11125
11142
|
if (padding) {
|
|
11126
|
-
if (width) x = padding[left], width -= padding[right] + padding[left]; else if (!style.autoSizeAlign) x = padding[left];
|
|
11127
|
-
if (height) y = padding[top], height -= padding[top] + padding[bottom]; else if (!style.autoSizeAlign) y = padding[top];
|
|
11143
|
+
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
11144
|
+
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
11128
11145
|
}
|
|
11129
11146
|
const drawData = {
|
|
11130
11147
|
bounds: {
|
|
@@ -11135,14 +11152,14 @@ function getDrawData(content, style) {
|
|
|
11135
11152
|
},
|
|
11136
11153
|
rows: [],
|
|
11137
11154
|
paraNumber: 0,
|
|
11138
|
-
font: Platform.canvas.font = __font
|
|
11155
|
+
font: Platform.canvas.font = style.__font
|
|
11139
11156
|
};
|
|
11140
11157
|
createRows(drawData, content, style);
|
|
11141
11158
|
if (padding) padAutoText(padding, drawData, style, width, height);
|
|
11142
11159
|
layoutText(drawData, style);
|
|
11143
|
-
layoutChar(drawData, style, width);
|
|
11160
|
+
if (style.__isCharMode) layoutChar(drawData, style, width);
|
|
11144
11161
|
if (drawData.overflow) clipText(drawData, style, x, width);
|
|
11145
|
-
if (textDecoration !== "none") decorationText(drawData, style);
|
|
11162
|
+
if (style.textDecoration !== "none") decorationText(drawData, style);
|
|
11146
11163
|
return drawData;
|
|
11147
11164
|
}
|
|
11148
11165
|
|