leafer-draw 1.9.12 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web.cjs +396 -394
- package/dist/web.esm.js +398 -396
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +514 -499
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +536 -517
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +3 -3
package/dist/web.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$9.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
|
const debug$4 = Debug.get("LeaferCanvas");
|
|
6418
6433
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6419
6434
|
set zIndex(zIndex) {
|
|
@@ -7341,7 +7356,7 @@ var LeaferUI = function(exports) {
|
|
|
7341
7356
|
}
|
|
7342
7357
|
};
|
|
7343
7358
|
const {parse: parse, objectToCanvasData: objectToCanvasData} = PathConvert;
|
|
7344
|
-
const {stintSet: stintSet$
|
|
7359
|
+
const {stintSet: stintSet$3} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
|
|
7345
7360
|
const emptyPaint = {};
|
|
7346
7361
|
const debug$1 = Debug.get("UIData");
|
|
7347
7362
|
class UIData extends LeafData {
|
|
@@ -7405,7 +7420,7 @@ var LeaferUI = function(exports) {
|
|
|
7405
7420
|
setFill(value) {
|
|
7406
7421
|
if (this.__naturalWidth) this.__removeNaturalSize();
|
|
7407
7422
|
if (isString(value) || !value) {
|
|
7408
|
-
stintSet$
|
|
7423
|
+
stintSet$3(this, "__isTransparentFill", hasTransparent$2(value));
|
|
7409
7424
|
this.__isFills && this.__removePaint("fill", true);
|
|
7410
7425
|
this._fill = value;
|
|
7411
7426
|
} else if (isObject(value)) {
|
|
@@ -7414,7 +7429,7 @@ var LeaferUI = function(exports) {
|
|
|
7414
7429
|
}
|
|
7415
7430
|
setStroke(value) {
|
|
7416
7431
|
if (isString(value) || !value) {
|
|
7417
|
-
stintSet$
|
|
7432
|
+
stintSet$3(this, "__isTransparentStroke", hasTransparent$2(value));
|
|
7418
7433
|
this.__isStrokes && this.__removePaint("stroke", true);
|
|
7419
7434
|
this._stroke = value;
|
|
7420
7435
|
} else if (isObject(value)) {
|
|
@@ -7472,11 +7487,11 @@ var LeaferUI = function(exports) {
|
|
|
7472
7487
|
if (removeInput) this.__removeInput(attrName);
|
|
7473
7488
|
PaintImage.recycleImage(attrName, this);
|
|
7474
7489
|
if (attrName === "fill") {
|
|
7475
|
-
stintSet$
|
|
7490
|
+
stintSet$3(this, "__isAlphaPixelFill", undefined);
|
|
7476
7491
|
this._fill = this.__isFills = undefined;
|
|
7477
7492
|
} else {
|
|
7478
|
-
stintSet$
|
|
7479
|
-
stintSet$
|
|
7493
|
+
stintSet$3(this, "__isAlphaPixelStroke", undefined);
|
|
7494
|
+
stintSet$3(this, "__hasMultiStrokeStyle", undefined);
|
|
7480
7495
|
this._stroke = this.__isStrokes = undefined;
|
|
7481
7496
|
}
|
|
7482
7497
|
}
|
|
@@ -7608,7 +7623,7 @@ var LeaferUI = function(exports) {
|
|
|
7608
7623
|
return data;
|
|
7609
7624
|
}
|
|
7610
7625
|
}
|
|
7611
|
-
const {max: max$
|
|
7626
|
+
const {max: max$1, add: add$1} = FourNumberHelper;
|
|
7612
7627
|
const UIBounds = {
|
|
7613
7628
|
__updateStrokeSpread() {
|
|
7614
7629
|
let spread = 0, boxSpread = 0;
|
|
@@ -7623,7 +7638,7 @@ var LeaferUI = function(exports) {
|
|
|
7623
7638
|
}
|
|
7624
7639
|
if (data.__useArrow) spread += strokeWidth * 5;
|
|
7625
7640
|
if (box) {
|
|
7626
|
-
spread = max$
|
|
7641
|
+
spread = max$1(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
|
|
7627
7642
|
boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
|
|
7628
7643
|
}
|
|
7629
7644
|
this.__layout.strokeBoxSpread = boxSpread;
|
|
@@ -7633,33 +7648,33 @@ var LeaferUI = function(exports) {
|
|
|
7633
7648
|
let spread = 0;
|
|
7634
7649
|
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
|
|
7635
7650
|
if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
|
|
7636
|
-
if (blur) spread = max$
|
|
7651
|
+
if (blur) spread = max$1(spread, blur);
|
|
7637
7652
|
if (filter) spread = add$1(spread, Filter.getSpread(filter));
|
|
7638
7653
|
if (renderSpread) spread = add$1(spread, renderSpread);
|
|
7639
7654
|
if (strokeSpread) spread = add$1(spread, strokeSpread);
|
|
7640
7655
|
let shapeSpread = spread;
|
|
7641
|
-
if (innerShadow) shapeSpread = max$
|
|
7642
|
-
if (backgroundBlur) shapeSpread = max$
|
|
7656
|
+
if (innerShadow) shapeSpread = max$1(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
|
|
7657
|
+
if (backgroundBlur) shapeSpread = max$1(shapeSpread, backgroundBlur);
|
|
7643
7658
|
this.__layout.renderShapeSpread = shapeSpread;
|
|
7644
|
-
return box ? max$
|
|
7659
|
+
return box ? max$1(box.__updateRenderSpread(), spread) : spread;
|
|
7645
7660
|
}
|
|
7646
7661
|
};
|
|
7647
|
-
const {stintSet: stintSet$
|
|
7662
|
+
const {stintSet: stintSet$2} = DataHelper;
|
|
7648
7663
|
const UIRender = {
|
|
7649
7664
|
__updateChange() {
|
|
7650
7665
|
const data = this.__;
|
|
7651
7666
|
if (data.__useStroke) {
|
|
7652
7667
|
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
7653
|
-
stintSet$
|
|
7654
|
-
stintSet$
|
|
7668
|
+
stintSet$2(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
|
|
7669
|
+
stintSet$2(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
|
|
7655
7670
|
}
|
|
7656
7671
|
if (data.__useEffect) {
|
|
7657
7672
|
const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7658
|
-
stintSet$
|
|
7673
|
+
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"));
|
|
7659
7674
|
data.__useEffect = !!(shadow || otherEffect);
|
|
7660
7675
|
}
|
|
7661
7676
|
data.__checkSingle();
|
|
7662
|
-
stintSet$
|
|
7677
|
+
stintSet$2(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
7663
7678
|
},
|
|
7664
7679
|
__drawFast(canvas, options) {
|
|
7665
7680
|
drawFast(this, canvas, options);
|
|
@@ -7675,24 +7690,24 @@ var LeaferUI = function(exports) {
|
|
|
7675
7690
|
this.__nowWorld = this.__getNowWorld(options);
|
|
7676
7691
|
const {shadow: shadow, innerShadow: innerShadow, filter: filter} = data;
|
|
7677
7692
|
if (shadow) Effect.shadow(this, canvas, shape);
|
|
7678
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7679
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7693
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7694
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
7680
7695
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
7681
7696
|
if (innerShadow) Effect.innerShadow(this, canvas, shape);
|
|
7682
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7697
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7683
7698
|
if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
7684
7699
|
if (shape.worldCanvas) shape.worldCanvas.recycle();
|
|
7685
7700
|
shape.canvas.recycle();
|
|
7686
7701
|
} else {
|
|
7687
|
-
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7702
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7688
7703
|
if (__isFastShadow) {
|
|
7689
7704
|
const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
|
|
7690
7705
|
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
7691
7706
|
}
|
|
7692
|
-
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7707
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
|
|
7693
7708
|
if (__isFastShadow) canvas.restore();
|
|
7694
7709
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
7695
|
-
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7710
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
7696
7711
|
}
|
|
7697
7712
|
} else {
|
|
7698
7713
|
if (data.__pathInputed) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
|
|
@@ -7701,9 +7716,9 @@ var LeaferUI = function(exports) {
|
|
|
7701
7716
|
__drawShape(canvas, options) {
|
|
7702
7717
|
this.__drawRenderPath(canvas);
|
|
7703
7718
|
const data = this.__, {fill: fill, stroke: stroke} = data;
|
|
7704
|
-
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill("#000000", this, canvas);
|
|
7719
|
+
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas, options) : Paint.fill("#000000", this, canvas, options);
|
|
7705
7720
|
if (data.__isCanvas) this.__drawAfterFill(canvas, options);
|
|
7706
|
-
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke("#000000", this, canvas);
|
|
7721
|
+
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke("#000000", this, canvas, options);
|
|
7707
7722
|
},
|
|
7708
7723
|
__drawAfterFill(canvas, options) {
|
|
7709
7724
|
if (this.__.__clipAfterFill) {
|
|
@@ -7717,10 +7732,10 @@ var LeaferUI = function(exports) {
|
|
|
7717
7732
|
function drawFast(ui, canvas, options) {
|
|
7718
7733
|
const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke} = ui.__;
|
|
7719
7734
|
ui.__drawRenderPath(canvas);
|
|
7720
|
-
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
7721
|
-
if (fill) Paint.fill(fill, ui, canvas);
|
|
7735
|
+
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
7736
|
+
if (fill) Paint.fill(fill, ui, canvas, options);
|
|
7722
7737
|
if (__drawAfterFill) ui.__drawAfterFill(canvas, options);
|
|
7723
|
-
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
7738
|
+
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
|
|
7724
7739
|
}
|
|
7725
7740
|
const RectRender = {
|
|
7726
7741
|
__drawFast(canvas, options) {
|
|
@@ -7855,8 +7870,8 @@ var LeaferUI = function(exports) {
|
|
|
7855
7870
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
7856
7871
|
} else drawer.rect(x, y, width, height);
|
|
7857
7872
|
}
|
|
7858
|
-
drawImagePlaceholder(canvas,
|
|
7859
|
-
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
7873
|
+
drawImagePlaceholder(_image, canvas, renderOptions) {
|
|
7874
|
+
Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
|
|
7860
7875
|
}
|
|
7861
7876
|
animate(keyframe, _options, _type, _isTemp) {
|
|
7862
7877
|
this.set(keyframe);
|
|
@@ -8719,7 +8734,7 @@ var LeaferUI = function(exports) {
|
|
|
8719
8734
|
__decorate([ dataType(false) ], exports.Canvas.prototype, "safeResize", void 0);
|
|
8720
8735
|
__decorate([ resizeType() ], exports.Canvas.prototype, "contextSettings", void 0);
|
|
8721
8736
|
exports.Canvas = __decorate([ registerUI() ], exports.Canvas);
|
|
8722
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
|
|
8737
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
8723
8738
|
exports.Text = class Text extends exports.UI {
|
|
8724
8739
|
get __tag() {
|
|
8725
8740
|
return "Text";
|
|
@@ -8730,13 +8745,14 @@ var LeaferUI = function(exports) {
|
|
|
8730
8745
|
}
|
|
8731
8746
|
__updateTextDrawData() {
|
|
8732
8747
|
const data = this.__;
|
|
8733
|
-
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
|
|
8748
|
+
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
|
|
8734
8749
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
8735
8750
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
8736
|
-
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
8737
8751
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
|
|
8738
8752
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
8739
|
-
data
|
|
8753
|
+
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
8754
|
+
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
8755
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
|
|
8740
8756
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
8741
8757
|
}
|
|
8742
8758
|
__updateBoxBounds() {
|
|
@@ -8908,34 +8924,18 @@ var LeaferUI = function(exports) {
|
|
|
8908
8924
|
});
|
|
8909
8925
|
};
|
|
8910
8926
|
}
|
|
8911
|
-
function
|
|
8912
|
-
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
8913
|
-
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
8914
|
-
let row;
|
|
8915
|
-
for (let i = 0, len = rows.length; i < len; i++) {
|
|
8916
|
-
row = rows[i];
|
|
8917
|
-
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
8918
|
-
canvas.fillText(charData.char, charData.x, row.y);
|
|
8919
|
-
});
|
|
8920
|
-
}
|
|
8921
|
-
if (decorationY) {
|
|
8922
|
-
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
8923
|
-
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
8924
|
-
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
8925
|
-
}
|
|
8926
|
-
}
|
|
8927
|
-
function fill(fill, ui, canvas) {
|
|
8927
|
+
function fill(fill, ui, canvas, renderOptions) {
|
|
8928
8928
|
canvas.fillStyle = fill;
|
|
8929
|
-
fillPathOrText(ui, canvas);
|
|
8929
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
8930
8930
|
}
|
|
8931
|
-
function fills(fills, ui, canvas) {
|
|
8931
|
+
function fills(fills, ui, canvas, renderOptions) {
|
|
8932
8932
|
let item;
|
|
8933
8933
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
8934
8934
|
item = fills[i];
|
|
8935
8935
|
if (item.image) {
|
|
8936
|
-
if (PaintImage.checkImage(
|
|
8936
|
+
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
8937
8937
|
if (!item.style) {
|
|
8938
|
-
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas,
|
|
8938
|
+
if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
|
|
8939
8939
|
continue;
|
|
8940
8940
|
}
|
|
8941
8941
|
}
|
|
@@ -8948,55 +8948,126 @@ var LeaferUI = function(exports) {
|
|
|
8948
8948
|
if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
8949
8949
|
}
|
|
8950
8950
|
if (item.blendMode) canvas.blendMode = item.blendMode;
|
|
8951
|
-
fillPathOrText(ui, canvas);
|
|
8951
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
8952
8952
|
canvas.restore();
|
|
8953
8953
|
} else {
|
|
8954
8954
|
if (item.blendMode) {
|
|
8955
8955
|
canvas.saveBlendMode(item.blendMode);
|
|
8956
|
-
fillPathOrText(ui, canvas);
|
|
8956
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
8957
8957
|
canvas.restoreBlendMode();
|
|
8958
|
-
} else fillPathOrText(ui, canvas);
|
|
8958
|
+
} else fillPathOrText(ui, canvas, renderOptions);
|
|
8959
|
+
}
|
|
8960
|
+
}
|
|
8961
|
+
}
|
|
8962
|
+
function fillPathOrText(ui, canvas, renderOptions) {
|
|
8963
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
8964
|
+
}
|
|
8965
|
+
function fillText(ui, canvas, _renderOptions) {
|
|
8966
|
+
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
8967
|
+
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
8968
|
+
let row;
|
|
8969
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
8970
|
+
row = rows[i];
|
|
8971
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
8972
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
8973
|
+
});
|
|
8974
|
+
}
|
|
8975
|
+
if (decorationY) {
|
|
8976
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
8977
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
8978
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
8979
|
+
}
|
|
8980
|
+
}
|
|
8981
|
+
function stroke(stroke, ui, canvas, renderOptions) {
|
|
8982
|
+
const data = ui.__;
|
|
8983
|
+
if (!data.__strokeWidth) return;
|
|
8984
|
+
if (data.__font) {
|
|
8985
|
+
Paint.strokeText(stroke, ui, canvas, renderOptions);
|
|
8986
|
+
} else {
|
|
8987
|
+
switch (data.strokeAlign) {
|
|
8988
|
+
case "center":
|
|
8989
|
+
drawCenter$1(stroke, 1, ui, canvas, renderOptions);
|
|
8990
|
+
break;
|
|
8991
|
+
|
|
8992
|
+
case "inside":
|
|
8993
|
+
drawInside(stroke, ui, canvas, renderOptions);
|
|
8994
|
+
break;
|
|
8995
|
+
|
|
8996
|
+
case "outside":
|
|
8997
|
+
drawOutside(stroke, ui, canvas, renderOptions);
|
|
8998
|
+
break;
|
|
8959
8999
|
}
|
|
8960
9000
|
}
|
|
8961
9001
|
}
|
|
8962
|
-
function
|
|
8963
|
-
|
|
9002
|
+
function strokes(strokes, ui, canvas, renderOptions) {
|
|
9003
|
+
Paint.stroke(strokes, ui, canvas, renderOptions);
|
|
9004
|
+
}
|
|
9005
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9006
|
+
const data = ui.__;
|
|
9007
|
+
if (isObject(stroke)) {
|
|
9008
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
|
|
9009
|
+
} else {
|
|
9010
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9011
|
+
canvas.stroke();
|
|
9012
|
+
}
|
|
9013
|
+
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
|
|
9014
|
+
}
|
|
9015
|
+
function drawInside(stroke, ui, canvas, renderOptions) {
|
|
9016
|
+
canvas.save();
|
|
9017
|
+
canvas.clipUI(ui);
|
|
9018
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9019
|
+
canvas.restore();
|
|
8964
9020
|
}
|
|
8965
|
-
function
|
|
9021
|
+
function drawOutside(stroke, ui, canvas, renderOptions) {
|
|
9022
|
+
const data = ui.__;
|
|
9023
|
+
if (data.__fillAfterStroke) {
|
|
9024
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9025
|
+
} else {
|
|
9026
|
+
const {renderBounds: renderBounds} = ui.__layout;
|
|
9027
|
+
const out = canvas.getSameCanvas(true, true);
|
|
9028
|
+
ui.__drawRenderPath(out);
|
|
9029
|
+
drawCenter$1(stroke, 2, ui, out, renderOptions);
|
|
9030
|
+
out.clipUI(data);
|
|
9031
|
+
out.clearWorld(renderBounds);
|
|
9032
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9033
|
+
out.recycle(ui.__nowWorld);
|
|
9034
|
+
}
|
|
9035
|
+
}
|
|
9036
|
+
function strokeText(stroke, ui, canvas, renderOptions) {
|
|
8966
9037
|
switch (ui.__.strokeAlign) {
|
|
8967
9038
|
case "center":
|
|
8968
|
-
drawCenter
|
|
9039
|
+
drawCenter(stroke, 1, ui, canvas, renderOptions);
|
|
8969
9040
|
break;
|
|
8970
9041
|
|
|
8971
9042
|
case "inside":
|
|
8972
|
-
drawAlign(stroke, "inside", ui, canvas);
|
|
9043
|
+
drawAlign(stroke, "inside", ui, canvas, renderOptions);
|
|
8973
9044
|
break;
|
|
8974
9045
|
|
|
8975
9046
|
case "outside":
|
|
8976
|
-
ui.__.__fillAfterStroke ? drawCenter
|
|
9047
|
+
ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
|
|
8977
9048
|
break;
|
|
8978
9049
|
}
|
|
8979
9050
|
}
|
|
8980
|
-
function drawCenter
|
|
9051
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
8981
9052
|
const data = ui.__;
|
|
8982
9053
|
if (isObject(stroke)) {
|
|
8983
|
-
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
9054
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
|
|
8984
9055
|
} else {
|
|
8985
9056
|
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
8986
|
-
drawTextStroke(ui, canvas);
|
|
9057
|
+
Paint.drawTextStroke(ui, canvas, renderOptions);
|
|
8987
9058
|
}
|
|
8988
9059
|
}
|
|
8989
|
-
function drawAlign(stroke, align, ui, canvas) {
|
|
9060
|
+
function drawAlign(stroke, align, ui, canvas, renderOptions) {
|
|
8990
9061
|
const out = canvas.getSameCanvas(true, true);
|
|
8991
9062
|
out.font = ui.__.__font;
|
|
8992
|
-
drawCenter
|
|
9063
|
+
drawCenter(stroke, 2, ui, out, renderOptions);
|
|
8993
9064
|
out.blendMode = align === "outside" ? "destination-out" : "destination-in";
|
|
8994
|
-
fillText(ui, out);
|
|
9065
|
+
Paint.fillText(ui, out, renderOptions);
|
|
8995
9066
|
out.blendMode = "normal";
|
|
8996
9067
|
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
8997
9068
|
out.recycle(ui.__nowWorld);
|
|
8998
9069
|
}
|
|
8999
|
-
function drawTextStroke(ui, canvas) {
|
|
9070
|
+
function drawTextStroke(ui, canvas, _renderOptions) {
|
|
9000
9071
|
let row, data = ui.__.__textDrawData;
|
|
9001
9072
|
const {rows: rows, decorationY: decorationY} = data;
|
|
9002
9073
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
@@ -9010,13 +9081,13 @@ var LeaferUI = function(exports) {
|
|
|
9010
9081
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
9011
9082
|
}
|
|
9012
9083
|
}
|
|
9013
|
-
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
9084
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
|
|
9014
9085
|
let item;
|
|
9015
9086
|
const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
|
|
9016
9087
|
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
9017
9088
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
9018
9089
|
item = strokes[i];
|
|
9019
|
-
if (item.image && PaintImage.checkImage(ui, canvas,
|
|
9090
|
+
if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
|
|
9020
9091
|
if (item.style) {
|
|
9021
9092
|
if (__hasMultiStrokeStyle) {
|
|
9022
9093
|
const {strokeStyle: strokeStyle} = item;
|
|
@@ -9024,69 +9095,14 @@ var LeaferUI = function(exports) {
|
|
|
9024
9095
|
} else canvas.strokeStyle = item.style;
|
|
9025
9096
|
if (item.blendMode) {
|
|
9026
9097
|
canvas.saveBlendMode(item.blendMode);
|
|
9027
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9098
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9028
9099
|
canvas.restoreBlendMode();
|
|
9029
9100
|
} else {
|
|
9030
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9101
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9031
9102
|
}
|
|
9032
9103
|
}
|
|
9033
9104
|
}
|
|
9034
9105
|
}
|
|
9035
|
-
function stroke(stroke, ui, canvas) {
|
|
9036
|
-
const data = ui.__;
|
|
9037
|
-
if (!data.__strokeWidth) return;
|
|
9038
|
-
if (data.__font) {
|
|
9039
|
-
strokeText(stroke, ui, canvas);
|
|
9040
|
-
} else {
|
|
9041
|
-
switch (data.strokeAlign) {
|
|
9042
|
-
case "center":
|
|
9043
|
-
drawCenter(stroke, 1, ui, canvas);
|
|
9044
|
-
break;
|
|
9045
|
-
|
|
9046
|
-
case "inside":
|
|
9047
|
-
drawInside(stroke, ui, canvas);
|
|
9048
|
-
break;
|
|
9049
|
-
|
|
9050
|
-
case "outside":
|
|
9051
|
-
drawOutside(stroke, ui, canvas);
|
|
9052
|
-
break;
|
|
9053
|
-
}
|
|
9054
|
-
}
|
|
9055
|
-
}
|
|
9056
|
-
function strokes(strokes, ui, canvas) {
|
|
9057
|
-
stroke(strokes, ui, canvas);
|
|
9058
|
-
}
|
|
9059
|
-
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
9060
|
-
const data = ui.__;
|
|
9061
|
-
if (isObject(stroke)) {
|
|
9062
|
-
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
9063
|
-
} else {
|
|
9064
|
-
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9065
|
-
canvas.stroke();
|
|
9066
|
-
}
|
|
9067
|
-
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas);
|
|
9068
|
-
}
|
|
9069
|
-
function drawInside(stroke, ui, canvas) {
|
|
9070
|
-
canvas.save();
|
|
9071
|
-
canvas.clipUI(ui);
|
|
9072
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
9073
|
-
canvas.restore();
|
|
9074
|
-
}
|
|
9075
|
-
function drawOutside(stroke, ui, canvas) {
|
|
9076
|
-
const data = ui.__;
|
|
9077
|
-
if (data.__fillAfterStroke) {
|
|
9078
|
-
drawCenter(stroke, 2, ui, canvas);
|
|
9079
|
-
} else {
|
|
9080
|
-
const {renderBounds: renderBounds} = ui.__layout;
|
|
9081
|
-
const out = canvas.getSameCanvas(true, true);
|
|
9082
|
-
ui.__drawRenderPath(out);
|
|
9083
|
-
drawCenter(stroke, 2, ui, out);
|
|
9084
|
-
out.clipUI(data);
|
|
9085
|
-
out.clearWorld(renderBounds);
|
|
9086
|
-
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9087
|
-
out.recycle(ui.__nowWorld);
|
|
9088
|
-
}
|
|
9089
|
-
}
|
|
9090
9106
|
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
9091
9107
|
const tempBounds$1 = {};
|
|
9092
9108
|
function shape(ui, current, options) {
|
|
@@ -9235,80 +9251,108 @@ var LeaferUI = function(exports) {
|
|
|
9235
9251
|
strokes: strokes,
|
|
9236
9252
|
strokeText: strokeText,
|
|
9237
9253
|
drawTextStroke: drawTextStroke,
|
|
9254
|
+
drawStrokesStyle: drawStrokesStyle,
|
|
9238
9255
|
shape: shape
|
|
9239
9256
|
};
|
|
9240
|
-
let
|
|
9241
|
-
const {
|
|
9242
|
-
function
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
if (
|
|
9246
|
-
|
|
9247
|
-
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
9259
|
-
const transform = get$3();
|
|
9260
|
-
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9261
|
-
if (clipScaleX) {
|
|
9262
|
-
if (rotation || skew) {
|
|
9263
|
-
set(tempMatrix$1);
|
|
9264
|
-
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
9265
|
-
multiplyParent(transform, tempMatrix$1);
|
|
9266
|
-
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
9257
|
+
let cache, box = new Bounds;
|
|
9258
|
+
const {isSame: isSame} = BoundsHelper;
|
|
9259
|
+
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
9260
|
+
let leafPaint, event;
|
|
9261
|
+
const image = ImageManager.get(paint);
|
|
9262
|
+
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
9263
|
+
leafPaint = cache.leafPaint;
|
|
9264
|
+
} else {
|
|
9265
|
+
leafPaint = {
|
|
9266
|
+
type: paint.type,
|
|
9267
|
+
image: image
|
|
9268
|
+
};
|
|
9269
|
+
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
9270
|
+
cache = image.use > 1 ? {
|
|
9271
|
+
leafPaint: leafPaint,
|
|
9272
|
+
paint: paint,
|
|
9273
|
+
boxBounds: box.set(boxBounds)
|
|
9274
|
+
} : null;
|
|
9267
9275
|
}
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9276
|
+
if (firstUse || image.loading) event = {
|
|
9277
|
+
image: image,
|
|
9278
|
+
attrName: attrName,
|
|
9279
|
+
attrValue: paint
|
|
9280
|
+
};
|
|
9281
|
+
if (image.ready) {
|
|
9282
|
+
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
9283
|
+
if (firstUse) {
|
|
9284
|
+
onLoad(ui, event);
|
|
9285
|
+
onLoadSuccess(ui, event);
|
|
9286
|
+
}
|
|
9287
|
+
} else if (image.error) {
|
|
9288
|
+
if (firstUse) onLoadError(ui, event, image.error);
|
|
9274
9289
|
} else {
|
|
9275
|
-
if (
|
|
9276
|
-
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
translate$1(transform, height, 0);
|
|
9286
|
-
break;
|
|
9287
|
-
|
|
9288
|
-
case 180:
|
|
9289
|
-
translate$1(transform, width, height);
|
|
9290
|
-
break;
|
|
9291
|
-
|
|
9292
|
-
case 270:
|
|
9293
|
-
translate$1(transform, 0, width);
|
|
9294
|
-
break;
|
|
9290
|
+
if (firstUse) {
|
|
9291
|
+
ignoreRender(ui, true);
|
|
9292
|
+
onLoad(ui, event);
|
|
9293
|
+
}
|
|
9294
|
+
leafPaint.loadId = image.load(() => {
|
|
9295
|
+
ignoreRender(ui, false);
|
|
9296
|
+
if (!ui.destroyed) {
|
|
9297
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
9298
|
+
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
9299
|
+
ui.forceUpdate("surface");
|
|
9295
9300
|
}
|
|
9301
|
+
onLoadSuccess(ui, event);
|
|
9296
9302
|
}
|
|
9303
|
+
leafPaint.loadId = undefined;
|
|
9304
|
+
}, error => {
|
|
9305
|
+
ignoreRender(ui, false);
|
|
9306
|
+
onLoadError(ui, event, error);
|
|
9307
|
+
leafPaint.loadId = undefined;
|
|
9308
|
+
});
|
|
9309
|
+
if (ui.placeholderColor) {
|
|
9310
|
+
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
9311
|
+
if (!image.ready) {
|
|
9312
|
+
image.isPlacehold = true;
|
|
9313
|
+
ui.forceUpdate("surface");
|
|
9314
|
+
}
|
|
9315
|
+
}, ui.placeholderDelay);
|
|
9297
9316
|
}
|
|
9298
|
-
origin.x = box.x + x;
|
|
9299
|
-
origin.y = box.y + y;
|
|
9300
|
-
translate$1(transform, origin.x, origin.y);
|
|
9301
|
-
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
9302
9317
|
}
|
|
9303
|
-
|
|
9318
|
+
return leafPaint;
|
|
9304
9319
|
}
|
|
9305
|
-
function
|
|
9306
|
-
if (
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9320
|
+
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
9321
|
+
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
9322
|
+
const data = ui.__;
|
|
9323
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
9324
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
9325
|
+
if (data.__autoSide) {
|
|
9326
|
+
ui.forceUpdate("width");
|
|
9327
|
+
if (ui.__proxyData) {
|
|
9328
|
+
ui.setProxyAttr("width", data.width);
|
|
9329
|
+
ui.setProxyAttr("height", data.height);
|
|
9330
|
+
}
|
|
9331
|
+
return false;
|
|
9332
|
+
}
|
|
9333
|
+
}
|
|
9334
|
+
if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
9335
|
+
return true;
|
|
9336
|
+
}
|
|
9337
|
+
function onLoad(ui, event) {
|
|
9338
|
+
emit(ui, ImageEvent.LOAD, event);
|
|
9339
|
+
}
|
|
9340
|
+
function onLoadSuccess(ui, event) {
|
|
9341
|
+
emit(ui, ImageEvent.LOADED, event);
|
|
9342
|
+
}
|
|
9343
|
+
function onLoadError(ui, event, error) {
|
|
9344
|
+
event.error = error;
|
|
9345
|
+
ui.forceUpdate("surface");
|
|
9346
|
+
emit(ui, ImageEvent.ERROR, event);
|
|
9347
|
+
}
|
|
9348
|
+
function emit(ui, type, data) {
|
|
9349
|
+
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
9350
|
+
}
|
|
9351
|
+
function ignoreRender(ui, value) {
|
|
9352
|
+
const {leafer: leafer} = ui;
|
|
9353
|
+
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
9310
9354
|
}
|
|
9311
|
-
const {get: get$
|
|
9355
|
+
const {get: get$3, translate: translate$1} = MatrixHelper;
|
|
9312
9356
|
const tempBox = new Bounds;
|
|
9313
9357
|
const tempScaleData = {};
|
|
9314
9358
|
const tempImage = {};
|
|
@@ -9317,12 +9361,12 @@ var LeaferUI = function(exports) {
|
|
|
9317
9361
|
if (changeful) leafPaint.changeful = changeful;
|
|
9318
9362
|
if (sync) leafPaint.sync = sync;
|
|
9319
9363
|
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
9320
|
-
leafPaint.data = getPatternData(paint, box, image);
|
|
9364
|
+
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
9321
9365
|
}
|
|
9322
9366
|
function getPatternData(paint, box, image) {
|
|
9323
9367
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
9324
9368
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
9325
|
-
|
|
9369
|
+
const {width: width, height: height} = image;
|
|
9326
9370
|
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;
|
|
9327
9371
|
const sameBox = box.width === width && box.height === height;
|
|
9328
9372
|
const data = {
|
|
@@ -9353,8 +9397,8 @@ var LeaferUI = function(exports) {
|
|
|
9353
9397
|
case "stretch":
|
|
9354
9398
|
if (!sameBox) {
|
|
9355
9399
|
scaleX = box.width / width, scaleY = box.height / height;
|
|
9356
|
-
stretchMode(data, box, scaleX, scaleY);
|
|
9357
|
-
}
|
|
9400
|
+
PaintImage.stretchMode(data, box, scaleX, scaleY);
|
|
9401
|
+
} else if (scaleX) scaleX = scaleY = undefined;
|
|
9358
9402
|
break;
|
|
9359
9403
|
|
|
9360
9404
|
case "normal":
|
|
@@ -9362,13 +9406,13 @@ var LeaferUI = function(exports) {
|
|
|
9362
9406
|
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
9363
9407
|
let clipScaleX, clipScaleY;
|
|
9364
9408
|
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
|
|
9365
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
9409
|
+
PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
9366
9410
|
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
9367
9411
|
}
|
|
9368
9412
|
break;
|
|
9369
9413
|
|
|
9370
9414
|
case "repeat":
|
|
9371
|
-
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
9415
|
+
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
9372
9416
|
if (!repeat) data.repeat = "repeat";
|
|
9373
9417
|
const count = isObject(repeat);
|
|
9374
9418
|
if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
|
|
@@ -9377,18 +9421,16 @@ var LeaferUI = function(exports) {
|
|
|
9377
9421
|
case "fit":
|
|
9378
9422
|
case "cover":
|
|
9379
9423
|
default:
|
|
9380
|
-
if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9424
|
+
if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9381
9425
|
}
|
|
9382
9426
|
if (!data.transform) {
|
|
9383
|
-
if (box.x || box.y) translate(data.transform = get$
|
|
9427
|
+
if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
|
|
9384
9428
|
}
|
|
9385
|
-
data.width = width;
|
|
9386
|
-
data.height = height;
|
|
9387
9429
|
if (scaleX) {
|
|
9388
9430
|
data.scaleX = scaleX;
|
|
9389
9431
|
data.scaleY = scaleY;
|
|
9390
9432
|
}
|
|
9391
|
-
if (opacity) data.opacity = opacity;
|
|
9433
|
+
if (opacity && opacity < 1) data.opacity = opacity;
|
|
9392
9434
|
if (filters) data.filters = filters;
|
|
9393
9435
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
9394
9436
|
return data;
|
|
@@ -9407,221 +9449,180 @@ var LeaferUI = function(exports) {
|
|
|
9407
9449
|
const value = auto ? remain / ((rows || Math.floor(totalSize / size)) - 1) : gap;
|
|
9408
9450
|
return gap === "auto" ? value < 0 ? 0 : value : value;
|
|
9409
9451
|
}
|
|
9410
|
-
let
|
|
9411
|
-
const {
|
|
9412
|
-
function
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9452
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
9453
|
+
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
9454
|
+
function stretchMode(data, box, scaleX, scaleY) {
|
|
9455
|
+
const transform = get$2(), {x: x, y: y} = box;
|
|
9456
|
+
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
9457
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
9458
|
+
data.transform = transform;
|
|
9459
|
+
}
|
|
9460
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
9461
|
+
const transform = get$2();
|
|
9462
|
+
translate(transform, box.x + x, box.y + y);
|
|
9463
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
9464
|
+
if (rotation) rotateOfOuter$1(transform, {
|
|
9465
|
+
x: box.x + box.width / 2,
|
|
9466
|
+
y: box.y + box.height / 2
|
|
9467
|
+
}, rotation);
|
|
9468
|
+
data.transform = transform;
|
|
9469
|
+
}
|
|
9470
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
9471
|
+
const transform = get$2();
|
|
9472
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9473
|
+
if (clipScaleX) {
|
|
9474
|
+
if (rotation || skew) {
|
|
9475
|
+
set(tempMatrix$1);
|
|
9476
|
+
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
9477
|
+
multiplyParent(transform, tempMatrix$1);
|
|
9478
|
+
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
9428
9479
|
}
|
|
9429
|
-
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
9436
|
-
if (firstUse) {
|
|
9437
|
-
onLoad(ui, event);
|
|
9438
|
-
onLoadSuccess(ui, event);
|
|
9439
|
-
}
|
|
9440
|
-
} else if (image.error) {
|
|
9441
|
-
if (firstUse) onLoadError(ui, event, image.error);
|
|
9480
|
+
data.transform = transform;
|
|
9481
|
+
}
|
|
9482
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
9483
|
+
const transform = get$2();
|
|
9484
|
+
if (freeTransform) {
|
|
9485
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9442
9486
|
} else {
|
|
9443
|
-
if (
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
9464
|
-
if (!image.ready) {
|
|
9465
|
-
image.isPlacehold = true;
|
|
9466
|
-
ui.forceUpdate("surface");
|
|
9487
|
+
if (rotation) {
|
|
9488
|
+
if (align === "center") {
|
|
9489
|
+
rotateOfOuter$1(transform, {
|
|
9490
|
+
x: width / 2,
|
|
9491
|
+
y: height / 2
|
|
9492
|
+
}, rotation);
|
|
9493
|
+
} else {
|
|
9494
|
+
rotate(transform, rotation);
|
|
9495
|
+
switch (rotation) {
|
|
9496
|
+
case 90:
|
|
9497
|
+
translate(transform, height, 0);
|
|
9498
|
+
break;
|
|
9499
|
+
|
|
9500
|
+
case 180:
|
|
9501
|
+
translate(transform, width, height);
|
|
9502
|
+
break;
|
|
9503
|
+
|
|
9504
|
+
case 270:
|
|
9505
|
+
translate(transform, 0, width);
|
|
9506
|
+
break;
|
|
9467
9507
|
}
|
|
9468
|
-
}, ui.placeholderDelay);
|
|
9469
|
-
}
|
|
9470
|
-
}
|
|
9471
|
-
return leafPaint;
|
|
9472
|
-
}
|
|
9473
|
-
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
9474
|
-
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
9475
|
-
const data = ui.__;
|
|
9476
|
-
data.__naturalWidth = image.width / data.pixelRatio;
|
|
9477
|
-
data.__naturalHeight = image.height / data.pixelRatio;
|
|
9478
|
-
if (data.__autoSide) {
|
|
9479
|
-
ui.forceUpdate("width");
|
|
9480
|
-
if (ui.__proxyData) {
|
|
9481
|
-
ui.setProxyAttr("width", data.width);
|
|
9482
|
-
ui.setProxyAttr("height", data.height);
|
|
9483
9508
|
}
|
|
9484
|
-
return false;
|
|
9485
9509
|
}
|
|
9510
|
+
origin.x = box.x + x;
|
|
9511
|
+
origin.y = box.y + y;
|
|
9512
|
+
translate(transform, origin.x, origin.y);
|
|
9513
|
+
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
9486
9514
|
}
|
|
9487
|
-
|
|
9488
|
-
return true;
|
|
9489
|
-
}
|
|
9490
|
-
function onLoad(ui, event) {
|
|
9491
|
-
emit(ui, ImageEvent.LOAD, event);
|
|
9492
|
-
}
|
|
9493
|
-
function onLoadSuccess(ui, event) {
|
|
9494
|
-
emit(ui, ImageEvent.LOADED, event);
|
|
9495
|
-
}
|
|
9496
|
-
function onLoadError(ui, event, error) {
|
|
9497
|
-
event.error = error;
|
|
9498
|
-
ui.forceUpdate("surface");
|
|
9499
|
-
emit(ui, ImageEvent.ERROR, event);
|
|
9500
|
-
}
|
|
9501
|
-
function emit(ui, type, data) {
|
|
9502
|
-
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
9515
|
+
data.transform = transform;
|
|
9503
9516
|
}
|
|
9504
|
-
function
|
|
9505
|
-
|
|
9506
|
-
if (
|
|
9517
|
+
function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
9518
|
+
if (rotation) rotate(transform, rotation);
|
|
9519
|
+
if (skew) skewHelper(transform, skew.x, skew.y);
|
|
9520
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
9521
|
+
translate(transform, box.x + x, box.y + y);
|
|
9507
9522
|
}
|
|
9508
9523
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
9509
|
-
const {
|
|
9510
|
-
function
|
|
9511
|
-
|
|
9512
|
-
|
|
9524
|
+
const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
9525
|
+
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
9526
|
+
if (!paint.patternTask) {
|
|
9527
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
9528
|
+
paint.patternTask = null;
|
|
9529
|
+
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
9530
|
+
ui.forceUpdate("surface");
|
|
9531
|
+
}), 300);
|
|
9532
|
+
}
|
|
9533
|
+
}
|
|
9534
|
+
function createPattern(paint, ui, canvas, renderOptions) {
|
|
9535
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
9513
9536
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
|
|
9518
|
-
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
scaleX
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
width *= scaleX;
|
|
9528
|
-
height *= scaleY;
|
|
9529
|
-
const size = width * height;
|
|
9530
|
-
if (!repeat) {
|
|
9531
|
-
if (size > Platform.image.maxCacheSize) return false;
|
|
9532
|
-
}
|
|
9533
|
-
let maxSize = Platform.image.maxPatternSize;
|
|
9534
|
-
if (image.isSVG) {
|
|
9535
|
-
const ws = width / image.width;
|
|
9536
|
-
if (ws > 1) imageScale = ws / ceil(ws);
|
|
9537
|
-
} else {
|
|
9538
|
-
const imageSize = image.width * image.height;
|
|
9539
|
-
if (maxSize > imageSize) maxSize = imageSize;
|
|
9540
|
-
}
|
|
9541
|
-
if (size > maxSize) imageScale = Math.sqrt(size / maxSize);
|
|
9542
|
-
if (imageScale) {
|
|
9543
|
-
scaleX /= imageScale;
|
|
9544
|
-
scaleY /= imageScale;
|
|
9545
|
-
width /= imageScale;
|
|
9546
|
-
height /= imageScale;
|
|
9547
|
-
}
|
|
9548
|
-
if (sx) {
|
|
9549
|
-
scaleX /= sx;
|
|
9550
|
-
scaleY /= sy;
|
|
9551
|
-
}
|
|
9552
|
-
const xGap = gap && gap.x * scaleX;
|
|
9553
|
-
const yGap = gap && gap.y * scaleY;
|
|
9554
|
-
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
9555
|
-
const canvasWidth = width + (xGap || 0);
|
|
9556
|
-
const canvasHeight = height + (yGap || 0);
|
|
9557
|
-
scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
|
|
9558
|
-
scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
|
|
9559
|
-
if (!imageMatrix) {
|
|
9537
|
+
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
9538
|
+
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
9539
|
+
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
9540
|
+
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
9541
|
+
width *= scaleX;
|
|
9542
|
+
height *= scaleY;
|
|
9543
|
+
if (gap) {
|
|
9544
|
+
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
9545
|
+
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
9546
|
+
}
|
|
9547
|
+
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
9548
|
+
scaleX *= getFloorScale(width + (xGap || 0));
|
|
9549
|
+
scaleY *= getFloorScale(height + (yGap || 0));
|
|
9560
9550
|
imageMatrix = get$1();
|
|
9561
9551
|
if (transform) copy$1(imageMatrix, transform);
|
|
9552
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
9562
9553
|
}
|
|
9563
|
-
|
|
9554
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
9555
|
+
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
9556
|
+
paint.style = pattern;
|
|
9557
|
+
paint.patternId = id;
|
|
9564
9558
|
}
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9559
|
+
}
|
|
9560
|
+
}
|
|
9561
|
+
function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
9562
|
+
const {image: image} = paint;
|
|
9563
|
+
let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
|
|
9564
|
+
if (image.isSVG) {
|
|
9565
|
+
if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
|
|
9570
9566
|
} else {
|
|
9571
|
-
|
|
9567
|
+
if (maxSize > imageSize) maxSize = imageSize;
|
|
9572
9568
|
}
|
|
9569
|
+
if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
|
|
9570
|
+
return fixScale;
|
|
9573
9571
|
}
|
|
9574
|
-
function checkImage(ui, canvas,
|
|
9575
|
-
const {scaleX: scaleX, scaleY: scaleY} =
|
|
9576
|
-
const {
|
|
9577
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY
|
|
9572
|
+
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
9573
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
9574
|
+
const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
|
|
9575
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
9578
9576
|
return false;
|
|
9579
9577
|
} else {
|
|
9580
|
-
if (
|
|
9578
|
+
if (drawImage) {
|
|
9581
9579
|
if (data.repeat) {
|
|
9582
|
-
|
|
9583
|
-
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) ||
|
|
9584
|
-
|
|
9585
|
-
width *= scaleX * pixelRatio;
|
|
9586
|
-
height *= scaleY * pixelRatio;
|
|
9587
|
-
if (data.scaleX) {
|
|
9588
|
-
width *= data.scaleX;
|
|
9589
|
-
height *= data.scaleY;
|
|
9590
|
-
}
|
|
9591
|
-
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
9580
|
+
drawImage = false;
|
|
9581
|
+
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
9582
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
9592
9583
|
}
|
|
9593
9584
|
}
|
|
9594
|
-
if (
|
|
9585
|
+
if (drawImage) {
|
|
9595
9586
|
if (ui.__.__isFastShadow) {
|
|
9596
9587
|
canvas.fillStyle = paint.style || "#000";
|
|
9597
9588
|
canvas.fill();
|
|
9598
9589
|
}
|
|
9599
|
-
drawImage(ui, canvas,
|
|
9590
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
9600
9591
|
return true;
|
|
9601
9592
|
} else {
|
|
9602
|
-
if (!paint.style || paint.sync ||
|
|
9603
|
-
createPattern(ui, paint, pixelRatio);
|
|
9604
|
-
} else {
|
|
9605
|
-
if (!paint.patternTask) {
|
|
9606
|
-
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
9607
|
-
paint.patternTask = null;
|
|
9608
|
-
if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio);
|
|
9609
|
-
ui.forceUpdate("surface");
|
|
9610
|
-
}), 300);
|
|
9611
|
-
}
|
|
9612
|
-
}
|
|
9593
|
+
if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
9613
9594
|
return false;
|
|
9614
9595
|
}
|
|
9615
9596
|
}
|
|
9616
9597
|
}
|
|
9617
|
-
function drawImage(ui, canvas,
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
if (
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9598
|
+
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
9599
|
+
const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
9600
|
+
let {width: width, height: height} = image, clipUI;
|
|
9601
|
+
if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
|
|
9602
|
+
canvas.save();
|
|
9603
|
+
clipUI && canvas.clipUI(ui);
|
|
9604
|
+
blendMode && (canvas.blendMode = blendMode);
|
|
9605
|
+
opacity && (canvas.opacity *= opacity);
|
|
9606
|
+
transform && canvas.transform(transform);
|
|
9607
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
9608
|
+
canvas.restore();
|
|
9609
|
+
} else {
|
|
9610
|
+
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
9611
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
9612
|
+
}
|
|
9613
|
+
}
|
|
9614
|
+
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
9615
|
+
const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
|
|
9616
|
+
if (canvas) {
|
|
9617
|
+
const {pixelRatio: pixelRatio} = canvas;
|
|
9618
|
+
scaleData.scaleX *= pixelRatio;
|
|
9619
|
+
scaleData.scaleY *= pixelRatio;
|
|
9620
|
+
}
|
|
9621
|
+
if (data && data.scaleX) {
|
|
9622
|
+
scaleData.scaleX *= Math.abs(data.scaleX);
|
|
9623
|
+
scaleData.scaleY *= Math.abs(data.scaleY);
|
|
9624
|
+
}
|
|
9625
|
+
return scaleData;
|
|
9625
9626
|
}
|
|
9626
9627
|
function recycleImage(attrName, data) {
|
|
9627
9628
|
const paints = data["_" + attrName];
|
|
@@ -9651,8 +9652,12 @@ var LeaferUI = function(exports) {
|
|
|
9651
9652
|
const PaintImageModule = {
|
|
9652
9653
|
image: image,
|
|
9653
9654
|
checkImage: checkImage,
|
|
9654
|
-
|
|
9655
|
+
drawImage: drawImage,
|
|
9656
|
+
getImageRenderScaleData: getImageRenderScaleData,
|
|
9655
9657
|
recycleImage: recycleImage,
|
|
9658
|
+
createPatternTask: createPatternTask,
|
|
9659
|
+
createPattern: createPattern,
|
|
9660
|
+
getPatternFixScale: getPatternFixScale,
|
|
9656
9661
|
createData: createData,
|
|
9657
9662
|
getPatternData: getPatternData,
|
|
9658
9663
|
stretchMode: stretchMode,
|
|
@@ -10039,10 +10044,8 @@ var LeaferUI = function(exports) {
|
|
|
10039
10044
|
bounds = drawData.bounds;
|
|
10040
10045
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
10041
10046
|
const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
|
|
10042
|
-
const {canvas: canvas} = Platform;
|
|
10043
|
-
|
|
10044
|
-
const charMode = width || height || __letterSpacing || textCase !== "none";
|
|
10045
|
-
if (charMode) {
|
|
10047
|
+
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
10048
|
+
if (style.__isCharMode) {
|
|
10046
10049
|
const wrap = style.textWrap !== "none";
|
|
10047
10050
|
const breakAll = style.textWrap === "break";
|
|
10048
10051
|
paraStart = true;
|
|
@@ -10163,12 +10166,19 @@ var LeaferUI = function(exports) {
|
|
|
10163
10166
|
function layoutChar(drawData, style, width, _height) {
|
|
10164
10167
|
const {rows: rows} = drawData;
|
|
10165
10168
|
const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
|
|
10166
|
-
|
|
10169
|
+
const justifyLast = width && textAlign.includes("both");
|
|
10170
|
+
const justify = justifyLast || width && textAlign.includes("justify");
|
|
10171
|
+
const justifyLetter = justify && textAlign.includes("letter");
|
|
10172
|
+
let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
|
|
10167
10173
|
rows.forEach(row => {
|
|
10168
10174
|
if (row.words) {
|
|
10169
10175
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
10170
|
-
|
|
10171
|
-
|
|
10176
|
+
if (justify) {
|
|
10177
|
+
canJustify = !row.paraEnd || justifyLast;
|
|
10178
|
+
remainingWidth = width - row.width - indentWidth;
|
|
10179
|
+
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
10180
|
+
}
|
|
10181
|
+
mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
10172
10182
|
if (row.isOverflow && !letterSpacing) row.textMode = true;
|
|
10173
10183
|
if (mode === TextMode) {
|
|
10174
10184
|
row.x += indentWidth;
|
|
@@ -10186,11 +10196,15 @@ var LeaferUI = function(exports) {
|
|
|
10186
10196
|
charX = toWordChar(word.data, charX, wordChar);
|
|
10187
10197
|
if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
|
|
10188
10198
|
} else {
|
|
10189
|
-
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
10199
|
+
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
10190
10200
|
}
|
|
10191
|
-
if (
|
|
10192
|
-
|
|
10193
|
-
|
|
10201
|
+
if (canJustify) {
|
|
10202
|
+
isLastWord = index === wordsLength - 1;
|
|
10203
|
+
if (addWordWidth) {
|
|
10204
|
+
if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
|
|
10205
|
+
} else if (addLetterWidth) {
|
|
10206
|
+
row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
|
|
10207
|
+
}
|
|
10194
10208
|
}
|
|
10195
10209
|
});
|
|
10196
10210
|
}
|
|
@@ -10213,13 +10227,14 @@ var LeaferUI = function(exports) {
|
|
|
10213
10227
|
});
|
|
10214
10228
|
return charX;
|
|
10215
10229
|
}
|
|
10216
|
-
function toChar(data, charX, rowData, isOverflow) {
|
|
10230
|
+
function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
|
|
10217
10231
|
data.forEach(char => {
|
|
10218
10232
|
if (isOverflow || char.char !== " ") {
|
|
10219
10233
|
char.x = charX;
|
|
10220
10234
|
rowData.push(char);
|
|
10221
10235
|
}
|
|
10222
10236
|
charX += char.width;
|
|
10237
|
+
addLetterWidth && (charX += addLetterWidth);
|
|
10223
10238
|
});
|
|
10224
10239
|
return charX;
|
|
10225
10240
|
}
|
|
@@ -10355,10 +10370,10 @@ var LeaferUI = function(exports) {
|
|
|
10355
10370
|
let x = 0, y = 0;
|
|
10356
10371
|
let width = style.__getInput("width") || 0;
|
|
10357
10372
|
let height = style.__getInput("height") || 0;
|
|
10358
|
-
const {
|
|
10373
|
+
const {__padding: padding} = style;
|
|
10359
10374
|
if (padding) {
|
|
10360
|
-
if (width) x = padding[left], width -= padding[right] + padding[left]; else if (!style.autoSizeAlign) x = padding[left];
|
|
10361
|
-
if (height) y = padding[top], height -= padding[top] + padding[bottom]; else if (!style.autoSizeAlign) y = padding[top];
|
|
10375
|
+
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
10376
|
+
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
10362
10377
|
}
|
|
10363
10378
|
const drawData = {
|
|
10364
10379
|
bounds: {
|
|
@@ -10369,14 +10384,14 @@ var LeaferUI = function(exports) {
|
|
|
10369
10384
|
},
|
|
10370
10385
|
rows: [],
|
|
10371
10386
|
paraNumber: 0,
|
|
10372
|
-
font: Platform.canvas.font = __font
|
|
10387
|
+
font: Platform.canvas.font = style.__font
|
|
10373
10388
|
};
|
|
10374
10389
|
createRows(drawData, content, style);
|
|
10375
10390
|
if (padding) padAutoText(padding, drawData, style, width, height);
|
|
10376
10391
|
layoutText(drawData, style);
|
|
10377
|
-
layoutChar(drawData, style, width);
|
|
10392
|
+
if (style.__isCharMode) layoutChar(drawData, style, width);
|
|
10378
10393
|
if (drawData.overflow) clipText(drawData, style, x, width);
|
|
10379
|
-
if (textDecoration !== "none") decorationText(drawData, style);
|
|
10394
|
+
if (style.textDecoration !== "none") decorationText(drawData, style);
|
|
10380
10395
|
return drawData;
|
|
10381
10396
|
}
|
|
10382
10397
|
function padAutoText(padding, drawData, style, width, height) {
|