leafer-draw 1.9.12 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web.cjs +428 -428
- package/dist/web.esm.js +430 -430
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +546 -533
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +567 -550
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +3 -3
package/dist/web.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.1";
|
|
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(_paint, 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,95 +8924,151 @@ 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) {
|
|
8932
|
-
let item;
|
|
8931
|
+
function fills(fills, ui, canvas, renderOptions) {
|
|
8932
|
+
let item, originPaint, countImage;
|
|
8933
8933
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
8934
|
-
item = fills[i];
|
|
8934
|
+
item = fills[i], originPaint = item.originPaint;
|
|
8935
8935
|
if (item.image) {
|
|
8936
|
-
|
|
8936
|
+
countImage ? countImage++ : countImage = 1;
|
|
8937
|
+
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
8937
8938
|
if (!item.style) {
|
|
8938
|
-
if (
|
|
8939
|
+
if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
|
|
8939
8940
|
continue;
|
|
8940
8941
|
}
|
|
8941
8942
|
}
|
|
8942
8943
|
canvas.fillStyle = item.style;
|
|
8943
|
-
if (item.transform ||
|
|
8944
|
+
if (item.transform || originPaint.scaleFixed) {
|
|
8944
8945
|
canvas.save();
|
|
8945
8946
|
if (item.transform) canvas.transform(item.transform);
|
|
8946
|
-
if (
|
|
8947
|
+
if (originPaint.scaleFixed) {
|
|
8947
8948
|
const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
8948
|
-
if (
|
|
8949
|
+
if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
8949
8950
|
}
|
|
8950
|
-
if (
|
|
8951
|
-
fillPathOrText(ui, canvas);
|
|
8951
|
+
if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
|
|
8952
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
8952
8953
|
canvas.restore();
|
|
8953
8954
|
} else {
|
|
8954
|
-
if (
|
|
8955
|
-
canvas.saveBlendMode(
|
|
8956
|
-
fillPathOrText(ui, canvas);
|
|
8955
|
+
if (originPaint.blendMode) {
|
|
8956
|
+
canvas.saveBlendMode(originPaint.blendMode);
|
|
8957
|
+
fillPathOrText(ui, canvas, renderOptions);
|
|
8957
8958
|
canvas.restoreBlendMode();
|
|
8958
|
-
} else fillPathOrText(ui, canvas);
|
|
8959
|
+
} else fillPathOrText(ui, canvas, renderOptions);
|
|
8960
|
+
}
|
|
8961
|
+
}
|
|
8962
|
+
}
|
|
8963
|
+
function fillPathOrText(ui, canvas, renderOptions) {
|
|
8964
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
8965
|
+
}
|
|
8966
|
+
function fillText(ui, canvas, _renderOptions) {
|
|
8967
|
+
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
8968
|
+
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
8969
|
+
let row;
|
|
8970
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
8971
|
+
row = rows[i];
|
|
8972
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
8973
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
8974
|
+
});
|
|
8975
|
+
}
|
|
8976
|
+
if (decorationY) {
|
|
8977
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
8978
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
8979
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
8980
|
+
}
|
|
8981
|
+
}
|
|
8982
|
+
function stroke(stroke, ui, canvas, renderOptions) {
|
|
8983
|
+
const data = ui.__;
|
|
8984
|
+
if (!data.__strokeWidth) return;
|
|
8985
|
+
if (data.__font) {
|
|
8986
|
+
Paint.strokeText(stroke, ui, canvas, renderOptions);
|
|
8987
|
+
} else {
|
|
8988
|
+
switch (data.strokeAlign) {
|
|
8989
|
+
case "center":
|
|
8990
|
+
drawCenter$1(stroke, 1, ui, canvas, renderOptions);
|
|
8991
|
+
break;
|
|
8992
|
+
|
|
8993
|
+
case "inside":
|
|
8994
|
+
drawInside(stroke, ui, canvas, renderOptions);
|
|
8995
|
+
break;
|
|
8996
|
+
|
|
8997
|
+
case "outside":
|
|
8998
|
+
drawOutside(stroke, ui, canvas, renderOptions);
|
|
8999
|
+
break;
|
|
8959
9000
|
}
|
|
8960
9001
|
}
|
|
8961
9002
|
}
|
|
8962
|
-
function
|
|
8963
|
-
|
|
9003
|
+
function strokes(strokes, ui, canvas, renderOptions) {
|
|
9004
|
+
Paint.stroke(strokes, ui, canvas, renderOptions);
|
|
9005
|
+
}
|
|
9006
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
9007
|
+
const data = ui.__;
|
|
9008
|
+
if (isObject(stroke)) {
|
|
9009
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
|
|
9010
|
+
} else {
|
|
9011
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9012
|
+
canvas.stroke();
|
|
9013
|
+
}
|
|
9014
|
+
if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
|
|
9015
|
+
}
|
|
9016
|
+
function drawInside(stroke, ui, canvas, renderOptions) {
|
|
9017
|
+
canvas.save();
|
|
9018
|
+
canvas.clipUI(ui);
|
|
9019
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9020
|
+
canvas.restore();
|
|
9021
|
+
}
|
|
9022
|
+
function drawOutside(stroke, ui, canvas, renderOptions) {
|
|
9023
|
+
const data = ui.__;
|
|
9024
|
+
if (data.__fillAfterStroke) {
|
|
9025
|
+
drawCenter$1(stroke, 2, ui, canvas, renderOptions);
|
|
9026
|
+
} else {
|
|
9027
|
+
const {renderBounds: renderBounds} = ui.__layout;
|
|
9028
|
+
const out = canvas.getSameCanvas(true, true);
|
|
9029
|
+
ui.__drawRenderPath(out);
|
|
9030
|
+
drawCenter$1(stroke, 2, ui, out, renderOptions);
|
|
9031
|
+
out.clipUI(data);
|
|
9032
|
+
out.clearWorld(renderBounds);
|
|
9033
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
9034
|
+
out.recycle(ui.__nowWorld);
|
|
9035
|
+
}
|
|
8964
9036
|
}
|
|
8965
|
-
function strokeText(stroke, ui, canvas) {
|
|
9037
|
+
function strokeText(stroke, ui, canvas, renderOptions) {
|
|
8966
9038
|
switch (ui.__.strokeAlign) {
|
|
8967
9039
|
case "center":
|
|
8968
|
-
drawCenter
|
|
9040
|
+
drawCenter(stroke, 1, ui, canvas, renderOptions);
|
|
8969
9041
|
break;
|
|
8970
9042
|
|
|
8971
9043
|
case "inside":
|
|
8972
|
-
drawAlign(stroke, "inside", ui, canvas);
|
|
9044
|
+
drawAlign(stroke, "inside", ui, canvas, renderOptions);
|
|
8973
9045
|
break;
|
|
8974
9046
|
|
|
8975
9047
|
case "outside":
|
|
8976
|
-
ui.__.__fillAfterStroke ? drawCenter
|
|
9048
|
+
ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
|
|
8977
9049
|
break;
|
|
8978
9050
|
}
|
|
8979
9051
|
}
|
|
8980
|
-
function drawCenter
|
|
9052
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
|
|
8981
9053
|
const data = ui.__;
|
|
8982
9054
|
if (isObject(stroke)) {
|
|
8983
|
-
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
9055
|
+
Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
|
|
8984
9056
|
} else {
|
|
8985
9057
|
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
8986
|
-
drawTextStroke(ui, canvas);
|
|
9058
|
+
Paint.drawTextStroke(ui, canvas, renderOptions);
|
|
8987
9059
|
}
|
|
8988
9060
|
}
|
|
8989
|
-
function drawAlign(stroke, align, ui, canvas) {
|
|
9061
|
+
function drawAlign(stroke, align, ui, canvas, renderOptions) {
|
|
8990
9062
|
const out = canvas.getSameCanvas(true, true);
|
|
8991
9063
|
out.font = ui.__.__font;
|
|
8992
|
-
drawCenter
|
|
9064
|
+
drawCenter(stroke, 2, ui, out, renderOptions);
|
|
8993
9065
|
out.blendMode = align === "outside" ? "destination-out" : "destination-in";
|
|
8994
|
-
fillText(ui, out);
|
|
9066
|
+
Paint.fillText(ui, out, renderOptions);
|
|
8995
9067
|
out.blendMode = "normal";
|
|
8996
9068
|
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
8997
9069
|
out.recycle(ui.__nowWorld);
|
|
8998
9070
|
}
|
|
8999
|
-
function drawTextStroke(ui, canvas) {
|
|
9071
|
+
function drawTextStroke(ui, canvas, _renderOptions) {
|
|
9000
9072
|
let row, data = ui.__.__textDrawData;
|
|
9001
9073
|
const {rows: rows, decorationY: decorationY} = data;
|
|
9002
9074
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
@@ -9010,83 +9082,28 @@ var LeaferUI = function(exports) {
|
|
|
9010
9082
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
9011
9083
|
}
|
|
9012
9084
|
}
|
|
9013
|
-
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
9085
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
|
|
9014
9086
|
let item;
|
|
9015
9087
|
const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
|
|
9016
9088
|
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
9017
9089
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
9018
9090
|
item = strokes[i];
|
|
9019
|
-
if (item.image && PaintImage.checkImage(ui, canvas,
|
|
9091
|
+
if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
|
|
9020
9092
|
if (item.style) {
|
|
9021
9093
|
if (__hasMultiStrokeStyle) {
|
|
9022
9094
|
const {strokeStyle: strokeStyle} = item;
|
|
9023
9095
|
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
9024
9096
|
} else canvas.strokeStyle = item.style;
|
|
9025
|
-
if (item.blendMode) {
|
|
9026
|
-
canvas.saveBlendMode(item.blendMode);
|
|
9027
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9097
|
+
if (item.originPaint.blendMode) {
|
|
9098
|
+
canvas.saveBlendMode(item.originPaint.blendMode);
|
|
9099
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9028
9100
|
canvas.restoreBlendMode();
|
|
9029
9101
|
} else {
|
|
9030
|
-
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
9102
|
+
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
9031
9103
|
}
|
|
9032
9104
|
}
|
|
9033
9105
|
}
|
|
9034
9106
|
}
|
|
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
9107
|
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
9091
9108
|
const tempBounds$1 = {};
|
|
9092
9109
|
function shape(ui, current, options) {
|
|
@@ -9169,61 +9186,62 @@ var LeaferUI = function(exports) {
|
|
|
9169
9186
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
9170
9187
|
isTransparent = true;
|
|
9171
9188
|
}
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9189
|
+
if (attrName === "fill") {
|
|
9190
|
+
stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
|
|
9191
|
+
stintSet(data, "__isTransparentFill", isTransparent);
|
|
9192
|
+
} else {
|
|
9193
|
+
stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
|
|
9194
|
+
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
9195
|
+
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
9196
|
+
}
|
|
9176
9197
|
} else {
|
|
9177
|
-
|
|
9178
|
-
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
9179
|
-
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
9198
|
+
data.__removePaint(attrName, false);
|
|
9180
9199
|
}
|
|
9181
9200
|
}
|
|
9182
9201
|
function getLeafPaint(attrName, paint, ui) {
|
|
9183
9202
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
9184
|
-
let
|
|
9203
|
+
let leafPaint;
|
|
9185
9204
|
const {boxBounds: boxBounds} = ui.__layout;
|
|
9186
9205
|
switch (paint.type) {
|
|
9187
9206
|
case "image":
|
|
9188
|
-
|
|
9207
|
+
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
9189
9208
|
break;
|
|
9190
9209
|
|
|
9191
9210
|
case "linear":
|
|
9192
|
-
|
|
9211
|
+
leafPaint = PaintGradient.linearGradient(paint, boxBounds);
|
|
9193
9212
|
break;
|
|
9194
9213
|
|
|
9195
9214
|
case "radial":
|
|
9196
|
-
|
|
9215
|
+
leafPaint = PaintGradient.radialGradient(paint, boxBounds);
|
|
9197
9216
|
break;
|
|
9198
9217
|
|
|
9199
9218
|
case "angular":
|
|
9200
|
-
|
|
9219
|
+
leafPaint = PaintGradient.conicGradient(paint, boxBounds);
|
|
9201
9220
|
break;
|
|
9202
9221
|
|
|
9203
9222
|
case "solid":
|
|
9204
9223
|
const {type: type, color: color, opacity: opacity} = paint;
|
|
9205
|
-
|
|
9224
|
+
leafPaint = {
|
|
9206
9225
|
type: type,
|
|
9207
9226
|
style: ColorConvert.string(color, opacity)
|
|
9208
9227
|
};
|
|
9209
9228
|
break;
|
|
9210
9229
|
|
|
9211
9230
|
default:
|
|
9212
|
-
if (!isUndefined(paint.r))
|
|
9231
|
+
if (!isUndefined(paint.r)) leafPaint = {
|
|
9213
9232
|
type: "solid",
|
|
9214
9233
|
style: ColorConvert.string(paint)
|
|
9215
9234
|
};
|
|
9216
9235
|
}
|
|
9217
|
-
if (
|
|
9218
|
-
|
|
9236
|
+
if (leafPaint) {
|
|
9237
|
+
leafPaint.originPaint = paint;
|
|
9238
|
+
if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
|
|
9219
9239
|
if (paint.style) {
|
|
9220
9240
|
if (paint.style.strokeWidth === 0) return undefined;
|
|
9221
|
-
|
|
9241
|
+
leafPaint.strokeStyle = paint.style;
|
|
9222
9242
|
}
|
|
9223
|
-
if (paint.editing) data.editing = paint.editing;
|
|
9224
|
-
if (paint.blendMode) data.blendMode = paint.blendMode;
|
|
9225
9243
|
}
|
|
9226
|
-
return
|
|
9244
|
+
return leafPaint;
|
|
9227
9245
|
}
|
|
9228
9246
|
const PaintModule = {
|
|
9229
9247
|
compute: compute,
|
|
@@ -9235,94 +9253,118 @@ var LeaferUI = function(exports) {
|
|
|
9235
9253
|
strokes: strokes,
|
|
9236
9254
|
strokeText: strokeText,
|
|
9237
9255
|
drawTextStroke: drawTextStroke,
|
|
9256
|
+
drawStrokesStyle: drawStrokesStyle,
|
|
9238
9257
|
shape: shape
|
|
9239
9258
|
};
|
|
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);
|
|
9259
|
+
let cache, box = new Bounds;
|
|
9260
|
+
const {isSame: isSame} = BoundsHelper;
|
|
9261
|
+
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
9262
|
+
let leafPaint, event;
|
|
9263
|
+
const image = ImageManager.get(paint);
|
|
9264
|
+
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
9265
|
+
leafPaint = cache.leafPaint;
|
|
9266
|
+
} else {
|
|
9267
|
+
leafPaint = {
|
|
9268
|
+
type: paint.type,
|
|
9269
|
+
image: image
|
|
9270
|
+
};
|
|
9271
|
+
if (image.hasAlphaPixel) leafPaint.isTransparent = true;
|
|
9272
|
+
cache = image.use > 1 ? {
|
|
9273
|
+
leafPaint: leafPaint,
|
|
9274
|
+
paint: paint,
|
|
9275
|
+
boxBounds: box.set(boxBounds)
|
|
9276
|
+
} : null;
|
|
9267
9277
|
}
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9278
|
+
if (firstUse || image.loading) event = {
|
|
9279
|
+
image: image,
|
|
9280
|
+
attrName: attrName,
|
|
9281
|
+
attrValue: paint
|
|
9282
|
+
};
|
|
9283
|
+
if (image.ready) {
|
|
9284
|
+
checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
|
|
9285
|
+
if (firstUse) {
|
|
9286
|
+
onLoad(ui, event);
|
|
9287
|
+
onLoadSuccess(ui, event);
|
|
9288
|
+
}
|
|
9289
|
+
} else if (image.error) {
|
|
9290
|
+
if (firstUse) onLoadError(ui, event, image.error);
|
|
9274
9291
|
} 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;
|
|
9292
|
+
if (firstUse) {
|
|
9293
|
+
ignoreRender(ui, true);
|
|
9294
|
+
onLoad(ui, event);
|
|
9295
|
+
}
|
|
9296
|
+
leafPaint.loadId = image.load(() => {
|
|
9297
|
+
ignoreRender(ui, false);
|
|
9298
|
+
if (!ui.destroyed) {
|
|
9299
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
9300
|
+
if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
|
|
9301
|
+
ui.forceUpdate("surface");
|
|
9295
9302
|
}
|
|
9303
|
+
onLoadSuccess(ui, event);
|
|
9296
9304
|
}
|
|
9305
|
+
leafPaint.loadId = undefined;
|
|
9306
|
+
}, error => {
|
|
9307
|
+
ignoreRender(ui, false);
|
|
9308
|
+
onLoadError(ui, event, error);
|
|
9309
|
+
leafPaint.loadId = undefined;
|
|
9310
|
+
});
|
|
9311
|
+
if (ui.placeholderColor) {
|
|
9312
|
+
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
9313
|
+
if (!image.ready) {
|
|
9314
|
+
image.isPlacehold = true;
|
|
9315
|
+
ui.forceUpdate("surface");
|
|
9316
|
+
}
|
|
9317
|
+
}, ui.placeholderDelay);
|
|
9297
9318
|
}
|
|
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
9319
|
}
|
|
9303
|
-
|
|
9320
|
+
return leafPaint;
|
|
9304
9321
|
}
|
|
9305
|
-
function
|
|
9306
|
-
if (
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9322
|
+
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
9323
|
+
if (attrName === "fill" && !ui.__.__naturalWidth) {
|
|
9324
|
+
const data = ui.__;
|
|
9325
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
9326
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
9327
|
+
if (data.__autoSide) {
|
|
9328
|
+
ui.forceUpdate("width");
|
|
9329
|
+
if (ui.__proxyData) {
|
|
9330
|
+
ui.setProxyAttr("width", data.width);
|
|
9331
|
+
ui.setProxyAttr("height", data.height);
|
|
9332
|
+
}
|
|
9333
|
+
return false;
|
|
9334
|
+
}
|
|
9335
|
+
}
|
|
9336
|
+
if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
9337
|
+
return true;
|
|
9338
|
+
}
|
|
9339
|
+
function onLoad(ui, event) {
|
|
9340
|
+
emit(ui, ImageEvent.LOAD, event);
|
|
9341
|
+
}
|
|
9342
|
+
function onLoadSuccess(ui, event) {
|
|
9343
|
+
emit(ui, ImageEvent.LOADED, event);
|
|
9310
9344
|
}
|
|
9311
|
-
|
|
9345
|
+
function onLoadError(ui, event, error) {
|
|
9346
|
+
event.error = error;
|
|
9347
|
+
ui.forceUpdate("surface");
|
|
9348
|
+
emit(ui, ImageEvent.ERROR, event);
|
|
9349
|
+
}
|
|
9350
|
+
function emit(ui, type, data) {
|
|
9351
|
+
if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
|
|
9352
|
+
}
|
|
9353
|
+
function ignoreRender(ui, value) {
|
|
9354
|
+
const {leafer: leafer} = ui;
|
|
9355
|
+
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
9356
|
+
}
|
|
9357
|
+
const {get: get$3, translate: translate$1} = MatrixHelper;
|
|
9312
9358
|
const tempBox = new Bounds;
|
|
9313
9359
|
const tempScaleData = {};
|
|
9314
9360
|
const tempImage = {};
|
|
9315
9361
|
function createData(leafPaint, image, paint, box) {
|
|
9316
|
-
|
|
9317
|
-
if (changeful) leafPaint.changeful = changeful;
|
|
9318
|
-
if (sync) leafPaint.sync = sync;
|
|
9319
|
-
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
9320
|
-
leafPaint.data = getPatternData(paint, box, image);
|
|
9362
|
+
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
9321
9363
|
}
|
|
9322
9364
|
function getPatternData(paint, box, image) {
|
|
9323
9365
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
9324
9366
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
9325
|
-
|
|
9367
|
+
const {width: width, height: height} = image;
|
|
9326
9368
|
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
9369
|
const sameBox = box.width === width && box.height === height;
|
|
9328
9370
|
const data = {
|
|
@@ -9353,8 +9395,8 @@ var LeaferUI = function(exports) {
|
|
|
9353
9395
|
case "stretch":
|
|
9354
9396
|
if (!sameBox) {
|
|
9355
9397
|
scaleX = box.width / width, scaleY = box.height / height;
|
|
9356
|
-
stretchMode(data, box, scaleX, scaleY);
|
|
9357
|
-
}
|
|
9398
|
+
PaintImage.stretchMode(data, box, scaleX, scaleY);
|
|
9399
|
+
} else if (scaleX) scaleX = scaleY = undefined;
|
|
9358
9400
|
break;
|
|
9359
9401
|
|
|
9360
9402
|
case "normal":
|
|
@@ -9362,13 +9404,13 @@ var LeaferUI = function(exports) {
|
|
|
9362
9404
|
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
9363
9405
|
let clipScaleX, clipScaleY;
|
|
9364
9406
|
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);
|
|
9407
|
+
PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
9366
9408
|
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
9367
9409
|
}
|
|
9368
9410
|
break;
|
|
9369
9411
|
|
|
9370
9412
|
case "repeat":
|
|
9371
|
-
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
9413
|
+
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
9372
9414
|
if (!repeat) data.repeat = "repeat";
|
|
9373
9415
|
const count = isObject(repeat);
|
|
9374
9416
|
if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
|
|
@@ -9377,18 +9419,16 @@ var LeaferUI = function(exports) {
|
|
|
9377
9419
|
case "fit":
|
|
9378
9420
|
case "cover":
|
|
9379
9421
|
default:
|
|
9380
|
-
if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9422
|
+
if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9381
9423
|
}
|
|
9382
9424
|
if (!data.transform) {
|
|
9383
|
-
if (box.x || box.y) translate(data.transform = get$
|
|
9425
|
+
if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
|
|
9384
9426
|
}
|
|
9385
|
-
data.width = width;
|
|
9386
|
-
data.height = height;
|
|
9387
9427
|
if (scaleX) {
|
|
9388
9428
|
data.scaleX = scaleX;
|
|
9389
9429
|
data.scaleY = scaleY;
|
|
9390
9430
|
}
|
|
9391
|
-
if (opacity) data.opacity = opacity;
|
|
9431
|
+
if (opacity && opacity < 1) data.opacity = opacity;
|
|
9392
9432
|
if (filters) data.filters = filters;
|
|
9393
9433
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
9394
9434
|
return data;
|
|
@@ -9407,221 +9447,180 @@ var LeaferUI = function(exports) {
|
|
|
9407
9447
|
const value = auto ? remain / ((rows || Math.floor(totalSize / size)) - 1) : gap;
|
|
9408
9448
|
return gap === "auto" ? value < 0 ? 0 : value : value;
|
|
9409
9449
|
}
|
|
9410
|
-
let
|
|
9411
|
-
const {
|
|
9412
|
-
function
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9450
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
9451
|
+
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
9452
|
+
function stretchMode(data, box, scaleX, scaleY) {
|
|
9453
|
+
const transform = get$2(), {x: x, y: y} = box;
|
|
9454
|
+
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
9455
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
9456
|
+
data.transform = transform;
|
|
9457
|
+
}
|
|
9458
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
9459
|
+
const transform = get$2();
|
|
9460
|
+
translate(transform, box.x + x, box.y + y);
|
|
9461
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
9462
|
+
if (rotation) rotateOfOuter$1(transform, {
|
|
9463
|
+
x: box.x + box.width / 2,
|
|
9464
|
+
y: box.y + box.height / 2
|
|
9465
|
+
}, rotation);
|
|
9466
|
+
data.transform = transform;
|
|
9467
|
+
}
|
|
9468
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
9469
|
+
const transform = get$2();
|
|
9470
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9471
|
+
if (clipScaleX) {
|
|
9472
|
+
if (rotation || skew) {
|
|
9473
|
+
set(tempMatrix$1);
|
|
9474
|
+
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
9475
|
+
multiplyParent(transform, tempMatrix$1);
|
|
9476
|
+
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
9428
9477
|
}
|
|
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);
|
|
9478
|
+
data.transform = transform;
|
|
9479
|
+
}
|
|
9480
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
|
|
9481
|
+
const transform = get$2();
|
|
9482
|
+
if (freeTransform) {
|
|
9483
|
+
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
9442
9484
|
} 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");
|
|
9485
|
+
if (rotation) {
|
|
9486
|
+
if (align === "center") {
|
|
9487
|
+
rotateOfOuter$1(transform, {
|
|
9488
|
+
x: width / 2,
|
|
9489
|
+
y: height / 2
|
|
9490
|
+
}, rotation);
|
|
9491
|
+
} else {
|
|
9492
|
+
rotate(transform, rotation);
|
|
9493
|
+
switch (rotation) {
|
|
9494
|
+
case 90:
|
|
9495
|
+
translate(transform, height, 0);
|
|
9496
|
+
break;
|
|
9497
|
+
|
|
9498
|
+
case 180:
|
|
9499
|
+
translate(transform, width, height);
|
|
9500
|
+
break;
|
|
9501
|
+
|
|
9502
|
+
case 270:
|
|
9503
|
+
translate(transform, 0, width);
|
|
9504
|
+
break;
|
|
9467
9505
|
}
|
|
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
9506
|
}
|
|
9484
|
-
return false;
|
|
9485
9507
|
}
|
|
9508
|
+
origin.x = box.x + x;
|
|
9509
|
+
origin.y = box.y + y;
|
|
9510
|
+
translate(transform, origin.x, origin.y);
|
|
9511
|
+
if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
9486
9512
|
}
|
|
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));
|
|
9513
|
+
data.transform = transform;
|
|
9503
9514
|
}
|
|
9504
|
-
function
|
|
9505
|
-
|
|
9506
|
-
if (
|
|
9515
|
+
function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
9516
|
+
if (rotation) rotate(transform, rotation);
|
|
9517
|
+
if (skew) skewHelper(transform, skew.x, skew.y);
|
|
9518
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY);
|
|
9519
|
+
translate(transform, box.x + x, box.y + y);
|
|
9507
9520
|
}
|
|
9508
9521
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
9509
|
-
const {
|
|
9510
|
-
function
|
|
9511
|
-
|
|
9512
|
-
|
|
9522
|
+
const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
9523
|
+
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
9524
|
+
if (!paint.patternTask) {
|
|
9525
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
9526
|
+
paint.patternTask = null;
|
|
9527
|
+
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
9528
|
+
ui.forceUpdate("surface");
|
|
9529
|
+
}), 300);
|
|
9530
|
+
}
|
|
9531
|
+
}
|
|
9532
|
+
function createPattern(paint, ui, canvas, renderOptions) {
|
|
9533
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
9513
9534
|
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) {
|
|
9535
|
+
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
9536
|
+
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
9537
|
+
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
9538
|
+
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
9539
|
+
width *= scaleX;
|
|
9540
|
+
height *= scaleY;
|
|
9541
|
+
if (gap) {
|
|
9542
|
+
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
9543
|
+
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
9544
|
+
}
|
|
9545
|
+
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
9546
|
+
scaleX *= getFloorScale(width + (xGap || 0));
|
|
9547
|
+
scaleY *= getFloorScale(height + (yGap || 0));
|
|
9560
9548
|
imageMatrix = get$1();
|
|
9561
9549
|
if (transform) copy$1(imageMatrix, transform);
|
|
9550
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
9562
9551
|
}
|
|
9563
|
-
|
|
9552
|
+
const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
9553
|
+
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
9554
|
+
paint.style = pattern;
|
|
9555
|
+
paint.patternId = id;
|
|
9564
9556
|
}
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9557
|
+
}
|
|
9558
|
+
}
|
|
9559
|
+
function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
9560
|
+
const {image: image} = paint;
|
|
9561
|
+
let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
|
|
9562
|
+
if (image.isSVG) {
|
|
9563
|
+
if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
|
|
9570
9564
|
} else {
|
|
9571
|
-
|
|
9565
|
+
if (maxSize > imageSize) maxSize = imageSize;
|
|
9572
9566
|
}
|
|
9567
|
+
if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
|
|
9568
|
+
return fixScale;
|
|
9573
9569
|
}
|
|
9574
|
-
function checkImage(ui, canvas,
|
|
9575
|
-
const {scaleX: scaleX, scaleY: scaleY} =
|
|
9576
|
-
const {
|
|
9577
|
-
if (!data || paint.patternId === scaleX + "-" + scaleY
|
|
9570
|
+
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
9571
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
9572
|
+
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
|
|
9573
|
+
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
9578
9574
|
return false;
|
|
9579
9575
|
} else {
|
|
9580
|
-
if (
|
|
9576
|
+
if (drawImage) {
|
|
9581
9577
|
if (data.repeat) {
|
|
9582
|
-
|
|
9583
|
-
} else if (!(
|
|
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;
|
|
9578
|
+
drawImage = false;
|
|
9579
|
+
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
9580
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
9592
9581
|
}
|
|
9593
9582
|
}
|
|
9594
|
-
if (
|
|
9583
|
+
if (drawImage) {
|
|
9595
9584
|
if (ui.__.__isFastShadow) {
|
|
9596
9585
|
canvas.fillStyle = paint.style || "#000";
|
|
9597
9586
|
canvas.fill();
|
|
9598
9587
|
}
|
|
9599
|
-
drawImage(ui, canvas,
|
|
9588
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
9600
9589
|
return true;
|
|
9601
9590
|
} else {
|
|
9602
|
-
if (!paint.style ||
|
|
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
|
-
}
|
|
9591
|
+
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
9613
9592
|
return false;
|
|
9614
9593
|
}
|
|
9615
9594
|
}
|
|
9616
9595
|
}
|
|
9617
|
-
function drawImage(ui, canvas,
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
if (
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9596
|
+
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
9597
|
+
const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
9598
|
+
let {width: width, height: height} = image, clipUI;
|
|
9599
|
+
if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
|
|
9600
|
+
canvas.save();
|
|
9601
|
+
clipUI && canvas.clipUI(ui);
|
|
9602
|
+
blendMode && (canvas.blendMode = blendMode);
|
|
9603
|
+
opacity && (canvas.opacity *= opacity);
|
|
9604
|
+
transform && canvas.transform(transform);
|
|
9605
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
9606
|
+
canvas.restore();
|
|
9607
|
+
} else {
|
|
9608
|
+
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
9609
|
+
canvas.drawImage(view, 0, 0, width, height);
|
|
9610
|
+
}
|
|
9611
|
+
}
|
|
9612
|
+
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
9613
|
+
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
9614
|
+
if (canvas) {
|
|
9615
|
+
const {pixelRatio: pixelRatio} = canvas;
|
|
9616
|
+
scaleData.scaleX *= pixelRatio;
|
|
9617
|
+
scaleData.scaleY *= pixelRatio;
|
|
9618
|
+
}
|
|
9619
|
+
if (data && data.scaleX) {
|
|
9620
|
+
scaleData.scaleX *= Math.abs(data.scaleX);
|
|
9621
|
+
scaleData.scaleY *= Math.abs(data.scaleY);
|
|
9622
|
+
}
|
|
9623
|
+
return scaleData;
|
|
9625
9624
|
}
|
|
9626
9625
|
function recycleImage(attrName, data) {
|
|
9627
9626
|
const paints = data["_" + attrName];
|
|
@@ -9651,8 +9650,12 @@ var LeaferUI = function(exports) {
|
|
|
9651
9650
|
const PaintImageModule = {
|
|
9652
9651
|
image: image,
|
|
9653
9652
|
checkImage: checkImage,
|
|
9654
|
-
|
|
9653
|
+
drawImage: drawImage,
|
|
9654
|
+
getImageRenderScaleData: getImageRenderScaleData,
|
|
9655
9655
|
recycleImage: recycleImage,
|
|
9656
|
+
createPatternTask: createPatternTask,
|
|
9657
|
+
createPattern: createPattern,
|
|
9658
|
+
getPatternFixScale: getPatternFixScale,
|
|
9656
9659
|
createData: createData,
|
|
9657
9660
|
getPatternData: getPatternData,
|
|
9658
9661
|
stretchMode: stretchMode,
|
|
@@ -10039,10 +10042,8 @@ var LeaferUI = function(exports) {
|
|
|
10039
10042
|
bounds = drawData.bounds;
|
|
10040
10043
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
10041
10044
|
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) {
|
|
10045
|
+
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
10046
|
+
if (style.__isCharMode) {
|
|
10046
10047
|
const wrap = style.textWrap !== "none";
|
|
10047
10048
|
const breakAll = style.textWrap === "break";
|
|
10048
10049
|
paraStart = true;
|
|
@@ -10163,12 +10164,19 @@ var LeaferUI = function(exports) {
|
|
|
10163
10164
|
function layoutChar(drawData, style, width, _height) {
|
|
10164
10165
|
const {rows: rows} = drawData;
|
|
10165
10166
|
const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
|
|
10166
|
-
|
|
10167
|
+
const justifyLast = width && textAlign.includes("both");
|
|
10168
|
+
const justify = justifyLast || width && textAlign.includes("justify");
|
|
10169
|
+
const justifyLetter = justify && textAlign.includes("letter");
|
|
10170
|
+
let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
|
|
10167
10171
|
rows.forEach(row => {
|
|
10168
10172
|
if (row.words) {
|
|
10169
10173
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
10170
|
-
|
|
10171
|
-
|
|
10174
|
+
if (justify) {
|
|
10175
|
+
canJustify = !row.paraEnd || justifyLast;
|
|
10176
|
+
remainingWidth = width - row.width - indentWidth;
|
|
10177
|
+
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
10178
|
+
}
|
|
10179
|
+
mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
10172
10180
|
if (row.isOverflow && !letterSpacing) row.textMode = true;
|
|
10173
10181
|
if (mode === TextMode) {
|
|
10174
10182
|
row.x += indentWidth;
|
|
@@ -10186,11 +10194,15 @@ var LeaferUI = function(exports) {
|
|
|
10186
10194
|
charX = toWordChar(word.data, charX, wordChar);
|
|
10187
10195
|
if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
|
|
10188
10196
|
} else {
|
|
10189
|
-
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
10197
|
+
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
10190
10198
|
}
|
|
10191
|
-
if (
|
|
10192
|
-
|
|
10193
|
-
|
|
10199
|
+
if (canJustify) {
|
|
10200
|
+
isLastWord = index === wordsLength - 1;
|
|
10201
|
+
if (addWordWidth) {
|
|
10202
|
+
if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
|
|
10203
|
+
} else if (addLetterWidth) {
|
|
10204
|
+
row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
|
|
10205
|
+
}
|
|
10194
10206
|
}
|
|
10195
10207
|
});
|
|
10196
10208
|
}
|
|
@@ -10213,13 +10225,14 @@ var LeaferUI = function(exports) {
|
|
|
10213
10225
|
});
|
|
10214
10226
|
return charX;
|
|
10215
10227
|
}
|
|
10216
|
-
function toChar(data, charX, rowData, isOverflow) {
|
|
10228
|
+
function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
|
|
10217
10229
|
data.forEach(char => {
|
|
10218
10230
|
if (isOverflow || char.char !== " ") {
|
|
10219
10231
|
char.x = charX;
|
|
10220
10232
|
rowData.push(char);
|
|
10221
10233
|
}
|
|
10222
10234
|
charX += char.width;
|
|
10235
|
+
addLetterWidth && (charX += addLetterWidth);
|
|
10223
10236
|
});
|
|
10224
10237
|
return charX;
|
|
10225
10238
|
}
|
|
@@ -10355,10 +10368,10 @@ var LeaferUI = function(exports) {
|
|
|
10355
10368
|
let x = 0, y = 0;
|
|
10356
10369
|
let width = style.__getInput("width") || 0;
|
|
10357
10370
|
let height = style.__getInput("height") || 0;
|
|
10358
|
-
const {
|
|
10371
|
+
const {__padding: padding} = style;
|
|
10359
10372
|
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];
|
|
10373
|
+
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
10374
|
+
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
10362
10375
|
}
|
|
10363
10376
|
const drawData = {
|
|
10364
10377
|
bounds: {
|
|
@@ -10369,14 +10382,14 @@ var LeaferUI = function(exports) {
|
|
|
10369
10382
|
},
|
|
10370
10383
|
rows: [],
|
|
10371
10384
|
paraNumber: 0,
|
|
10372
|
-
font: Platform.canvas.font = __font
|
|
10385
|
+
font: Platform.canvas.font = style.__font
|
|
10373
10386
|
};
|
|
10374
10387
|
createRows(drawData, content, style);
|
|
10375
10388
|
if (padding) padAutoText(padding, drawData, style, width, height);
|
|
10376
10389
|
layoutText(drawData, style);
|
|
10377
|
-
layoutChar(drawData, style, width);
|
|
10390
|
+
if (style.__isCharMode) layoutChar(drawData, style, width);
|
|
10378
10391
|
if (drawData.overflow) clipText(drawData, style, x, width);
|
|
10379
|
-
if (textDecoration !== "none") decorationText(drawData, style);
|
|
10392
|
+
if (style.textDecoration !== "none") decorationText(drawData, style);
|
|
10380
10393
|
return drawData;
|
|
10381
10394
|
}
|
|
10382
10395
|
function padAutoText(padding, drawData, style, width, height) {
|