leafer-draw 1.9.12 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web.cjs +428 -428
- package/dist/web.esm.js +430 -430
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +546 -533
- 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 +567 -550
- 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.1";
|
|
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(_paint, 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,102 +9606,163 @@ 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) {
|
|
9615
|
-
let item;
|
|
9614
|
+
function fills(fills, ui, canvas, renderOptions) {
|
|
9615
|
+
let item, originPaint, countImage;
|
|
9616
9616
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
9617
|
-
item = fills[i];
|
|
9617
|
+
item = fills[i], originPaint = item.originPaint;
|
|
9618
9618
|
if (item.image) {
|
|
9619
|
-
|
|
9619
|
+
countImage ? countImage++ : countImage = 1;
|
|
9620
|
+
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
9620
9621
|
if (!item.style) {
|
|
9621
|
-
if (
|
|
9622
|
+
if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
|
|
9622
9623
|
continue;
|
|
9623
9624
|
}
|
|
9624
9625
|
}
|
|
9625
9626
|
canvas.fillStyle = item.style;
|
|
9626
|
-
if (item.transform ||
|
|
9627
|
+
if (item.transform || originPaint.scaleFixed) {
|
|
9627
9628
|
canvas.save();
|
|
9628
9629
|
if (item.transform) canvas.transform(item.transform);
|
|
9629
|
-
if (
|
|
9630
|
+
if (originPaint.scaleFixed) {
|
|
9630
9631
|
const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
9631
|
-
if (
|
|
9632
|
+
if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
9632
9633
|
}
|
|
9633
|
-
if (
|
|
9634
|
-
fillPathOrText(ui, canvas);
|
|
9634
|
+
if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
|
|
9635
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9635
9636
|
canvas.restore();
|
|
9636
9637
|
} else {
|
|
9637
|
-
if (
|
|
9638
|
-
canvas.saveBlendMode(
|
|
9639
|
-
fillPathOrText(ui, canvas);
|
|
9638
|
+
if (originPaint.blendMode) {
|
|
9639
|
+
canvas.saveBlendMode(originPaint.blendMode);
|
|
9640
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
9640
9641
|
canvas.restoreBlendMode();
|
|
9641
|
-
} else fillPathOrText(ui, canvas);
|
|
9642
|
+
} else fillPathOrText(ui, canvas, renderOptions);
|
|
9643
|
+
}
|
|
9644
|
+
}
|
|
9645
|
+
}
|
|
9646
|
+
|
|
9647
|
+
function fillPathOrText(ui, canvas, renderOptions) {
|
|
9648
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
9649
|
+
}
|
|
9650
|
+
|
|
9651
|
+
function fillText(ui, canvas, _renderOptions) {
|
|
9652
|
+
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
9653
|
+
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
9654
|
+
let row;
|
|
9655
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
9656
|
+
row = rows[i];
|
|
9657
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
9658
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
9659
|
+
});
|
|
9660
|
+
}
|
|
9661
|
+
if (decorationY) {
|
|
9662
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
9663
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
9664
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
9665
|
+
}
|
|
9666
|
+
}
|
|
9667
|
+
|
|
9668
|
+
function stroke(stroke, ui, canvas, renderOptions) {
|
|
9669
|
+
const data = ui.__;
|
|
9670
|
+
if (!data.__strokeWidth) return;
|
|
9671
|
+
if (data.__font) {
|
|
9672
|
+
Paint.strokeText(stroke, ui, canvas, renderOptions);
|
|
9673
|
+
} else {
|
|
9674
|
+
switch (data.strokeAlign) {
|
|
9675
|
+
case "center":
|
|
9676
|
+
drawCenter$1(stroke, 1, ui, canvas, renderOptions);
|
|
9677
|
+
break;
|
|
9678
|
+
|
|
9679
|
+
case "inside":
|
|
9680
|
+
drawInside(stroke, ui, canvas, renderOptions);
|
|
9681
|
+
break;
|
|
9682
|
+
|
|
9683
|
+
case "outside":
|
|
9684
|
+
drawOutside(stroke, ui, canvas, renderOptions);
|
|
9685
|
+
break;
|
|
9642
9686
|
}
|
|
9643
9687
|
}
|
|
9644
9688
|
}
|
|
9645
9689
|
|
|
9646
|
-
function
|
|
9647
|
-
|
|
9690
|
+
function strokes(strokes, ui, canvas, renderOptions) {
|
|
9691
|
+
Paint.stroke(strokes, ui, canvas, renderOptions);
|
|
9692
|
+
}
|
|
9693
|
+
|
|
9694
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9695
|
+
const data = ui.__;
|
|
9696
|
+
if (isObject(stroke)) {
|
|
9697
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
|
|
9698
|
+
} else {
|
|
9699
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9700
|
+
canvas.stroke();
|
|
9701
|
+
}
|
|
9702
|
+
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
|
|
9703
|
+
}
|
|
9704
|
+
|
|
9705
|
+
function drawInside(stroke, ui, canvas, renderOptions) {
|
|
9706
|
+
canvas.save();
|
|
9707
|
+
canvas.clipUI(ui);
|
|
9708
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9709
|
+
canvas.restore();
|
|
9710
|
+
}
|
|
9711
|
+
|
|
9712
|
+
function drawOutside(stroke, ui, canvas, renderOptions) {
|
|
9713
|
+
const data = ui.__;
|
|
9714
|
+
if (data.__fillAfterStroke) {
|
|
9715
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9716
|
+
} else {
|
|
9717
|
+
const {renderBounds: renderBounds} = ui.__layout;
|
|
9718
|
+
const out = canvas.getSameCanvas(true, true);
|
|
9719
|
+
ui.__drawRenderPath(out);
|
|
9720
|
+
drawCenter$1(stroke, 2, ui, out, renderOptions);
|
|
9721
|
+
out.clipUI(data);
|
|
9722
|
+
out.clearWorld(renderBounds);
|
|
9723
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9724
|
+
out.recycle(ui.__nowWorld);
|
|
9725
|
+
}
|
|
9648
9726
|
}
|
|
9649
9727
|
|
|
9650
|
-
function strokeText(stroke, ui, canvas) {
|
|
9728
|
+
function strokeText(stroke, ui, canvas, renderOptions) {
|
|
9651
9729
|
switch (ui.__.strokeAlign) {
|
|
9652
9730
|
case "center":
|
|
9653
|
-
drawCenter
|
|
9731
|
+
drawCenter(stroke, 1, ui, canvas, renderOptions);
|
|
9654
9732
|
break;
|
|
9655
9733
|
|
|
9656
9734
|
case "inside":
|
|
9657
|
-
drawAlign(stroke, "inside", ui, canvas);
|
|
9735
|
+
drawAlign(stroke, "inside", ui, canvas, renderOptions);
|
|
9658
9736
|
break;
|
|
9659
9737
|
|
|
9660
9738
|
case "outside":
|
|
9661
|
-
ui.__.__fillAfterStroke ? drawCenter
|
|
9739
|
+
ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
|
|
9662
9740
|
break;
|
|
9663
9741
|
}
|
|
9664
9742
|
}
|
|
9665
9743
|
|
|
9666
|
-
function drawCenter
|
|
9744
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9667
9745
|
const data = ui.__;
|
|
9668
9746
|
if (isObject(stroke)) {
|
|
9669
|
-
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
9747
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
|
|
9670
9748
|
} else {
|
|
9671
9749
|
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9672
|
-
drawTextStroke(ui, canvas);
|
|
9750
|
+
Paint.drawTextStroke(ui, canvas, renderOptions);
|
|
9673
9751
|
}
|
|
9674
9752
|
}
|
|
9675
9753
|
|
|
9676
|
-
function drawAlign(stroke, align, ui, canvas) {
|
|
9754
|
+
function drawAlign(stroke, align, ui, canvas, renderOptions) {
|
|
9677
9755
|
const out = canvas.getSameCanvas(true, true);
|
|
9678
9756
|
out.font = ui.__.__font;
|
|
9679
|
-
drawCenter
|
|
9757
|
+
drawCenter(stroke, 2, ui, out, renderOptions);
|
|
9680
9758
|
out.blendMode = align === "outside" ? "destination-out" : "destination-in";
|
|
9681
|
-
fillText(ui, out);
|
|
9759
|
+
Paint.fillText(ui, out, renderOptions);
|
|
9682
9760
|
out.blendMode = "normal";
|
|
9683
9761
|
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9684
9762
|
out.recycle(ui.__nowWorld);
|
|
9685
9763
|
}
|
|
9686
9764
|
|
|
9687
|
-
function drawTextStroke(ui, canvas) {
|
|
9765
|
+
function drawTextStroke(ui, canvas, _renderOptions) {
|
|
9688
9766
|
let row, data = ui.__.__textDrawData;
|
|
9689
9767
|
const {rows: rows, decorationY: decorationY} = data;
|
|
9690
9768
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
@@ -9699,89 +9777,29 @@ function drawTextStroke(ui, canvas) {
|
|
|
9699
9777
|
}
|
|
9700
9778
|
}
|
|
9701
9779
|
|
|
9702
|
-
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
9780
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
|
|
9703
9781
|
let item;
|
|
9704
9782
|
const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
|
|
9705
9783
|
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
9706
9784
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
9707
9785
|
item = strokes[i];
|
|
9708
|
-
if (item.image && PaintImage.checkImage(ui, canvas,
|
|
9786
|
+
if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
|
|
9709
9787
|
if (item.style) {
|
|
9710
9788
|
if (__hasMultiStrokeStyle) {
|
|
9711
9789
|
const {strokeStyle: strokeStyle} = item;
|
|
9712
9790
|
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
9713
9791
|
} else canvas.strokeStyle = item.style;
|
|
9714
|
-
if (item.blendMode) {
|
|
9715
|
-
canvas.saveBlendMode(item.blendMode);
|
|
9716
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9792
|
+
if (item.originPaint.blendMode) {
|
|
9793
|
+
canvas.saveBlendMode(item.originPaint.blendMode);
|
|
9794
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9717
9795
|
canvas.restoreBlendMode();
|
|
9718
9796
|
} else {
|
|
9719
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9797
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9720
9798
|
}
|
|
9721
9799
|
}
|
|
9722
9800
|
}
|
|
9723
9801
|
}
|
|
9724
9802
|
|
|
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
9803
|
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
9786
9804
|
|
|
9787
9805
|
const tempBounds$1 = {};
|
|
@@ -9869,62 +9887,63 @@ function compute(attrName, ui) {
|
|
|
9869
9887
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
9870
9888
|
isTransparent = true;
|
|
9871
9889
|
}
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
9890
|
+
if (attrName === "fill") {
|
|
9891
|
+
stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
|
|
9892
|
+
stintSet(data, "__isTransparentFill", isTransparent);
|
|
9893
|
+
} else {
|
|
9894
|
+
stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
|
|
9895
|
+
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
9896
|
+
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
9897
|
+
}
|
|
9876
9898
|
} else {
|
|
9877
|
-
|
|
9878
|
-
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
9879
|
-
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
9899
|
+
data.__removePaint(attrName, false);
|
|
9880
9900
|
}
|
|
9881
9901
|
}
|
|
9882
9902
|
|
|
9883
9903
|
function getLeafPaint(attrName, paint, ui) {
|
|
9884
9904
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
9885
|
-
let
|
|
9905
|
+
let leafPaint;
|
|
9886
9906
|
const {boxBounds: boxBounds} = ui.__layout;
|
|
9887
9907
|
switch (paint.type) {
|
|
9888
9908
|
case "image":
|
|
9889
|
-
|
|
9909
|
+
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
9890
9910
|
break;
|
|
9891
9911
|
|
|
9892
9912
|
case "linear":
|
|
9893
|
-
|
|
9913
|
+
leafPaint = PaintGradient.linearGradient(paint, boxBounds);
|
|
9894
9914
|
break;
|
|
9895
9915
|
|
|
9896
9916
|
case "radial":
|
|
9897
|
-
|
|
9917
|
+
leafPaint = PaintGradient.radialGradient(paint, boxBounds);
|
|
9898
9918
|
break;
|
|
9899
9919
|
|
|
9900
9920
|
case "angular":
|
|
9901
|
-
|
|
9921
|
+
leafPaint = PaintGradient.conicGradient(paint, boxBounds);
|
|
9902
9922
|
break;
|
|
9903
9923
|
|
|
9904
9924
|
case "solid":
|
|
9905
9925
|
const {type: type, color: color, opacity: opacity} = paint;
|
|
9906
|
-
|
|
9926
|
+
leafPaint = {
|
|
9907
9927
|
type: type,
|
|
9908
9928
|
style: ColorConvert.string(color, opacity)
|
|
9909
9929
|
};
|
|
9910
9930
|
break;
|
|
9911
9931
|
|
|
9912
9932
|
default:
|
|
9913
|
-
if (!isUndefined(paint.r))
|
|
9933
|
+
if (!isUndefined(paint.r)) leafPaint = {
|
|
9914
9934
|
type: "solid",
|
|
9915
9935
|
style: ColorConvert.string(paint)
|
|
9916
9936
|
};
|
|
9917
9937
|
}
|
|
9918
|
-
if (
|
|
9919
|
-
|
|
9938
|
+
if (leafPaint) {
|
|
9939
|
+
leafPaint.originPaint = paint;
|
|
9940
|
+
if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
|
|
9920
9941
|
if (paint.style) {
|
|
9921
9942
|
if (paint.style.strokeWidth === 0) return undefined;
|
|
9922
|
-
|
|
9943
|
+
leafPaint.strokeStyle = paint.style;
|
|
9923
9944
|
}
|
|
9924
|
-
if (paint.editing) data.editing = paint.editing;
|
|
9925
|
-
if (paint.blendMode) data.blendMode = paint.blendMode;
|
|
9926
9945
|
}
|
|
9927
|
-
return
|
|
9946
|
+
return leafPaint;
|
|
9928
9947
|
}
|
|
9929
9948
|
|
|
9930
9949
|
const PaintModule = {
|
|
@@ -9937,88 +9956,118 @@ const PaintModule = {
|
|
|
9937
9956
|
strokes: strokes,
|
|
9938
9957
|
strokeText: strokeText,
|
|
9939
9958
|
drawTextStroke: drawTextStroke,
|
|
9959
|
+
drawStrokesStyle: drawStrokesStyle,
|
|
9940
9960
|
shape: shape
|
|
9941
9961
|
};
|
|
9942
9962
|
|
|
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
|
-
}
|
|
9963
|
+
let cache, box = new Bounds;
|
|
9953
9964
|
|
|
9954
|
-
|
|
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
|
-
}
|
|
9965
|
+
const {isSame: isSame} = BoundsHelper;
|
|
9964
9966
|
|
|
9965
|
-
function
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
if (
|
|
9969
|
-
|
|
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
|
-
}
|
|
9977
|
-
|
|
9978
|
-
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
9979
|
-
const transform = get$3();
|
|
9980
|
-
if (freeTransform) {
|
|
9981
|
-
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9967
|
+
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
9968
|
+
let leafPaint, event;
|
|
9969
|
+
const image = ImageManager.get(paint);
|
|
9970
|
+
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
9971
|
+
leafPaint = cache.leafPaint;
|
|
9982
9972
|
} else {
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
9973
|
+
leafPaint = {
|
|
9974
|
+
type: paint.type,
|
|
9975
|
+
image: image
|
|
9976
|
+
};
|
|
9977
|
+
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
9978
|
+
cache = image.use > 1 ? {
|
|
9979
|
+
leafPaint: leafPaint,
|
|
9980
|
+
paint: paint,
|
|
9981
|
+
boxBounds: box.set(boxBounds)
|
|
9982
|
+
} : null;
|
|
9983
|
+
}
|
|
9984
|
+
if (firstUse || image.loading) event = {
|
|
9985
|
+
image: image,
|
|
9986
|
+
attrName: attrName,
|
|
9987
|
+
attrValue: paint
|
|
9988
|
+
};
|
|
9989
|
+
if (image.ready) {
|
|
9990
|
+
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
9991
|
+
if (firstUse) {
|
|
9992
|
+
onLoad(ui, event);
|
|
9993
|
+
onLoadSuccess(ui, event);
|
|
9994
|
+
}
|
|
9995
|
+
} else if (image.error) {
|
|
9996
|
+
if (firstUse) onLoadError(ui, event, image.error);
|
|
9997
|
+
} else {
|
|
9998
|
+
if (firstUse) {
|
|
9999
|
+
ignoreRender(ui, true);
|
|
10000
|
+
onLoad(ui, event);
|
|
10001
|
+
}
|
|
10002
|
+
leafPaint.loadId = image.load(() => {
|
|
10003
|
+
ignoreRender(ui, false);
|
|
10004
|
+
if (!ui.destroyed) {
|
|
10005
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
10006
|
+
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
10007
|
+
ui.forceUpdate("surface");
|
|
10008
|
+
}
|
|
10009
|
+
onLoadSuccess(ui, event);
|
|
10010
|
+
}
|
|
10011
|
+
leafPaint.loadId = undefined;
|
|
10012
|
+
}, error => {
|
|
10013
|
+
ignoreRender(ui, false);
|
|
10014
|
+
onLoadError(ui, event, error);
|
|
10015
|
+
leafPaint.loadId = undefined;
|
|
10016
|
+
});
|
|
10017
|
+
if (ui.placeholderColor) {
|
|
10018
|
+
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
10019
|
+
if (!image.ready) {
|
|
10020
|
+
image.isPlacehold = true;
|
|
10021
|
+
ui.forceUpdate("surface");
|
|
10003
10022
|
}
|
|
10023
|
+
}, ui.placeholderDelay);
|
|
10024
|
+
}
|
|
10025
|
+
}
|
|
10026
|
+
return leafPaint;
|
|
10027
|
+
}
|
|
10028
|
+
|
|
10029
|
+
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
10030
|
+
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
10031
|
+
const data = ui.__;
|
|
10032
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
10033
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
10034
|
+
if (data.__autoSide) {
|
|
10035
|
+
ui.forceUpdate("width");
|
|
10036
|
+
if (ui.__proxyData) {
|
|
10037
|
+
ui.setProxyAttr("width", data.width);
|
|
10038
|
+
ui.setProxyAttr("height", data.height);
|
|
10004
10039
|
}
|
|
10040
|
+
return false;
|
|
10005
10041
|
}
|
|
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
10042
|
}
|
|
10011
|
-
data.
|
|
10043
|
+
if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
10044
|
+
return true;
|
|
10012
10045
|
}
|
|
10013
10046
|
|
|
10014
|
-
function
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10047
|
+
function onLoad(ui, event) {
|
|
10048
|
+
emit(ui, ImageEvent.LOAD, event);
|
|
10049
|
+
}
|
|
10050
|
+
|
|
10051
|
+
function onLoadSuccess(ui, event) {
|
|
10052
|
+
emit(ui, ImageEvent.LOADED, event);
|
|
10053
|
+
}
|
|
10054
|
+
|
|
10055
|
+
function onLoadError(ui, event, error) {
|
|
10056
|
+
event.error = error;
|
|
10057
|
+
ui.forceUpdate("surface");
|
|
10058
|
+
emit(ui, ImageEvent.ERROR, event);
|
|
10019
10059
|
}
|
|
10020
10060
|
|
|
10021
|
-
|
|
10061
|
+
function emit(ui, type, data) {
|
|
10062
|
+
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
10063
|
+
}
|
|
10064
|
+
|
|
10065
|
+
function ignoreRender(ui, value) {
|
|
10066
|
+
const {leafer: leafer} = ui;
|
|
10067
|
+
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
10068
|
+
}
|
|
10069
|
+
|
|
10070
|
+
const {get: get$3, translate: translate$1} = MatrixHelper;
|
|
10022
10071
|
|
|
10023
10072
|
const tempBox = new Bounds;
|
|
10024
10073
|
|
|
@@ -10027,17 +10076,13 @@ const tempScaleData = {};
|
|
|
10027
10076
|
const tempImage = {};
|
|
10028
10077
|
|
|
10029
10078
|
function createData(leafPaint, image, paint, box) {
|
|
10030
|
-
|
|
10031
|
-
if (changeful) leafPaint.changeful = changeful;
|
|
10032
|
-
if (sync) leafPaint.sync = sync;
|
|
10033
|
-
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
10034
|
-
leafPaint.data = getPatternData(paint, box, image);
|
|
10079
|
+
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
10035
10080
|
}
|
|
10036
10081
|
|
|
10037
10082
|
function getPatternData(paint, box, image) {
|
|
10038
10083
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
10039
10084
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
10040
|
-
|
|
10085
|
+
const {width: width, height: height} = image;
|
|
10041
10086
|
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
10087
|
const sameBox = box.width === width && box.height === height;
|
|
10043
10088
|
const data = {
|
|
@@ -10068,8 +10113,8 @@ function getPatternData(paint, box, image) {
|
|
|
10068
10113
|
case "stretch":
|
|
10069
10114
|
if (!sameBox) {
|
|
10070
10115
|
scaleX = box.width / width, scaleY = box.height / height;
|
|
10071
|
-
stretchMode(data, box, scaleX, scaleY);
|
|
10072
|
-
}
|
|
10116
|
+
PaintImage.stretchMode(data, box, scaleX, scaleY);
|
|
10117
|
+
} else if (scaleX) scaleX = scaleY = undefined;
|
|
10073
10118
|
break;
|
|
10074
10119
|
|
|
10075
10120
|
case "normal":
|
|
@@ -10077,13 +10122,13 @@ function getPatternData(paint, box, image) {
|
|
|
10077
10122
|
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
10078
10123
|
let clipScaleX, clipScaleY;
|
|
10079
10124
|
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);
|
|
10125
|
+
PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
10081
10126
|
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
10082
10127
|
}
|
|
10083
10128
|
break;
|
|
10084
10129
|
|
|
10085
10130
|
case "repeat":
|
|
10086
|
-
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
10131
|
+
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
10087
10132
|
if (!repeat) data.repeat = "repeat";
|
|
10088
10133
|
const count = isObject(repeat);
|
|
10089
10134
|
if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
|
|
@@ -10092,18 +10137,16 @@ function getPatternData(paint, box, image) {
|
|
|
10092
10137
|
case "fit":
|
|
10093
10138
|
case "cover":
|
|
10094
10139
|
default:
|
|
10095
|
-
if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
10140
|
+
if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
10096
10141
|
}
|
|
10097
10142
|
if (!data.transform) {
|
|
10098
|
-
if (box.x || box.y) translate(data.transform = get$
|
|
10143
|
+
if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
|
|
10099
10144
|
}
|
|
10100
|
-
data.width = width;
|
|
10101
|
-
data.height = height;
|
|
10102
10145
|
if (scaleX) {
|
|
10103
10146
|
data.scaleX = scaleX;
|
|
10104
10147
|
data.scaleY = scaleY;
|
|
10105
10148
|
}
|
|
10106
|
-
if (opacity) data.opacity = opacity;
|
|
10149
|
+
if (opacity && opacity < 1) data.opacity = opacity;
|
|
10107
10150
|
if (filters) data.filters = filters;
|
|
10108
10151
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
10109
10152
|
return data;
|
|
@@ -10125,234 +10168,194 @@ function getGapValue(gap, size, totalSize, rows) {
|
|
|
10125
10168
|
return gap === "auto" ? value < 0 ? 0 : value : value;
|
|
10126
10169
|
}
|
|
10127
10170
|
|
|
10128
|
-
let
|
|
10171
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
10129
10172
|
|
|
10130
|
-
const {
|
|
10173
|
+
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
10131
10174
|
|
|
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;
|
|
10175
|
+
function stretchMode(data, box, scaleX, scaleY) {
|
|
10176
|
+
const transform = get$2(), {x: x, y: y} = box;
|
|
10177
|
+
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
10178
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
10179
|
+
data.transform = transform;
|
|
10192
10180
|
}
|
|
10193
10181
|
|
|
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;
|
|
10182
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10183
|
+
const transform = get$2();
|
|
10184
|
+
translate(transform, box.x + x, box.y + y);
|
|
10185
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
10186
|
+
if (rotation) rotateOfOuter$1(transform, {
|
|
10187
|
+
x: box.x + box.width / 2,
|
|
10188
|
+
y: box.y + box.height / 2
|
|
10189
|
+
}, rotation);
|
|
10190
|
+
data.transform = transform;
|
|
10210
10191
|
}
|
|
10211
10192
|
|
|
10212
|
-
function
|
|
10213
|
-
|
|
10193
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
10194
|
+
const transform = get$2();
|
|
10195
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
10196
|
+
if (clipScaleX) {
|
|
10197
|
+
if (rotation || skew) {
|
|
10198
|
+
set(tempMatrix$1);
|
|
10199
|
+
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
10200
|
+
multiplyParent(transform, tempMatrix$1);
|
|
10201
|
+
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
10202
|
+
}
|
|
10203
|
+
data.transform = transform;
|
|
10214
10204
|
}
|
|
10215
10205
|
|
|
10216
|
-
function
|
|
10217
|
-
|
|
10218
|
-
|
|
10206
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
10207
|
+
const transform = get$2();
|
|
10208
|
+
if (freeTransform) {
|
|
10209
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
10210
|
+
} else {
|
|
10211
|
+
if (rotation) {
|
|
10212
|
+
if (align === "center") {
|
|
10213
|
+
rotateOfOuter$1(transform, {
|
|
10214
|
+
x: width / 2,
|
|
10215
|
+
y: height / 2
|
|
10216
|
+
}, rotation);
|
|
10217
|
+
} else {
|
|
10218
|
+
rotate(transform, rotation);
|
|
10219
|
+
switch (rotation) {
|
|
10220
|
+
case 90:
|
|
10221
|
+
translate(transform, height, 0);
|
|
10222
|
+
break;
|
|
10219
10223
|
|
|
10220
|
-
|
|
10221
|
-
|
|
10222
|
-
|
|
10223
|
-
emit(ui, ImageEvent.ERROR, event);
|
|
10224
|
-
}
|
|
10224
|
+
case 180:
|
|
10225
|
+
translate(transform, width, height);
|
|
10226
|
+
break;
|
|
10225
10227
|
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
+
case 270:
|
|
10229
|
+
translate(transform, 0, width);
|
|
10230
|
+
break;
|
|
10231
|
+
}
|
|
10232
|
+
}
|
|
10233
|
+
}
|
|
10234
|
+
origin.x = box.x + x;
|
|
10235
|
+
origin.y = box.y + y;
|
|
10236
|
+
translate(transform, origin.x, origin.y);
|
|
10237
|
+
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
10238
|
+
}
|
|
10239
|
+
data.transform = transform;
|
|
10228
10240
|
}
|
|
10229
10241
|
|
|
10230
|
-
function
|
|
10231
|
-
|
|
10232
|
-
if (
|
|
10242
|
+
function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
10243
|
+
if (rotation) rotate(transform, rotation);
|
|
10244
|
+
if (skew) skewHelper(transform, skew.x, skew.y);
|
|
10245
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
10246
|
+
translate(transform, box.x + x, box.y + y);
|
|
10233
10247
|
}
|
|
10234
10248
|
|
|
10235
10249
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
10236
10250
|
|
|
10237
|
-
const {
|
|
10251
|
+
const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
10238
10252
|
|
|
10239
|
-
function
|
|
10240
|
-
|
|
10241
|
-
|
|
10253
|
+
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
10254
|
+
if (!paint.patternTask) {
|
|
10255
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
10256
|
+
paint.patternTask = null;
|
|
10257
|
+
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
10258
|
+
ui.forceUpdate("surface");
|
|
10259
|
+
}), 300);
|
|
10260
|
+
}
|
|
10261
|
+
}
|
|
10262
|
+
|
|
10263
|
+
function createPattern(paint, ui, canvas, renderOptions) {
|
|
10264
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
10242
10265
|
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) {
|
|
10266
|
+
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
10267
|
+
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
10268
|
+
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
10269
|
+
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
10270
|
+
width *= scaleX;
|
|
10271
|
+
height *= scaleY;
|
|
10272
|
+
if (gap) {
|
|
10273
|
+
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
10274
|
+
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
10275
|
+
}
|
|
10276
|
+
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10277
|
+
scaleX *= getFloorScale(width + (xGap || 0));
|
|
10278
|
+
scaleY *= getFloorScale(height + (yGap || 0));
|
|
10289
10279
|
imageMatrix = get$1();
|
|
10290
10280
|
if (transform) copy$1(imageMatrix, transform);
|
|
10281
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10291
10282
|
}
|
|
10292
|
-
|
|
10283
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
10284
|
+
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10285
|
+
paint.style = pattern;
|
|
10286
|
+
paint.patternId = id;
|
|
10293
10287
|
}
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10288
|
+
}
|
|
10289
|
+
}
|
|
10290
|
+
|
|
10291
|
+
function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
10292
|
+
const {image: image} = paint;
|
|
10293
|
+
let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
|
|
10294
|
+
if (image.isSVG) {
|
|
10295
|
+
if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
|
|
10299
10296
|
} else {
|
|
10300
|
-
|
|
10297
|
+
if (maxSize > imageSize) maxSize = imageSize;
|
|
10301
10298
|
}
|
|
10299
|
+
if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
|
|
10300
|
+
return fixScale;
|
|
10302
10301
|
}
|
|
10303
10302
|
|
|
10304
|
-
function checkImage(ui, canvas,
|
|
10305
|
-
const {scaleX: scaleX, scaleY: scaleY} =
|
|
10306
|
-
const {
|
|
10307
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY
|
|
10303
|
+
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
10304
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
10305
|
+
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
|
|
10306
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
10308
10307
|
return false;
|
|
10309
10308
|
} else {
|
|
10310
|
-
if (
|
|
10309
|
+
if (drawImage) {
|
|
10311
10310
|
if (data.repeat) {
|
|
10312
|
-
|
|
10313
|
-
} else if (!(
|
|
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;
|
|
10311
|
+
drawImage = false;
|
|
10312
|
+
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
10313
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
10322
10314
|
}
|
|
10323
10315
|
}
|
|
10324
|
-
if (
|
|
10316
|
+
if (drawImage) {
|
|
10325
10317
|
if (ui.__.__isFastShadow) {
|
|
10326
10318
|
canvas.fillStyle = paint.style || "#000";
|
|
10327
10319
|
canvas.fill();
|
|
10328
10320
|
}
|
|
10329
|
-
drawImage(ui, canvas,
|
|
10321
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
10330
10322
|
return true;
|
|
10331
10323
|
} else {
|
|
10332
|
-
if (!paint.style ||
|
|
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
|
-
}
|
|
10324
|
+
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
10343
10325
|
return false;
|
|
10344
10326
|
}
|
|
10345
10327
|
}
|
|
10346
10328
|
}
|
|
10347
10329
|
|
|
10348
|
-
function drawImage(ui, canvas,
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
if (
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10330
|
+
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
10331
|
+
const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
10332
|
+
let {width: width, height: height} = image, clipUI;
|
|
10333
|
+
if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
|
|
10334
|
+
canvas.save();
|
|
10335
|
+
clipUI && canvas.clipUI(ui);
|
|
10336
|
+
blendMode && (canvas.blendMode = blendMode);
|
|
10337
|
+
opacity && (canvas.opacity *= opacity);
|
|
10338
|
+
transform && canvas.transform(transform);
|
|
10339
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
10340
|
+
canvas.restore();
|
|
10341
|
+
} else {
|
|
10342
|
+
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
10343
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
10344
|
+
}
|
|
10345
|
+
}
|
|
10346
|
+
|
|
10347
|
+
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
10348
|
+
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
10349
|
+
if (canvas) {
|
|
10350
|
+
const {pixelRatio: pixelRatio} = canvas;
|
|
10351
|
+
scaleData.scaleX *= pixelRatio;
|
|
10352
|
+
scaleData.scaleY *= pixelRatio;
|
|
10353
|
+
}
|
|
10354
|
+
if (data && data.scaleX) {
|
|
10355
|
+
scaleData.scaleX *= Math.abs(data.scaleX);
|
|
10356
|
+
scaleData.scaleY *= Math.abs(data.scaleY);
|
|
10357
|
+
}
|
|
10358
|
+
return scaleData;
|
|
10356
10359
|
}
|
|
10357
10360
|
|
|
10358
10361
|
function recycleImage(attrName, data) {
|
|
@@ -10384,8 +10387,12 @@ function recycleImage(attrName, data) {
|
|
|
10384
10387
|
const PaintImageModule = {
|
|
10385
10388
|
image: image,
|
|
10386
10389
|
checkImage: checkImage,
|
|
10387
|
-
|
|
10390
|
+
drawImage: drawImage,
|
|
10391
|
+
getImageRenderScaleData: getImageRenderScaleData,
|
|
10388
10392
|
recycleImage: recycleImage,
|
|
10393
|
+
createPatternTask: createPatternTask,
|
|
10394
|
+
createPattern: createPattern,
|
|
10395
|
+
getPatternFixScale: getPatternFixScale,
|
|
10389
10396
|
createData: createData,
|
|
10390
10397
|
getPatternData: getPatternData,
|
|
10391
10398
|
stretchMode: stretchMode,
|
|
@@ -10841,10 +10848,8 @@ function createRows(drawData, content, style) {
|
|
|
10841
10848
|
bounds = drawData.bounds;
|
|
10842
10849
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
10843
10850
|
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) {
|
|
10851
|
+
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
10852
|
+
if (style.__isCharMode) {
|
|
10848
10853
|
const wrap = style.textWrap !== "none";
|
|
10849
10854
|
const breakAll = style.textWrap === "break";
|
|
10850
10855
|
paraStart = true;
|
|
@@ -10973,12 +10978,19 @@ const TextMode = 2;
|
|
|
10973
10978
|
function layoutChar(drawData, style, width, _height) {
|
|
10974
10979
|
const {rows: rows} = drawData;
|
|
10975
10980
|
const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
|
|
10976
|
-
|
|
10981
|
+
const justifyLast = width && textAlign.includes("both");
|
|
10982
|
+
const justify = justifyLast || width && textAlign.includes("justify");
|
|
10983
|
+
const justifyLetter = justify && textAlign.includes("letter");
|
|
10984
|
+
let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
|
|
10977
10985
|
rows.forEach(row => {
|
|
10978
10986
|
if (row.words) {
|
|
10979
10987
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
10980
|
-
|
|
10981
|
-
|
|
10988
|
+
if (justify) {
|
|
10989
|
+
canJustify = !row.paraEnd || justifyLast;
|
|
10990
|
+
remainingWidth = width - row.width - indentWidth;
|
|
10991
|
+
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
10992
|
+
}
|
|
10993
|
+
mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
10982
10994
|
if (row.isOverflow && !letterSpacing) row.textMode = true;
|
|
10983
10995
|
if (mode === TextMode) {
|
|
10984
10996
|
row.x += indentWidth;
|
|
@@ -10996,11 +11008,15 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
10996
11008
|
charX = toWordChar(word.data, charX, wordChar);
|
|
10997
11009
|
if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
|
|
10998
11010
|
} else {
|
|
10999
|
-
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
11011
|
+
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
11000
11012
|
}
|
|
11001
|
-
if (
|
|
11002
|
-
|
|
11003
|
-
|
|
11013
|
+
if (canJustify) {
|
|
11014
|
+
isLastWord = index === wordsLength - 1;
|
|
11015
|
+
if (addWordWidth) {
|
|
11016
|
+
if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
|
|
11017
|
+
} else if (addLetterWidth) {
|
|
11018
|
+
row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
|
|
11019
|
+
}
|
|
11004
11020
|
}
|
|
11005
11021
|
});
|
|
11006
11022
|
}
|
|
@@ -11026,13 +11042,14 @@ function toWordChar(data, charX, wordChar) {
|
|
|
11026
11042
|
return charX;
|
|
11027
11043
|
}
|
|
11028
11044
|
|
|
11029
|
-
function toChar(data, charX, rowData, isOverflow) {
|
|
11045
|
+
function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
|
|
11030
11046
|
data.forEach(char => {
|
|
11031
11047
|
if (isOverflow || char.char !== " ") {
|
|
11032
11048
|
char.x = charX;
|
|
11033
11049
|
rowData.push(char);
|
|
11034
11050
|
}
|
|
11035
11051
|
charX += char.width;
|
|
11052
|
+
addLetterWidth && (charX += addLetterWidth);
|
|
11036
11053
|
});
|
|
11037
11054
|
return charX;
|
|
11038
11055
|
}
|
|
@@ -11174,10 +11191,10 @@ function getDrawData(content, style) {
|
|
|
11174
11191
|
let x = 0, y = 0;
|
|
11175
11192
|
let width = style.__getInput("width") || 0;
|
|
11176
11193
|
let height = style.__getInput("height") || 0;
|
|
11177
|
-
const {
|
|
11194
|
+
const {__padding: padding} = style;
|
|
11178
11195
|
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];
|
|
11196
|
+
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
11197
|
+
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
11181
11198
|
}
|
|
11182
11199
|
const drawData = {
|
|
11183
11200
|
bounds: {
|
|
@@ -11188,14 +11205,14 @@ function getDrawData(content, style) {
|
|
|
11188
11205
|
},
|
|
11189
11206
|
rows: [],
|
|
11190
11207
|
paraNumber: 0,
|
|
11191
|
-
font: Platform.canvas.font = __font
|
|
11208
|
+
font: Platform.canvas.font = style.__font
|
|
11192
11209
|
};
|
|
11193
11210
|
createRows(drawData, content, style);
|
|
11194
11211
|
if (padding) padAutoText(padding, drawData, style, width, height);
|
|
11195
11212
|
layoutText(drawData, style);
|
|
11196
|
-
layoutChar(drawData, style, width);
|
|
11213
|
+
if (style.__isCharMode) layoutChar(drawData, style, width);
|
|
11197
11214
|
if (drawData.overflow) clipText(drawData, style, x, width);
|
|
11198
|
-
if (textDecoration !== "none") decorationText(drawData, style);
|
|
11215
|
+
if (style.textDecoration !== "none") decorationText(drawData, style);
|
|
11199
11216
|
return drawData;
|
|
11200
11217
|
}
|
|
11201
11218
|
|