leafer-draw 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/web.cjs +396 -394
- package/dist/web.esm.js +398 -396
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +514 -499
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +536 -517
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +3 -3
package/dist/web.module.js
CHANGED
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
const Platform = {
|
|
2
|
-
toURL(text, fileType) {
|
|
3
|
-
let url = encodeURIComponent(text);
|
|
4
|
-
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
5
|
-
return url;
|
|
6
|
-
},
|
|
7
|
-
image: {
|
|
8
|
-
hitCanvasSize: 100,
|
|
9
|
-
maxCacheSize: 2560 * 1600,
|
|
10
|
-
maxPatternSize: 4096 * 2160,
|
|
11
|
-
crossOrigin: "anonymous",
|
|
12
|
-
getRealURL(url) {
|
|
13
|
-
const {prefix: prefix, suffix: suffix} = Platform.image;
|
|
14
|
-
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
15
|
-
if (prefix && url[0] === "/") url = prefix + url;
|
|
16
|
-
return url;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const IncrementId = {
|
|
22
|
-
RUNTIME: "runtime",
|
|
23
|
-
LEAF: "leaf",
|
|
24
|
-
TASK: "task",
|
|
25
|
-
CNAVAS: "canvas",
|
|
26
|
-
IMAGE: "image",
|
|
27
|
-
types: {},
|
|
28
|
-
create(typeName) {
|
|
29
|
-
const {types: types} = I$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$9.error(error);
|
|
3714
3750
|
}
|
|
@@ -3716,8 +3752,7 @@ class TaskItem {
|
|
|
3716
3752
|
}
|
|
3717
3753
|
complete() {
|
|
3718
3754
|
this.isComplete = true;
|
|
3719
|
-
this.parent = null;
|
|
3720
|
-
this.task = null;
|
|
3755
|
+
this.parent = this.task = this.canUse = null;
|
|
3721
3756
|
}
|
|
3722
3757
|
cancel() {
|
|
3723
3758
|
this.isCancel = true;
|
|
@@ -3760,7 +3795,7 @@ class TaskProcessor {
|
|
|
3760
3795
|
if (config) DataHelper.assign(this.config, config);
|
|
3761
3796
|
this.empty();
|
|
3762
3797
|
}
|
|
3763
|
-
add(taskCallback, options) {
|
|
3798
|
+
add(taskCallback, options, canUse) {
|
|
3764
3799
|
let start, parallel, time, delay;
|
|
3765
3800
|
const task = new TaskItem(taskCallback);
|
|
3766
3801
|
task.parent = this;
|
|
@@ -3771,9 +3806,11 @@ class TaskProcessor {
|
|
|
3771
3806
|
start = options.start;
|
|
3772
3807
|
time = options.time;
|
|
3773
3808
|
delay = options.delay;
|
|
3809
|
+
if (!canUse) canUse = options.canUse;
|
|
3774
3810
|
}
|
|
3775
3811
|
if (time) task.time = time;
|
|
3776
3812
|
if (parallel === false) task.parallel = false;
|
|
3813
|
+
if (canUse) task.canUse = canUse;
|
|
3777
3814
|
if (isUndefined(delay)) {
|
|
3778
3815
|
this.push(task, start);
|
|
3779
3816
|
} else {
|
|
@@ -3843,15 +3880,10 @@ class TaskProcessor {
|
|
|
3843
3880
|
this.timer = setTimeout(() => this.nextTask());
|
|
3844
3881
|
return;
|
|
3845
3882
|
}
|
|
3846
|
-
if (task.isCancel) {
|
|
3847
|
-
this.index++;
|
|
3848
|
-
this.runTask();
|
|
3849
|
-
return;
|
|
3850
|
-
}
|
|
3851
3883
|
task.run().then(() => {
|
|
3852
3884
|
this.onTask(task);
|
|
3853
3885
|
this.index++;
|
|
3854
|
-
this.nextTask();
|
|
3886
|
+
task.isCancel ? this.runTask() : this.nextTask();
|
|
3855
3887
|
}).catch(error => {
|
|
3856
3888
|
this.onError(error);
|
|
3857
3889
|
});
|
|
@@ -4027,8 +4059,6 @@ const I = 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
|
const debug$4 = Debug.get("LeaferCanvas");
|
|
6825
6841
|
|
|
@@ -7797,7 +7813,7 @@ const Transition = {
|
|
|
7797
7813
|
|
|
7798
7814
|
const {parse: parse, objectToCanvasData: objectToCanvasData} = PathConvert;
|
|
7799
7815
|
|
|
7800
|
-
const {stintSet: stintSet$
|
|
7816
|
+
const {stintSet: stintSet$3} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
|
|
7801
7817
|
|
|
7802
7818
|
const emptyPaint = {};
|
|
7803
7819
|
|
|
@@ -7864,7 +7880,7 @@ class UIData extends LeafData {
|
|
|
7864
7880
|
setFill(value) {
|
|
7865
7881
|
if (this.__naturalWidth) this.__removeNaturalSize();
|
|
7866
7882
|
if (isString(value) || !value) {
|
|
7867
|
-
stintSet$
|
|
7883
|
+
stintSet$3(this, "__isTransparentFill", hasTransparent$2(value));
|
|
7868
7884
|
this.__isFills && this.__removePaint("fill", true);
|
|
7869
7885
|
this._fill = value;
|
|
7870
7886
|
} else if (isObject(value)) {
|
|
@@ -7873,7 +7889,7 @@ class UIData extends LeafData {
|
|
|
7873
7889
|
}
|
|
7874
7890
|
setStroke(value) {
|
|
7875
7891
|
if (isString(value) || !value) {
|
|
7876
|
-
stintSet$
|
|
7892
|
+
stintSet$3(this, "__isTransparentStroke", hasTransparent$2(value));
|
|
7877
7893
|
this.__isStrokes && this.__removePaint("stroke", true);
|
|
7878
7894
|
this._stroke = value;
|
|
7879
7895
|
} else if (isObject(value)) {
|
|
@@ -7931,11 +7947,11 @@ class UIData extends LeafData {
|
|
|
7931
7947
|
if (removeInput) this.__removeInput(attrName);
|
|
7932
7948
|
PaintImage.recycleImage(attrName, this);
|
|
7933
7949
|
if (attrName === "fill") {
|
|
7934
|
-
stintSet$
|
|
7950
|
+
stintSet$3(this, "__isAlphaPixelFill", undefined);
|
|
7935
7951
|
this._fill = this.__isFills = undefined;
|
|
7936
7952
|
} else {
|
|
7937
|
-
stintSet$
|
|
7938
|
-
stintSet$
|
|
7953
|
+
stintSet$3(this, "__isAlphaPixelStroke", undefined);
|
|
7954
|
+
stintSet$3(this, "__hasMultiStrokeStyle", undefined);
|
|
7939
7955
|
this._stroke = this.__isStrokes = undefined;
|
|
7940
7956
|
}
|
|
7941
7957
|
}
|
|
@@ -8084,7 +8100,7 @@ class CanvasData extends RectData {
|
|
|
8084
8100
|
}
|
|
8085
8101
|
}
|
|
8086
8102
|
|
|
8087
|
-
const {max: max$
|
|
8103
|
+
const {max: max$1, add: add$1} = FourNumberHelper;
|
|
8088
8104
|
|
|
8089
8105
|
const UIBounds = {
|
|
8090
8106
|
__updateStrokeSpread() {
|
|
@@ -8100,7 +8116,7 @@ const UIBounds = {
|
|
|
8100
8116
|
}
|
|
8101
8117
|
if (data.__useArrow) spread += strokeWidth * 5;
|
|
8102
8118
|
if (box) {
|
|
8103
|
-
spread = max$
|
|
8119
|
+
spread = max$1(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
|
|
8104
8120
|
boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
|
|
8105
8121
|
}
|
|
8106
8122
|
this.__layout.strokeBoxSpread = boxSpread;
|
|
@@ -8110,35 +8126,35 @@ const UIBounds = {
|
|
|
8110
8126
|
let spread = 0;
|
|
8111
8127
|
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
|
|
8112
8128
|
if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
|
|
8113
|
-
if (blur) spread = max$
|
|
8129
|
+
if (blur) spread = max$1(spread, blur);
|
|
8114
8130
|
if (filter) spread = add$1(spread, Filter.getSpread(filter));
|
|
8115
8131
|
if (renderSpread) spread = add$1(spread, renderSpread);
|
|
8116
8132
|
if (strokeSpread) spread = add$1(spread, strokeSpread);
|
|
8117
8133
|
let shapeSpread = spread;
|
|
8118
|
-
if (innerShadow) shapeSpread = max$
|
|
8119
|
-
if (backgroundBlur) shapeSpread = max$
|
|
8134
|
+
if (innerShadow) shapeSpread = max$1(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
|
|
8135
|
+
if (backgroundBlur) shapeSpread = max$1(shapeSpread, backgroundBlur);
|
|
8120
8136
|
this.__layout.renderShapeSpread = shapeSpread;
|
|
8121
|
-
return box ? max$
|
|
8137
|
+
return box ? max$1(box.__updateRenderSpread(), spread) : spread;
|
|
8122
8138
|
}
|
|
8123
8139
|
};
|
|
8124
8140
|
|
|
8125
|
-
const {stintSet: stintSet$
|
|
8141
|
+
const {stintSet: stintSet$2} = DataHelper;
|
|
8126
8142
|
|
|
8127
8143
|
const UIRender = {
|
|
8128
8144
|
__updateChange() {
|
|
8129
8145
|
const data = this.__;
|
|
8130
8146
|
if (data.__useStroke) {
|
|
8131
8147
|
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
8132
|
-
stintSet$
|
|
8133
|
-
stintSet$
|
|
8148
|
+
stintSet$2(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
|
|
8149
|
+
stintSet$2(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
|
|
8134
8150
|
}
|
|
8135
8151
|
if (data.__useEffect) {
|
|
8136
8152
|
const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
8137
|
-
stintSet$
|
|
8153
|
+
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"));
|
|
8138
8154
|
data.__useEffect = !!(shadow || otherEffect);
|
|
8139
8155
|
}
|
|
8140
8156
|
data.__checkSingle();
|
|
8141
|
-
stintSet$
|
|
8157
|
+
stintSet$2(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
8142
8158
|
},
|
|
8143
8159
|
__drawFast(canvas, options) {
|
|
8144
8160
|
drawFast(this, canvas, options);
|
|
@@ -8154,24 +8170,24 @@ const UIRender = {
|
|
|
8154
8170
|
this.__nowWorld = this.__getNowWorld(options);
|
|
8155
8171
|
const {shadow: shadow, innerShadow: innerShadow, filter: filter} = data;
|
|
8156
8172
|
if (shadow) Effect.shadow(this, canvas, shape);
|
|
8157
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8158
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
8173
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8174
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
8159
8175
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
8160
8176
|
if (innerShadow) Effect.innerShadow(this, canvas, shape);
|
|
8161
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8177
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8162
8178
|
if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
8163
8179
|
if (shape.worldCanvas) shape.worldCanvas.recycle();
|
|
8164
8180
|
shape.canvas.recycle();
|
|
8165
8181
|
} else {
|
|
8166
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8182
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8167
8183
|
if (__isFastShadow) {
|
|
8168
8184
|
const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
|
|
8169
8185
|
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
8170
8186
|
}
|
|
8171
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
8187
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
8172
8188
|
if (__isFastShadow) canvas.restore();
|
|
8173
8189
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
8174
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
8190
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8175
8191
|
}
|
|
8176
8192
|
} else {
|
|
8177
8193
|
if (data.__pathInputed) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
|
|
@@ -8180,9 +8196,9 @@ const UIRender = {
|
|
|
8180
8196
|
__drawShape(canvas, options) {
|
|
8181
8197
|
this.__drawRenderPath(canvas);
|
|
8182
8198
|
const data = this.__, {fill: fill, stroke: stroke} = data;
|
|
8183
|
-
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill("#000000", this, canvas);
|
|
8199
|
+
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas, options) : Paint.fill("#000000", this, canvas, options);
|
|
8184
8200
|
if (data.__isCanvas) this.__drawAfterFill(canvas, options);
|
|
8185
|
-
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke("#000000", this, canvas);
|
|
8201
|
+
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke("#000000", this, canvas, options);
|
|
8186
8202
|
},
|
|
8187
8203
|
__drawAfterFill(canvas, options) {
|
|
8188
8204
|
if (this.__.__clipAfterFill) {
|
|
@@ -8197,10 +8213,10 @@ const UIRender = {
|
|
|
8197
8213
|
function drawFast(ui, canvas, options) {
|
|
8198
8214
|
const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke} = ui.__;
|
|
8199
8215
|
ui.__drawRenderPath(canvas);
|
|
8200
|
-
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
8201
|
-
if (fill) Paint.fill(fill, ui, canvas);
|
|
8216
|
+
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
8217
|
+
if (fill) Paint.fill(fill, ui, canvas, options);
|
|
8202
8218
|
if (__drawAfterFill) ui.__drawAfterFill(canvas, options);
|
|
8203
|
-
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
8219
|
+
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
8204
8220
|
}
|
|
8205
8221
|
|
|
8206
8222
|
const RectRender = {
|
|
@@ -8338,8 +8354,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8338
8354
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
8339
8355
|
} else drawer.rect(x, y, width, height);
|
|
8340
8356
|
}
|
|
8341
|
-
drawImagePlaceholder(canvas,
|
|
8342
|
-
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
8357
|
+
drawImagePlaceholder(_image, canvas, renderOptions) {
|
|
8358
|
+
Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
|
|
8343
8359
|
}
|
|
8344
8360
|
animate(keyframe, _options, _type, _isTemp) {
|
|
8345
8361
|
this.set(keyframe);
|
|
@@ -9361,7 +9377,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
|
|
|
9361
9377
|
|
|
9362
9378
|
Canvas = __decorate([ registerUI() ], Canvas);
|
|
9363
9379
|
|
|
9364
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
|
|
9380
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9365
9381
|
|
|
9366
9382
|
let Text = class Text extends UI {
|
|
9367
9383
|
get __tag() {
|
|
@@ -9373,13 +9389,14 @@ let Text = class Text extends UI {
|
|
|
9373
9389
|
}
|
|
9374
9390
|
__updateTextDrawData() {
|
|
9375
9391
|
const data = this.__;
|
|
9376
|
-
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
|
|
9392
|
+
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
|
|
9377
9393
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
9378
9394
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
9379
|
-
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
9380
9395
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
|
|
9381
9396
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
9382
|
-
data
|
|
9397
|
+
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
9398
|
+
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
9399
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
|
|
9383
9400
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
9384
9401
|
}
|
|
9385
9402
|
__updateBoxBounds() {
|
|
@@ -9589,36 +9606,19 @@ function penPathType() {
|
|
|
9589
9606
|
};
|
|
9590
9607
|
}
|
|
9591
9608
|
|
|
9592
|
-
function
|
|
9593
|
-
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
9594
|
-
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
9595
|
-
let row;
|
|
9596
|
-
for (let i = 0, len = rows.length; i < len; i++) {
|
|
9597
|
-
row = rows[i];
|
|
9598
|
-
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
9599
|
-
canvas.fillText(charData.char, charData.x, row.y);
|
|
9600
|
-
});
|
|
9601
|
-
}
|
|
9602
|
-
if (decorationY) {
|
|
9603
|
-
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
9604
|
-
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
9605
|
-
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
9606
|
-
}
|
|
9607
|
-
}
|
|
9608
|
-
|
|
9609
|
-
function fill(fill, ui, canvas) {
|
|
9609
|
+
function fill(fill, ui, canvas, renderOptions) {
|
|
9610
9610
|
canvas.fillStyle = fill;
|
|
9611
|
-
fillPathOrText(ui, canvas);
|
|
9611
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9612
9612
|
}
|
|
9613
9613
|
|
|
9614
|
-
function fills(fills, ui, canvas) {
|
|
9614
|
+
function fills(fills, ui, canvas, renderOptions) {
|
|
9615
9615
|
let item;
|
|
9616
9616
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
9617
9617
|
item = fills[i];
|
|
9618
9618
|
if (item.image) {
|
|
9619
|
-
if (PaintImage.checkImage(
|
|
9619
|
+
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
9620
9620
|
if (!item.style) {
|
|
9621
|
-
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas,
|
|
9621
|
+
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
|
|
9622
9622
|
continue;
|
|
9623
9623
|
}
|
|
9624
9624
|
}
|
|
@@ -9631,60 +9631,137 @@ function fills(fills, ui, canvas) {
|
|
|
9631
9631
|
if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
9632
9632
|
}
|
|
9633
9633
|
if (item.blendMode) canvas.blendMode = item.blendMode;
|
|
9634
|
-
fillPathOrText(ui, canvas);
|
|
9634
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9635
9635
|
canvas.restore();
|
|
9636
9636
|
} else {
|
|
9637
9637
|
if (item.blendMode) {
|
|
9638
9638
|
canvas.saveBlendMode(item.blendMode);
|
|
9639
|
-
fillPathOrText(ui, canvas);
|
|
9639
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9640
9640
|
canvas.restoreBlendMode();
|
|
9641
|
-
} else fillPathOrText(ui, canvas);
|
|
9641
|
+
} else fillPathOrText(ui, canvas, renderOptions);
|
|
9642
|
+
}
|
|
9643
|
+
}
|
|
9644
|
+
}
|
|
9645
|
+
|
|
9646
|
+
function fillPathOrText(ui, canvas, renderOptions) {
|
|
9647
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
9648
|
+
}
|
|
9649
|
+
|
|
9650
|
+
function fillText(ui, canvas, _renderOptions) {
|
|
9651
|
+
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
9652
|
+
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
9653
|
+
let row;
|
|
9654
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
9655
|
+
row = rows[i];
|
|
9656
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
9657
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
9658
|
+
});
|
|
9659
|
+
}
|
|
9660
|
+
if (decorationY) {
|
|
9661
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
9662
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
9663
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
9664
|
+
}
|
|
9665
|
+
}
|
|
9666
|
+
|
|
9667
|
+
function stroke(stroke, ui, canvas, renderOptions) {
|
|
9668
|
+
const data = ui.__;
|
|
9669
|
+
if (!data.__strokeWidth) return;
|
|
9670
|
+
if (data.__font) {
|
|
9671
|
+
Paint.strokeText(stroke, ui, canvas, renderOptions);
|
|
9672
|
+
} else {
|
|
9673
|
+
switch (data.strokeAlign) {
|
|
9674
|
+
case "center":
|
|
9675
|
+
drawCenter$1(stroke, 1, ui, canvas, renderOptions);
|
|
9676
|
+
break;
|
|
9677
|
+
|
|
9678
|
+
case "inside":
|
|
9679
|
+
drawInside(stroke, ui, canvas, renderOptions);
|
|
9680
|
+
break;
|
|
9681
|
+
|
|
9682
|
+
case "outside":
|
|
9683
|
+
drawOutside(stroke, ui, canvas, renderOptions);
|
|
9684
|
+
break;
|
|
9642
9685
|
}
|
|
9643
9686
|
}
|
|
9644
9687
|
}
|
|
9645
9688
|
|
|
9646
|
-
function
|
|
9647
|
-
|
|
9689
|
+
function strokes(strokes, ui, canvas, renderOptions) {
|
|
9690
|
+
Paint.stroke(strokes, ui, canvas, renderOptions);
|
|
9691
|
+
}
|
|
9692
|
+
|
|
9693
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9694
|
+
const data = ui.__;
|
|
9695
|
+
if (isObject(stroke)) {
|
|
9696
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
|
|
9697
|
+
} else {
|
|
9698
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9699
|
+
canvas.stroke();
|
|
9700
|
+
}
|
|
9701
|
+
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
|
|
9702
|
+
}
|
|
9703
|
+
|
|
9704
|
+
function drawInside(stroke, ui, canvas, renderOptions) {
|
|
9705
|
+
canvas.save();
|
|
9706
|
+
canvas.clipUI(ui);
|
|
9707
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9708
|
+
canvas.restore();
|
|
9709
|
+
}
|
|
9710
|
+
|
|
9711
|
+
function drawOutside(stroke, ui, canvas, renderOptions) {
|
|
9712
|
+
const data = ui.__;
|
|
9713
|
+
if (data.__fillAfterStroke) {
|
|
9714
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9715
|
+
} else {
|
|
9716
|
+
const {renderBounds: renderBounds} = ui.__layout;
|
|
9717
|
+
const out = canvas.getSameCanvas(true, true);
|
|
9718
|
+
ui.__drawRenderPath(out);
|
|
9719
|
+
drawCenter$1(stroke, 2, ui, out, renderOptions);
|
|
9720
|
+
out.clipUI(data);
|
|
9721
|
+
out.clearWorld(renderBounds);
|
|
9722
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9723
|
+
out.recycle(ui.__nowWorld);
|
|
9724
|
+
}
|
|
9648
9725
|
}
|
|
9649
9726
|
|
|
9650
|
-
function strokeText(stroke, ui, canvas) {
|
|
9727
|
+
function strokeText(stroke, ui, canvas, renderOptions) {
|
|
9651
9728
|
switch (ui.__.strokeAlign) {
|
|
9652
9729
|
case "center":
|
|
9653
|
-
drawCenter
|
|
9730
|
+
drawCenter(stroke, 1, ui, canvas, renderOptions);
|
|
9654
9731
|
break;
|
|
9655
9732
|
|
|
9656
9733
|
case "inside":
|
|
9657
|
-
drawAlign(stroke, "inside", ui, canvas);
|
|
9734
|
+
drawAlign(stroke, "inside", ui, canvas, renderOptions);
|
|
9658
9735
|
break;
|
|
9659
9736
|
|
|
9660
9737
|
case "outside":
|
|
9661
|
-
ui.__.__fillAfterStroke ? drawCenter
|
|
9738
|
+
ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
|
|
9662
9739
|
break;
|
|
9663
9740
|
}
|
|
9664
9741
|
}
|
|
9665
9742
|
|
|
9666
|
-
function drawCenter
|
|
9743
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9667
9744
|
const data = ui.__;
|
|
9668
9745
|
if (isObject(stroke)) {
|
|
9669
|
-
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
9746
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
|
|
9670
9747
|
} else {
|
|
9671
9748
|
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9672
|
-
drawTextStroke(ui, canvas);
|
|
9749
|
+
Paint.drawTextStroke(ui, canvas, renderOptions);
|
|
9673
9750
|
}
|
|
9674
9751
|
}
|
|
9675
9752
|
|
|
9676
|
-
function drawAlign(stroke, align, ui, canvas) {
|
|
9753
|
+
function drawAlign(stroke, align, ui, canvas, renderOptions) {
|
|
9677
9754
|
const out = canvas.getSameCanvas(true, true);
|
|
9678
9755
|
out.font = ui.__.__font;
|
|
9679
|
-
drawCenter
|
|
9756
|
+
drawCenter(stroke, 2, ui, out, renderOptions);
|
|
9680
9757
|
out.blendMode = align === "outside" ? "destination-out" : "destination-in";
|
|
9681
|
-
fillText(ui, out);
|
|
9758
|
+
Paint.fillText(ui, out, renderOptions);
|
|
9682
9759
|
out.blendMode = "normal";
|
|
9683
9760
|
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9684
9761
|
out.recycle(ui.__nowWorld);
|
|
9685
9762
|
}
|
|
9686
9763
|
|
|
9687
|
-
function drawTextStroke(ui, canvas) {
|
|
9764
|
+
function drawTextStroke(ui, canvas, _renderOptions) {
|
|
9688
9765
|
let row, data = ui.__.__textDrawData;
|
|
9689
9766
|
const {rows: rows, decorationY: decorationY} = data;
|
|
9690
9767
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
@@ -9699,13 +9776,13 @@ function drawTextStroke(ui, canvas) {
|
|
|
9699
9776
|
}
|
|
9700
9777
|
}
|
|
9701
9778
|
|
|
9702
|
-
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
9779
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
|
|
9703
9780
|
let item;
|
|
9704
9781
|
const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
|
|
9705
9782
|
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
9706
9783
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
9707
9784
|
item = strokes[i];
|
|
9708
|
-
if (item.image && PaintImage.checkImage(ui, canvas,
|
|
9785
|
+
if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
|
|
9709
9786
|
if (item.style) {
|
|
9710
9787
|
if (__hasMultiStrokeStyle) {
|
|
9711
9788
|
const {strokeStyle: strokeStyle} = item;
|
|
@@ -9713,75 +9790,15 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
|
9713
9790
|
} else canvas.strokeStyle = item.style;
|
|
9714
9791
|
if (item.blendMode) {
|
|
9715
9792
|
canvas.saveBlendMode(item.blendMode);
|
|
9716
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9793
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9717
9794
|
canvas.restoreBlendMode();
|
|
9718
9795
|
} else {
|
|
9719
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9796
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9720
9797
|
}
|
|
9721
9798
|
}
|
|
9722
9799
|
}
|
|
9723
9800
|
}
|
|
9724
9801
|
|
|
9725
|
-
function stroke(stroke, ui, canvas) {
|
|
9726
|
-
const data = ui.__;
|
|
9727
|
-
if (!data.__strokeWidth) return;
|
|
9728
|
-
if (data.__font) {
|
|
9729
|
-
strokeText(stroke, ui, canvas);
|
|
9730
|
-
} else {
|
|
9731
|
-
switch (data.strokeAlign) {
|
|
9732
|
-
case "center":
|
|
9733
|
-
drawCenter(stroke, 1, ui, canvas);
|
|
9734
|
-
break;
|
|
9735
|
-
|
|
9736
|
-
case "inside":
|
|
9737
|
-
drawInside(stroke, ui, canvas);
|
|
9738
|
-
break;
|
|
9739
|
-
|
|
9740
|
-
case "outside":
|
|
9741
|
-
drawOutside(stroke, ui, canvas);
|
|
9742
|
-
break;
|
|
9743
|
-
}
|
|
9744
|
-
}
|
|
9745
|
-
}
|
|
9746
|
-
|
|
9747
|
-
function strokes(strokes, ui, canvas) {
|
|
9748
|
-
stroke(strokes, ui, canvas);
|
|
9749
|
-
}
|
|
9750
|
-
|
|
9751
|
-
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
9752
|
-
const data = ui.__;
|
|
9753
|
-
if (isObject(stroke)) {
|
|
9754
|
-
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
9755
|
-
} else {
|
|
9756
|
-
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9757
|
-
canvas.stroke();
|
|
9758
|
-
}
|
|
9759
|
-
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas);
|
|
9760
|
-
}
|
|
9761
|
-
|
|
9762
|
-
function drawInside(stroke, ui, canvas) {
|
|
9763
|
-
canvas.save();
|
|
9764
|
-
canvas.clipUI(ui);
|
|
9765
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
9766
|
-
canvas.restore();
|
|
9767
|
-
}
|
|
9768
|
-
|
|
9769
|
-
function drawOutside(stroke, ui, canvas) {
|
|
9770
|
-
const data = ui.__;
|
|
9771
|
-
if (data.__fillAfterStroke) {
|
|
9772
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
9773
|
-
} else {
|
|
9774
|
-
const {renderBounds: renderBounds} = ui.__layout;
|
|
9775
|
-
const out = canvas.getSameCanvas(true, true);
|
|
9776
|
-
ui.__drawRenderPath(out);
|
|
9777
|
-
drawCenter(stroke, 2, ui, out);
|
|
9778
|
-
out.clipUI(data);
|
|
9779
|
-
out.clearWorld(renderBounds);
|
|
9780
|
-
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9781
|
-
out.recycle(ui.__nowWorld);
|
|
9782
|
-
}
|
|
9783
|
-
}
|
|
9784
|
-
|
|
9785
9802
|
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
9786
9803
|
|
|
9787
9804
|
const tempBounds$1 = {};
|
|
@@ -9937,88 +9954,118 @@ const PaintModule = {
|
|
|
9937
9954
|
strokes: strokes,
|
|
9938
9955
|
strokeText: strokeText,
|
|
9939
9956
|
drawTextStroke: drawTextStroke,
|
|
9957
|
+
drawStrokesStyle: drawStrokesStyle,
|
|
9940
9958
|
shape: shape
|
|
9941
9959
|
};
|
|
9942
9960
|
|
|
9943
|
-
let
|
|
9944
|
-
|
|
9945
|
-
const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
9946
|
-
|
|
9947
|
-
function stretchMode(data, box, scaleX, scaleY) {
|
|
9948
|
-
const transform = get$3();
|
|
9949
|
-
translate$1(transform, box.x, box.y);
|
|
9950
|
-
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
9951
|
-
data.transform = transform;
|
|
9952
|
-
}
|
|
9953
|
-
|
|
9954
|
-
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
9955
|
-
const transform = get$3();
|
|
9956
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
9957
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
9958
|
-
if (rotation) rotateOfOuter$1(transform, {
|
|
9959
|
-
x: box.x + box.width / 2,
|
|
9960
|
-
y: box.y + box.height / 2
|
|
9961
|
-
}, rotation);
|
|
9962
|
-
data.transform = transform;
|
|
9963
|
-
}
|
|
9961
|
+
let cache, box = new Bounds;
|
|
9964
9962
|
|
|
9965
|
-
|
|
9966
|
-
const transform = get$3();
|
|
9967
|
-
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9968
|
-
if (clipScaleX) {
|
|
9969
|
-
if (rotation || skew) {
|
|
9970
|
-
set(tempMatrix$1);
|
|
9971
|
-
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
9972
|
-
multiplyParent(transform, tempMatrix$1);
|
|
9973
|
-
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
9974
|
-
}
|
|
9975
|
-
data.transform = transform;
|
|
9976
|
-
}
|
|
9963
|
+
const {isSame: isSame} = BoundsHelper;
|
|
9977
9964
|
|
|
9978
|
-
function
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
9965
|
+
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
9966
|
+
let leafPaint, event;
|
|
9967
|
+
const image = ImageManager.get(paint);
|
|
9968
|
+
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
9969
|
+
leafPaint = cache.leafPaint;
|
|
9970
|
+
} else {
|
|
9971
|
+
leafPaint = {
|
|
9972
|
+
type: paint.type,
|
|
9973
|
+
image: image
|
|
9974
|
+
};
|
|
9975
|
+
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
9976
|
+
cache = image.use > 1 ? {
|
|
9977
|
+
leafPaint: leafPaint,
|
|
9978
|
+
paint: paint,
|
|
9979
|
+
boxBounds: box.set(boxBounds)
|
|
9980
|
+
} : null;
|
|
9981
|
+
}
|
|
9982
|
+
if (firstUse || image.loading) event = {
|
|
9983
|
+
image: image,
|
|
9984
|
+
attrName: attrName,
|
|
9985
|
+
attrValue: paint
|
|
9986
|
+
};
|
|
9987
|
+
if (image.ready) {
|
|
9988
|
+
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
9989
|
+
if (firstUse) {
|
|
9990
|
+
onLoad(ui, event);
|
|
9991
|
+
onLoadSuccess(ui, event);
|
|
9992
|
+
}
|
|
9993
|
+
} else if (image.error) {
|
|
9994
|
+
if (firstUse) onLoadError(ui, event, image.error);
|
|
9995
|
+
} else {
|
|
9996
|
+
if (firstUse) {
|
|
9997
|
+
ignoreRender(ui, true);
|
|
9998
|
+
onLoad(ui, event);
|
|
9999
|
+
}
|
|
10000
|
+
leafPaint.loadId = image.load(() => {
|
|
10001
|
+
ignoreRender(ui, false);
|
|
10002
|
+
if (!ui.destroyed) {
|
|
10003
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
10004
|
+
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
10005
|
+
ui.forceUpdate("surface");
|
|
10003
10006
|
}
|
|
10007
|
+
onLoadSuccess(ui, event);
|
|
10004
10008
|
}
|
|
10009
|
+
leafPaint.loadId = undefined;
|
|
10010
|
+
}, error => {
|
|
10011
|
+
ignoreRender(ui, false);
|
|
10012
|
+
onLoadError(ui, event, error);
|
|
10013
|
+
leafPaint.loadId = undefined;
|
|
10014
|
+
});
|
|
10015
|
+
if (ui.placeholderColor) {
|
|
10016
|
+
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
10017
|
+
if (!image.ready) {
|
|
10018
|
+
image.isPlacehold = true;
|
|
10019
|
+
ui.forceUpdate("surface");
|
|
10020
|
+
}
|
|
10021
|
+
}, ui.placeholderDelay);
|
|
10005
10022
|
}
|
|
10006
|
-
origin.x = box.x + x;
|
|
10007
|
-
origin.y = box.y + y;
|
|
10008
|
-
translate$1(transform, origin.x, origin.y);
|
|
10009
|
-
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
10010
10023
|
}
|
|
10011
|
-
|
|
10024
|
+
return leafPaint;
|
|
10012
10025
|
}
|
|
10013
10026
|
|
|
10014
|
-
function
|
|
10015
|
-
if (
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10027
|
+
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
10028
|
+
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
10029
|
+
const data = ui.__;
|
|
10030
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
10031
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
10032
|
+
if (data.__autoSide) {
|
|
10033
|
+
ui.forceUpdate("width");
|
|
10034
|
+
if (ui.__proxyData) {
|
|
10035
|
+
ui.setProxyAttr("width", data.width);
|
|
10036
|
+
ui.setProxyAttr("height", data.height);
|
|
10037
|
+
}
|
|
10038
|
+
return false;
|
|
10039
|
+
}
|
|
10040
|
+
}
|
|
10041
|
+
if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
10042
|
+
return true;
|
|
10043
|
+
}
|
|
10044
|
+
|
|
10045
|
+
function onLoad(ui, event) {
|
|
10046
|
+
emit(ui, ImageEvent.LOAD, event);
|
|
10047
|
+
}
|
|
10048
|
+
|
|
10049
|
+
function onLoadSuccess(ui, event) {
|
|
10050
|
+
emit(ui, ImageEvent.LOADED, event);
|
|
10051
|
+
}
|
|
10052
|
+
|
|
10053
|
+
function onLoadError(ui, event, error) {
|
|
10054
|
+
event.error = error;
|
|
10055
|
+
ui.forceUpdate("surface");
|
|
10056
|
+
emit(ui, ImageEvent.ERROR, event);
|
|
10057
|
+
}
|
|
10058
|
+
|
|
10059
|
+
function emit(ui, type, data) {
|
|
10060
|
+
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
10019
10061
|
}
|
|
10020
10062
|
|
|
10021
|
-
|
|
10063
|
+
function ignoreRender(ui, value) {
|
|
10064
|
+
const {leafer: leafer} = ui;
|
|
10065
|
+
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
10066
|
+
}
|
|
10067
|
+
|
|
10068
|
+
const {get: get$3, translate: translate$1} = MatrixHelper;
|
|
10022
10069
|
|
|
10023
10070
|
const tempBox = new Bounds;
|
|
10024
10071
|
|
|
@@ -10031,13 +10078,13 @@ function createData(leafPaint, image, paint, box) {
|
|
|
10031
10078
|
if (changeful) leafPaint.changeful = changeful;
|
|
10032
10079
|
if (sync) leafPaint.sync = sync;
|
|
10033
10080
|
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
10034
|
-
leafPaint.data = getPatternData(paint, box, image);
|
|
10081
|
+
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
10035
10082
|
}
|
|
10036
10083
|
|
|
10037
10084
|
function getPatternData(paint, box, image) {
|
|
10038
10085
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
10039
10086
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
10040
|
-
|
|
10087
|
+
const {width: width, height: height} = image;
|
|
10041
10088
|
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;
|
|
10042
10089
|
const sameBox = box.width === width && box.height === height;
|
|
10043
10090
|
const data = {
|
|
@@ -10068,8 +10115,8 @@ function getPatternData(paint, box, image) {
|
|
|
10068
10115
|
case "stretch":
|
|
10069
10116
|
if (!sameBox) {
|
|
10070
10117
|
scaleX = box.width / width, scaleY = box.height / height;
|
|
10071
|
-
stretchMode(data, box, scaleX, scaleY);
|
|
10072
|
-
}
|
|
10118
|
+
PaintImage.stretchMode(data, box, scaleX, scaleY);
|
|
10119
|
+
} else if (scaleX) scaleX = scaleY = undefined;
|
|
10073
10120
|
break;
|
|
10074
10121
|
|
|
10075
10122
|
case "normal":
|
|
@@ -10077,13 +10124,13 @@ function getPatternData(paint, box, image) {
|
|
|
10077
10124
|
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
10078
10125
|
let clipScaleX, clipScaleY;
|
|
10079
10126
|
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
|
|
10080
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
10127
|
+
PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
10081
10128
|
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
10082
10129
|
}
|
|
10083
10130
|
break;
|
|
10084
10131
|
|
|
10085
10132
|
case "repeat":
|
|
10086
|
-
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
10133
|
+
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
10087
10134
|
if (!repeat) data.repeat = "repeat";
|
|
10088
10135
|
const count = isObject(repeat);
|
|
10089
10136
|
if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
|
|
@@ -10092,18 +10139,16 @@ function getPatternData(paint, box, image) {
|
|
|
10092
10139
|
case "fit":
|
|
10093
10140
|
case "cover":
|
|
10094
10141
|
default:
|
|
10095
|
-
if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
10142
|
+
if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
10096
10143
|
}
|
|
10097
10144
|
if (!data.transform) {
|
|
10098
|
-
if (box.x || box.y) translate(data.transform = get$
|
|
10145
|
+
if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
|
|
10099
10146
|
}
|
|
10100
|
-
data.width = width;
|
|
10101
|
-
data.height = height;
|
|
10102
10147
|
if (scaleX) {
|
|
10103
10148
|
data.scaleX = scaleX;
|
|
10104
10149
|
data.scaleY = scaleY;
|
|
10105
10150
|
}
|
|
10106
|
-
if (opacity) data.opacity = opacity;
|
|
10151
|
+
if (opacity && opacity < 1) data.opacity = opacity;
|
|
10107
10152
|
if (filters) data.filters = filters;
|
|
10108
10153
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
10109
10154
|
return data;
|
|
@@ -10125,234 +10170,194 @@ function getGapValue(gap, size, totalSize, rows) {
|
|
|
10125
10170
|
return gap === "auto" ? value < 0 ? 0 : value : value;
|
|
10126
10171
|
}
|
|
10127
10172
|
|
|
10128
|
-
let
|
|
10173
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
10129
10174
|
|
|
10130
|
-
const {
|
|
10175
|
+
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
10131
10176
|
|
|
10132
|
-
function
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
} else {
|
|
10138
|
-
leafPaint = {
|
|
10139
|
-
type: paint.type,
|
|
10140
|
-
image: image
|
|
10141
|
-
};
|
|
10142
|
-
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
10143
|
-
cache = image.use > 1 ? {
|
|
10144
|
-
leafPaint: leafPaint,
|
|
10145
|
-
paint: paint,
|
|
10146
|
-
boxBounds: box.set(boxBounds)
|
|
10147
|
-
} : null;
|
|
10148
|
-
}
|
|
10149
|
-
if (firstUse || image.loading) event = {
|
|
10150
|
-
image: image,
|
|
10151
|
-
attrName: attrName,
|
|
10152
|
-
attrValue: paint
|
|
10153
|
-
};
|
|
10154
|
-
if (image.ready) {
|
|
10155
|
-
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
10156
|
-
if (firstUse) {
|
|
10157
|
-
onLoad(ui, event);
|
|
10158
|
-
onLoadSuccess(ui, event);
|
|
10159
|
-
}
|
|
10160
|
-
} else if (image.error) {
|
|
10161
|
-
if (firstUse) onLoadError(ui, event, image.error);
|
|
10162
|
-
} else {
|
|
10163
|
-
if (firstUse) {
|
|
10164
|
-
ignoreRender(ui, true);
|
|
10165
|
-
onLoad(ui, event);
|
|
10166
|
-
}
|
|
10167
|
-
leafPaint.loadId = image.load(() => {
|
|
10168
|
-
ignoreRender(ui, false);
|
|
10169
|
-
if (!ui.destroyed) {
|
|
10170
|
-
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
10171
|
-
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
10172
|
-
ui.forceUpdate("surface");
|
|
10173
|
-
}
|
|
10174
|
-
onLoadSuccess(ui, event);
|
|
10175
|
-
}
|
|
10176
|
-
leafPaint.loadId = undefined;
|
|
10177
|
-
}, error => {
|
|
10178
|
-
ignoreRender(ui, false);
|
|
10179
|
-
onLoadError(ui, event, error);
|
|
10180
|
-
leafPaint.loadId = undefined;
|
|
10181
|
-
});
|
|
10182
|
-
if (ui.placeholderColor) {
|
|
10183
|
-
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
10184
|
-
if (!image.ready) {
|
|
10185
|
-
image.isPlacehold = true;
|
|
10186
|
-
ui.forceUpdate("surface");
|
|
10187
|
-
}
|
|
10188
|
-
}, ui.placeholderDelay);
|
|
10189
|
-
}
|
|
10190
|
-
}
|
|
10191
|
-
return leafPaint;
|
|
10177
|
+
function stretchMode(data, box, scaleX, scaleY) {
|
|
10178
|
+
const transform = get$2(), {x: x, y: y} = box;
|
|
10179
|
+
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
10180
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
10181
|
+
data.transform = transform;
|
|
10192
10182
|
}
|
|
10193
10183
|
|
|
10194
|
-
function
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
|
|
10200
|
-
|
|
10201
|
-
|
|
10202
|
-
|
|
10203
|
-
ui.setProxyAttr("height", data.height);
|
|
10204
|
-
}
|
|
10205
|
-
return false;
|
|
10206
|
-
}
|
|
10207
|
-
}
|
|
10208
|
-
if (!leafPaint.data) createData(leafPaint, image, paint, boxBounds);
|
|
10209
|
-
return true;
|
|
10184
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10185
|
+
const transform = get$2();
|
|
10186
|
+
translate(transform, box.x + x, box.y + y);
|
|
10187
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
10188
|
+
if (rotation) rotateOfOuter$1(transform, {
|
|
10189
|
+
x: box.x + box.width / 2,
|
|
10190
|
+
y: box.y + box.height / 2
|
|
10191
|
+
}, rotation);
|
|
10192
|
+
data.transform = transform;
|
|
10210
10193
|
}
|
|
10211
10194
|
|
|
10212
|
-
function
|
|
10213
|
-
|
|
10195
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
10196
|
+
const transform = get$2();
|
|
10197
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
10198
|
+
if (clipScaleX) {
|
|
10199
|
+
if (rotation || skew) {
|
|
10200
|
+
set(tempMatrix$1);
|
|
10201
|
+
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
10202
|
+
multiplyParent(transform, tempMatrix$1);
|
|
10203
|
+
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
10204
|
+
}
|
|
10205
|
+
data.transform = transform;
|
|
10214
10206
|
}
|
|
10215
10207
|
|
|
10216
|
-
function
|
|
10217
|
-
|
|
10218
|
-
|
|
10208
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
10209
|
+
const transform = get$2();
|
|
10210
|
+
if (freeTransform) {
|
|
10211
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
10212
|
+
} else {
|
|
10213
|
+
if (rotation) {
|
|
10214
|
+
if (align === "center") {
|
|
10215
|
+
rotateOfOuter$1(transform, {
|
|
10216
|
+
x: width / 2,
|
|
10217
|
+
y: height / 2
|
|
10218
|
+
}, rotation);
|
|
10219
|
+
} else {
|
|
10220
|
+
rotate(transform, rotation);
|
|
10221
|
+
switch (rotation) {
|
|
10222
|
+
case 90:
|
|
10223
|
+
translate(transform, height, 0);
|
|
10224
|
+
break;
|
|
10219
10225
|
|
|
10220
|
-
|
|
10221
|
-
|
|
10222
|
-
|
|
10223
|
-
emit(ui, ImageEvent.ERROR, event);
|
|
10224
|
-
}
|
|
10226
|
+
case 180:
|
|
10227
|
+
translate(transform, width, height);
|
|
10228
|
+
break;
|
|
10225
10229
|
|
|
10226
|
-
|
|
10227
|
-
|
|
10230
|
+
case 270:
|
|
10231
|
+
translate(transform, 0, width);
|
|
10232
|
+
break;
|
|
10233
|
+
}
|
|
10234
|
+
}
|
|
10235
|
+
}
|
|
10236
|
+
origin.x = box.x + x;
|
|
10237
|
+
origin.y = box.y + y;
|
|
10238
|
+
translate(transform, origin.x, origin.y);
|
|
10239
|
+
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
10240
|
+
}
|
|
10241
|
+
data.transform = transform;
|
|
10228
10242
|
}
|
|
10229
10243
|
|
|
10230
|
-
function
|
|
10231
|
-
|
|
10232
|
-
if (
|
|
10244
|
+
function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
10245
|
+
if (rotation) rotate(transform, rotation);
|
|
10246
|
+
if (skew) skewHelper(transform, skew.x, skew.y);
|
|
10247
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
10248
|
+
translate(transform, box.x + x, box.y + y);
|
|
10233
10249
|
}
|
|
10234
10250
|
|
|
10235
10251
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
10236
10252
|
|
|
10237
|
-
const {
|
|
10253
|
+
const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
10254
|
+
|
|
10255
|
+
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
10256
|
+
if (!paint.patternTask) {
|
|
10257
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
10258
|
+
paint.patternTask = null;
|
|
10259
|
+
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
10260
|
+
ui.forceUpdate("surface");
|
|
10261
|
+
}), 300);
|
|
10262
|
+
}
|
|
10263
|
+
}
|
|
10238
10264
|
|
|
10239
|
-
function createPattern(ui,
|
|
10240
|
-
let {scaleX: scaleX, scaleY: scaleY} =
|
|
10241
|
-
const id = scaleX + "-" + scaleY + "-" + pixelRatio;
|
|
10265
|
+
function createPattern(paint, ui, canvas, renderOptions) {
|
|
10266
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
10242
10267
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
scaleX
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
width *= scaleX;
|
|
10257
|
-
height *= scaleY;
|
|
10258
|
-
const size = width * height;
|
|
10259
|
-
if (!repeat) {
|
|
10260
|
-
if (size > Platform.image.maxCacheSize) return false;
|
|
10261
|
-
}
|
|
10262
|
-
let maxSize = Platform.image.maxPatternSize;
|
|
10263
|
-
if (image.isSVG) {
|
|
10264
|
-
const ws = width / image.width;
|
|
10265
|
-
if (ws > 1) imageScale = ws / ceil(ws);
|
|
10266
|
-
} else {
|
|
10267
|
-
const imageSize = image.width * image.height;
|
|
10268
|
-
if (maxSize > imageSize) maxSize = imageSize;
|
|
10269
|
-
}
|
|
10270
|
-
if (size > maxSize) imageScale = Math.sqrt(size / maxSize);
|
|
10271
|
-
if (imageScale) {
|
|
10272
|
-
scaleX /= imageScale;
|
|
10273
|
-
scaleY /= imageScale;
|
|
10274
|
-
width /= imageScale;
|
|
10275
|
-
height /= imageScale;
|
|
10276
|
-
}
|
|
10277
|
-
if (sx) {
|
|
10278
|
-
scaleX /= sx;
|
|
10279
|
-
scaleY /= sy;
|
|
10280
|
-
}
|
|
10281
|
-
const xGap = gap && gap.x * scaleX;
|
|
10282
|
-
const yGap = gap && gap.y * scaleY;
|
|
10283
|
-
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10284
|
-
const canvasWidth = width + (xGap || 0);
|
|
10285
|
-
const canvasHeight = height + (yGap || 0);
|
|
10286
|
-
scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
|
|
10287
|
-
scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
|
|
10288
|
-
if (!imageMatrix) {
|
|
10268
|
+
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
10269
|
+
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
10270
|
+
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
10271
|
+
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
10272
|
+
width *= scaleX;
|
|
10273
|
+
height *= scaleY;
|
|
10274
|
+
if (gap) {
|
|
10275
|
+
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
10276
|
+
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
10277
|
+
}
|
|
10278
|
+
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10279
|
+
scaleX *= getFloorScale(width + (xGap || 0));
|
|
10280
|
+
scaleY *= getFloorScale(height + (yGap || 0));
|
|
10289
10281
|
imageMatrix = get$1();
|
|
10290
10282
|
if (transform) copy$1(imageMatrix, transform);
|
|
10283
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10291
10284
|
}
|
|
10292
|
-
|
|
10285
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
10286
|
+
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10287
|
+
paint.style = pattern;
|
|
10288
|
+
paint.patternId = id;
|
|
10293
10289
|
}
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10290
|
+
}
|
|
10291
|
+
}
|
|
10292
|
+
|
|
10293
|
+
function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
10294
|
+
const {image: image} = paint;
|
|
10295
|
+
let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
|
|
10296
|
+
if (image.isSVG) {
|
|
10297
|
+
if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
|
|
10299
10298
|
} else {
|
|
10300
|
-
|
|
10299
|
+
if (maxSize > imageSize) maxSize = imageSize;
|
|
10301
10300
|
}
|
|
10301
|
+
if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
|
|
10302
|
+
return fixScale;
|
|
10302
10303
|
}
|
|
10303
10304
|
|
|
10304
|
-
function checkImage(ui, canvas,
|
|
10305
|
-
const {scaleX: scaleX, scaleY: scaleY} =
|
|
10306
|
-
const {
|
|
10307
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY
|
|
10305
|
+
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
10306
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
10307
|
+
const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
|
|
10308
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
10308
10309
|
return false;
|
|
10309
10310
|
} else {
|
|
10310
|
-
if (
|
|
10311
|
+
if (drawImage) {
|
|
10311
10312
|
if (data.repeat) {
|
|
10312
|
-
|
|
10313
|
-
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) ||
|
|
10314
|
-
|
|
10315
|
-
width *= scaleX * pixelRatio;
|
|
10316
|
-
height *= scaleY * pixelRatio;
|
|
10317
|
-
if (data.scaleX) {
|
|
10318
|
-
width *= data.scaleX;
|
|
10319
|
-
height *= data.scaleY;
|
|
10320
|
-
}
|
|
10321
|
-
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
10313
|
+
drawImage = false;
|
|
10314
|
+
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
10315
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
10322
10316
|
}
|
|
10323
10317
|
}
|
|
10324
|
-
if (
|
|
10318
|
+
if (drawImage) {
|
|
10325
10319
|
if (ui.__.__isFastShadow) {
|
|
10326
10320
|
canvas.fillStyle = paint.style || "#000";
|
|
10327
10321
|
canvas.fill();
|
|
10328
10322
|
}
|
|
10329
|
-
drawImage(ui, canvas,
|
|
10323
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
10330
10324
|
return true;
|
|
10331
10325
|
} else {
|
|
10332
|
-
if (!paint.style || paint.sync ||
|
|
10333
|
-
createPattern(ui, paint, pixelRatio);
|
|
10334
|
-
} else {
|
|
10335
|
-
if (!paint.patternTask) {
|
|
10336
|
-
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
10337
|
-
paint.patternTask = null;
|
|
10338
|
-
if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio);
|
|
10339
|
-
ui.forceUpdate("surface");
|
|
10340
|
-
}), 300);
|
|
10341
|
-
}
|
|
10342
|
-
}
|
|
10326
|
+
if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
10343
10327
|
return false;
|
|
10344
10328
|
}
|
|
10345
10329
|
}
|
|
10346
10330
|
}
|
|
10347
10331
|
|
|
10348
|
-
function drawImage(ui, canvas,
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
if (
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10332
|
+
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
10333
|
+
const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
10334
|
+
let {width: width, height: height} = image, clipUI;
|
|
10335
|
+
if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
|
|
10336
|
+
canvas.save();
|
|
10337
|
+
clipUI && canvas.clipUI(ui);
|
|
10338
|
+
blendMode && (canvas.blendMode = blendMode);
|
|
10339
|
+
opacity && (canvas.opacity *= opacity);
|
|
10340
|
+
transform && canvas.transform(transform);
|
|
10341
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
10342
|
+
canvas.restore();
|
|
10343
|
+
} else {
|
|
10344
|
+
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
10345
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
10346
|
+
}
|
|
10347
|
+
}
|
|
10348
|
+
|
|
10349
|
+
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
10350
|
+
const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
|
|
10351
|
+
if (canvas) {
|
|
10352
|
+
const {pixelRatio: pixelRatio} = canvas;
|
|
10353
|
+
scaleData.scaleX *= pixelRatio;
|
|
10354
|
+
scaleData.scaleY *= pixelRatio;
|
|
10355
|
+
}
|
|
10356
|
+
if (data && data.scaleX) {
|
|
10357
|
+
scaleData.scaleX *= Math.abs(data.scaleX);
|
|
10358
|
+
scaleData.scaleY *= Math.abs(data.scaleY);
|
|
10359
|
+
}
|
|
10360
|
+
return scaleData;
|
|
10356
10361
|
}
|
|
10357
10362
|
|
|
10358
10363
|
function recycleImage(attrName, data) {
|
|
@@ -10384,8 +10389,12 @@ function recycleImage(attrName, data) {
|
|
|
10384
10389
|
const PaintImageModule = {
|
|
10385
10390
|
image: image,
|
|
10386
10391
|
checkImage: checkImage,
|
|
10387
|
-
|
|
10392
|
+
drawImage: drawImage,
|
|
10393
|
+
getImageRenderScaleData: getImageRenderScaleData,
|
|
10388
10394
|
recycleImage: recycleImage,
|
|
10395
|
+
createPatternTask: createPatternTask,
|
|
10396
|
+
createPattern: createPattern,
|
|
10397
|
+
getPatternFixScale: getPatternFixScale,
|
|
10389
10398
|
createData: createData,
|
|
10390
10399
|
getPatternData: getPatternData,
|
|
10391
10400
|
stretchMode: stretchMode,
|
|
@@ -10841,10 +10850,8 @@ function createRows(drawData, content, style) {
|
|
|
10841
10850
|
bounds = drawData.bounds;
|
|
10842
10851
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
10843
10852
|
const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
|
|
10844
|
-
const {canvas: canvas} = Platform;
|
|
10845
|
-
|
|
10846
|
-
const charMode = width || height || __letterSpacing || textCase !== "none";
|
|
10847
|
-
if (charMode) {
|
|
10853
|
+
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
10854
|
+
if (style.__isCharMode) {
|
|
10848
10855
|
const wrap = style.textWrap !== "none";
|
|
10849
10856
|
const breakAll = style.textWrap === "break";
|
|
10850
10857
|
paraStart = true;
|
|
@@ -10973,12 +10980,19 @@ const TextMode = 2;
|
|
|
10973
10980
|
function layoutChar(drawData, style, width, _height) {
|
|
10974
10981
|
const {rows: rows} = drawData;
|
|
10975
10982
|
const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
|
|
10976
|
-
|
|
10983
|
+
const justifyLast = width && textAlign.includes("both");
|
|
10984
|
+
const justify = justifyLast || width && textAlign.includes("justify");
|
|
10985
|
+
const justifyLetter = justify && textAlign.includes("letter");
|
|
10986
|
+
let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
|
|
10977
10987
|
rows.forEach(row => {
|
|
10978
10988
|
if (row.words) {
|
|
10979
10989
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
10980
|
-
|
|
10981
|
-
|
|
10990
|
+
if (justify) {
|
|
10991
|
+
canJustify = !row.paraEnd || justifyLast;
|
|
10992
|
+
remainingWidth = width - row.width - indentWidth;
|
|
10993
|
+
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
10994
|
+
}
|
|
10995
|
+
mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
10982
10996
|
if (row.isOverflow && !letterSpacing) row.textMode = true;
|
|
10983
10997
|
if (mode === TextMode) {
|
|
10984
10998
|
row.x += indentWidth;
|
|
@@ -10996,11 +11010,15 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
10996
11010
|
charX = toWordChar(word.data, charX, wordChar);
|
|
10997
11011
|
if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
|
|
10998
11012
|
} else {
|
|
10999
|
-
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
11013
|
+
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
11000
11014
|
}
|
|
11001
|
-
if (
|
|
11002
|
-
|
|
11003
|
-
|
|
11015
|
+
if (canJustify) {
|
|
11016
|
+
isLastWord = index === wordsLength - 1;
|
|
11017
|
+
if (addWordWidth) {
|
|
11018
|
+
if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
|
|
11019
|
+
} else if (addLetterWidth) {
|
|
11020
|
+
row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
|
|
11021
|
+
}
|
|
11004
11022
|
}
|
|
11005
11023
|
});
|
|
11006
11024
|
}
|
|
@@ -11026,13 +11044,14 @@ function toWordChar(data, charX, wordChar) {
|
|
|
11026
11044
|
return charX;
|
|
11027
11045
|
}
|
|
11028
11046
|
|
|
11029
|
-
function toChar(data, charX, rowData, isOverflow) {
|
|
11047
|
+
function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
|
|
11030
11048
|
data.forEach(char => {
|
|
11031
11049
|
if (isOverflow || char.char !== " ") {
|
|
11032
11050
|
char.x = charX;
|
|
11033
11051
|
rowData.push(char);
|
|
11034
11052
|
}
|
|
11035
11053
|
charX += char.width;
|
|
11054
|
+
addLetterWidth && (charX += addLetterWidth);
|
|
11036
11055
|
});
|
|
11037
11056
|
return charX;
|
|
11038
11057
|
}
|
|
@@ -11174,10 +11193,10 @@ function getDrawData(content, style) {
|
|
|
11174
11193
|
let x = 0, y = 0;
|
|
11175
11194
|
let width = style.__getInput("width") || 0;
|
|
11176
11195
|
let height = style.__getInput("height") || 0;
|
|
11177
|
-
const {
|
|
11196
|
+
const {__padding: padding} = style;
|
|
11178
11197
|
if (padding) {
|
|
11179
|
-
if (width) x = padding[left], width -= padding[right] + padding[left]; else if (!style.autoSizeAlign) x = padding[left];
|
|
11180
|
-
if (height) y = padding[top], height -= padding[top] + padding[bottom]; else if (!style.autoSizeAlign) y = padding[top];
|
|
11198
|
+
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
11199
|
+
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
11181
11200
|
}
|
|
11182
11201
|
const drawData = {
|
|
11183
11202
|
bounds: {
|
|
@@ -11188,14 +11207,14 @@ function getDrawData(content, style) {
|
|
|
11188
11207
|
},
|
|
11189
11208
|
rows: [],
|
|
11190
11209
|
paraNumber: 0,
|
|
11191
|
-
font: Platform.canvas.font = __font
|
|
11210
|
+
font: Platform.canvas.font = style.__font
|
|
11192
11211
|
};
|
|
11193
11212
|
createRows(drawData, content, style);
|
|
11194
11213
|
if (padding) padAutoText(padding, drawData, style, width, height);
|
|
11195
11214
|
layoutText(drawData, style);
|
|
11196
|
-
layoutChar(drawData, style, width);
|
|
11215
|
+
if (style.__isCharMode) layoutChar(drawData, style, width);
|
|
11197
11216
|
if (drawData.overflow) clipText(drawData, style, x, width);
|
|
11198
|
-
if (textDecoration !== "none") decorationText(drawData, style);
|
|
11217
|
+
if (style.textDecoration !== "none") decorationText(drawData, style);
|
|
11199
11218
|
return drawData;
|
|
11200
11219
|
}
|
|
11201
11220
|
|