leafer-ui 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.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$2;
31
- if (types[typeName]) {
32
- return types[typeName]++;
33
- } else {
34
- types[typeName] = 1;
35
- return 0;
36
- }
37
- }
38
- };
39
- const I$2 = 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$5} = 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$5(floor$2(width + (xGap || 0)), 1), max$5(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$2;
252
+ if (types[typeName]) {
253
+ return types[typeName]++;
254
+ } else {
255
+ types[typeName] = 1;
256
+ return 0;
257
+ }
258
+ }
259
+ };
260
+ const I$2 = IncrementId;
232
261
  let tempA, tempB, tempTo;
233
- const {max: max$5} = Math, tempFour = [ 0, 0, 0, 0 ];
262
+ const {max: max$4} = 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$5(t, other);
313
+ if (isNumber(t) && isNumber(other)) return max$4(t, other);
285
314
  toTempAB(t, other, change);
286
- return set$2(tempTo, max$5(tempA[0], tempB[0]), max$5(tempA[1], tempB[1]), max$5(tempA[2], tempB[2]), max$5(tempA[3], tempB[3]));
315
+ return set$2(tempTo, max$4(tempA[0], tempB[0]), max$4(tempA[1], tempB[1]), max$4(tempA[2], tempB[2]), max$4(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$3, 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$3(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$1, fourNumber: fourNumber} = MathHelper;
1144
- const {floor: floor$2, ceil: ceil$2} = Math;
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 = matrix.e + t.x * a;
1266
+ to.x = e + t.x * a;
1235
1267
  } else {
1236
1268
  to.width = t.width * -a;
1237
- to.x = matrix.e + t.x * a - to.width;
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 = matrix.f + t.y * d;
1273
+ to.y = f + t.y * d;
1242
1274
  } else {
1243
1275
  to.height = t.height * -d;
1244
- to.y = matrix.f + t.y * d - to.height;
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$2(t.x);
1297
- t.y = floor$2(t.y);
1298
- t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
1299
- t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
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$1, abs: abs$4, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
2452
+ const {sin: sin$3, cos: cos$3, hypot: hypot, atan2: atan2$1, ceil: ceil, abs: abs$4, 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$1(abs$4(totalRadian / PI_2));
2555
+ const parts = ceil(abs$4(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.task && !this.isComplete && this.parent.running) yield this.task();
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$a.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$1 = ImageManager;
3793
3823
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
3794
- const {floor: floor$1, max: max$4} = 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
- let {loadImage: loadImage, loadImageWithProgress: loadImageWithProgress} = Platform.origin, onProgress = this.config.showProgress && loadImageWithProgress && this.onProgress.bind(this);
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, onProgress).then(img => this.setView(img)).catch(e => {
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, _filters, xGap, yGap, smooth) {
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.origin.createCanvas(max$4(floor$1(width + (xGap || 0)), 1), max$4(floor$1(height + (yGap || 0)), 1));
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
- try {
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 layout = this.__layout;
5428
- toOuterOf$2(layout.renderBounds, this.__world, this.__world);
5429
- if (layout.resized) {
5430
- if (layout.resized === "inner") this.__onUpdateSize();
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
- layout.resized = undefined;
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$3} = DataHelper;
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$3, 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$3(cameraWorld, "half", world.half);
5903
- stintSet$3(cameraWorld, "ignorePixelSnap", world.ignorePixelSnap);
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.9.12";
6431
+ const version = "1.10.1";
6417
6432
  const debug$5 = Debug.get("LeaferCanvas");
6418
6433
  class LeaferCanvas extends LeaferCanvasBase {
6419
6434
  set zIndex(zIndex) {
@@ -7364,6 +7379,7 @@ var LeaferUI = function(exports) {
7364
7379
  hit = child.__.hitRadius ? true : hitRadiusPoint$1(child.__world, point);
7365
7380
  if (child.isBranch) {
7366
7381
  if (hit || child.__ignoreHitWorld) {
7382
+ if (child.isBranchLeaf && child.__.__clipAfterFill && !child.__hitWorld(point)) continue;
7367
7383
  if (child.topChildren) this.eachFind(child.topChildren, false);
7368
7384
  this.eachFind(child.children, child.__onlyHitMask);
7369
7385
  if (child.isBranchLeaf) this.hitChild(child, point);
@@ -7533,7 +7549,7 @@ var LeaferUI = function(exports) {
7533
7549
  }
7534
7550
  };
7535
7551
  const {parse: parse, objectToCanvasData: objectToCanvasData} = PathConvert;
7536
- const {stintSet: stintSet$2} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
7552
+ const {stintSet: stintSet$3} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
7537
7553
  const emptyPaint = {};
7538
7554
  const debug$2 = Debug.get("UIData");
7539
7555
  class UIData extends LeafData {
@@ -7597,7 +7613,7 @@ var LeaferUI = function(exports) {
7597
7613
  setFill(value) {
7598
7614
  if (this.__naturalWidth) this.__removeNaturalSize();
7599
7615
  if (isString(value) || !value) {
7600
- stintSet$2(this, "__isTransparentFill", hasTransparent$2(value));
7616
+ stintSet$3(this, "__isTransparentFill", hasTransparent$2(value));
7601
7617
  this.__isFills && this.__removePaint("fill", true);
7602
7618
  this._fill = value;
7603
7619
  } else if (isObject(value)) {
@@ -7606,7 +7622,7 @@ var LeaferUI = function(exports) {
7606
7622
  }
7607
7623
  setStroke(value) {
7608
7624
  if (isString(value) || !value) {
7609
- stintSet$2(this, "__isTransparentStroke", hasTransparent$2(value));
7625
+ stintSet$3(this, "__isTransparentStroke", hasTransparent$2(value));
7610
7626
  this.__isStrokes && this.__removePaint("stroke", true);
7611
7627
  this._stroke = value;
7612
7628
  } else if (isObject(value)) {
@@ -7664,11 +7680,11 @@ var LeaferUI = function(exports) {
7664
7680
  if (removeInput) this.__removeInput(attrName);
7665
7681
  PaintImage.recycleImage(attrName, this);
7666
7682
  if (attrName === "fill") {
7667
- stintSet$2(this, "__isAlphaPixelFill", undefined);
7683
+ stintSet$3(this, "__isAlphaPixelFill", undefined);
7668
7684
  this._fill = this.__isFills = undefined;
7669
7685
  } else {
7670
- stintSet$2(this, "__isAlphaPixelStroke", undefined);
7671
- stintSet$2(this, "__hasMultiStrokeStyle", undefined);
7686
+ stintSet$3(this, "__isAlphaPixelStroke", undefined);
7687
+ stintSet$3(this, "__hasMultiStrokeStyle", undefined);
7672
7688
  this._stroke = this.__isStrokes = undefined;
7673
7689
  }
7674
7690
  }
@@ -7800,7 +7816,7 @@ var LeaferUI = function(exports) {
7800
7816
  return data;
7801
7817
  }
7802
7818
  }
7803
- const {max: max$3, add: add$1} = FourNumberHelper;
7819
+ const {max: max$2, add: add$1} = FourNumberHelper;
7804
7820
  const UIBounds = {
7805
7821
  __updateStrokeSpread() {
7806
7822
  let spread = 0, boxSpread = 0;
@@ -7815,7 +7831,7 @@ var LeaferUI = function(exports) {
7815
7831
  }
7816
7832
  if (data.__useArrow) spread += strokeWidth * 5;
7817
7833
  if (box) {
7818
- spread = max$3(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
7834
+ spread = max$2(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
7819
7835
  boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
7820
7836
  }
7821
7837
  this.__layout.strokeBoxSpread = boxSpread;
@@ -7825,33 +7841,33 @@ var LeaferUI = function(exports) {
7825
7841
  let spread = 0;
7826
7842
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
7827
7843
  if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
7828
- if (blur) spread = max$3(spread, blur);
7844
+ if (blur) spread = max$2(spread, blur);
7829
7845
  if (filter) spread = add$1(spread, Filter.getSpread(filter));
7830
7846
  if (renderSpread) spread = add$1(spread, renderSpread);
7831
7847
  if (strokeSpread) spread = add$1(spread, strokeSpread);
7832
7848
  let shapeSpread = spread;
7833
- if (innerShadow) shapeSpread = max$3(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
7834
- if (backgroundBlur) shapeSpread = max$3(shapeSpread, backgroundBlur);
7849
+ if (innerShadow) shapeSpread = max$2(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
7850
+ if (backgroundBlur) shapeSpread = max$2(shapeSpread, backgroundBlur);
7835
7851
  this.__layout.renderShapeSpread = shapeSpread;
7836
- return box ? max$3(box.__updateRenderSpread(), spread) : spread;
7852
+ return box ? max$2(box.__updateRenderSpread(), spread) : spread;
7837
7853
  }
7838
7854
  };
7839
- const {stintSet: stintSet$1} = DataHelper;
7855
+ const {stintSet: stintSet$2} = DataHelper;
7840
7856
  const UIRender = {
7841
7857
  __updateChange() {
7842
7858
  const data = this.__;
7843
7859
  if (data.__useStroke) {
7844
7860
  const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
7845
- stintSet$1(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
7846
- stintSet$1(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
7861
+ stintSet$2(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
7862
+ stintSet$2(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
7847
7863
  }
7848
7864
  if (data.__useEffect) {
7849
7865
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7850
- stintSet$1(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"));
7866
+ 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"));
7851
7867
  data.__useEffect = !!(shadow || otherEffect);
7852
7868
  }
7853
7869
  data.__checkSingle();
7854
- stintSet$1(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7870
+ stintSet$2(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7855
7871
  },
7856
7872
  __drawFast(canvas, options) {
7857
7873
  drawFast(this, canvas, options);
@@ -7867,24 +7883,24 @@ var LeaferUI = function(exports) {
7867
7883
  this.__nowWorld = this.__getNowWorld(options);
7868
7884
  const {shadow: shadow, innerShadow: innerShadow, filter: filter} = data;
7869
7885
  if (shadow) Effect.shadow(this, canvas, shape);
7870
- if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7871
- if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7886
+ if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
7887
+ if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
7872
7888
  if (__drawAfterFill) this.__drawAfterFill(canvas, options);
7873
7889
  if (innerShadow) Effect.innerShadow(this, canvas, shape);
7874
- if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7890
+ if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
7875
7891
  if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
7876
7892
  if (shape.worldCanvas) shape.worldCanvas.recycle();
7877
7893
  shape.canvas.recycle();
7878
7894
  } else {
7879
- if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7895
+ if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
7880
7896
  if (__isFastShadow) {
7881
7897
  const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
7882
7898
  canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
7883
7899
  }
7884
- if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7900
+ if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
7885
7901
  if (__isFastShadow) canvas.restore();
7886
7902
  if (__drawAfterFill) this.__drawAfterFill(canvas, options);
7887
- if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7903
+ if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
7888
7904
  }
7889
7905
  } else {
7890
7906
  if (data.__pathInputed) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
@@ -7893,9 +7909,9 @@ var LeaferUI = function(exports) {
7893
7909
  __drawShape(canvas, options) {
7894
7910
  this.__drawRenderPath(canvas);
7895
7911
  const data = this.__, {fill: fill, stroke: stroke} = data;
7896
- if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill("#000000", this, canvas);
7912
+ if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas, options) : Paint.fill("#000000", this, canvas, options);
7897
7913
  if (data.__isCanvas) this.__drawAfterFill(canvas, options);
7898
- if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke("#000000", this, canvas);
7914
+ if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke("#000000", this, canvas, options);
7899
7915
  },
7900
7916
  __drawAfterFill(canvas, options) {
7901
7917
  if (this.__.__clipAfterFill) {
@@ -7909,10 +7925,10 @@ var LeaferUI = function(exports) {
7909
7925
  function drawFast(ui, canvas, options) {
7910
7926
  const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke} = ui.__;
7911
7927
  ui.__drawRenderPath(canvas);
7912
- if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
7913
- if (fill) Paint.fill(fill, ui, canvas);
7928
+ if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
7929
+ if (fill) Paint.fill(fill, ui, canvas, options);
7914
7930
  if (__drawAfterFill) ui.__drawAfterFill(canvas, options);
7915
- if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
7931
+ if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
7916
7932
  }
7917
7933
  const RectRender = {
7918
7934
  __drawFast(canvas, options) {
@@ -8047,8 +8063,8 @@ var LeaferUI = function(exports) {
8047
8063
  drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
8048
8064
  } else drawer.rect(x, y, width, height);
8049
8065
  }
8050
- drawImagePlaceholder(canvas, _image) {
8051
- Paint.fill(this.__.placeholderColor, this, canvas);
8066
+ drawImagePlaceholder(_paint, canvas, renderOptions) {
8067
+ Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
8052
8068
  }
8053
8069
  animate(keyframe, _options, _type, _isTemp) {
8054
8070
  this.set(keyframe);
@@ -8911,7 +8927,7 @@ var LeaferUI = function(exports) {
8911
8927
  __decorate([ dataType(false) ], exports.Canvas.prototype, "safeResize", void 0);
8912
8928
  __decorate([ resizeType() ], exports.Canvas.prototype, "contextSettings", void 0);
8913
8929
  exports.Canvas = __decorate([ registerUI() ], exports.Canvas);
8914
- const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
8930
+ const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
8915
8931
  exports.Text = class Text extends exports.UI {
8916
8932
  get __tag() {
8917
8933
  return "Text";
@@ -8922,13 +8938,14 @@ var LeaferUI = function(exports) {
8922
8938
  }
8923
8939
  __updateTextDrawData() {
8924
8940
  const data = this.__;
8925
- const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
8941
+ const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
8926
8942
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
8927
8943
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
8928
- data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
8929
8944
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
8930
8945
  data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
8931
- data.__clipText = textOverflow !== "show" && !data.__autoSize;
8946
+ stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
8947
+ stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
8948
+ stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
8932
8949
  data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
8933
8950
  }
8934
8951
  __updateBoxBounds() {
@@ -9292,7 +9309,7 @@ var LeaferUI = function(exports) {
9292
9309
  EventCreator.changeName(oldName, newName);
9293
9310
  }
9294
9311
  }
9295
- const {min: min, max: max$2, abs: abs$2} = Math, {float: float, sign: sign} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
9312
+ const {min: min, max: max$1, abs: abs$2} = Math, {float: float, sign: sign} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
9296
9313
  const tempContent = new Bounds, tempDragBounds = new Bounds;
9297
9314
  const DragBoundsHelper = {
9298
9315
  limitMove(leaf, move) {
@@ -9347,7 +9364,7 @@ var LeaferUI = function(exports) {
9347
9364
  bSize = float(tempDragBounds.maxX - tempContent.maxX);
9348
9365
  aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
9349
9366
  bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
9350
- correctScaleX *= max$2(aScale, bScale);
9367
+ correctScaleX *= max$1(aScale, bScale);
9351
9368
  } else {
9352
9369
  if (scale.x < 0) {
9353
9370
  if (float(minX(content) - minX(dragBounds)) <= 0 || float(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
@@ -9365,9 +9382,9 @@ var LeaferUI = function(exports) {
9365
9382
  bSize = float(tempDragBounds.maxY - tempContent.maxY);
9366
9383
  aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
9367
9384
  bScale = originBottomScale && bSize > 0 ? 1 + bSize / (originBottomScale * tempContent.height) : 1;
9368
- correctScaleY *= max$2(aScale, bScale);
9385
+ correctScaleY *= max$1(aScale, bScale);
9369
9386
  if (lockRatio) {
9370
- aScale = max$2(abs$2(correctScaleX), abs$2(correctScaleY));
9387
+ aScale = max$1(abs$2(correctScaleX), abs$2(correctScaleY));
9371
9388
  correctScaleX = sign(correctScaleX) * aScale;
9372
9389
  correctScaleY = sign(correctScaleY) * aScale;
9373
9390
  }
@@ -9488,6 +9505,9 @@ var LeaferUI = function(exports) {
9488
9505
  exports.MoveEvent.MOVE = "move";
9489
9506
  exports.MoveEvent.END = "move.end";
9490
9507
  exports.MoveEvent = __decorate([ registerUIEvent() ], exports.MoveEvent);
9508
+ exports.TouchEvent = class TouchEvent extends UIEvent {};
9509
+ exports.TouchEvent = __decorate([ registerUIEvent() ], exports.TouchEvent);
9510
+ const MyTouchEvent = exports.TouchEvent;
9491
9511
  exports.RotateEvent = class RotateEvent extends exports.PointerEvent {};
9492
9512
  exports.RotateEvent.BEFORE_ROTATE = "rotate.before_rotate";
9493
9513
  exports.RotateEvent.START = "rotate.start";
@@ -10793,95 +10813,151 @@ var LeaferUI = function(exports) {
10793
10813
  }
10794
10814
  }
10795
10815
  }
10796
- function fillText(ui, canvas) {
10797
- const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
10798
- if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
10799
- let row;
10800
- for (let i = 0, len = rows.length; i < len; i++) {
10801
- row = rows[i];
10802
- if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
10803
- canvas.fillText(charData.char, charData.x, row.y);
10804
- });
10805
- }
10806
- if (decorationY) {
10807
- const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
10808
- if (decorationColor) canvas.fillStyle = decorationColor;
10809
- rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
10810
- }
10811
- }
10812
- function fill(fill, ui, canvas) {
10816
+ function fill(fill, ui, canvas, renderOptions) {
10813
10817
  canvas.fillStyle = fill;
10814
- fillPathOrText(ui, canvas);
10818
+ fillPathOrText(ui, canvas, renderOptions);
10815
10819
  }
10816
- function fills(fills, ui, canvas) {
10817
- let item;
10820
+ function fills(fills, ui, canvas, renderOptions) {
10821
+ let item, originPaint, countImage;
10818
10822
  for (let i = 0, len = fills.length; i < len; i++) {
10819
- item = fills[i];
10823
+ item = fills[i], originPaint = item.originPaint;
10820
10824
  if (item.image) {
10821
- if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font)) continue;
10825
+ countImage ? countImage++ : countImage = 1;
10826
+ if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
10822
10827
  if (!item.style) {
10823
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas, item.image);
10828
+ if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
10824
10829
  continue;
10825
10830
  }
10826
10831
  }
10827
10832
  canvas.fillStyle = item.style;
10828
- if (item.transform || item.scaleFixed) {
10833
+ if (item.transform || originPaint.scaleFixed) {
10829
10834
  canvas.save();
10830
10835
  if (item.transform) canvas.transform(item.transform);
10831
- if (item.scaleFixed) {
10836
+ if (originPaint.scaleFixed) {
10832
10837
  const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
10833
- if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
10838
+ if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
10834
10839
  }
10835
- if (item.blendMode) canvas.blendMode = item.blendMode;
10836
- fillPathOrText(ui, canvas);
10840
+ if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
10841
+ fillPathOrText(ui, canvas, renderOptions);
10837
10842
  canvas.restore();
10838
10843
  } else {
10839
- if (item.blendMode) {
10840
- canvas.saveBlendMode(item.blendMode);
10841
- fillPathOrText(ui, canvas);
10844
+ if (originPaint.blendMode) {
10845
+ canvas.saveBlendMode(originPaint.blendMode);
10846
+ fillPathOrText(ui, canvas, renderOptions);
10842
10847
  canvas.restoreBlendMode();
10843
- } else fillPathOrText(ui, canvas);
10848
+ } else fillPathOrText(ui, canvas, renderOptions);
10849
+ }
10850
+ }
10851
+ }
10852
+ function fillPathOrText(ui, canvas, renderOptions) {
10853
+ ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
10854
+ }
10855
+ function fillText(ui, canvas, _renderOptions) {
10856
+ const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
10857
+ if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
10858
+ let row;
10859
+ for (let i = 0, len = rows.length; i < len; i++) {
10860
+ row = rows[i];
10861
+ if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
10862
+ canvas.fillText(charData.char, charData.x, row.y);
10863
+ });
10864
+ }
10865
+ if (decorationY) {
10866
+ const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
10867
+ if (decorationColor) canvas.fillStyle = decorationColor;
10868
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
10869
+ }
10870
+ }
10871
+ function stroke(stroke, ui, canvas, renderOptions) {
10872
+ const data = ui.__;
10873
+ if (!data.__strokeWidth) return;
10874
+ if (data.__font) {
10875
+ Paint.strokeText(stroke, ui, canvas, renderOptions);
10876
+ } else {
10877
+ switch (data.strokeAlign) {
10878
+ case "center":
10879
+ drawCenter$1(stroke, 1, ui, canvas, renderOptions);
10880
+ break;
10881
+
10882
+ case "inside":
10883
+ drawInside(stroke, ui, canvas, renderOptions);
10884
+ break;
10885
+
10886
+ case "outside":
10887
+ drawOutside(stroke, ui, canvas, renderOptions);
10888
+ break;
10844
10889
  }
10845
10890
  }
10846
10891
  }
10847
- function fillPathOrText(ui, canvas) {
10848
- ui.__.__font ? fillText(ui, canvas) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
10892
+ function strokes(strokes, ui, canvas, renderOptions) {
10893
+ Paint.stroke(strokes, ui, canvas, renderOptions);
10894
+ }
10895
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
10896
+ const data = ui.__;
10897
+ if (isObject(stroke)) {
10898
+ Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
10899
+ } else {
10900
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
10901
+ canvas.stroke();
10902
+ }
10903
+ if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
10904
+ }
10905
+ function drawInside(stroke, ui, canvas, renderOptions) {
10906
+ canvas.save();
10907
+ canvas.clipUI(ui);
10908
+ drawCenter$1(stroke, 2, ui, canvas, renderOptions);
10909
+ canvas.restore();
10910
+ }
10911
+ function drawOutside(stroke, ui, canvas, renderOptions) {
10912
+ const data = ui.__;
10913
+ if (data.__fillAfterStroke) {
10914
+ drawCenter$1(stroke, 2, ui, canvas, renderOptions);
10915
+ } else {
10916
+ const {renderBounds: renderBounds} = ui.__layout;
10917
+ const out = canvas.getSameCanvas(true, true);
10918
+ ui.__drawRenderPath(out);
10919
+ drawCenter$1(stroke, 2, ui, out, renderOptions);
10920
+ out.clipUI(data);
10921
+ out.clearWorld(renderBounds);
10922
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
10923
+ out.recycle(ui.__nowWorld);
10924
+ }
10849
10925
  }
10850
- function strokeText(stroke, ui, canvas) {
10926
+ function strokeText(stroke, ui, canvas, renderOptions) {
10851
10927
  switch (ui.__.strokeAlign) {
10852
10928
  case "center":
10853
- drawCenter$1(stroke, 1, ui, canvas);
10929
+ drawCenter(stroke, 1, ui, canvas, renderOptions);
10854
10930
  break;
10855
10931
 
10856
10932
  case "inside":
10857
- drawAlign(stroke, "inside", ui, canvas);
10933
+ drawAlign(stroke, "inside", ui, canvas, renderOptions);
10858
10934
  break;
10859
10935
 
10860
10936
  case "outside":
10861
- ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, "outside", ui, canvas);
10937
+ ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
10862
10938
  break;
10863
10939
  }
10864
10940
  }
10865
- function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
10941
+ function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
10866
10942
  const data = ui.__;
10867
10943
  if (isObject(stroke)) {
10868
- drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
10944
+ Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
10869
10945
  } else {
10870
10946
  canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
10871
- drawTextStroke(ui, canvas);
10947
+ Paint.drawTextStroke(ui, canvas, renderOptions);
10872
10948
  }
10873
10949
  }
10874
- function drawAlign(stroke, align, ui, canvas) {
10950
+ function drawAlign(stroke, align, ui, canvas, renderOptions) {
10875
10951
  const out = canvas.getSameCanvas(true, true);
10876
10952
  out.font = ui.__.__font;
10877
- drawCenter$1(stroke, 2, ui, out);
10953
+ drawCenter(stroke, 2, ui, out, renderOptions);
10878
10954
  out.blendMode = align === "outside" ? "destination-out" : "destination-in";
10879
- fillText(ui, out);
10955
+ Paint.fillText(ui, out, renderOptions);
10880
10956
  out.blendMode = "normal";
10881
10957
  LeafHelper.copyCanvasByWorld(ui, canvas, out);
10882
10958
  out.recycle(ui.__nowWorld);
10883
10959
  }
10884
- function drawTextStroke(ui, canvas) {
10960
+ function drawTextStroke(ui, canvas, _renderOptions) {
10885
10961
  let row, data = ui.__.__textDrawData;
10886
10962
  const {rows: rows, decorationY: decorationY} = data;
10887
10963
  for (let i = 0, len = rows.length; i < len; i++) {
@@ -10895,83 +10971,28 @@ var LeaferUI = function(exports) {
10895
10971
  rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
10896
10972
  }
10897
10973
  }
10898
- function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
10974
+ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
10899
10975
  let item;
10900
10976
  const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
10901
10977
  __hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
10902
10978
  for (let i = 0, len = strokes.length; i < len; i++) {
10903
10979
  item = strokes[i];
10904
- if (item.image && PaintImage.checkImage(ui, canvas, item, false)) continue;
10980
+ if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
10905
10981
  if (item.style) {
10906
10982
  if (__hasMultiStrokeStyle) {
10907
10983
  const {strokeStyle: strokeStyle} = item;
10908
10984
  strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
10909
10985
  } else canvas.strokeStyle = item.style;
10910
- if (item.blendMode) {
10911
- canvas.saveBlendMode(item.blendMode);
10912
- isText ? drawTextStroke(ui, canvas) : canvas.stroke();
10986
+ if (item.originPaint.blendMode) {
10987
+ canvas.saveBlendMode(item.originPaint.blendMode);
10988
+ isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
10913
10989
  canvas.restoreBlendMode();
10914
10990
  } else {
10915
- isText ? drawTextStroke(ui, canvas) : canvas.stroke();
10991
+ isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
10916
10992
  }
10917
10993
  }
10918
10994
  }
10919
10995
  }
10920
- function stroke(stroke, ui, canvas) {
10921
- const data = ui.__;
10922
- if (!data.__strokeWidth) return;
10923
- if (data.__font) {
10924
- strokeText(stroke, ui, canvas);
10925
- } else {
10926
- switch (data.strokeAlign) {
10927
- case "center":
10928
- drawCenter(stroke, 1, ui, canvas);
10929
- break;
10930
-
10931
- case "inside":
10932
- drawInside(stroke, ui, canvas);
10933
- break;
10934
-
10935
- case "outside":
10936
- drawOutside(stroke, ui, canvas);
10937
- break;
10938
- }
10939
- }
10940
- }
10941
- function strokes(strokes, ui, canvas) {
10942
- stroke(strokes, ui, canvas);
10943
- }
10944
- function drawCenter(stroke, strokeWidthScale, ui, canvas) {
10945
- const data = ui.__;
10946
- if (isObject(stroke)) {
10947
- drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
10948
- } else {
10949
- canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
10950
- canvas.stroke();
10951
- }
10952
- if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas);
10953
- }
10954
- function drawInside(stroke, ui, canvas) {
10955
- canvas.save();
10956
- canvas.clipUI(ui);
10957
- drawCenter(stroke, 2, ui, canvas);
10958
- canvas.restore();
10959
- }
10960
- function drawOutside(stroke, ui, canvas) {
10961
- const data = ui.__;
10962
- if (data.__fillAfterStroke) {
10963
- drawCenter(stroke, 2, ui, canvas);
10964
- } else {
10965
- const {renderBounds: renderBounds} = ui.__layout;
10966
- const out = canvas.getSameCanvas(true, true);
10967
- ui.__drawRenderPath(out);
10968
- drawCenter(stroke, 2, ui, out);
10969
- out.clipUI(data);
10970
- out.clearWorld(renderBounds);
10971
- LeafHelper.copyCanvasByWorld(ui, canvas, out);
10972
- out.recycle(ui.__nowWorld);
10973
- }
10974
- }
10975
10996
  const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
10976
10997
  const tempBounds$1 = {};
10977
10998
  function shape(ui, current, options) {
@@ -11054,61 +11075,62 @@ var LeaferUI = function(exports) {
11054
11075
  if (leafPaints.some(item => item.image)) isAlphaPixel = true;
11055
11076
  isTransparent = true;
11056
11077
  }
11057
- }
11058
- if (attrName === "fill") {
11059
- stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
11060
- stintSet(data, "__isTransparentFill", isTransparent);
11078
+ if (attrName === "fill") {
11079
+ stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
11080
+ stintSet(data, "__isTransparentFill", isTransparent);
11081
+ } else {
11082
+ stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
11083
+ stintSet(data, "__isTransparentStroke", isTransparent);
11084
+ stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
11085
+ }
11061
11086
  } else {
11062
- stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
11063
- stintSet(data, "__isTransparentStroke", isTransparent);
11064
- stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
11087
+ data.__removePaint(attrName, false);
11065
11088
  }
11066
11089
  }
11067
11090
  function getLeafPaint(attrName, paint, ui) {
11068
11091
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
11069
- let data;
11092
+ let leafPaint;
11070
11093
  const {boxBounds: boxBounds} = ui.__layout;
11071
11094
  switch (paint.type) {
11072
11095
  case "image":
11073
- data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11096
+ leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11074
11097
  break;
11075
11098
 
11076
11099
  case "linear":
11077
- data = PaintGradient.linearGradient(paint, boxBounds);
11100
+ leafPaint = PaintGradient.linearGradient(paint, boxBounds);
11078
11101
  break;
11079
11102
 
11080
11103
  case "radial":
11081
- data = PaintGradient.radialGradient(paint, boxBounds);
11104
+ leafPaint = PaintGradient.radialGradient(paint, boxBounds);
11082
11105
  break;
11083
11106
 
11084
11107
  case "angular":
11085
- data = PaintGradient.conicGradient(paint, boxBounds);
11108
+ leafPaint = PaintGradient.conicGradient(paint, boxBounds);
11086
11109
  break;
11087
11110
 
11088
11111
  case "solid":
11089
11112
  const {type: type, color: color, opacity: opacity} = paint;
11090
- data = {
11113
+ leafPaint = {
11091
11114
  type: type,
11092
11115
  style: ColorConvert.string(color, opacity)
11093
11116
  };
11094
11117
  break;
11095
11118
 
11096
11119
  default:
11097
- if (!isUndefined(paint.r)) data = {
11120
+ if (!isUndefined(paint.r)) leafPaint = {
11098
11121
  type: "solid",
11099
11122
  style: ColorConvert.string(paint)
11100
11123
  };
11101
11124
  }
11102
- if (data) {
11103
- if (isString(data.style) && hasTransparent$1(data.style)) data.isTransparent = true;
11125
+ if (leafPaint) {
11126
+ leafPaint.originPaint = paint;
11127
+ if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
11104
11128
  if (paint.style) {
11105
11129
  if (paint.style.strokeWidth === 0) return undefined;
11106
- data.strokeStyle = paint.style;
11130
+ leafPaint.strokeStyle = paint.style;
11107
11131
  }
11108
- if (paint.editing) data.editing = paint.editing;
11109
- if (paint.blendMode) data.blendMode = paint.blendMode;
11110
11132
  }
11111
- return data;
11133
+ return leafPaint;
11112
11134
  }
11113
11135
  const PaintModule = {
11114
11136
  compute: compute,
@@ -11120,94 +11142,118 @@ var LeaferUI = function(exports) {
11120
11142
  strokes: strokes,
11121
11143
  strokeText: strokeText,
11122
11144
  drawTextStroke: drawTextStroke,
11145
+ drawStrokesStyle: drawStrokesStyle,
11123
11146
  shape: shape
11124
11147
  };
11125
- let origin = {}, tempMatrix$1 = getMatrixData();
11126
- const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
11127
- function stretchMode(data, box, scaleX, scaleY) {
11128
- const transform = get$3();
11129
- translate$1(transform, box.x, box.y);
11130
- if (scaleX) scaleHelper(transform, scaleX, scaleY);
11131
- data.transform = transform;
11132
- }
11133
- function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
11134
- const transform = get$3();
11135
- translate$1(transform, box.x + x, box.y + y);
11136
- scaleHelper(transform, scaleX, scaleY);
11137
- if (rotation) rotateOfOuter$1(transform, {
11138
- x: box.x + box.width / 2,
11139
- y: box.y + box.height / 2
11140
- }, rotation);
11141
- data.transform = transform;
11142
- }
11143
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
11144
- const transform = get$3();
11145
- layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
11146
- if (clipScaleX) {
11147
- if (rotation || skew) {
11148
- set(tempMatrix$1);
11149
- scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
11150
- multiplyParent(transform, tempMatrix$1);
11151
- } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
11148
+ let cache, box = new Bounds;
11149
+ const {isSame: isSame} = BoundsHelper;
11150
+ function image(ui, attrName, paint, boxBounds, firstUse) {
11151
+ let leafPaint, event;
11152
+ const image = ImageManager.get(paint);
11153
+ if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
11154
+ leafPaint = cache.leafPaint;
11155
+ } else {
11156
+ leafPaint = {
11157
+ type: paint.type,
11158
+ image: image
11159
+ };
11160
+ if (image.hasAlphaPixel) leafPaint.isTransparent = true;
11161
+ cache = image.use > 1 ? {
11162
+ leafPaint: leafPaint,
11163
+ paint: paint,
11164
+ boxBounds: box.set(boxBounds)
11165
+ } : null;
11152
11166
  }
11153
- data.transform = transform;
11154
- }
11155
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
11156
- const transform = get$3();
11157
- if (freeTransform) {
11158
- layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
11167
+ if (firstUse || image.loading) event = {
11168
+ image: image,
11169
+ attrName: attrName,
11170
+ attrValue: paint
11171
+ };
11172
+ if (image.ready) {
11173
+ checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
11174
+ if (firstUse) {
11175
+ onLoad(ui, event);
11176
+ onLoadSuccess(ui, event);
11177
+ }
11178
+ } else if (image.error) {
11179
+ if (firstUse) onLoadError(ui, event, image.error);
11159
11180
  } else {
11160
- if (rotation) {
11161
- if (align === "center") {
11162
- rotateOfOuter$1(transform, {
11163
- x: width / 2,
11164
- y: height / 2
11165
- }, rotation);
11166
- } else {
11167
- rotate(transform, rotation);
11168
- switch (rotation) {
11169
- case 90:
11170
- translate$1(transform, height, 0);
11171
- break;
11172
-
11173
- case 180:
11174
- translate$1(transform, width, height);
11175
- break;
11176
-
11177
- case 270:
11178
- translate$1(transform, 0, width);
11179
- break;
11181
+ if (firstUse) {
11182
+ ignoreRender(ui, true);
11183
+ onLoad(ui, event);
11184
+ }
11185
+ leafPaint.loadId = image.load(() => {
11186
+ ignoreRender(ui, false);
11187
+ if (!ui.destroyed) {
11188
+ if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
11189
+ if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
11190
+ ui.forceUpdate("surface");
11180
11191
  }
11192
+ onLoadSuccess(ui, event);
11181
11193
  }
11194
+ leafPaint.loadId = undefined;
11195
+ }, error => {
11196
+ ignoreRender(ui, false);
11197
+ onLoadError(ui, event, error);
11198
+ leafPaint.loadId = undefined;
11199
+ });
11200
+ if (ui.placeholderColor) {
11201
+ if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
11202
+ if (!image.ready) {
11203
+ image.isPlacehold = true;
11204
+ ui.forceUpdate("surface");
11205
+ }
11206
+ }, ui.placeholderDelay);
11182
11207
  }
11183
- origin.x = box.x + x;
11184
- origin.y = box.y + y;
11185
- translate$1(transform, origin.x, origin.y);
11186
- if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
11187
11208
  }
11188
- data.transform = transform;
11209
+ return leafPaint;
11189
11210
  }
11190
- function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
11191
- if (rotation) rotate(transform, rotation);
11192
- if (skew) skewHelper(transform, skew.x, skew.y);
11193
- if (scaleX) scaleHelper(transform, scaleX, scaleY);
11194
- translate$1(transform, box.x + x, box.y + y);
11211
+ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
11212
+ if (attrName === "fill" && !ui.__.__naturalWidth) {
11213
+ const data = ui.__;
11214
+ data.__naturalWidth = image.width / data.pixelRatio;
11215
+ data.__naturalHeight = image.height / data.pixelRatio;
11216
+ if (data.__autoSide) {
11217
+ ui.forceUpdate("width");
11218
+ if (ui.__proxyData) {
11219
+ ui.setProxyAttr("width", data.width);
11220
+ ui.setProxyAttr("height", data.height);
11221
+ }
11222
+ return false;
11223
+ }
11224
+ }
11225
+ if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
11226
+ return true;
11227
+ }
11228
+ function onLoad(ui, event) {
11229
+ emit(ui, ImageEvent.LOAD, event);
11230
+ }
11231
+ function onLoadSuccess(ui, event) {
11232
+ emit(ui, ImageEvent.LOADED, event);
11195
11233
  }
11196
- const {get: get$2, translate: translate} = MatrixHelper;
11234
+ function onLoadError(ui, event, error) {
11235
+ event.error = error;
11236
+ ui.forceUpdate("surface");
11237
+ emit(ui, ImageEvent.ERROR, event);
11238
+ }
11239
+ function emit(ui, type, data) {
11240
+ if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
11241
+ }
11242
+ function ignoreRender(ui, value) {
11243
+ const {leafer: leafer} = ui;
11244
+ if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
11245
+ }
11246
+ const {get: get$3, translate: translate$1} = MatrixHelper;
11197
11247
  const tempBox = new Bounds;
11198
11248
  const tempScaleData = {};
11199
11249
  const tempImage = {};
11200
11250
  function createData(leafPaint, image, paint, box) {
11201
- const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
11202
- if (changeful) leafPaint.changeful = changeful;
11203
- if (sync) leafPaint.sync = sync;
11204
- if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
11205
- leafPaint.data = getPatternData(paint, box, image);
11251
+ leafPaint.data = PaintImage.getPatternData(paint, box, image);
11206
11252
  }
11207
11253
  function getPatternData(paint, box, image) {
11208
11254
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
11209
11255
  if (paint.mode === "strench") paint.mode = "stretch";
11210
- let {width: width, height: height} = image;
11256
+ const {width: width, height: height} = image;
11211
11257
  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;
11212
11258
  const sameBox = box.width === width && box.height === height;
11213
11259
  const data = {
@@ -11238,8 +11284,8 @@ var LeaferUI = function(exports) {
11238
11284
  case "stretch":
11239
11285
  if (!sameBox) {
11240
11286
  scaleX = box.width / width, scaleY = box.height / height;
11241
- stretchMode(data, box, scaleX, scaleY);
11242
- }
11287
+ PaintImage.stretchMode(data, box, scaleX, scaleY);
11288
+ } else if (scaleX) scaleX = scaleY = undefined;
11243
11289
  break;
11244
11290
 
11245
11291
  case "normal":
@@ -11247,13 +11293,13 @@ var LeaferUI = function(exports) {
11247
11293
  if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
11248
11294
  let clipScaleX, clipScaleY;
11249
11295
  if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
11250
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
11296
+ PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
11251
11297
  if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
11252
11298
  }
11253
11299
  break;
11254
11300
 
11255
11301
  case "repeat":
11256
- if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
11302
+ if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
11257
11303
  if (!repeat) data.repeat = "repeat";
11258
11304
  const count = isObject(repeat);
11259
11305
  if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
@@ -11262,18 +11308,16 @@ var LeaferUI = function(exports) {
11262
11308
  case "fit":
11263
11309
  case "cover":
11264
11310
  default:
11265
- if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11311
+ if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11266
11312
  }
11267
11313
  if (!data.transform) {
11268
- if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
11314
+ if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
11269
11315
  }
11270
- data.width = width;
11271
- data.height = height;
11272
11316
  if (scaleX) {
11273
11317
  data.scaleX = scaleX;
11274
11318
  data.scaleY = scaleY;
11275
11319
  }
11276
- if (opacity) data.opacity = opacity;
11320
+ if (opacity && opacity < 1) data.opacity = opacity;
11277
11321
  if (filters) data.filters = filters;
11278
11322
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
11279
11323
  return data;
@@ -11292,221 +11336,180 @@ var LeaferUI = function(exports) {
11292
11336
  const value = auto ? remain / ((rows || Math.floor(totalSize / size)) - 1) : gap;
11293
11337
  return gap === "auto" ? value < 0 ? 0 : value : value;
11294
11338
  }
11295
- let cache, box = new Bounds;
11296
- const {isSame: isSame} = BoundsHelper;
11297
- function image(ui, attrName, paint, boxBounds, firstUse) {
11298
- let leafPaint, event;
11299
- const image = ImageManager.get(paint);
11300
- if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
11301
- leafPaint = cache.leafPaint;
11302
- } else {
11303
- leafPaint = {
11304
- type: paint.type,
11305
- image: image
11306
- };
11307
- if (image.hasAlphaPixel) leafPaint.isTransparent = true;
11308
- cache = image.use > 1 ? {
11309
- leafPaint: leafPaint,
11310
- paint: paint,
11311
- boxBounds: box.set(boxBounds)
11312
- } : null;
11339
+ let origin = {}, tempMatrix$1 = getMatrixData();
11340
+ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
11341
+ function stretchMode(data, box, scaleX, scaleY) {
11342
+ const transform = get$2(), {x: x, y: y} = box;
11343
+ if (x || y) translate(transform, x, y); else transform.onlyScale = true;
11344
+ scaleHelper(transform, scaleX, scaleY);
11345
+ data.transform = transform;
11346
+ }
11347
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
11348
+ const transform = get$2();
11349
+ translate(transform, box.x + x, box.y + y);
11350
+ scaleHelper(transform, scaleX, scaleY);
11351
+ if (rotation) rotateOfOuter$1(transform, {
11352
+ x: box.x + box.width / 2,
11353
+ y: box.y + box.height / 2
11354
+ }, rotation);
11355
+ data.transform = transform;
11356
+ }
11357
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
11358
+ const transform = get$2();
11359
+ layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
11360
+ if (clipScaleX) {
11361
+ if (rotation || skew) {
11362
+ set(tempMatrix$1);
11363
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
11364
+ multiplyParent(transform, tempMatrix$1);
11365
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
11313
11366
  }
11314
- if (firstUse || image.loading) event = {
11315
- image: image,
11316
- attrName: attrName,
11317
- attrValue: paint
11318
- };
11319
- if (image.ready) {
11320
- checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
11321
- if (firstUse) {
11322
- onLoad(ui, event);
11323
- onLoadSuccess(ui, event);
11324
- }
11325
- } else if (image.error) {
11326
- if (firstUse) onLoadError(ui, event, image.error);
11367
+ data.transform = transform;
11368
+ }
11369
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
11370
+ const transform = get$2();
11371
+ if (freeTransform) {
11372
+ layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
11327
11373
  } else {
11328
- if (firstUse) {
11329
- ignoreRender(ui, true);
11330
- onLoad(ui, event);
11331
- }
11332
- leafPaint.loadId = image.load(() => {
11333
- ignoreRender(ui, false);
11334
- if (!ui.destroyed) {
11335
- if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
11336
- if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
11337
- ui.forceUpdate("surface");
11338
- }
11339
- onLoadSuccess(ui, event);
11340
- }
11341
- leafPaint.loadId = undefined;
11342
- }, error => {
11343
- ignoreRender(ui, false);
11344
- onLoadError(ui, event, error);
11345
- leafPaint.loadId = undefined;
11346
- });
11347
- if (ui.placeholderColor) {
11348
- if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
11349
- if (!image.ready) {
11350
- image.isPlacehold = true;
11351
- ui.forceUpdate("surface");
11374
+ if (rotation) {
11375
+ if (align === "center") {
11376
+ rotateOfOuter$1(transform, {
11377
+ x: width / 2,
11378
+ y: height / 2
11379
+ }, rotation);
11380
+ } else {
11381
+ rotate(transform, rotation);
11382
+ switch (rotation) {
11383
+ case 90:
11384
+ translate(transform, height, 0);
11385
+ break;
11386
+
11387
+ case 180:
11388
+ translate(transform, width, height);
11389
+ break;
11390
+
11391
+ case 270:
11392
+ translate(transform, 0, width);
11393
+ break;
11352
11394
  }
11353
- }, ui.placeholderDelay);
11354
- }
11355
- }
11356
- return leafPaint;
11357
- }
11358
- function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
11359
- if (attrName === "fill" && !ui.__.__naturalWidth) {
11360
- const data = ui.__;
11361
- data.__naturalWidth = image.width / data.pixelRatio;
11362
- data.__naturalHeight = image.height / data.pixelRatio;
11363
- if (data.__autoSide) {
11364
- ui.forceUpdate("width");
11365
- if (ui.__proxyData) {
11366
- ui.setProxyAttr("width", data.width);
11367
- ui.setProxyAttr("height", data.height);
11368
11395
  }
11369
- return false;
11370
11396
  }
11397
+ origin.x = box.x + x;
11398
+ origin.y = box.y + y;
11399
+ translate(transform, origin.x, origin.y);
11400
+ if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
11371
11401
  }
11372
- if (!leafPaint.data) createData(leafPaint, image, paint, boxBounds);
11373
- return true;
11374
- }
11375
- function onLoad(ui, event) {
11376
- emit(ui, ImageEvent.LOAD, event);
11377
- }
11378
- function onLoadSuccess(ui, event) {
11379
- emit(ui, ImageEvent.LOADED, event);
11380
- }
11381
- function onLoadError(ui, event, error) {
11382
- event.error = error;
11383
- ui.forceUpdate("surface");
11384
- emit(ui, ImageEvent.ERROR, event);
11385
- }
11386
- function emit(ui, type, data) {
11387
- if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
11402
+ data.transform = transform;
11388
11403
  }
11389
- function ignoreRender(ui, value) {
11390
- const {leafer: leafer} = ui;
11391
- if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
11404
+ function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
11405
+ if (rotation) rotate(transform, rotation);
11406
+ if (skew) skewHelper(transform, skew.x, skew.y);
11407
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
11408
+ translate(transform, box.x + x, box.y + y);
11392
11409
  }
11393
11410
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
11394
- const {floor: floor, ceil: ceil, max: max$1, abs: abs$1} = Math;
11395
- function createPattern(ui, paint, pixelRatio) {
11396
- let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
11397
- const id = scaleX + "-" + scaleY + "-" + pixelRatio;
11411
+ const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
11412
+ function createPatternTask(paint, ui, canvas, renderOptions) {
11413
+ if (!paint.patternTask) {
11414
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
11415
+ paint.patternTask = null;
11416
+ if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
11417
+ ui.forceUpdate("surface");
11418
+ }), 300);
11419
+ }
11420
+ }
11421
+ function createPattern(paint, ui, canvas, renderOptions) {
11422
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
11398
11423
  if (paint.patternId !== id && !ui.destroyed) {
11399
- const {image: image, data: data} = paint;
11400
- let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
11401
- scaleX *= pixelRatio;
11402
- scaleY *= pixelRatio;
11403
- if (sx) {
11404
- sx = abs$1(sx);
11405
- sy = abs$1(sy);
11406
- imageMatrix = get$1();
11407
- copy$1(imageMatrix, transform);
11408
- scale(imageMatrix, 1 / sx, 1 / sy);
11409
- scaleX *= sx;
11410
- scaleY *= sy;
11411
- }
11412
- width *= scaleX;
11413
- height *= scaleY;
11414
- const size = width * height;
11415
- if (!repeat) {
11416
- if (size > Platform.image.maxCacheSize) return false;
11417
- }
11418
- let maxSize = Platform.image.maxPatternSize;
11419
- if (image.isSVG) {
11420
- const ws = width / image.width;
11421
- if (ws > 1) imageScale = ws / ceil(ws);
11422
- } else {
11423
- const imageSize = image.width * image.height;
11424
- if (maxSize > imageSize) maxSize = imageSize;
11425
- }
11426
- if (size > maxSize) imageScale = Math.sqrt(size / maxSize);
11427
- if (imageScale) {
11428
- scaleX /= imageScale;
11429
- scaleY /= imageScale;
11430
- width /= imageScale;
11431
- height /= imageScale;
11432
- }
11433
- if (sx) {
11434
- scaleX /= sx;
11435
- scaleY /= sy;
11436
- }
11437
- const xGap = gap && gap.x * scaleX;
11438
- const yGap = gap && gap.y * scaleY;
11439
- if (transform || scaleX !== 1 || scaleY !== 1) {
11440
- const canvasWidth = width + (xGap || 0);
11441
- const canvasHeight = height + (yGap || 0);
11442
- scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
11443
- scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
11444
- if (!imageMatrix) {
11424
+ if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
11425
+ const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11426
+ let imageMatrix, xGap, yGap, {width: width, height: height} = image;
11427
+ if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
11428
+ width *= scaleX;
11429
+ height *= scaleY;
11430
+ if (gap) {
11431
+ xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
11432
+ yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
11433
+ }
11434
+ if (transform || scaleX !== 1 || scaleY !== 1) {
11435
+ scaleX *= getFloorScale(width + (xGap || 0));
11436
+ scaleY *= getFloorScale(height + (yGap || 0));
11445
11437
  imageMatrix = get$1();
11446
11438
  if (transform) copy$1(imageMatrix, transform);
11439
+ scale(imageMatrix, 1 / scaleX, 1 / scaleY);
11447
11440
  }
11448
- scale(imageMatrix, 1 / scaleX, 1 / scaleY);
11441
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11442
+ const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11443
+ paint.style = pattern;
11444
+ paint.patternId = id;
11449
11445
  }
11450
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11451
- const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11452
- paint.style = pattern;
11453
- paint.patternId = id;
11454
- return true;
11446
+ }
11447
+ }
11448
+ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
11449
+ const {image: image} = paint;
11450
+ let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
11451
+ if (image.isSVG) {
11452
+ if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
11455
11453
  } else {
11456
- return false;
11454
+ if (maxSize > imageSize) maxSize = imageSize;
11457
11455
  }
11456
+ if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
11457
+ return fixScale;
11458
11458
  }
11459
- function checkImage(ui, canvas, paint, allowDraw) {
11460
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
11461
- const {pixelRatio: pixelRatio} = canvas, {data: data} = paint;
11462
- if (!data || paint.patternId === scaleX + "-" + scaleY + "-" + pixelRatio && !Export.running) {
11459
+ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
11460
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
11461
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
11462
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
11463
11463
  return false;
11464
11464
  } else {
11465
- if (allowDraw) {
11465
+ if (drawImage) {
11466
11466
  if (data.repeat) {
11467
- allowDraw = false;
11468
- } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
11469
- let {width: width, height: height} = data;
11470
- width *= scaleX * pixelRatio;
11471
- height *= scaleY * pixelRatio;
11472
- if (data.scaleX) {
11473
- width *= data.scaleX;
11474
- height *= data.scaleY;
11475
- }
11476
- allowDraw = width * height > Platform.image.maxCacheSize;
11467
+ drawImage = false;
11468
+ } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
11469
+ drawImage = Platform.image.isLarge(image, scaleX, scaleY);
11477
11470
  }
11478
11471
  }
11479
- if (allowDraw) {
11472
+ if (drawImage) {
11480
11473
  if (ui.__.__isFastShadow) {
11481
11474
  canvas.fillStyle = paint.style || "#000";
11482
11475
  canvas.fill();
11483
11476
  }
11484
- drawImage(ui, canvas, paint, data);
11477
+ PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
11485
11478
  return true;
11486
11479
  } else {
11487
- if (!paint.style || paint.sync || Export.running) {
11488
- createPattern(ui, paint, pixelRatio);
11489
- } else {
11490
- if (!paint.patternTask) {
11491
- paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
11492
- paint.patternTask = null;
11493
- if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio);
11494
- ui.forceUpdate("surface");
11495
- }), 300);
11496
- }
11497
- }
11480
+ if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
11498
11481
  return false;
11499
11482
  }
11500
11483
  }
11501
11484
  }
11502
- function drawImage(ui, canvas, paint, data) {
11503
- canvas.save();
11504
- canvas.clipUI(ui);
11505
- if (paint.blendMode) canvas.blendMode = paint.blendMode;
11506
- if (data.opacity) canvas.opacity *= data.opacity;
11507
- if (data.transform) canvas.transform(data.transform);
11508
- canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
11509
- canvas.restore();
11485
+ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
11486
+ const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
11487
+ let {width: width, height: height} = image, clipUI;
11488
+ if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
11489
+ canvas.save();
11490
+ clipUI && canvas.clipUI(ui);
11491
+ blendMode && (canvas.blendMode = blendMode);
11492
+ opacity && (canvas.opacity *= opacity);
11493
+ transform && canvas.transform(transform);
11494
+ canvas.drawImage(view, 0, 0, width, height);
11495
+ canvas.restore();
11496
+ } else {
11497
+ if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
11498
+ canvas.drawImage(view, 0, 0, width, height);
11499
+ }
11500
+ }
11501
+ function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
11502
+ const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
11503
+ if (canvas) {
11504
+ const {pixelRatio: pixelRatio} = canvas;
11505
+ scaleData.scaleX *= pixelRatio;
11506
+ scaleData.scaleY *= pixelRatio;
11507
+ }
11508
+ if (data && data.scaleX) {
11509
+ scaleData.scaleX *= Math.abs(data.scaleX);
11510
+ scaleData.scaleY *= Math.abs(data.scaleY);
11511
+ }
11512
+ return scaleData;
11510
11513
  }
11511
11514
  function recycleImage(attrName, data) {
11512
11515
  const paints = data["_" + attrName];
@@ -11536,8 +11539,12 @@ var LeaferUI = function(exports) {
11536
11539
  const PaintImageModule = {
11537
11540
  image: image,
11538
11541
  checkImage: checkImage,
11539
- createPattern: createPattern,
11542
+ drawImage: drawImage,
11543
+ getImageRenderScaleData: getImageRenderScaleData,
11540
11544
  recycleImage: recycleImage,
11545
+ createPatternTask: createPatternTask,
11546
+ createPattern: createPattern,
11547
+ getPatternFixScale: getPatternFixScale,
11541
11548
  createData: createData,
11542
11549
  getPatternData: getPatternData,
11543
11550
  stretchMode: stretchMode,
@@ -11924,10 +11931,8 @@ var LeaferUI = function(exports) {
11924
11931
  bounds = drawData.bounds;
11925
11932
  findMaxWidth = !bounds.width && !style.autoSizeAlign;
11926
11933
  const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
11927
- const {canvas: canvas} = Platform;
11928
- const {width: width, height: height} = bounds;
11929
- const charMode = width || height || __letterSpacing || textCase !== "none";
11930
- if (charMode) {
11934
+ const {canvas: canvas} = Platform, {width: width} = bounds;
11935
+ if (style.__isCharMode) {
11931
11936
  const wrap = style.textWrap !== "none";
11932
11937
  const breakAll = style.textWrap === "break";
11933
11938
  paraStart = true;
@@ -12048,12 +12053,19 @@ var LeaferUI = function(exports) {
12048
12053
  function layoutChar(drawData, style, width, _height) {
12049
12054
  const {rows: rows} = drawData;
12050
12055
  const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
12051
- let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
12056
+ const justifyLast = width && textAlign.includes("both");
12057
+ const justify = justifyLast || width && textAlign.includes("justify");
12058
+ const justifyLetter = justify && textAlign.includes("letter");
12059
+ let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
12052
12060
  rows.forEach(row => {
12053
12061
  if (row.words) {
12054
12062
  indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
12055
- addWordWidth = width && (textAlign === "justify" || textAlign === "both") && wordsLength > 1 ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
12056
- mode = letterSpacing || row.isOverflow ? CharMode : addWordWidth > .01 ? WordMode : TextMode;
12063
+ if (justify) {
12064
+ canJustify = !row.paraEnd || justifyLast;
12065
+ remainingWidth = width - row.width - indentWidth;
12066
+ if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
12067
+ }
12068
+ mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
12057
12069
  if (row.isOverflow && !letterSpacing) row.textMode = true;
12058
12070
  if (mode === TextMode) {
12059
12071
  row.x += indentWidth;
@@ -12071,11 +12083,15 @@ var LeaferUI = function(exports) {
12071
12083
  charX = toWordChar(word.data, charX, wordChar);
12072
12084
  if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
12073
12085
  } else {
12074
- charX = toChar(word.data, charX, row.data, row.isOverflow);
12086
+ charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
12075
12087
  }
12076
- if (addWordWidth && (!row.paraEnd || textAlign === "both") && index !== wordsLength - 1) {
12077
- charX += addWordWidth;
12078
- row.width += addWordWidth;
12088
+ if (canJustify) {
12089
+ isLastWord = index === wordsLength - 1;
12090
+ if (addWordWidth) {
12091
+ if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
12092
+ } else if (addLetterWidth) {
12093
+ row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
12094
+ }
12079
12095
  }
12080
12096
  });
12081
12097
  }
@@ -12098,13 +12114,14 @@ var LeaferUI = function(exports) {
12098
12114
  });
12099
12115
  return charX;
12100
12116
  }
12101
- function toChar(data, charX, rowData, isOverflow) {
12117
+ function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
12102
12118
  data.forEach(char => {
12103
12119
  if (isOverflow || char.char !== " ") {
12104
12120
  char.x = charX;
12105
12121
  rowData.push(char);
12106
12122
  }
12107
12123
  charX += char.width;
12124
+ addLetterWidth && (charX += addLetterWidth);
12108
12125
  });
12109
12126
  return charX;
12110
12127
  }
@@ -12240,10 +12257,10 @@ var LeaferUI = function(exports) {
12240
12257
  let x = 0, y = 0;
12241
12258
  let width = style.__getInput("width") || 0;
12242
12259
  let height = style.__getInput("height") || 0;
12243
- const {textDecoration: textDecoration, __font: __font, __padding: padding} = style;
12260
+ const {__padding: padding} = style;
12244
12261
  if (padding) {
12245
- if (width) x = padding[left], width -= padding[right] + padding[left]; else if (!style.autoSizeAlign) x = padding[left];
12246
- if (height) y = padding[top], height -= padding[top] + padding[bottom]; else if (!style.autoSizeAlign) y = padding[top];
12262
+ if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
12263
+ if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
12247
12264
  }
12248
12265
  const drawData = {
12249
12266
  bounds: {
@@ -12254,14 +12271,14 @@ var LeaferUI = function(exports) {
12254
12271
  },
12255
12272
  rows: [],
12256
12273
  paraNumber: 0,
12257
- font: Platform.canvas.font = __font
12274
+ font: Platform.canvas.font = style.__font
12258
12275
  };
12259
12276
  createRows(drawData, content, style);
12260
12277
  if (padding) padAutoText(padding, drawData, style, width, height);
12261
12278
  layoutText(drawData, style);
12262
- layoutChar(drawData, style, width);
12279
+ if (style.__isCharMode) layoutChar(drawData, style, width);
12263
12280
  if (drawData.overflow) clipText(drawData, style, x, width);
12264
- if (textDecoration !== "none") decorationText(drawData, style);
12281
+ if (style.textDecoration !== "none") decorationText(drawData, style);
12265
12282
  return drawData;
12266
12283
  }
12267
12284
  function padAutoText(padding, drawData, style, width, height) {
@@ -12386,6 +12403,7 @@ var LeaferUI = function(exports) {
12386
12403
  exports.MyDragEvent = MyDragEvent;
12387
12404
  exports.MyImage = MyImage;
12388
12405
  exports.MyPointerEvent = MyPointerEvent;
12406
+ exports.MyTouchEvent = MyTouchEvent;
12389
12407
  exports.NeedConvertToCanvasCommandMap = NeedConvertToCanvasCommandMap;
12390
12408
  exports.OneRadian = OneRadian;
12391
12409
  exports.PI2 = PI2;