@leafer-draw/worker 1.9.11 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.cjs +396 -394
- package/dist/worker.esm.js +398 -396
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +514 -499
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +536 -517
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/worker.js
CHANGED
|
@@ -1,42 +1,5 @@
|
|
|
1
1
|
var LeaferUI = function(exports) {
|
|
2
2
|
"use strict";
|
|
3
|
-
const Platform = {
|
|
4
|
-
toURL(text, fileType) {
|
|
5
|
-
let url = encodeURIComponent(text);
|
|
6
|
-
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
7
|
-
return url;
|
|
8
|
-
},
|
|
9
|
-
image: {
|
|
10
|
-
hitCanvasSize: 100,
|
|
11
|
-
maxCacheSize: 2560 * 1600,
|
|
12
|
-
maxPatternSize: 4096 * 2160,
|
|
13
|
-
crossOrigin: "anonymous",
|
|
14
|
-
getRealURL(url) {
|
|
15
|
-
const {prefix: prefix, suffix: suffix} = Platform.image;
|
|
16
|
-
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
17
|
-
if (prefix && url[0] === "/") url = prefix + url;
|
|
18
|
-
return url;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const IncrementId = {
|
|
23
|
-
RUNTIME: "runtime",
|
|
24
|
-
LEAF: "leaf",
|
|
25
|
-
TASK: "task",
|
|
26
|
-
CNAVAS: "canvas",
|
|
27
|
-
IMAGE: "image",
|
|
28
|
-
types: {},
|
|
29
|
-
create(typeName) {
|
|
30
|
-
const {types: types} = I$1;
|
|
31
|
-
if (types[typeName]) {
|
|
32
|
-
return types[typeName]++;
|
|
33
|
-
} else {
|
|
34
|
-
types[typeName] = 1;
|
|
35
|
-
return 0;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const I$1 = IncrementId;
|
|
40
3
|
exports.Answer = void 0;
|
|
41
4
|
(function(Answer) {
|
|
42
5
|
Answer[Answer["No"] = 0] = "No";
|
|
@@ -229,8 +192,74 @@ var LeaferUI = function(exports) {
|
|
|
229
192
|
this.__input = this.__middle = null;
|
|
230
193
|
}
|
|
231
194
|
}
|
|
195
|
+
const {floor: floor$2, max: max$4} = Math;
|
|
196
|
+
const Platform = {
|
|
197
|
+
toURL(text, fileType) {
|
|
198
|
+
let url = encodeURIComponent(text);
|
|
199
|
+
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
200
|
+
return url;
|
|
201
|
+
},
|
|
202
|
+
image: {
|
|
203
|
+
hitCanvasSize: 100,
|
|
204
|
+
maxCacheSize: 2560 * 1600,
|
|
205
|
+
maxPatternSize: 4096 * 2160,
|
|
206
|
+
crossOrigin: "anonymous",
|
|
207
|
+
isLarge(size, scaleX, scaleY, largeSize) {
|
|
208
|
+
return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image$1.maxCacheSize);
|
|
209
|
+
},
|
|
210
|
+
isSuperLarge(size, scaleX, scaleY) {
|
|
211
|
+
return image$1.isLarge(size, scaleX, scaleY, image$1.maxPatternSize);
|
|
212
|
+
},
|
|
213
|
+
getRealURL(url) {
|
|
214
|
+
const {prefix: prefix, suffix: suffix} = Platform.image;
|
|
215
|
+
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
216
|
+
if (prefix && url[0] === "/") url = prefix + url;
|
|
217
|
+
return url;
|
|
218
|
+
},
|
|
219
|
+
resize(image, width, height, xGap, yGap, clip, smooth, opacity, _filters) {
|
|
220
|
+
const canvas = Platform.origin.createCanvas(max$4(floor$2(width + (xGap || 0)), 1), max$4(floor$2(height + (yGap || 0)), 1));
|
|
221
|
+
const ctx = canvas.getContext("2d");
|
|
222
|
+
if (opacity) ctx.globalAlpha = opacity;
|
|
223
|
+
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
224
|
+
if (clip) {
|
|
225
|
+
const scaleX = width / clip.width, scaleY = height / clip.height;
|
|
226
|
+
ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
|
|
227
|
+
ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
228
|
+
} else ctx.drawImage(image, 0, 0, width, height);
|
|
229
|
+
return canvas;
|
|
230
|
+
},
|
|
231
|
+
setPatternTransform(pattern, transform, paint) {
|
|
232
|
+
try {
|
|
233
|
+
if (transform && pattern.setTransform) {
|
|
234
|
+
pattern.setTransform(transform);
|
|
235
|
+
transform = undefined;
|
|
236
|
+
}
|
|
237
|
+
} catch (_a) {}
|
|
238
|
+
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
const {image: image$1} = Platform;
|
|
243
|
+
const IncrementId = {
|
|
244
|
+
RUNTIME: "runtime",
|
|
245
|
+
LEAF: "leaf",
|
|
246
|
+
TASK: "task",
|
|
247
|
+
CNAVAS: "canvas",
|
|
248
|
+
IMAGE: "image",
|
|
249
|
+
types: {},
|
|
250
|
+
create(typeName) {
|
|
251
|
+
const {types: types} = I$1;
|
|
252
|
+
if (types[typeName]) {
|
|
253
|
+
return types[typeName]++;
|
|
254
|
+
} else {
|
|
255
|
+
types[typeName] = 1;
|
|
256
|
+
return 0;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const I$1 = IncrementId;
|
|
232
261
|
let tempA, tempB, tempTo;
|
|
233
|
-
const {max: max$
|
|
262
|
+
const {max: max$3} = Math, tempFour = [ 0, 0, 0, 0 ];
|
|
234
263
|
const FourNumberHelper = {
|
|
235
264
|
zero: [ ...tempFour ],
|
|
236
265
|
tempFour: tempFour,
|
|
@@ -281,9 +310,9 @@ var LeaferUI = function(exports) {
|
|
|
281
310
|
return data;
|
|
282
311
|
},
|
|
283
312
|
max(t, other, change) {
|
|
284
|
-
if (isNumber(t) && isNumber(other)) return max$
|
|
313
|
+
if (isNumber(t) && isNumber(other)) return max$3(t, other);
|
|
285
314
|
toTempAB(t, other, change);
|
|
286
|
-
return set$2(tempTo, max$
|
|
315
|
+
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]));
|
|
287
316
|
},
|
|
288
317
|
add(t, other, change) {
|
|
289
318
|
if (isNumber(t) && isNumber(other)) return t + other;
|
|
@@ -298,7 +327,7 @@ var LeaferUI = function(exports) {
|
|
|
298
327
|
}
|
|
299
328
|
};
|
|
300
329
|
const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
|
|
301
|
-
const {round: round$3, pow: pow$1, PI: PI$3} = Math;
|
|
330
|
+
const {round: round$3, pow: pow$1, max: max$2, floor: floor$1, PI: PI$3} = Math;
|
|
302
331
|
const MathHelper = {
|
|
303
332
|
within(value, min, max) {
|
|
304
333
|
if (isObject(min)) max = min.max, min = min.min;
|
|
@@ -350,6 +379,9 @@ var LeaferUI = function(exports) {
|
|
|
350
379
|
scaleData.scaleY = scale.y;
|
|
351
380
|
}
|
|
352
381
|
},
|
|
382
|
+
getFloorScale(num, min = 1) {
|
|
383
|
+
return max$2(floor$1(num), min) / num;
|
|
384
|
+
},
|
|
353
385
|
randInt: randInt,
|
|
354
386
|
randColor(opacity) {
|
|
355
387
|
return `rgba(${randInt(255)},${randInt(255)},${randInt(255)},${opacity || 1})`;
|
|
@@ -1141,7 +1173,7 @@ var LeaferUI = function(exports) {
|
|
|
1141
1173
|
const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2} = TwoPointBoundsHelper;
|
|
1142
1174
|
const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
|
|
1143
1175
|
const {float: float, fourNumber: fourNumber} = MathHelper;
|
|
1144
|
-
const {floor: floor
|
|
1176
|
+
const {floor: floor, ceil: ceil$1} = Math;
|
|
1145
1177
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
1146
1178
|
const point = {};
|
|
1147
1179
|
const toPoint$4 = {};
|
|
@@ -1228,20 +1260,20 @@ var LeaferUI = function(exports) {
|
|
|
1228
1260
|
toOuterOf(t, matrix, to) {
|
|
1229
1261
|
to || (to = t);
|
|
1230
1262
|
if (matrix.b === 0 && matrix.c === 0) {
|
|
1231
|
-
const {a: a, d: d} = matrix;
|
|
1263
|
+
const {a: a, d: d, e: e, f: f} = matrix;
|
|
1232
1264
|
if (a > 0) {
|
|
1233
1265
|
to.width = t.width * a;
|
|
1234
|
-
to.x =
|
|
1266
|
+
to.x = e + t.x * a;
|
|
1235
1267
|
} else {
|
|
1236
1268
|
to.width = t.width * -a;
|
|
1237
|
-
to.x =
|
|
1269
|
+
to.x = e + t.x * a - to.width;
|
|
1238
1270
|
}
|
|
1239
1271
|
if (d > 0) {
|
|
1240
1272
|
to.height = t.height * d;
|
|
1241
|
-
to.y =
|
|
1273
|
+
to.y = f + t.y * d;
|
|
1242
1274
|
} else {
|
|
1243
1275
|
to.height = t.height * -d;
|
|
1244
|
-
to.y =
|
|
1276
|
+
to.y = f + t.y * d - to.height;
|
|
1245
1277
|
}
|
|
1246
1278
|
} else {
|
|
1247
1279
|
point.x = t.x;
|
|
@@ -1293,10 +1325,10 @@ var LeaferUI = function(exports) {
|
|
|
1293
1325
|
},
|
|
1294
1326
|
ceil(t) {
|
|
1295
1327
|
const {x: x, y: y} = t;
|
|
1296
|
-
t.x = floor
|
|
1297
|
-
t.y = floor
|
|
1298
|
-
t.width = x > t.x ? ceil$
|
|
1299
|
-
t.height = y > t.y ? ceil$
|
|
1328
|
+
t.x = floor(t.x);
|
|
1329
|
+
t.y = floor(t.y);
|
|
1330
|
+
t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
|
|
1331
|
+
t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
|
|
1300
1332
|
},
|
|
1301
1333
|
unsign(t) {
|
|
1302
1334
|
if (t.width < 0) {
|
|
@@ -2417,7 +2449,7 @@ var LeaferUI = function(exports) {
|
|
|
2417
2449
|
data[0] ? drawer.arcTo(x, y, right, y, data[0]) : drawer.lineTo(x, y);
|
|
2418
2450
|
}
|
|
2419
2451
|
};
|
|
2420
|
-
const {sin: sin$3, cos: cos$3, hypot: hypot, atan2: atan2$1, ceil: ceil
|
|
2452
|
+
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;
|
|
2421
2453
|
const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
|
|
2422
2454
|
const {set: set$1, toNumberPoints: toNumberPoints} = PointHelper;
|
|
2423
2455
|
const {M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5} = PathCommandMap;
|
|
@@ -2520,7 +2552,7 @@ var LeaferUI = function(exports) {
|
|
|
2520
2552
|
let totalRadian = endRadian - startRadian;
|
|
2521
2553
|
if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
|
|
2522
2554
|
if (anticlockwise) totalRadian -= PI2;
|
|
2523
|
-
const parts = ceil
|
|
2555
|
+
const parts = ceil(abs$3(totalRadian / PI_2));
|
|
2524
2556
|
const partRadian = totalRadian / parts;
|
|
2525
2557
|
const partRadian4Sin = sin$3(partRadian / 4);
|
|
2526
2558
|
const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
|
|
@@ -3480,7 +3512,9 @@ var LeaferUI = function(exports) {
|
|
|
3480
3512
|
run() {
|
|
3481
3513
|
return __awaiter(this, void 0, void 0, function*() {
|
|
3482
3514
|
try {
|
|
3483
|
-
if (this.
|
|
3515
|
+
if (this.isComplete) return;
|
|
3516
|
+
if (this.canUse && !this.canUse()) return this.cancel();
|
|
3517
|
+
if (this.task && this.parent.running) yield this.task();
|
|
3484
3518
|
} catch (error) {
|
|
3485
3519
|
debug$8.error(error);
|
|
3486
3520
|
}
|
|
@@ -3488,8 +3522,7 @@ var LeaferUI = function(exports) {
|
|
|
3488
3522
|
}
|
|
3489
3523
|
complete() {
|
|
3490
3524
|
this.isComplete = true;
|
|
3491
|
-
this.parent = null;
|
|
3492
|
-
this.task = null;
|
|
3525
|
+
this.parent = this.task = this.canUse = null;
|
|
3493
3526
|
}
|
|
3494
3527
|
cancel() {
|
|
3495
3528
|
this.isCancel = true;
|
|
@@ -3531,7 +3564,7 @@ var LeaferUI = function(exports) {
|
|
|
3531
3564
|
if (config) DataHelper.assign(this.config, config);
|
|
3532
3565
|
this.empty();
|
|
3533
3566
|
}
|
|
3534
|
-
add(taskCallback, options) {
|
|
3567
|
+
add(taskCallback, options, canUse) {
|
|
3535
3568
|
let start, parallel, time, delay;
|
|
3536
3569
|
const task = new TaskItem(taskCallback);
|
|
3537
3570
|
task.parent = this;
|
|
@@ -3542,9 +3575,11 @@ var LeaferUI = function(exports) {
|
|
|
3542
3575
|
start = options.start;
|
|
3543
3576
|
time = options.time;
|
|
3544
3577
|
delay = options.delay;
|
|
3578
|
+
if (!canUse) canUse = options.canUse;
|
|
3545
3579
|
}
|
|
3546
3580
|
if (time) task.time = time;
|
|
3547
3581
|
if (parallel === false) task.parallel = false;
|
|
3582
|
+
if (canUse) task.canUse = canUse;
|
|
3548
3583
|
if (isUndefined(delay)) {
|
|
3549
3584
|
this.push(task, start);
|
|
3550
3585
|
} else {
|
|
@@ -3614,15 +3649,10 @@ var LeaferUI = function(exports) {
|
|
|
3614
3649
|
this.timer = setTimeout(() => this.nextTask());
|
|
3615
3650
|
return;
|
|
3616
3651
|
}
|
|
3617
|
-
if (task.isCancel) {
|
|
3618
|
-
this.index++;
|
|
3619
|
-
this.runTask();
|
|
3620
|
-
return;
|
|
3621
|
-
}
|
|
3622
3652
|
task.run().then(() => {
|
|
3623
3653
|
this.onTask(task);
|
|
3624
3654
|
this.index++;
|
|
3625
|
-
this.nextTask();
|
|
3655
|
+
task.isCancel ? this.runTask() : this.nextTask();
|
|
3626
3656
|
}).catch(error => {
|
|
3627
3657
|
this.onError(error);
|
|
3628
3658
|
});
|
|
@@ -3791,7 +3821,6 @@ var LeaferUI = function(exports) {
|
|
|
3791
3821
|
};
|
|
3792
3822
|
const I = ImageManager;
|
|
3793
3823
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
3794
|
-
const {floor: floor$1, max: max$3} = Math;
|
|
3795
3824
|
class LeaferImage {
|
|
3796
3825
|
get url() {
|
|
3797
3826
|
return this.config.url;
|
|
@@ -3816,10 +3845,9 @@ var LeaferUI = function(exports) {
|
|
|
3816
3845
|
load(onSuccess, onError) {
|
|
3817
3846
|
if (!this.loading) {
|
|
3818
3847
|
this.loading = true;
|
|
3819
|
-
|
|
3820
|
-
if (onProgress) loadImage = loadImageWithProgress;
|
|
3848
|
+
const {crossOrigin: crossOrigin} = this.config;
|
|
3821
3849
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
3822
|
-
return yield loadImage(this.url,
|
|
3850
|
+
return yield Platform.origin.loadImage(this.url, isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin, this).then(img => this.setView(img)).catch(e => {
|
|
3823
3851
|
this.error = e;
|
|
3824
3852
|
this.onComplete(false);
|
|
3825
3853
|
});
|
|
@@ -3845,9 +3873,6 @@ var LeaferUI = function(exports) {
|
|
|
3845
3873
|
this.view = img;
|
|
3846
3874
|
this.onComplete(true);
|
|
3847
3875
|
}
|
|
3848
|
-
onProgress(progress) {
|
|
3849
|
-
this.progress = progress;
|
|
3850
|
-
}
|
|
3851
3876
|
onComplete(isSuccess) {
|
|
3852
3877
|
let odd;
|
|
3853
3878
|
this.waitComplete.forEach((item, index) => {
|
|
@@ -3866,7 +3891,7 @@ var LeaferUI = function(exports) {
|
|
|
3866
3891
|
getFull(_filters) {
|
|
3867
3892
|
return this.view;
|
|
3868
3893
|
}
|
|
3869
|
-
getCanvas(width, height, opacity,
|
|
3894
|
+
getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
|
|
3870
3895
|
width || (width = this.width);
|
|
3871
3896
|
height || (height = this.height);
|
|
3872
3897
|
if (this.cache) {
|
|
@@ -3879,11 +3904,7 @@ var LeaferUI = function(exports) {
|
|
|
3879
3904
|
}
|
|
3880
3905
|
if (data) return data;
|
|
3881
3906
|
}
|
|
3882
|
-
const canvas = Platform.
|
|
3883
|
-
const ctx = canvas.getContext("2d");
|
|
3884
|
-
if (opacity) ctx.globalAlpha = opacity;
|
|
3885
|
-
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
3886
|
-
ctx.drawImage(this.view, 0, 0, width, height);
|
|
3907
|
+
const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
|
|
3887
3908
|
this.cache = this.use > 1 ? {
|
|
3888
3909
|
data: canvas,
|
|
3889
3910
|
params: arguments
|
|
@@ -3892,13 +3913,7 @@ var LeaferUI = function(exports) {
|
|
|
3892
3913
|
}
|
|
3893
3914
|
getPattern(canvas, repeat, transform, paint) {
|
|
3894
3915
|
const pattern = Platform.canvas.createPattern(canvas, repeat);
|
|
3895
|
-
|
|
3896
|
-
if (transform && pattern.setTransform) {
|
|
3897
|
-
pattern.setTransform(transform);
|
|
3898
|
-
transform = undefined;
|
|
3899
|
-
}
|
|
3900
|
-
} catch (_a) {}
|
|
3901
|
-
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
3916
|
+
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
3902
3917
|
return pattern;
|
|
3903
3918
|
}
|
|
3904
3919
|
destroy() {
|
|
@@ -5424,12 +5439,12 @@ var LeaferUI = function(exports) {
|
|
|
5424
5439
|
const {toBounds: toBounds} = PathBounds;
|
|
5425
5440
|
const LeafBounds = {
|
|
5426
5441
|
__updateWorldBounds() {
|
|
5427
|
-
const
|
|
5428
|
-
toOuterOf$2(
|
|
5429
|
-
if (
|
|
5430
|
-
if (
|
|
5442
|
+
const {__layout: __layout, __world: __world} = this;
|
|
5443
|
+
toOuterOf$2(__layout.renderBounds, __world, __world);
|
|
5444
|
+
if (__layout.resized) {
|
|
5445
|
+
if (__layout.resized === "inner") this.__onUpdateSize();
|
|
5431
5446
|
if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
|
|
5432
|
-
|
|
5447
|
+
__layout.resized = undefined;
|
|
5433
5448
|
}
|
|
5434
5449
|
if (this.__hasWorldEvent) BoundsEvent.emitWorld(this);
|
|
5435
5450
|
},
|
|
@@ -5621,7 +5636,7 @@ var LeaferUI = function(exports) {
|
|
|
5621
5636
|
};
|
|
5622
5637
|
const tempScaleData$1 = {};
|
|
5623
5638
|
const {LEAF: LEAF, create: create} = IncrementId;
|
|
5624
|
-
const {stintSet: stintSet$
|
|
5639
|
+
const {stintSet: stintSet$4} = DataHelper;
|
|
5625
5640
|
const {toInnerPoint: toInnerPoint, toOuterPoint: toOuterPoint, multiplyParent: multiplyParent$1} = MatrixHelper;
|
|
5626
5641
|
const {toOuterOf: toOuterOf$1} = BoundsHelper;
|
|
5627
5642
|
const {copy: copy$2, move: move$2} = PointHelper;
|
|
@@ -5899,8 +5914,8 @@ var LeaferUI = function(exports) {
|
|
|
5899
5914
|
const cameraWorld = this.__cameraWorld, world = this.__world;
|
|
5900
5915
|
multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
|
|
5901
5916
|
toOuterOf$1(this.__layout.renderBounds, cameraWorld, cameraWorld);
|
|
5902
|
-
stintSet$
|
|
5903
|
-
stintSet$
|
|
5917
|
+
stintSet$4(cameraWorld, "half", world.half);
|
|
5918
|
+
stintSet$4(cameraWorld, "ignorePixelSnap", world.ignorePixelSnap);
|
|
5904
5919
|
return cameraWorld;
|
|
5905
5920
|
} else {
|
|
5906
5921
|
return this.__world;
|
|
@@ -6413,7 +6428,7 @@ var LeaferUI = function(exports) {
|
|
|
6413
6428
|
this.levelMap = null;
|
|
6414
6429
|
}
|
|
6415
6430
|
}
|
|
6416
|
-
const version = "1.
|
|
6431
|
+
const version = "1.10.0";
|
|
6417
6432
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6418
6433
|
get allowBackgroundColor() {
|
|
6419
6434
|
return true;
|
|
@@ -7135,7 +7150,7 @@ var LeaferUI = function(exports) {
|
|
|
7135
7150
|
}
|
|
7136
7151
|
};
|
|
7137
7152
|
const {parse: parse, objectToCanvasData: objectToCanvasData} = PathConvert;
|
|
7138
|
-
const {stintSet: stintSet$
|
|
7153
|
+
const {stintSet: stintSet$3} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
|
|
7139
7154
|
const emptyPaint = {};
|
|
7140
7155
|
const debug$1 = Debug.get("UIData");
|
|
7141
7156
|
class UIData extends LeafData {
|
|
@@ -7199,7 +7214,7 @@ var LeaferUI = function(exports) {
|
|
|
7199
7214
|
setFill(value) {
|
|
7200
7215
|
if (this.__naturalWidth) this.__removeNaturalSize();
|
|
7201
7216
|
if (isString(value) || !value) {
|
|
7202
|
-
stintSet$
|
|
7217
|
+
stintSet$3(this, "__isTransparentFill", hasTransparent$2(value));
|
|
7203
7218
|
this.__isFills && this.__removePaint("fill", true);
|
|
7204
7219
|
this._fill = value;
|
|
7205
7220
|
} else if (isObject(value)) {
|
|
@@ -7208,7 +7223,7 @@ var LeaferUI = function(exports) {
|
|
|
7208
7223
|
}
|
|
7209
7224
|
setStroke(value) {
|
|
7210
7225
|
if (isString(value) || !value) {
|
|
7211
|
-
stintSet$
|
|
7226
|
+
stintSet$3(this, "__isTransparentStroke", hasTransparent$2(value));
|
|
7212
7227
|
this.__isStrokes && this.__removePaint("stroke", true);
|
|
7213
7228
|
this._stroke = value;
|
|
7214
7229
|
} else if (isObject(value)) {
|
|
@@ -7266,11 +7281,11 @@ var LeaferUI = function(exports) {
|
|
|
7266
7281
|
if (removeInput) this.__removeInput(attrName);
|
|
7267
7282
|
PaintImage.recycleImage(attrName, this);
|
|
7268
7283
|
if (attrName === "fill") {
|
|
7269
|
-
stintSet$
|
|
7284
|
+
stintSet$3(this, "__isAlphaPixelFill", undefined);
|
|
7270
7285
|
this._fill = this.__isFills = undefined;
|
|
7271
7286
|
} else {
|
|
7272
|
-
stintSet$
|
|
7273
|
-
stintSet$
|
|
7287
|
+
stintSet$3(this, "__isAlphaPixelStroke", undefined);
|
|
7288
|
+
stintSet$3(this, "__hasMultiStrokeStyle", undefined);
|
|
7274
7289
|
this._stroke = this.__isStrokes = undefined;
|
|
7275
7290
|
}
|
|
7276
7291
|
}
|
|
@@ -7402,7 +7417,7 @@ var LeaferUI = function(exports) {
|
|
|
7402
7417
|
return data;
|
|
7403
7418
|
}
|
|
7404
7419
|
}
|
|
7405
|
-
const {max: max$
|
|
7420
|
+
const {max: max$1, add: add$1} = FourNumberHelper;
|
|
7406
7421
|
const UIBounds = {
|
|
7407
7422
|
__updateStrokeSpread() {
|
|
7408
7423
|
let spread = 0, boxSpread = 0;
|
|
@@ -7417,7 +7432,7 @@ var LeaferUI = function(exports) {
|
|
|
7417
7432
|
}
|
|
7418
7433
|
if (data.__useArrow) spread += strokeWidth * 5;
|
|
7419
7434
|
if (box) {
|
|
7420
|
-
spread = max$
|
|
7435
|
+
spread = max$1(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
|
|
7421
7436
|
boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
|
|
7422
7437
|
}
|
|
7423
7438
|
this.__layout.strokeBoxSpread = boxSpread;
|
|
@@ -7427,33 +7442,33 @@ var LeaferUI = function(exports) {
|
|
|
7427
7442
|
let spread = 0;
|
|
7428
7443
|
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
|
|
7429
7444
|
if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
|
|
7430
|
-
if (blur) spread = max$
|
|
7445
|
+
if (blur) spread = max$1(spread, blur);
|
|
7431
7446
|
if (filter) spread = add$1(spread, Filter.getSpread(filter));
|
|
7432
7447
|
if (renderSpread) spread = add$1(spread, renderSpread);
|
|
7433
7448
|
if (strokeSpread) spread = add$1(spread, strokeSpread);
|
|
7434
7449
|
let shapeSpread = spread;
|
|
7435
|
-
if (innerShadow) shapeSpread = max$
|
|
7436
|
-
if (backgroundBlur) shapeSpread = max$
|
|
7450
|
+
if (innerShadow) shapeSpread = max$1(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
|
|
7451
|
+
if (backgroundBlur) shapeSpread = max$1(shapeSpread, backgroundBlur);
|
|
7437
7452
|
this.__layout.renderShapeSpread = shapeSpread;
|
|
7438
|
-
return box ? max$
|
|
7453
|
+
return box ? max$1(box.__updateRenderSpread(), spread) : spread;
|
|
7439
7454
|
}
|
|
7440
7455
|
};
|
|
7441
|
-
const {stintSet: stintSet$
|
|
7456
|
+
const {stintSet: stintSet$2} = DataHelper;
|
|
7442
7457
|
const UIRender = {
|
|
7443
7458
|
__updateChange() {
|
|
7444
7459
|
const data = this.__;
|
|
7445
7460
|
if (data.__useStroke) {
|
|
7446
7461
|
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
7447
|
-
stintSet$
|
|
7448
|
-
stintSet$
|
|
7462
|
+
stintSet$2(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
|
|
7463
|
+
stintSet$2(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
|
|
7449
7464
|
}
|
|
7450
7465
|
if (data.__useEffect) {
|
|
7451
7466
|
const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7452
|
-
stintSet$
|
|
7467
|
+
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"));
|
|
7453
7468
|
data.__useEffect = !!(shadow || otherEffect);
|
|
7454
7469
|
}
|
|
7455
7470
|
data.__checkSingle();
|
|
7456
|
-
stintSet$
|
|
7471
|
+
stintSet$2(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
7457
7472
|
},
|
|
7458
7473
|
__drawFast(canvas, options) {
|
|
7459
7474
|
drawFast(this, canvas, options);
|
|
@@ -7469,24 +7484,24 @@ var LeaferUI = function(exports) {
|
|
|
7469
7484
|
this.__nowWorld = this.__getNowWorld(options);
|
|
7470
7485
|
const {shadow: shadow, innerShadow: innerShadow, filter: filter} = data;
|
|
7471
7486
|
if (shadow) Effect.shadow(this, canvas, shape);
|
|
7472
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7473
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7487
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7488
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
7474
7489
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
7475
7490
|
if (innerShadow) Effect.innerShadow(this, canvas, shape);
|
|
7476
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7491
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7477
7492
|
if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
7478
7493
|
if (shape.worldCanvas) shape.worldCanvas.recycle();
|
|
7479
7494
|
shape.canvas.recycle();
|
|
7480
7495
|
} else {
|
|
7481
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7496
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7482
7497
|
if (__isFastShadow) {
|
|
7483
7498
|
const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
|
|
7484
7499
|
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
7485
7500
|
}
|
|
7486
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7501
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
7487
7502
|
if (__isFastShadow) canvas.restore();
|
|
7488
7503
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
7489
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7504
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7490
7505
|
}
|
|
7491
7506
|
} else {
|
|
7492
7507
|
if (data.__pathInputed) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
|
|
@@ -7495,9 +7510,9 @@ var LeaferUI = function(exports) {
|
|
|
7495
7510
|
__drawShape(canvas, options) {
|
|
7496
7511
|
this.__drawRenderPath(canvas);
|
|
7497
7512
|
const data = this.__, {fill: fill, stroke: stroke} = data;
|
|
7498
|
-
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill("#000000", this, canvas);
|
|
7513
|
+
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas, options) : Paint.fill("#000000", this, canvas, options);
|
|
7499
7514
|
if (data.__isCanvas) this.__drawAfterFill(canvas, options);
|
|
7500
|
-
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke("#000000", this, canvas);
|
|
7515
|
+
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke("#000000", this, canvas, options);
|
|
7501
7516
|
},
|
|
7502
7517
|
__drawAfterFill(canvas, options) {
|
|
7503
7518
|
if (this.__.__clipAfterFill) {
|
|
@@ -7511,10 +7526,10 @@ var LeaferUI = function(exports) {
|
|
|
7511
7526
|
function drawFast(ui, canvas, options) {
|
|
7512
7527
|
const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke} = ui.__;
|
|
7513
7528
|
ui.__drawRenderPath(canvas);
|
|
7514
|
-
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
7515
|
-
if (fill) Paint.fill(fill, ui, canvas);
|
|
7529
|
+
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
7530
|
+
if (fill) Paint.fill(fill, ui, canvas, options);
|
|
7516
7531
|
if (__drawAfterFill) ui.__drawAfterFill(canvas, options);
|
|
7517
|
-
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
7532
|
+
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
7518
7533
|
}
|
|
7519
7534
|
const RectRender = {
|
|
7520
7535
|
__drawFast(canvas, options) {
|
|
@@ -7649,8 +7664,8 @@ var LeaferUI = function(exports) {
|
|
|
7649
7664
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
7650
7665
|
} else drawer.rect(x, y, width, height);
|
|
7651
7666
|
}
|
|
7652
|
-
drawImagePlaceholder(canvas,
|
|
7653
|
-
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
7667
|
+
drawImagePlaceholder(_image, canvas, renderOptions) {
|
|
7668
|
+
Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
|
|
7654
7669
|
}
|
|
7655
7670
|
animate(keyframe, _options, _type, _isTemp) {
|
|
7656
7671
|
this.set(keyframe);
|
|
@@ -8513,7 +8528,7 @@ var LeaferUI = function(exports) {
|
|
|
8513
8528
|
__decorate([ dataType(false) ], exports.Canvas.prototype, "safeResize", void 0);
|
|
8514
8529
|
__decorate([ resizeType() ], exports.Canvas.prototype, "contextSettings", void 0);
|
|
8515
8530
|
exports.Canvas = __decorate([ registerUI() ], exports.Canvas);
|
|
8516
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
|
|
8531
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
8517
8532
|
exports.Text = class Text extends exports.UI {
|
|
8518
8533
|
get __tag() {
|
|
8519
8534
|
return "Text";
|
|
@@ -8524,13 +8539,14 @@ var LeaferUI = function(exports) {
|
|
|
8524
8539
|
}
|
|
8525
8540
|
__updateTextDrawData() {
|
|
8526
8541
|
const data = this.__;
|
|
8527
|
-
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
|
|
8542
|
+
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
|
|
8528
8543
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
8529
8544
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
8530
|
-
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
8531
8545
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
|
|
8532
8546
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
8533
|
-
data
|
|
8547
|
+
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
8548
|
+
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
8549
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
|
|
8534
8550
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
8535
8551
|
}
|
|
8536
8552
|
__updateBoxBounds() {
|
|
@@ -8702,34 +8718,18 @@ var LeaferUI = function(exports) {
|
|
|
8702
8718
|
});
|
|
8703
8719
|
};
|
|
8704
8720
|
}
|
|
8705
|
-
function
|
|
8706
|
-
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
8707
|
-
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
8708
|
-
let row;
|
|
8709
|
-
for (let i = 0, len = rows.length; i < len; i++) {
|
|
8710
|
-
row = rows[i];
|
|
8711
|
-
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
8712
|
-
canvas.fillText(charData.char, charData.x, row.y);
|
|
8713
|
-
});
|
|
8714
|
-
}
|
|
8715
|
-
if (decorationY) {
|
|
8716
|
-
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
8717
|
-
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
8718
|
-
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
8719
|
-
}
|
|
8720
|
-
}
|
|
8721
|
-
function fill(fill, ui, canvas) {
|
|
8721
|
+
function fill(fill, ui, canvas, renderOptions) {
|
|
8722
8722
|
canvas.fillStyle = fill;
|
|
8723
|
-
fillPathOrText(ui, canvas);
|
|
8723
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
8724
8724
|
}
|
|
8725
|
-
function fills(fills, ui, canvas) {
|
|
8725
|
+
function fills(fills, ui, canvas, renderOptions) {
|
|
8726
8726
|
let item;
|
|
8727
8727
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
8728
8728
|
item = fills[i];
|
|
8729
8729
|
if (item.image) {
|
|
8730
|
-
if (PaintImage.checkImage(
|
|
8730
|
+
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
8731
8731
|
if (!item.style) {
|
|
8732
|
-
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas,
|
|
8732
|
+
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
|
|
8733
8733
|
continue;
|
|
8734
8734
|
}
|
|
8735
8735
|
}
|
|
@@ -8742,55 +8742,126 @@ var LeaferUI = function(exports) {
|
|
|
8742
8742
|
if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
8743
8743
|
}
|
|
8744
8744
|
if (item.blendMode) canvas.blendMode = item.blendMode;
|
|
8745
|
-
fillPathOrText(ui, canvas);
|
|
8745
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
8746
8746
|
canvas.restore();
|
|
8747
8747
|
} else {
|
|
8748
8748
|
if (item.blendMode) {
|
|
8749
8749
|
canvas.saveBlendMode(item.blendMode);
|
|
8750
|
-
fillPathOrText(ui, canvas);
|
|
8750
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
8751
8751
|
canvas.restoreBlendMode();
|
|
8752
|
-
} else fillPathOrText(ui, canvas);
|
|
8752
|
+
} else fillPathOrText(ui, canvas, renderOptions);
|
|
8753
|
+
}
|
|
8754
|
+
}
|
|
8755
|
+
}
|
|
8756
|
+
function fillPathOrText(ui, canvas, renderOptions) {
|
|
8757
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
8758
|
+
}
|
|
8759
|
+
function fillText(ui, canvas, _renderOptions) {
|
|
8760
|
+
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
8761
|
+
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
8762
|
+
let row;
|
|
8763
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
8764
|
+
row = rows[i];
|
|
8765
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
8766
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
8767
|
+
});
|
|
8768
|
+
}
|
|
8769
|
+
if (decorationY) {
|
|
8770
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
8771
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
8772
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
8773
|
+
}
|
|
8774
|
+
}
|
|
8775
|
+
function stroke(stroke, ui, canvas, renderOptions) {
|
|
8776
|
+
const data = ui.__;
|
|
8777
|
+
if (!data.__strokeWidth) return;
|
|
8778
|
+
if (data.__font) {
|
|
8779
|
+
Paint.strokeText(stroke, ui, canvas, renderOptions);
|
|
8780
|
+
} else {
|
|
8781
|
+
switch (data.strokeAlign) {
|
|
8782
|
+
case "center":
|
|
8783
|
+
drawCenter$1(stroke, 1, ui, canvas, renderOptions);
|
|
8784
|
+
break;
|
|
8785
|
+
|
|
8786
|
+
case "inside":
|
|
8787
|
+
drawInside(stroke, ui, canvas, renderOptions);
|
|
8788
|
+
break;
|
|
8789
|
+
|
|
8790
|
+
case "outside":
|
|
8791
|
+
drawOutside(stroke, ui, canvas, renderOptions);
|
|
8792
|
+
break;
|
|
8753
8793
|
}
|
|
8754
8794
|
}
|
|
8755
8795
|
}
|
|
8756
|
-
function
|
|
8757
|
-
|
|
8796
|
+
function strokes(strokes, ui, canvas, renderOptions) {
|
|
8797
|
+
Paint.stroke(strokes, ui, canvas, renderOptions);
|
|
8798
|
+
}
|
|
8799
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
8800
|
+
const data = ui.__;
|
|
8801
|
+
if (isObject(stroke)) {
|
|
8802
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
|
|
8803
|
+
} else {
|
|
8804
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
8805
|
+
canvas.stroke();
|
|
8806
|
+
}
|
|
8807
|
+
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
|
|
8808
|
+
}
|
|
8809
|
+
function drawInside(stroke, ui, canvas, renderOptions) {
|
|
8810
|
+
canvas.save();
|
|
8811
|
+
canvas.clipUI(ui);
|
|
8812
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
8813
|
+
canvas.restore();
|
|
8758
8814
|
}
|
|
8759
|
-
function
|
|
8815
|
+
function drawOutside(stroke, ui, canvas, renderOptions) {
|
|
8816
|
+
const data = ui.__;
|
|
8817
|
+
if (data.__fillAfterStroke) {
|
|
8818
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
8819
|
+
} else {
|
|
8820
|
+
const {renderBounds: renderBounds} = ui.__layout;
|
|
8821
|
+
const out = canvas.getSameCanvas(true, true);
|
|
8822
|
+
ui.__drawRenderPath(out);
|
|
8823
|
+
drawCenter$1(stroke, 2, ui, out, renderOptions);
|
|
8824
|
+
out.clipUI(data);
|
|
8825
|
+
out.clearWorld(renderBounds);
|
|
8826
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
8827
|
+
out.recycle(ui.__nowWorld);
|
|
8828
|
+
}
|
|
8829
|
+
}
|
|
8830
|
+
function strokeText(stroke, ui, canvas, renderOptions) {
|
|
8760
8831
|
switch (ui.__.strokeAlign) {
|
|
8761
8832
|
case "center":
|
|
8762
|
-
drawCenter
|
|
8833
|
+
drawCenter(stroke, 1, ui, canvas, renderOptions);
|
|
8763
8834
|
break;
|
|
8764
8835
|
|
|
8765
8836
|
case "inside":
|
|
8766
|
-
drawAlign(stroke, "inside", ui, canvas);
|
|
8837
|
+
drawAlign(stroke, "inside", ui, canvas, renderOptions);
|
|
8767
8838
|
break;
|
|
8768
8839
|
|
|
8769
8840
|
case "outside":
|
|
8770
|
-
ui.__.__fillAfterStroke ? drawCenter
|
|
8841
|
+
ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
|
|
8771
8842
|
break;
|
|
8772
8843
|
}
|
|
8773
8844
|
}
|
|
8774
|
-
function drawCenter
|
|
8845
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
8775
8846
|
const data = ui.__;
|
|
8776
8847
|
if (isObject(stroke)) {
|
|
8777
|
-
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
8848
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
|
|
8778
8849
|
} else {
|
|
8779
8850
|
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
8780
|
-
drawTextStroke(ui, canvas);
|
|
8851
|
+
Paint.drawTextStroke(ui, canvas, renderOptions);
|
|
8781
8852
|
}
|
|
8782
8853
|
}
|
|
8783
|
-
function drawAlign(stroke, align, ui, canvas) {
|
|
8854
|
+
function drawAlign(stroke, align, ui, canvas, renderOptions) {
|
|
8784
8855
|
const out = canvas.getSameCanvas(true, true);
|
|
8785
8856
|
out.font = ui.__.__font;
|
|
8786
|
-
drawCenter
|
|
8857
|
+
drawCenter(stroke, 2, ui, out, renderOptions);
|
|
8787
8858
|
out.blendMode = align === "outside" ? "destination-out" : "destination-in";
|
|
8788
|
-
fillText(ui, out);
|
|
8859
|
+
Paint.fillText(ui, out, renderOptions);
|
|
8789
8860
|
out.blendMode = "normal";
|
|
8790
8861
|
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
8791
8862
|
out.recycle(ui.__nowWorld);
|
|
8792
8863
|
}
|
|
8793
|
-
function drawTextStroke(ui, canvas) {
|
|
8864
|
+
function drawTextStroke(ui, canvas, _renderOptions) {
|
|
8794
8865
|
let row, data = ui.__.__textDrawData;
|
|
8795
8866
|
const {rows: rows, decorationY: decorationY} = data;
|
|
8796
8867
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
@@ -8804,13 +8875,13 @@ var LeaferUI = function(exports) {
|
|
|
8804
8875
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
8805
8876
|
}
|
|
8806
8877
|
}
|
|
8807
|
-
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
8878
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
|
|
8808
8879
|
let item;
|
|
8809
8880
|
const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
|
|
8810
8881
|
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
8811
8882
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
8812
8883
|
item = strokes[i];
|
|
8813
|
-
if (item.image && PaintImage.checkImage(ui, canvas,
|
|
8884
|
+
if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
|
|
8814
8885
|
if (item.style) {
|
|
8815
8886
|
if (__hasMultiStrokeStyle) {
|
|
8816
8887
|
const {strokeStyle: strokeStyle} = item;
|
|
@@ -8818,69 +8889,14 @@ var LeaferUI = function(exports) {
|
|
|
8818
8889
|
} else canvas.strokeStyle = item.style;
|
|
8819
8890
|
if (item.blendMode) {
|
|
8820
8891
|
canvas.saveBlendMode(item.blendMode);
|
|
8821
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
8892
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
8822
8893
|
canvas.restoreBlendMode();
|
|
8823
8894
|
} else {
|
|
8824
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
8895
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
8825
8896
|
}
|
|
8826
8897
|
}
|
|
8827
8898
|
}
|
|
8828
8899
|
}
|
|
8829
|
-
function stroke(stroke, ui, canvas) {
|
|
8830
|
-
const data = ui.__;
|
|
8831
|
-
if (!data.__strokeWidth) return;
|
|
8832
|
-
if (data.__font) {
|
|
8833
|
-
strokeText(stroke, ui, canvas);
|
|
8834
|
-
} else {
|
|
8835
|
-
switch (data.strokeAlign) {
|
|
8836
|
-
case "center":
|
|
8837
|
-
drawCenter(stroke, 1, ui, canvas);
|
|
8838
|
-
break;
|
|
8839
|
-
|
|
8840
|
-
case "inside":
|
|
8841
|
-
drawInside(stroke, ui, canvas);
|
|
8842
|
-
break;
|
|
8843
|
-
|
|
8844
|
-
case "outside":
|
|
8845
|
-
drawOutside(stroke, ui, canvas);
|
|
8846
|
-
break;
|
|
8847
|
-
}
|
|
8848
|
-
}
|
|
8849
|
-
}
|
|
8850
|
-
function strokes(strokes, ui, canvas) {
|
|
8851
|
-
stroke(strokes, ui, canvas);
|
|
8852
|
-
}
|
|
8853
|
-
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
8854
|
-
const data = ui.__;
|
|
8855
|
-
if (isObject(stroke)) {
|
|
8856
|
-
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
8857
|
-
} else {
|
|
8858
|
-
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
8859
|
-
canvas.stroke();
|
|
8860
|
-
}
|
|
8861
|
-
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas);
|
|
8862
|
-
}
|
|
8863
|
-
function drawInside(stroke, ui, canvas) {
|
|
8864
|
-
canvas.save();
|
|
8865
|
-
canvas.clipUI(ui);
|
|
8866
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
8867
|
-
canvas.restore();
|
|
8868
|
-
}
|
|
8869
|
-
function drawOutside(stroke, ui, canvas) {
|
|
8870
|
-
const data = ui.__;
|
|
8871
|
-
if (data.__fillAfterStroke) {
|
|
8872
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
8873
|
-
} else {
|
|
8874
|
-
const {renderBounds: renderBounds} = ui.__layout;
|
|
8875
|
-
const out = canvas.getSameCanvas(true, true);
|
|
8876
|
-
ui.__drawRenderPath(out);
|
|
8877
|
-
drawCenter(stroke, 2, ui, out);
|
|
8878
|
-
out.clipUI(data);
|
|
8879
|
-
out.clearWorld(renderBounds);
|
|
8880
|
-
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
8881
|
-
out.recycle(ui.__nowWorld);
|
|
8882
|
-
}
|
|
8883
|
-
}
|
|
8884
8900
|
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
8885
8901
|
const tempBounds$1 = {};
|
|
8886
8902
|
function shape(ui, current, options) {
|
|
@@ -9029,80 +9045,108 @@ var LeaferUI = function(exports) {
|
|
|
9029
9045
|
strokes: strokes,
|
|
9030
9046
|
strokeText: strokeText,
|
|
9031
9047
|
drawTextStroke: drawTextStroke,
|
|
9048
|
+
drawStrokesStyle: drawStrokesStyle,
|
|
9032
9049
|
shape: shape
|
|
9033
9050
|
};
|
|
9034
|
-
let
|
|
9035
|
-
const {
|
|
9036
|
-
function
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
if (
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
9053
|
-
const transform = get$3();
|
|
9054
|
-
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9055
|
-
if (clipScaleX) {
|
|
9056
|
-
if (rotation || skew) {
|
|
9057
|
-
set(tempMatrix$1);
|
|
9058
|
-
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
9059
|
-
multiplyParent(transform, tempMatrix$1);
|
|
9060
|
-
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
9051
|
+
let cache, box = new Bounds;
|
|
9052
|
+
const {isSame: isSame} = BoundsHelper;
|
|
9053
|
+
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
9054
|
+
let leafPaint, event;
|
|
9055
|
+
const image = ImageManager.get(paint);
|
|
9056
|
+
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
9057
|
+
leafPaint = cache.leafPaint;
|
|
9058
|
+
} else {
|
|
9059
|
+
leafPaint = {
|
|
9060
|
+
type: paint.type,
|
|
9061
|
+
image: image
|
|
9062
|
+
};
|
|
9063
|
+
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
9064
|
+
cache = image.use > 1 ? {
|
|
9065
|
+
leafPaint: leafPaint,
|
|
9066
|
+
paint: paint,
|
|
9067
|
+
boxBounds: box.set(boxBounds)
|
|
9068
|
+
} : null;
|
|
9061
9069
|
}
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9070
|
+
if (firstUse || image.loading) event = {
|
|
9071
|
+
image: image,
|
|
9072
|
+
attrName: attrName,
|
|
9073
|
+
attrValue: paint
|
|
9074
|
+
};
|
|
9075
|
+
if (image.ready) {
|
|
9076
|
+
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
9077
|
+
if (firstUse) {
|
|
9078
|
+
onLoad(ui, event);
|
|
9079
|
+
onLoadSuccess(ui, event);
|
|
9080
|
+
}
|
|
9081
|
+
} else if (image.error) {
|
|
9082
|
+
if (firstUse) onLoadError(ui, event, image.error);
|
|
9068
9083
|
} else {
|
|
9069
|
-
if (
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
translate$1(transform, height, 0);
|
|
9080
|
-
break;
|
|
9081
|
-
|
|
9082
|
-
case 180:
|
|
9083
|
-
translate$1(transform, width, height);
|
|
9084
|
-
break;
|
|
9085
|
-
|
|
9086
|
-
case 270:
|
|
9087
|
-
translate$1(transform, 0, width);
|
|
9088
|
-
break;
|
|
9084
|
+
if (firstUse) {
|
|
9085
|
+
ignoreRender(ui, true);
|
|
9086
|
+
onLoad(ui, event);
|
|
9087
|
+
}
|
|
9088
|
+
leafPaint.loadId = image.load(() => {
|
|
9089
|
+
ignoreRender(ui, false);
|
|
9090
|
+
if (!ui.destroyed) {
|
|
9091
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
9092
|
+
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
9093
|
+
ui.forceUpdate("surface");
|
|
9089
9094
|
}
|
|
9095
|
+
onLoadSuccess(ui, event);
|
|
9090
9096
|
}
|
|
9097
|
+
leafPaint.loadId = undefined;
|
|
9098
|
+
}, error => {
|
|
9099
|
+
ignoreRender(ui, false);
|
|
9100
|
+
onLoadError(ui, event, error);
|
|
9101
|
+
leafPaint.loadId = undefined;
|
|
9102
|
+
});
|
|
9103
|
+
if (ui.placeholderColor) {
|
|
9104
|
+
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
9105
|
+
if (!image.ready) {
|
|
9106
|
+
image.isPlacehold = true;
|
|
9107
|
+
ui.forceUpdate("surface");
|
|
9108
|
+
}
|
|
9109
|
+
}, ui.placeholderDelay);
|
|
9091
9110
|
}
|
|
9092
|
-
origin.x = box.x + x;
|
|
9093
|
-
origin.y = box.y + y;
|
|
9094
|
-
translate$1(transform, origin.x, origin.y);
|
|
9095
|
-
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
9096
9111
|
}
|
|
9097
|
-
|
|
9112
|
+
return leafPaint;
|
|
9098
9113
|
}
|
|
9099
|
-
function
|
|
9100
|
-
if (
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
|
|
9114
|
+
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
9115
|
+
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
9116
|
+
const data = ui.__;
|
|
9117
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
9118
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
9119
|
+
if (data.__autoSide) {
|
|
9120
|
+
ui.forceUpdate("width");
|
|
9121
|
+
if (ui.__proxyData) {
|
|
9122
|
+
ui.setProxyAttr("width", data.width);
|
|
9123
|
+
ui.setProxyAttr("height", data.height);
|
|
9124
|
+
}
|
|
9125
|
+
return false;
|
|
9126
|
+
}
|
|
9127
|
+
}
|
|
9128
|
+
if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
9129
|
+
return true;
|
|
9130
|
+
}
|
|
9131
|
+
function onLoad(ui, event) {
|
|
9132
|
+
emit(ui, ImageEvent.LOAD, event);
|
|
9133
|
+
}
|
|
9134
|
+
function onLoadSuccess(ui, event) {
|
|
9135
|
+
emit(ui, ImageEvent.LOADED, event);
|
|
9136
|
+
}
|
|
9137
|
+
function onLoadError(ui, event, error) {
|
|
9138
|
+
event.error = error;
|
|
9139
|
+
ui.forceUpdate("surface");
|
|
9140
|
+
emit(ui, ImageEvent.ERROR, event);
|
|
9141
|
+
}
|
|
9142
|
+
function emit(ui, type, data) {
|
|
9143
|
+
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
9144
|
+
}
|
|
9145
|
+
function ignoreRender(ui, value) {
|
|
9146
|
+
const {leafer: leafer} = ui;
|
|
9147
|
+
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
9104
9148
|
}
|
|
9105
|
-
const {get: get$
|
|
9149
|
+
const {get: get$3, translate: translate$1} = MatrixHelper;
|
|
9106
9150
|
const tempBox = new Bounds;
|
|
9107
9151
|
const tempScaleData = {};
|
|
9108
9152
|
const tempImage = {};
|
|
@@ -9111,12 +9155,12 @@ var LeaferUI = function(exports) {
|
|
|
9111
9155
|
if (changeful) leafPaint.changeful = changeful;
|
|
9112
9156
|
if (sync) leafPaint.sync = sync;
|
|
9113
9157
|
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
9114
|
-
leafPaint.data = getPatternData(paint, box, image);
|
|
9158
|
+
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
9115
9159
|
}
|
|
9116
9160
|
function getPatternData(paint, box, image) {
|
|
9117
9161
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
9118
9162
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
9119
|
-
|
|
9163
|
+
const {width: width, height: height} = image;
|
|
9120
9164
|
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;
|
|
9121
9165
|
const sameBox = box.width === width && box.height === height;
|
|
9122
9166
|
const data = {
|
|
@@ -9147,8 +9191,8 @@ var LeaferUI = function(exports) {
|
|
|
9147
9191
|
case "stretch":
|
|
9148
9192
|
if (!sameBox) {
|
|
9149
9193
|
scaleX = box.width / width, scaleY = box.height / height;
|
|
9150
|
-
stretchMode(data, box, scaleX, scaleY);
|
|
9151
|
-
}
|
|
9194
|
+
PaintImage.stretchMode(data, box, scaleX, scaleY);
|
|
9195
|
+
} else if (scaleX) scaleX = scaleY = undefined;
|
|
9152
9196
|
break;
|
|
9153
9197
|
|
|
9154
9198
|
case "normal":
|
|
@@ -9156,13 +9200,13 @@ var LeaferUI = function(exports) {
|
|
|
9156
9200
|
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
9157
9201
|
let clipScaleX, clipScaleY;
|
|
9158
9202
|
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
|
|
9159
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
9203
|
+
PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
9160
9204
|
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
9161
9205
|
}
|
|
9162
9206
|
break;
|
|
9163
9207
|
|
|
9164
9208
|
case "repeat":
|
|
9165
|
-
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
9209
|
+
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
9166
9210
|
if (!repeat) data.repeat = "repeat";
|
|
9167
9211
|
const count = isObject(repeat);
|
|
9168
9212
|
if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
|
|
@@ -9171,18 +9215,16 @@ var LeaferUI = function(exports) {
|
|
|
9171
9215
|
case "fit":
|
|
9172
9216
|
case "cover":
|
|
9173
9217
|
default:
|
|
9174
|
-
if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9218
|
+
if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9175
9219
|
}
|
|
9176
9220
|
if (!data.transform) {
|
|
9177
|
-
if (box.x || box.y) translate(data.transform = get$
|
|
9221
|
+
if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
|
|
9178
9222
|
}
|
|
9179
|
-
data.width = width;
|
|
9180
|
-
data.height = height;
|
|
9181
9223
|
if (scaleX) {
|
|
9182
9224
|
data.scaleX = scaleX;
|
|
9183
9225
|
data.scaleY = scaleY;
|
|
9184
9226
|
}
|
|
9185
|
-
if (opacity) data.opacity = opacity;
|
|
9227
|
+
if (opacity && opacity < 1) data.opacity = opacity;
|
|
9186
9228
|
if (filters) data.filters = filters;
|
|
9187
9229
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
9188
9230
|
return data;
|
|
@@ -9201,221 +9243,180 @@ var LeaferUI = function(exports) {
|
|
|
9201
9243
|
const value = auto ? remain / ((rows || Math.floor(totalSize / size)) - 1) : gap;
|
|
9202
9244
|
return gap === "auto" ? value < 0 ? 0 : value : value;
|
|
9203
9245
|
}
|
|
9204
|
-
let
|
|
9205
|
-
const {
|
|
9206
|
-
function
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9246
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
9247
|
+
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
9248
|
+
function stretchMode(data, box, scaleX, scaleY) {
|
|
9249
|
+
const transform = get$2(), {x: x, y: y} = box;
|
|
9250
|
+
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
9251
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
9252
|
+
data.transform = transform;
|
|
9253
|
+
}
|
|
9254
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
9255
|
+
const transform = get$2();
|
|
9256
|
+
translate(transform, box.x + x, box.y + y);
|
|
9257
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
9258
|
+
if (rotation) rotateOfOuter$1(transform, {
|
|
9259
|
+
x: box.x + box.width / 2,
|
|
9260
|
+
y: box.y + box.height / 2
|
|
9261
|
+
}, rotation);
|
|
9262
|
+
data.transform = transform;
|
|
9263
|
+
}
|
|
9264
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
9265
|
+
const transform = get$2();
|
|
9266
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9267
|
+
if (clipScaleX) {
|
|
9268
|
+
if (rotation || skew) {
|
|
9269
|
+
set(tempMatrix$1);
|
|
9270
|
+
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
9271
|
+
multiplyParent(transform, tempMatrix$1);
|
|
9272
|
+
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
9222
9273
|
}
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
9230
|
-
if (firstUse) {
|
|
9231
|
-
onLoad(ui, event);
|
|
9232
|
-
onLoadSuccess(ui, event);
|
|
9233
|
-
}
|
|
9234
|
-
} else if (image.error) {
|
|
9235
|
-
if (firstUse) onLoadError(ui, event, image.error);
|
|
9274
|
+
data.transform = transform;
|
|
9275
|
+
}
|
|
9276
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
9277
|
+
const transform = get$2();
|
|
9278
|
+
if (freeTransform) {
|
|
9279
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9236
9280
|
} else {
|
|
9237
|
-
if (
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
|
|
9281
|
+
if (rotation) {
|
|
9282
|
+
if (align === "center") {
|
|
9283
|
+
rotateOfOuter$1(transform, {
|
|
9284
|
+
x: width / 2,
|
|
9285
|
+
y: height / 2
|
|
9286
|
+
}, rotation);
|
|
9287
|
+
} else {
|
|
9288
|
+
rotate(transform, rotation);
|
|
9289
|
+
switch (rotation) {
|
|
9290
|
+
case 90:
|
|
9291
|
+
translate(transform, height, 0);
|
|
9292
|
+
break;
|
|
9293
|
+
|
|
9294
|
+
case 180:
|
|
9295
|
+
translate(transform, width, height);
|
|
9296
|
+
break;
|
|
9297
|
+
|
|
9298
|
+
case 270:
|
|
9299
|
+
translate(transform, 0, width);
|
|
9300
|
+
break;
|
|
9247
9301
|
}
|
|
9248
|
-
onLoadSuccess(ui, event);
|
|
9249
9302
|
}
|
|
9250
|
-
leafPaint.loadId = undefined;
|
|
9251
|
-
}, error => {
|
|
9252
|
-
ignoreRender(ui, false);
|
|
9253
|
-
onLoadError(ui, event, error);
|
|
9254
|
-
leafPaint.loadId = undefined;
|
|
9255
|
-
});
|
|
9256
|
-
if (ui.placeholderColor) {
|
|
9257
|
-
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
9258
|
-
if (!image.ready) {
|
|
9259
|
-
image.isPlacehold = true;
|
|
9260
|
-
ui.forceUpdate("surface");
|
|
9261
|
-
}
|
|
9262
|
-
}, ui.placeholderDelay);
|
|
9263
|
-
}
|
|
9264
|
-
}
|
|
9265
|
-
return leafPaint;
|
|
9266
|
-
}
|
|
9267
|
-
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
9268
|
-
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
9269
|
-
const data = ui.__;
|
|
9270
|
-
data.__naturalWidth = image.width / data.pixelRatio;
|
|
9271
|
-
data.__naturalHeight = image.height / data.pixelRatio;
|
|
9272
|
-
if (data.__autoSide) {
|
|
9273
|
-
ui.forceUpdate("width");
|
|
9274
|
-
if (ui.__proxyData) {
|
|
9275
|
-
ui.setProxyAttr("width", data.width);
|
|
9276
|
-
ui.setProxyAttr("height", data.height);
|
|
9277
|
-
}
|
|
9278
|
-
return false;
|
|
9279
9303
|
}
|
|
9304
|
+
origin.x = box.x + x;
|
|
9305
|
+
origin.y = box.y + y;
|
|
9306
|
+
translate(transform, origin.x, origin.y);
|
|
9307
|
+
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
9280
9308
|
}
|
|
9281
|
-
|
|
9282
|
-
return true;
|
|
9283
|
-
}
|
|
9284
|
-
function onLoad(ui, event) {
|
|
9285
|
-
emit(ui, ImageEvent.LOAD, event);
|
|
9286
|
-
}
|
|
9287
|
-
function onLoadSuccess(ui, event) {
|
|
9288
|
-
emit(ui, ImageEvent.LOADED, event);
|
|
9289
|
-
}
|
|
9290
|
-
function onLoadError(ui, event, error) {
|
|
9291
|
-
event.error = error;
|
|
9292
|
-
ui.forceUpdate("surface");
|
|
9293
|
-
emit(ui, ImageEvent.ERROR, event);
|
|
9294
|
-
}
|
|
9295
|
-
function emit(ui, type, data) {
|
|
9296
|
-
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
9309
|
+
data.transform = transform;
|
|
9297
9310
|
}
|
|
9298
|
-
function
|
|
9299
|
-
|
|
9300
|
-
if (
|
|
9311
|
+
function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
9312
|
+
if (rotation) rotate(transform, rotation);
|
|
9313
|
+
if (skew) skewHelper(transform, skew.x, skew.y);
|
|
9314
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
9315
|
+
translate(transform, box.x + x, box.y + y);
|
|
9301
9316
|
}
|
|
9302
9317
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
9303
|
-
const {
|
|
9304
|
-
function
|
|
9305
|
-
|
|
9306
|
-
|
|
9318
|
+
const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
9319
|
+
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
9320
|
+
if (!paint.patternTask) {
|
|
9321
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
9322
|
+
paint.patternTask = null;
|
|
9323
|
+
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
9324
|
+
ui.forceUpdate("surface");
|
|
9325
|
+
}), 300);
|
|
9326
|
+
}
|
|
9327
|
+
}
|
|
9328
|
+
function createPattern(paint, ui, canvas, renderOptions) {
|
|
9329
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
9307
9330
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
scaleX
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
width *= scaleX;
|
|
9322
|
-
height *= scaleY;
|
|
9323
|
-
const size = width * height;
|
|
9324
|
-
if (!repeat) {
|
|
9325
|
-
if (size > Platform.image.maxCacheSize) return false;
|
|
9326
|
-
}
|
|
9327
|
-
let maxSize = Platform.image.maxPatternSize;
|
|
9328
|
-
if (image.isSVG) {
|
|
9329
|
-
const ws = width / image.width;
|
|
9330
|
-
if (ws > 1) imageScale = ws / ceil(ws);
|
|
9331
|
-
} else {
|
|
9332
|
-
const imageSize = image.width * image.height;
|
|
9333
|
-
if (maxSize > imageSize) maxSize = imageSize;
|
|
9334
|
-
}
|
|
9335
|
-
if (size > maxSize) imageScale = Math.sqrt(size / maxSize);
|
|
9336
|
-
if (imageScale) {
|
|
9337
|
-
scaleX /= imageScale;
|
|
9338
|
-
scaleY /= imageScale;
|
|
9339
|
-
width /= imageScale;
|
|
9340
|
-
height /= imageScale;
|
|
9341
|
-
}
|
|
9342
|
-
if (sx) {
|
|
9343
|
-
scaleX /= sx;
|
|
9344
|
-
scaleY /= sy;
|
|
9345
|
-
}
|
|
9346
|
-
const xGap = gap && gap.x * scaleX;
|
|
9347
|
-
const yGap = gap && gap.y * scaleY;
|
|
9348
|
-
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
9349
|
-
const canvasWidth = width + (xGap || 0);
|
|
9350
|
-
const canvasHeight = height + (yGap || 0);
|
|
9351
|
-
scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
|
|
9352
|
-
scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
|
|
9353
|
-
if (!imageMatrix) {
|
|
9331
|
+
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
9332
|
+
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
9333
|
+
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
9334
|
+
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
9335
|
+
width *= scaleX;
|
|
9336
|
+
height *= scaleY;
|
|
9337
|
+
if (gap) {
|
|
9338
|
+
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
9339
|
+
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
9340
|
+
}
|
|
9341
|
+
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
9342
|
+
scaleX *= getFloorScale(width + (xGap || 0));
|
|
9343
|
+
scaleY *= getFloorScale(height + (yGap || 0));
|
|
9354
9344
|
imageMatrix = get$1();
|
|
9355
9345
|
if (transform) copy$1(imageMatrix, transform);
|
|
9346
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
9356
9347
|
}
|
|
9357
|
-
|
|
9348
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
9349
|
+
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
9350
|
+
paint.style = pattern;
|
|
9351
|
+
paint.patternId = id;
|
|
9358
9352
|
}
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9353
|
+
}
|
|
9354
|
+
}
|
|
9355
|
+
function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
9356
|
+
const {image: image} = paint;
|
|
9357
|
+
let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
|
|
9358
|
+
if (image.isSVG) {
|
|
9359
|
+
if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
|
|
9364
9360
|
} else {
|
|
9365
|
-
|
|
9361
|
+
if (maxSize > imageSize) maxSize = imageSize;
|
|
9366
9362
|
}
|
|
9363
|
+
if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
|
|
9364
|
+
return fixScale;
|
|
9367
9365
|
}
|
|
9368
|
-
function checkImage(ui, canvas,
|
|
9369
|
-
const {scaleX: scaleX, scaleY: scaleY} =
|
|
9370
|
-
const {
|
|
9371
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY
|
|
9366
|
+
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
9367
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
9368
|
+
const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
|
|
9369
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
9372
9370
|
return false;
|
|
9373
9371
|
} else {
|
|
9374
|
-
if (
|
|
9372
|
+
if (drawImage) {
|
|
9375
9373
|
if (data.repeat) {
|
|
9376
|
-
|
|
9377
|
-
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) ||
|
|
9378
|
-
|
|
9379
|
-
width *= scaleX * pixelRatio;
|
|
9380
|
-
height *= scaleY * pixelRatio;
|
|
9381
|
-
if (data.scaleX) {
|
|
9382
|
-
width *= data.scaleX;
|
|
9383
|
-
height *= data.scaleY;
|
|
9384
|
-
}
|
|
9385
|
-
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
9374
|
+
drawImage = false;
|
|
9375
|
+
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
9376
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
9386
9377
|
}
|
|
9387
9378
|
}
|
|
9388
|
-
if (
|
|
9379
|
+
if (drawImage) {
|
|
9389
9380
|
if (ui.__.__isFastShadow) {
|
|
9390
9381
|
canvas.fillStyle = paint.style || "#000";
|
|
9391
9382
|
canvas.fill();
|
|
9392
9383
|
}
|
|
9393
|
-
drawImage(ui, canvas,
|
|
9384
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
9394
9385
|
return true;
|
|
9395
9386
|
} else {
|
|
9396
|
-
if (!paint.style || paint.sync ||
|
|
9397
|
-
createPattern(ui, paint, pixelRatio);
|
|
9398
|
-
} else {
|
|
9399
|
-
if (!paint.patternTask) {
|
|
9400
|
-
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
9401
|
-
paint.patternTask = null;
|
|
9402
|
-
if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio);
|
|
9403
|
-
ui.forceUpdate("surface");
|
|
9404
|
-
}), 300);
|
|
9405
|
-
}
|
|
9406
|
-
}
|
|
9387
|
+
if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
9407
9388
|
return false;
|
|
9408
9389
|
}
|
|
9409
9390
|
}
|
|
9410
9391
|
}
|
|
9411
|
-
function drawImage(ui, canvas,
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
if (
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9392
|
+
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
9393
|
+
const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
9394
|
+
let {width: width, height: height} = image, clipUI;
|
|
9395
|
+
if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
|
|
9396
|
+
canvas.save();
|
|
9397
|
+
clipUI && canvas.clipUI(ui);
|
|
9398
|
+
blendMode && (canvas.blendMode = blendMode);
|
|
9399
|
+
opacity && (canvas.opacity *= opacity);
|
|
9400
|
+
transform && canvas.transform(transform);
|
|
9401
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
9402
|
+
canvas.restore();
|
|
9403
|
+
} else {
|
|
9404
|
+
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
9405
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
9406
|
+
}
|
|
9407
|
+
}
|
|
9408
|
+
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
9409
|
+
const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
|
|
9410
|
+
if (canvas) {
|
|
9411
|
+
const {pixelRatio: pixelRatio} = canvas;
|
|
9412
|
+
scaleData.scaleX *= pixelRatio;
|
|
9413
|
+
scaleData.scaleY *= pixelRatio;
|
|
9414
|
+
}
|
|
9415
|
+
if (data && data.scaleX) {
|
|
9416
|
+
scaleData.scaleX *= Math.abs(data.scaleX);
|
|
9417
|
+
scaleData.scaleY *= Math.abs(data.scaleY);
|
|
9418
|
+
}
|
|
9419
|
+
return scaleData;
|
|
9419
9420
|
}
|
|
9420
9421
|
function recycleImage(attrName, data) {
|
|
9421
9422
|
const paints = data["_" + attrName];
|
|
@@ -9445,8 +9446,12 @@ var LeaferUI = function(exports) {
|
|
|
9445
9446
|
const PaintImageModule = {
|
|
9446
9447
|
image: image,
|
|
9447
9448
|
checkImage: checkImage,
|
|
9448
|
-
|
|
9449
|
+
drawImage: drawImage,
|
|
9450
|
+
getImageRenderScaleData: getImageRenderScaleData,
|
|
9449
9451
|
recycleImage: recycleImage,
|
|
9452
|
+
createPatternTask: createPatternTask,
|
|
9453
|
+
createPattern: createPattern,
|
|
9454
|
+
getPatternFixScale: getPatternFixScale,
|
|
9450
9455
|
createData: createData,
|
|
9451
9456
|
getPatternData: getPatternData,
|
|
9452
9457
|
stretchMode: stretchMode,
|
|
@@ -9833,10 +9838,8 @@ var LeaferUI = function(exports) {
|
|
|
9833
9838
|
bounds = drawData.bounds;
|
|
9834
9839
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
9835
9840
|
const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
|
|
9836
|
-
const {canvas: canvas} = Platform;
|
|
9837
|
-
|
|
9838
|
-
const charMode = width || height || __letterSpacing || textCase !== "none";
|
|
9839
|
-
if (charMode) {
|
|
9841
|
+
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
9842
|
+
if (style.__isCharMode) {
|
|
9840
9843
|
const wrap = style.textWrap !== "none";
|
|
9841
9844
|
const breakAll = style.textWrap === "break";
|
|
9842
9845
|
paraStart = true;
|
|
@@ -9957,12 +9960,19 @@ var LeaferUI = function(exports) {
|
|
|
9957
9960
|
function layoutChar(drawData, style, width, _height) {
|
|
9958
9961
|
const {rows: rows} = drawData;
|
|
9959
9962
|
const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
|
|
9960
|
-
|
|
9963
|
+
const justifyLast = width && textAlign.includes("both");
|
|
9964
|
+
const justify = justifyLast || width && textAlign.includes("justify");
|
|
9965
|
+
const justifyLetter = justify && textAlign.includes("letter");
|
|
9966
|
+
let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
|
|
9961
9967
|
rows.forEach(row => {
|
|
9962
9968
|
if (row.words) {
|
|
9963
9969
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
9964
|
-
|
|
9965
|
-
|
|
9970
|
+
if (justify) {
|
|
9971
|
+
canJustify = !row.paraEnd || justifyLast;
|
|
9972
|
+
remainingWidth = width - row.width - indentWidth;
|
|
9973
|
+
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
9974
|
+
}
|
|
9975
|
+
mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
9966
9976
|
if (row.isOverflow && !letterSpacing) row.textMode = true;
|
|
9967
9977
|
if (mode === TextMode) {
|
|
9968
9978
|
row.x += indentWidth;
|
|
@@ -9980,11 +9990,15 @@ var LeaferUI = function(exports) {
|
|
|
9980
9990
|
charX = toWordChar(word.data, charX, wordChar);
|
|
9981
9991
|
if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
|
|
9982
9992
|
} else {
|
|
9983
|
-
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
9993
|
+
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
9984
9994
|
}
|
|
9985
|
-
if (
|
|
9986
|
-
|
|
9987
|
-
|
|
9995
|
+
if (canJustify) {
|
|
9996
|
+
isLastWord = index === wordsLength - 1;
|
|
9997
|
+
if (addWordWidth) {
|
|
9998
|
+
if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
|
|
9999
|
+
} else if (addLetterWidth) {
|
|
10000
|
+
row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
|
|
10001
|
+
}
|
|
9988
10002
|
}
|
|
9989
10003
|
});
|
|
9990
10004
|
}
|
|
@@ -10007,13 +10021,14 @@ var LeaferUI = function(exports) {
|
|
|
10007
10021
|
});
|
|
10008
10022
|
return charX;
|
|
10009
10023
|
}
|
|
10010
|
-
function toChar(data, charX, rowData, isOverflow) {
|
|
10024
|
+
function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
|
|
10011
10025
|
data.forEach(char => {
|
|
10012
10026
|
if (isOverflow || char.char !== " ") {
|
|
10013
10027
|
char.x = charX;
|
|
10014
10028
|
rowData.push(char);
|
|
10015
10029
|
}
|
|
10016
10030
|
charX += char.width;
|
|
10031
|
+
addLetterWidth && (charX += addLetterWidth);
|
|
10017
10032
|
});
|
|
10018
10033
|
return charX;
|
|
10019
10034
|
}
|
|
@@ -10149,10 +10164,10 @@ var LeaferUI = function(exports) {
|
|
|
10149
10164
|
let x = 0, y = 0;
|
|
10150
10165
|
let width = style.__getInput("width") || 0;
|
|
10151
10166
|
let height = style.__getInput("height") || 0;
|
|
10152
|
-
const {
|
|
10167
|
+
const {__padding: padding} = style;
|
|
10153
10168
|
if (padding) {
|
|
10154
|
-
if (width) x = padding[left], width -= padding[right] + padding[left]; else if (!style.autoSizeAlign) x = padding[left];
|
|
10155
|
-
if (height) y = padding[top], height -= padding[top] + padding[bottom]; else if (!style.autoSizeAlign) y = padding[top];
|
|
10169
|
+
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
10170
|
+
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
10156
10171
|
}
|
|
10157
10172
|
const drawData = {
|
|
10158
10173
|
bounds: {
|
|
@@ -10163,14 +10178,14 @@ var LeaferUI = function(exports) {
|
|
|
10163
10178
|
},
|
|
10164
10179
|
rows: [],
|
|
10165
10180
|
paraNumber: 0,
|
|
10166
|
-
font: Platform.canvas.font = __font
|
|
10181
|
+
font: Platform.canvas.font = style.__font
|
|
10167
10182
|
};
|
|
10168
10183
|
createRows(drawData, content, style);
|
|
10169
10184
|
if (padding) padAutoText(padding, drawData, style, width, height);
|
|
10170
10185
|
layoutText(drawData, style);
|
|
10171
|
-
layoutChar(drawData, style, width);
|
|
10186
|
+
if (style.__isCharMode) layoutChar(drawData, style, width);
|
|
10172
10187
|
if (drawData.overflow) clipText(drawData, style, x, width);
|
|
10173
|
-
if (textDecoration !== "none") decorationText(drawData, style);
|
|
10188
|
+
if (style.textDecoration !== "none") decorationText(drawData, style);
|
|
10174
10189
|
return drawData;
|
|
10175
10190
|
}
|
|
10176
10191
|
function padAutoText(padding, drawData, style, width, height) {
|