@leafer-draw/worker 1.9.12 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.cjs +396 -394
- package/dist/worker.esm.js +398 -396
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +514 -499
- 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 +536 -517
- 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.0";
|
|
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(_image, 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,36 +9400,19 @@ 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) {
|
|
9408
|
+
function fills(fills, ui, canvas, renderOptions) {
|
|
9409
9409
|
let item;
|
|
9410
9410
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
9411
9411
|
item = fills[i];
|
|
9412
9412
|
if (item.image) {
|
|
9413
|
-
if (PaintImage.checkImage(
|
|
9413
|
+
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
9414
9414
|
if (!item.style) {
|
|
9415
|
-
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas,
|
|
9415
|
+
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
|
|
9416
9416
|
continue;
|
|
9417
9417
|
}
|
|
9418
9418
|
}
|
|
@@ -9425,60 +9425,137 @@ function fills(fills, ui, canvas) {
|
|
|
9425
9425
|
if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
9426
9426
|
}
|
|
9427
9427
|
if (item.blendMode) canvas.blendMode = item.blendMode;
|
|
9428
|
-
fillPathOrText(ui, canvas);
|
|
9428
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9429
9429
|
canvas.restore();
|
|
9430
9430
|
} else {
|
|
9431
9431
|
if (item.blendMode) {
|
|
9432
9432
|
canvas.saveBlendMode(item.blendMode);
|
|
9433
|
-
fillPathOrText(ui, canvas);
|
|
9433
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9434
9434
|
canvas.restoreBlendMode();
|
|
9435
|
-
} else fillPathOrText(ui, canvas);
|
|
9435
|
+
} else fillPathOrText(ui, canvas, renderOptions);
|
|
9436
|
+
}
|
|
9437
|
+
}
|
|
9438
|
+
}
|
|
9439
|
+
|
|
9440
|
+
function fillPathOrText(ui, canvas, renderOptions) {
|
|
9441
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
9442
|
+
}
|
|
9443
|
+
|
|
9444
|
+
function fillText(ui, canvas, _renderOptions) {
|
|
9445
|
+
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
9446
|
+
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
9447
|
+
let row;
|
|
9448
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
9449
|
+
row = rows[i];
|
|
9450
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
9451
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
9452
|
+
});
|
|
9453
|
+
}
|
|
9454
|
+
if (decorationY) {
|
|
9455
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
9456
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
9457
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
9458
|
+
}
|
|
9459
|
+
}
|
|
9460
|
+
|
|
9461
|
+
function stroke(stroke, ui, canvas, renderOptions) {
|
|
9462
|
+
const data = ui.__;
|
|
9463
|
+
if (!data.__strokeWidth) return;
|
|
9464
|
+
if (data.__font) {
|
|
9465
|
+
Paint.strokeText(stroke, ui, canvas, renderOptions);
|
|
9466
|
+
} else {
|
|
9467
|
+
switch (data.strokeAlign) {
|
|
9468
|
+
case "center":
|
|
9469
|
+
drawCenter$1(stroke, 1, ui, canvas, renderOptions);
|
|
9470
|
+
break;
|
|
9471
|
+
|
|
9472
|
+
case "inside":
|
|
9473
|
+
drawInside(stroke, ui, canvas, renderOptions);
|
|
9474
|
+
break;
|
|
9475
|
+
|
|
9476
|
+
case "outside":
|
|
9477
|
+
drawOutside(stroke, ui, canvas, renderOptions);
|
|
9478
|
+
break;
|
|
9436
9479
|
}
|
|
9437
9480
|
}
|
|
9438
9481
|
}
|
|
9439
9482
|
|
|
9440
|
-
function
|
|
9441
|
-
|
|
9483
|
+
function strokes(strokes, ui, canvas, renderOptions) {
|
|
9484
|
+
Paint.stroke(strokes, ui, canvas, renderOptions);
|
|
9485
|
+
}
|
|
9486
|
+
|
|
9487
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9488
|
+
const data = ui.__;
|
|
9489
|
+
if (isObject(stroke)) {
|
|
9490
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
|
|
9491
|
+
} else {
|
|
9492
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9493
|
+
canvas.stroke();
|
|
9494
|
+
}
|
|
9495
|
+
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
|
|
9496
|
+
}
|
|
9497
|
+
|
|
9498
|
+
function drawInside(stroke, ui, canvas, renderOptions) {
|
|
9499
|
+
canvas.save();
|
|
9500
|
+
canvas.clipUI(ui);
|
|
9501
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9502
|
+
canvas.restore();
|
|
9503
|
+
}
|
|
9504
|
+
|
|
9505
|
+
function drawOutside(stroke, ui, canvas, renderOptions) {
|
|
9506
|
+
const data = ui.__;
|
|
9507
|
+
if (data.__fillAfterStroke) {
|
|
9508
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9509
|
+
} else {
|
|
9510
|
+
const {renderBounds: renderBounds} = ui.__layout;
|
|
9511
|
+
const out = canvas.getSameCanvas(true, true);
|
|
9512
|
+
ui.__drawRenderPath(out);
|
|
9513
|
+
drawCenter$1(stroke, 2, ui, out, renderOptions);
|
|
9514
|
+
out.clipUI(data);
|
|
9515
|
+
out.clearWorld(renderBounds);
|
|
9516
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9517
|
+
out.recycle(ui.__nowWorld);
|
|
9518
|
+
}
|
|
9442
9519
|
}
|
|
9443
9520
|
|
|
9444
|
-
function strokeText(stroke, ui, canvas) {
|
|
9521
|
+
function strokeText(stroke, ui, canvas, renderOptions) {
|
|
9445
9522
|
switch (ui.__.strokeAlign) {
|
|
9446
9523
|
case "center":
|
|
9447
|
-
drawCenter
|
|
9524
|
+
drawCenter(stroke, 1, ui, canvas, renderOptions);
|
|
9448
9525
|
break;
|
|
9449
9526
|
|
|
9450
9527
|
case "inside":
|
|
9451
|
-
drawAlign(stroke, "inside", ui, canvas);
|
|
9528
|
+
drawAlign(stroke, "inside", ui, canvas, renderOptions);
|
|
9452
9529
|
break;
|
|
9453
9530
|
|
|
9454
9531
|
case "outside":
|
|
9455
|
-
ui.__.__fillAfterStroke ? drawCenter
|
|
9532
|
+
ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
|
|
9456
9533
|
break;
|
|
9457
9534
|
}
|
|
9458
9535
|
}
|
|
9459
9536
|
|
|
9460
|
-
function drawCenter
|
|
9537
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9461
9538
|
const data = ui.__;
|
|
9462
9539
|
if (isObject(stroke)) {
|
|
9463
|
-
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
9540
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
|
|
9464
9541
|
} else {
|
|
9465
9542
|
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9466
|
-
drawTextStroke(ui, canvas);
|
|
9543
|
+
Paint.drawTextStroke(ui, canvas, renderOptions);
|
|
9467
9544
|
}
|
|
9468
9545
|
}
|
|
9469
9546
|
|
|
9470
|
-
function drawAlign(stroke, align, ui, canvas) {
|
|
9547
|
+
function drawAlign(stroke, align, ui, canvas, renderOptions) {
|
|
9471
9548
|
const out = canvas.getSameCanvas(true, true);
|
|
9472
9549
|
out.font = ui.__.__font;
|
|
9473
|
-
drawCenter
|
|
9550
|
+
drawCenter(stroke, 2, ui, out, renderOptions);
|
|
9474
9551
|
out.blendMode = align === "outside" ? "destination-out" : "destination-in";
|
|
9475
|
-
fillText(ui, out);
|
|
9552
|
+
Paint.fillText(ui, out, renderOptions);
|
|
9476
9553
|
out.blendMode = "normal";
|
|
9477
9554
|
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9478
9555
|
out.recycle(ui.__nowWorld);
|
|
9479
9556
|
}
|
|
9480
9557
|
|
|
9481
|
-
function drawTextStroke(ui, canvas) {
|
|
9558
|
+
function drawTextStroke(ui, canvas, _renderOptions) {
|
|
9482
9559
|
let row, data = ui.__.__textDrawData;
|
|
9483
9560
|
const {rows: rows, decorationY: decorationY} = data;
|
|
9484
9561
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
@@ -9493,13 +9570,13 @@ function drawTextStroke(ui, canvas) {
|
|
|
9493
9570
|
}
|
|
9494
9571
|
}
|
|
9495
9572
|
|
|
9496
|
-
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
9573
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
|
|
9497
9574
|
let item;
|
|
9498
9575
|
const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
|
|
9499
9576
|
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
9500
9577
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
9501
9578
|
item = strokes[i];
|
|
9502
|
-
if (item.image && PaintImage.checkImage(ui, canvas,
|
|
9579
|
+
if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
|
|
9503
9580
|
if (item.style) {
|
|
9504
9581
|
if (__hasMultiStrokeStyle) {
|
|
9505
9582
|
const {strokeStyle: strokeStyle} = item;
|
|
@@ -9507,75 +9584,15 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
|
9507
9584
|
} else canvas.strokeStyle = item.style;
|
|
9508
9585
|
if (item.blendMode) {
|
|
9509
9586
|
canvas.saveBlendMode(item.blendMode);
|
|
9510
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9587
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9511
9588
|
canvas.restoreBlendMode();
|
|
9512
9589
|
} else {
|
|
9513
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9590
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9514
9591
|
}
|
|
9515
9592
|
}
|
|
9516
9593
|
}
|
|
9517
9594
|
}
|
|
9518
9595
|
|
|
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
9596
|
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
9580
9597
|
|
|
9581
9598
|
const tempBounds$1 = {};
|
|
@@ -9731,88 +9748,118 @@ const PaintModule = {
|
|
|
9731
9748
|
strokes: strokes,
|
|
9732
9749
|
strokeText: strokeText,
|
|
9733
9750
|
drawTextStroke: drawTextStroke,
|
|
9751
|
+
drawStrokesStyle: drawStrokesStyle,
|
|
9734
9752
|
shape: shape
|
|
9735
9753
|
};
|
|
9736
9754
|
|
|
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
|
-
}
|
|
9747
|
-
|
|
9748
|
-
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
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
|
-
}
|
|
9755
|
+
let cache, box = new Bounds;
|
|
9758
9756
|
|
|
9759
|
-
|
|
9760
|
-
const transform = get$3();
|
|
9761
|
-
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9762
|
-
if (clipScaleX) {
|
|
9763
|
-
if (rotation || skew) {
|
|
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
|
-
}
|
|
9757
|
+
const {isSame: isSame} = BoundsHelper;
|
|
9771
9758
|
|
|
9772
|
-
function
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
9759
|
+
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
9760
|
+
let leafPaint, event;
|
|
9761
|
+
const image = ImageManager.get(paint);
|
|
9762
|
+
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
9763
|
+
leafPaint = cache.leafPaint;
|
|
9764
|
+
} else {
|
|
9765
|
+
leafPaint = {
|
|
9766
|
+
type: paint.type,
|
|
9767
|
+
image: image
|
|
9768
|
+
};
|
|
9769
|
+
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
9770
|
+
cache = image.use > 1 ? {
|
|
9771
|
+
leafPaint: leafPaint,
|
|
9772
|
+
paint: paint,
|
|
9773
|
+
boxBounds: box.set(boxBounds)
|
|
9774
|
+
} : null;
|
|
9775
|
+
}
|
|
9776
|
+
if (firstUse || image.loading) event = {
|
|
9777
|
+
image: image,
|
|
9778
|
+
attrName: attrName,
|
|
9779
|
+
attrValue: paint
|
|
9780
|
+
};
|
|
9781
|
+
if (image.ready) {
|
|
9782
|
+
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
9783
|
+
if (firstUse) {
|
|
9784
|
+
onLoad(ui, event);
|
|
9785
|
+
onLoadSuccess(ui, event);
|
|
9786
|
+
}
|
|
9787
|
+
} else if (image.error) {
|
|
9788
|
+
if (firstUse) onLoadError(ui, event, image.error);
|
|
9789
|
+
} else {
|
|
9790
|
+
if (firstUse) {
|
|
9791
|
+
ignoreRender(ui, true);
|
|
9792
|
+
onLoad(ui, event);
|
|
9793
|
+
}
|
|
9794
|
+
leafPaint.loadId = image.load(() => {
|
|
9795
|
+
ignoreRender(ui, false);
|
|
9796
|
+
if (!ui.destroyed) {
|
|
9797
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
9798
|
+
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
9799
|
+
ui.forceUpdate("surface");
|
|
9797
9800
|
}
|
|
9801
|
+
onLoadSuccess(ui, event);
|
|
9798
9802
|
}
|
|
9803
|
+
leafPaint.loadId = undefined;
|
|
9804
|
+
}, error => {
|
|
9805
|
+
ignoreRender(ui, false);
|
|
9806
|
+
onLoadError(ui, event, error);
|
|
9807
|
+
leafPaint.loadId = undefined;
|
|
9808
|
+
});
|
|
9809
|
+
if (ui.placeholderColor) {
|
|
9810
|
+
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
9811
|
+
if (!image.ready) {
|
|
9812
|
+
image.isPlacehold = true;
|
|
9813
|
+
ui.forceUpdate("surface");
|
|
9814
|
+
}
|
|
9815
|
+
}, ui.placeholderDelay);
|
|
9799
9816
|
}
|
|
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
9817
|
}
|
|
9805
|
-
|
|
9818
|
+
return leafPaint;
|
|
9806
9819
|
}
|
|
9807
9820
|
|
|
9808
|
-
function
|
|
9809
|
-
if (
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9821
|
+
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
9822
|
+
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
9823
|
+
const data = ui.__;
|
|
9824
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
9825
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
9826
|
+
if (data.__autoSide) {
|
|
9827
|
+
ui.forceUpdate("width");
|
|
9828
|
+
if (ui.__proxyData) {
|
|
9829
|
+
ui.setProxyAttr("width", data.width);
|
|
9830
|
+
ui.setProxyAttr("height", data.height);
|
|
9831
|
+
}
|
|
9832
|
+
return false;
|
|
9833
|
+
}
|
|
9834
|
+
}
|
|
9835
|
+
if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
9836
|
+
return true;
|
|
9837
|
+
}
|
|
9838
|
+
|
|
9839
|
+
function onLoad(ui, event) {
|
|
9840
|
+
emit(ui, ImageEvent.LOAD, event);
|
|
9841
|
+
}
|
|
9842
|
+
|
|
9843
|
+
function onLoadSuccess(ui, event) {
|
|
9844
|
+
emit(ui, ImageEvent.LOADED, event);
|
|
9845
|
+
}
|
|
9846
|
+
|
|
9847
|
+
function onLoadError(ui, event, error) {
|
|
9848
|
+
event.error = error;
|
|
9849
|
+
ui.forceUpdate("surface");
|
|
9850
|
+
emit(ui, ImageEvent.ERROR, event);
|
|
9851
|
+
}
|
|
9852
|
+
|
|
9853
|
+
function emit(ui, type, data) {
|
|
9854
|
+
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
9813
9855
|
}
|
|
9814
9856
|
|
|
9815
|
-
|
|
9857
|
+
function ignoreRender(ui, value) {
|
|
9858
|
+
const {leafer: leafer} = ui;
|
|
9859
|
+
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
9860
|
+
}
|
|
9861
|
+
|
|
9862
|
+
const {get: get$3, translate: translate$1} = MatrixHelper;
|
|
9816
9863
|
|
|
9817
9864
|
const tempBox = new Bounds;
|
|
9818
9865
|
|
|
@@ -9825,13 +9872,13 @@ function createData(leafPaint, image, paint, box) {
|
|
|
9825
9872
|
if (changeful) leafPaint.changeful = changeful;
|
|
9826
9873
|
if (sync) leafPaint.sync = sync;
|
|
9827
9874
|
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
9828
|
-
leafPaint.data = getPatternData(paint, box, image);
|
|
9875
|
+
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
9829
9876
|
}
|
|
9830
9877
|
|
|
9831
9878
|
function getPatternData(paint, box, image) {
|
|
9832
9879
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
9833
9880
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
9834
|
-
|
|
9881
|
+
const {width: width, height: height} = image;
|
|
9835
9882
|
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
9883
|
const sameBox = box.width === width && box.height === height;
|
|
9837
9884
|
const data = {
|
|
@@ -9862,8 +9909,8 @@ function getPatternData(paint, box, image) {
|
|
|
9862
9909
|
case "stretch":
|
|
9863
9910
|
if (!sameBox) {
|
|
9864
9911
|
scaleX = box.width / width, scaleY = box.height / height;
|
|
9865
|
-
stretchMode(data, box, scaleX, scaleY);
|
|
9866
|
-
}
|
|
9912
|
+
PaintImage.stretchMode(data, box, scaleX, scaleY);
|
|
9913
|
+
} else if (scaleX) scaleX = scaleY = undefined;
|
|
9867
9914
|
break;
|
|
9868
9915
|
|
|
9869
9916
|
case "normal":
|
|
@@ -9871,13 +9918,13 @@ function getPatternData(paint, box, image) {
|
|
|
9871
9918
|
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
9872
9919
|
let clipScaleX, clipScaleY;
|
|
9873
9920
|
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);
|
|
9921
|
+
PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
9875
9922
|
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
9876
9923
|
}
|
|
9877
9924
|
break;
|
|
9878
9925
|
|
|
9879
9926
|
case "repeat":
|
|
9880
|
-
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
9927
|
+
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
9881
9928
|
if (!repeat) data.repeat = "repeat";
|
|
9882
9929
|
const count = isObject(repeat);
|
|
9883
9930
|
if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
|
|
@@ -9886,18 +9933,16 @@ function getPatternData(paint, box, image) {
|
|
|
9886
9933
|
case "fit":
|
|
9887
9934
|
case "cover":
|
|
9888
9935
|
default:
|
|
9889
|
-
if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9936
|
+
if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9890
9937
|
}
|
|
9891
9938
|
if (!data.transform) {
|
|
9892
|
-
if (box.x || box.y) translate(data.transform = get$
|
|
9939
|
+
if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
|
|
9893
9940
|
}
|
|
9894
|
-
data.width = width;
|
|
9895
|
-
data.height = height;
|
|
9896
9941
|
if (scaleX) {
|
|
9897
9942
|
data.scaleX = scaleX;
|
|
9898
9943
|
data.scaleY = scaleY;
|
|
9899
9944
|
}
|
|
9900
|
-
if (opacity) data.opacity = opacity;
|
|
9945
|
+
if (opacity && opacity < 1) data.opacity = opacity;
|
|
9901
9946
|
if (filters) data.filters = filters;
|
|
9902
9947
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
9903
9948
|
return data;
|
|
@@ -9919,234 +9964,194 @@ function getGapValue(gap, size, totalSize, rows) {
|
|
|
9919
9964
|
return gap === "auto" ? value < 0 ? 0 : value : value;
|
|
9920
9965
|
}
|
|
9921
9966
|
|
|
9922
|
-
let
|
|
9967
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
9923
9968
|
|
|
9924
|
-
const {
|
|
9969
|
+
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
9925
9970
|
|
|
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;
|
|
9971
|
+
function stretchMode(data, box, scaleX, scaleY) {
|
|
9972
|
+
const transform = get$2(), {x: x, y: y} = box;
|
|
9973
|
+
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
9974
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
9975
|
+
data.transform = transform;
|
|
9986
9976
|
}
|
|
9987
9977
|
|
|
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;
|
|
9978
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
9979
|
+
const transform = get$2();
|
|
9980
|
+
translate(transform, box.x + x, box.y + y);
|
|
9981
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
9982
|
+
if (rotation) rotateOfOuter$1(transform, {
|
|
9983
|
+
x: box.x + box.width / 2,
|
|
9984
|
+
y: box.y + box.height / 2
|
|
9985
|
+
}, rotation);
|
|
9986
|
+
data.transform = transform;
|
|
10004
9987
|
}
|
|
10005
9988
|
|
|
10006
|
-
function
|
|
10007
|
-
|
|
9989
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
9990
|
+
const transform = get$2();
|
|
9991
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9992
|
+
if (clipScaleX) {
|
|
9993
|
+
if (rotation || skew) {
|
|
9994
|
+
set(tempMatrix$1);
|
|
9995
|
+
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
9996
|
+
multiplyParent(transform, tempMatrix$1);
|
|
9997
|
+
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
9998
|
+
}
|
|
9999
|
+
data.transform = transform;
|
|
10008
10000
|
}
|
|
10009
10001
|
|
|
10010
|
-
function
|
|
10011
|
-
|
|
10012
|
-
|
|
10002
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
10003
|
+
const transform = get$2();
|
|
10004
|
+
if (freeTransform) {
|
|
10005
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
10006
|
+
} else {
|
|
10007
|
+
if (rotation) {
|
|
10008
|
+
if (align === "center") {
|
|
10009
|
+
rotateOfOuter$1(transform, {
|
|
10010
|
+
x: width / 2,
|
|
10011
|
+
y: height / 2
|
|
10012
|
+
}, rotation);
|
|
10013
|
+
} else {
|
|
10014
|
+
rotate(transform, rotation);
|
|
10015
|
+
switch (rotation) {
|
|
10016
|
+
case 90:
|
|
10017
|
+
translate(transform, height, 0);
|
|
10018
|
+
break;
|
|
10013
10019
|
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
emit(ui, ImageEvent.ERROR, event);
|
|
10018
|
-
}
|
|
10020
|
+
case 180:
|
|
10021
|
+
translate(transform, width, height);
|
|
10022
|
+
break;
|
|
10019
10023
|
|
|
10020
|
-
|
|
10021
|
-
|
|
10024
|
+
case 270:
|
|
10025
|
+
translate(transform, 0, width);
|
|
10026
|
+
break;
|
|
10027
|
+
}
|
|
10028
|
+
}
|
|
10029
|
+
}
|
|
10030
|
+
origin.x = box.x + x;
|
|
10031
|
+
origin.y = box.y + y;
|
|
10032
|
+
translate(transform, origin.x, origin.y);
|
|
10033
|
+
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
10034
|
+
}
|
|
10035
|
+
data.transform = transform;
|
|
10022
10036
|
}
|
|
10023
10037
|
|
|
10024
|
-
function
|
|
10025
|
-
|
|
10026
|
-
if (
|
|
10038
|
+
function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
10039
|
+
if (rotation) rotate(transform, rotation);
|
|
10040
|
+
if (skew) skewHelper(transform, skew.x, skew.y);
|
|
10041
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
10042
|
+
translate(transform, box.x + x, box.y + y);
|
|
10027
10043
|
}
|
|
10028
10044
|
|
|
10029
10045
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
10030
10046
|
|
|
10031
|
-
const {
|
|
10047
|
+
const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
10048
|
+
|
|
10049
|
+
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
10050
|
+
if (!paint.patternTask) {
|
|
10051
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
10052
|
+
paint.patternTask = null;
|
|
10053
|
+
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
10054
|
+
ui.forceUpdate("surface");
|
|
10055
|
+
}), 300);
|
|
10056
|
+
}
|
|
10057
|
+
}
|
|
10032
10058
|
|
|
10033
|
-
function createPattern(ui,
|
|
10034
|
-
let {scaleX: scaleX, scaleY: scaleY} =
|
|
10035
|
-
const id = scaleX + "-" + scaleY + "-" + pixelRatio;
|
|
10059
|
+
function createPattern(paint, ui, canvas, renderOptions) {
|
|
10060
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
10036
10061
|
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) {
|
|
10062
|
+
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
10063
|
+
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
10064
|
+
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
10065
|
+
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
10066
|
+
width *= scaleX;
|
|
10067
|
+
height *= scaleY;
|
|
10068
|
+
if (gap) {
|
|
10069
|
+
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
10070
|
+
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
10071
|
+
}
|
|
10072
|
+
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10073
|
+
scaleX *= getFloorScale(width + (xGap || 0));
|
|
10074
|
+
scaleY *= getFloorScale(height + (yGap || 0));
|
|
10083
10075
|
imageMatrix = get$1();
|
|
10084
10076
|
if (transform) copy$1(imageMatrix, transform);
|
|
10077
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10085
10078
|
}
|
|
10086
|
-
|
|
10079
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
10080
|
+
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10081
|
+
paint.style = pattern;
|
|
10082
|
+
paint.patternId = id;
|
|
10087
10083
|
}
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10084
|
+
}
|
|
10085
|
+
}
|
|
10086
|
+
|
|
10087
|
+
function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
10088
|
+
const {image: image} = paint;
|
|
10089
|
+
let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
|
|
10090
|
+
if (image.isSVG) {
|
|
10091
|
+
if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
|
|
10093
10092
|
} else {
|
|
10094
|
-
|
|
10093
|
+
if (maxSize > imageSize) maxSize = imageSize;
|
|
10095
10094
|
}
|
|
10095
|
+
if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
|
|
10096
|
+
return fixScale;
|
|
10096
10097
|
}
|
|
10097
10098
|
|
|
10098
|
-
function checkImage(ui, canvas,
|
|
10099
|
-
const {scaleX: scaleX, scaleY: scaleY} =
|
|
10100
|
-
const {
|
|
10101
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY
|
|
10099
|
+
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
10100
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
10101
|
+
const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
|
|
10102
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
10102
10103
|
return false;
|
|
10103
10104
|
} else {
|
|
10104
|
-
if (
|
|
10105
|
+
if (drawImage) {
|
|
10105
10106
|
if (data.repeat) {
|
|
10106
|
-
|
|
10107
|
-
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) ||
|
|
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;
|
|
10107
|
+
drawImage = false;
|
|
10108
|
+
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
10109
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
10116
10110
|
}
|
|
10117
10111
|
}
|
|
10118
|
-
if (
|
|
10112
|
+
if (drawImage) {
|
|
10119
10113
|
if (ui.__.__isFastShadow) {
|
|
10120
10114
|
canvas.fillStyle = paint.style || "#000";
|
|
10121
10115
|
canvas.fill();
|
|
10122
10116
|
}
|
|
10123
|
-
drawImage(ui, canvas,
|
|
10117
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
10124
10118
|
return true;
|
|
10125
10119
|
} else {
|
|
10126
|
-
if (!paint.style || paint.sync ||
|
|
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
|
-
}
|
|
10120
|
+
if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
10137
10121
|
return false;
|
|
10138
10122
|
}
|
|
10139
10123
|
}
|
|
10140
10124
|
}
|
|
10141
10125
|
|
|
10142
|
-
function drawImage(ui, canvas,
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
if (
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10126
|
+
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
10127
|
+
const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
10128
|
+
let {width: width, height: height} = image, clipUI;
|
|
10129
|
+
if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
|
|
10130
|
+
canvas.save();
|
|
10131
|
+
clipUI && canvas.clipUI(ui);
|
|
10132
|
+
blendMode && (canvas.blendMode = blendMode);
|
|
10133
|
+
opacity && (canvas.opacity *= opacity);
|
|
10134
|
+
transform && canvas.transform(transform);
|
|
10135
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
10136
|
+
canvas.restore();
|
|
10137
|
+
} else {
|
|
10138
|
+
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
10139
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
10140
|
+
}
|
|
10141
|
+
}
|
|
10142
|
+
|
|
10143
|
+
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
10144
|
+
const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
|
|
10145
|
+
if (canvas) {
|
|
10146
|
+
const {pixelRatio: pixelRatio} = canvas;
|
|
10147
|
+
scaleData.scaleX *= pixelRatio;
|
|
10148
|
+
scaleData.scaleY *= pixelRatio;
|
|
10149
|
+
}
|
|
10150
|
+
if (data && data.scaleX) {
|
|
10151
|
+
scaleData.scaleX *= Math.abs(data.scaleX);
|
|
10152
|
+
scaleData.scaleY *= Math.abs(data.scaleY);
|
|
10153
|
+
}
|
|
10154
|
+
return scaleData;
|
|
10150
10155
|
}
|
|
10151
10156
|
|
|
10152
10157
|
function recycleImage(attrName, data) {
|
|
@@ -10178,8 +10183,12 @@ function recycleImage(attrName, data) {
|
|
|
10178
10183
|
const PaintImageModule = {
|
|
10179
10184
|
image: image,
|
|
10180
10185
|
checkImage: checkImage,
|
|
10181
|
-
|
|
10186
|
+
drawImage: drawImage,
|
|
10187
|
+
getImageRenderScaleData: getImageRenderScaleData,
|
|
10182
10188
|
recycleImage: recycleImage,
|
|
10189
|
+
createPatternTask: createPatternTask,
|
|
10190
|
+
createPattern: createPattern,
|
|
10191
|
+
getPatternFixScale: getPatternFixScale,
|
|
10183
10192
|
createData: createData,
|
|
10184
10193
|
getPatternData: getPatternData,
|
|
10185
10194
|
stretchMode: stretchMode,
|
|
@@ -10635,10 +10644,8 @@ function createRows(drawData, content, style) {
|
|
|
10635
10644
|
bounds = drawData.bounds;
|
|
10636
10645
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
10637
10646
|
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) {
|
|
10647
|
+
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
10648
|
+
if (style.__isCharMode) {
|
|
10642
10649
|
const wrap = style.textWrap !== "none";
|
|
10643
10650
|
const breakAll = style.textWrap === "break";
|
|
10644
10651
|
paraStart = true;
|
|
@@ -10767,12 +10774,19 @@ const TextMode = 2;
|
|
|
10767
10774
|
function layoutChar(drawData, style, width, _height) {
|
|
10768
10775
|
const {rows: rows} = drawData;
|
|
10769
10776
|
const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
|
|
10770
|
-
|
|
10777
|
+
const justifyLast = width && textAlign.includes("both");
|
|
10778
|
+
const justify = justifyLast || width && textAlign.includes("justify");
|
|
10779
|
+
const justifyLetter = justify && textAlign.includes("letter");
|
|
10780
|
+
let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
|
|
10771
10781
|
rows.forEach(row => {
|
|
10772
10782
|
if (row.words) {
|
|
10773
10783
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
10774
|
-
|
|
10775
|
-
|
|
10784
|
+
if (justify) {
|
|
10785
|
+
canJustify = !row.paraEnd || justifyLast;
|
|
10786
|
+
remainingWidth = width - row.width - indentWidth;
|
|
10787
|
+
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
10788
|
+
}
|
|
10789
|
+
mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
10776
10790
|
if (row.isOverflow && !letterSpacing) row.textMode = true;
|
|
10777
10791
|
if (mode === TextMode) {
|
|
10778
10792
|
row.x += indentWidth;
|
|
@@ -10790,11 +10804,15 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
10790
10804
|
charX = toWordChar(word.data, charX, wordChar);
|
|
10791
10805
|
if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
|
|
10792
10806
|
} else {
|
|
10793
|
-
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
10807
|
+
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
10794
10808
|
}
|
|
10795
|
-
if (
|
|
10796
|
-
|
|
10797
|
-
|
|
10809
|
+
if (canJustify) {
|
|
10810
|
+
isLastWord = index === wordsLength - 1;
|
|
10811
|
+
if (addWordWidth) {
|
|
10812
|
+
if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
|
|
10813
|
+
} else if (addLetterWidth) {
|
|
10814
|
+
row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
|
|
10815
|
+
}
|
|
10798
10816
|
}
|
|
10799
10817
|
});
|
|
10800
10818
|
}
|
|
@@ -10820,13 +10838,14 @@ function toWordChar(data, charX, wordChar) {
|
|
|
10820
10838
|
return charX;
|
|
10821
10839
|
}
|
|
10822
10840
|
|
|
10823
|
-
function toChar(data, charX, rowData, isOverflow) {
|
|
10841
|
+
function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
|
|
10824
10842
|
data.forEach(char => {
|
|
10825
10843
|
if (isOverflow || char.char !== " ") {
|
|
10826
10844
|
char.x = charX;
|
|
10827
10845
|
rowData.push(char);
|
|
10828
10846
|
}
|
|
10829
10847
|
charX += char.width;
|
|
10848
|
+
addLetterWidth && (charX += addLetterWidth);
|
|
10830
10849
|
});
|
|
10831
10850
|
return charX;
|
|
10832
10851
|
}
|
|
@@ -10968,10 +10987,10 @@ function getDrawData(content, style) {
|
|
|
10968
10987
|
let x = 0, y = 0;
|
|
10969
10988
|
let width = style.__getInput("width") || 0;
|
|
10970
10989
|
let height = style.__getInput("height") || 0;
|
|
10971
|
-
const {
|
|
10990
|
+
const {__padding: padding} = style;
|
|
10972
10991
|
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];
|
|
10992
|
+
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
10993
|
+
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
10975
10994
|
}
|
|
10976
10995
|
const drawData = {
|
|
10977
10996
|
bounds: {
|
|
@@ -10982,14 +11001,14 @@ function getDrawData(content, style) {
|
|
|
10982
11001
|
},
|
|
10983
11002
|
rows: [],
|
|
10984
11003
|
paraNumber: 0,
|
|
10985
|
-
font: Platform.canvas.font = __font
|
|
11004
|
+
font: Platform.canvas.font = style.__font
|
|
10986
11005
|
};
|
|
10987
11006
|
createRows(drawData, content, style);
|
|
10988
11007
|
if (padding) padAutoText(padding, drawData, style, width, height);
|
|
10989
11008
|
layoutText(drawData, style);
|
|
10990
|
-
layoutChar(drawData, style, width);
|
|
11009
|
+
if (style.__isCharMode) layoutChar(drawData, style, width);
|
|
10991
11010
|
if (drawData.overflow) clipText(drawData, style, x, width);
|
|
10992
|
-
if (textDecoration !== "none") decorationText(drawData, style);
|
|
11011
|
+
if (style.textDecoration !== "none") decorationText(drawData, style);
|
|
10993
11012
|
return drawData;
|
|
10994
11013
|
}
|
|
10995
11014
|
|