leafer-ui 1.9.12 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.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.0";
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(_image, 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,34 +10813,18 @@ 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) {
10820
+ function fills(fills, ui, canvas, renderOptions) {
10817
10821
  let item;
10818
10822
  for (let i = 0, len = fills.length; i < len; i++) {
10819
10823
  item = fills[i];
10820
10824
  if (item.image) {
10821
- if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font)) continue;
10825
+ if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
10822
10826
  if (!item.style) {
10823
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas, item.image);
10827
+ if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
10824
10828
  continue;
10825
10829
  }
10826
10830
  }
@@ -10833,55 +10837,126 @@ var LeaferUI = function(exports) {
10833
10837
  if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
10834
10838
  }
10835
10839
  if (item.blendMode) canvas.blendMode = item.blendMode;
10836
- fillPathOrText(ui, canvas);
10840
+ fillPathOrText(ui, canvas, renderOptions);
10837
10841
  canvas.restore();
10838
10842
  } else {
10839
10843
  if (item.blendMode) {
10840
10844
  canvas.saveBlendMode(item.blendMode);
10841
- fillPathOrText(ui, canvas);
10845
+ fillPathOrText(ui, canvas, renderOptions);
10842
10846
  canvas.restoreBlendMode();
10843
- } else fillPathOrText(ui, canvas);
10847
+ } else fillPathOrText(ui, canvas, renderOptions);
10848
+ }
10849
+ }
10850
+ }
10851
+ function fillPathOrText(ui, canvas, renderOptions) {
10852
+ ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
10853
+ }
10854
+ function fillText(ui, canvas, _renderOptions) {
10855
+ const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
10856
+ if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
10857
+ let row;
10858
+ for (let i = 0, len = rows.length; i < len; i++) {
10859
+ row = rows[i];
10860
+ if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
10861
+ canvas.fillText(charData.char, charData.x, row.y);
10862
+ });
10863
+ }
10864
+ if (decorationY) {
10865
+ const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
10866
+ if (decorationColor) canvas.fillStyle = decorationColor;
10867
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
10868
+ }
10869
+ }
10870
+ function stroke(stroke, ui, canvas, renderOptions) {
10871
+ const data = ui.__;
10872
+ if (!data.__strokeWidth) return;
10873
+ if (data.__font) {
10874
+ Paint.strokeText(stroke, ui, canvas, renderOptions);
10875
+ } else {
10876
+ switch (data.strokeAlign) {
10877
+ case "center":
10878
+ drawCenter$1(stroke, 1, ui, canvas, renderOptions);
10879
+ break;
10880
+
10881
+ case "inside":
10882
+ drawInside(stroke, ui, canvas, renderOptions);
10883
+ break;
10884
+
10885
+ case "outside":
10886
+ drawOutside(stroke, ui, canvas, renderOptions);
10887
+ break;
10844
10888
  }
10845
10889
  }
10846
10890
  }
10847
- function fillPathOrText(ui, canvas) {
10848
- ui.__.__font ? fillText(ui, canvas) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
10891
+ function strokes(strokes, ui, canvas, renderOptions) {
10892
+ Paint.stroke(strokes, ui, canvas, renderOptions);
10893
+ }
10894
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
10895
+ const data = ui.__;
10896
+ if (isObject(stroke)) {
10897
+ Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
10898
+ } else {
10899
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
10900
+ canvas.stroke();
10901
+ }
10902
+ if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
10903
+ }
10904
+ function drawInside(stroke, ui, canvas, renderOptions) {
10905
+ canvas.save();
10906
+ canvas.clipUI(ui);
10907
+ drawCenter$1(stroke, 2, ui, canvas, renderOptions);
10908
+ canvas.restore();
10849
10909
  }
10850
- function strokeText(stroke, ui, canvas) {
10910
+ function drawOutside(stroke, ui, canvas, renderOptions) {
10911
+ const data = ui.__;
10912
+ if (data.__fillAfterStroke) {
10913
+ drawCenter$1(stroke, 2, ui, canvas, renderOptions);
10914
+ } else {
10915
+ const {renderBounds: renderBounds} = ui.__layout;
10916
+ const out = canvas.getSameCanvas(true, true);
10917
+ ui.__drawRenderPath(out);
10918
+ drawCenter$1(stroke, 2, ui, out, renderOptions);
10919
+ out.clipUI(data);
10920
+ out.clearWorld(renderBounds);
10921
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
10922
+ out.recycle(ui.__nowWorld);
10923
+ }
10924
+ }
10925
+ function strokeText(stroke, ui, canvas, renderOptions) {
10851
10926
  switch (ui.__.strokeAlign) {
10852
10927
  case "center":
10853
- drawCenter$1(stroke, 1, ui, canvas);
10928
+ drawCenter(stroke, 1, ui, canvas, renderOptions);
10854
10929
  break;
10855
10930
 
10856
10931
  case "inside":
10857
- drawAlign(stroke, "inside", ui, canvas);
10932
+ drawAlign(stroke, "inside", ui, canvas, renderOptions);
10858
10933
  break;
10859
10934
 
10860
10935
  case "outside":
10861
- ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, "outside", ui, canvas);
10936
+ ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
10862
10937
  break;
10863
10938
  }
10864
10939
  }
10865
- function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
10940
+ function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
10866
10941
  const data = ui.__;
10867
10942
  if (isObject(stroke)) {
10868
- drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
10943
+ Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
10869
10944
  } else {
10870
10945
  canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
10871
- drawTextStroke(ui, canvas);
10946
+ Paint.drawTextStroke(ui, canvas, renderOptions);
10872
10947
  }
10873
10948
  }
10874
- function drawAlign(stroke, align, ui, canvas) {
10949
+ function drawAlign(stroke, align, ui, canvas, renderOptions) {
10875
10950
  const out = canvas.getSameCanvas(true, true);
10876
10951
  out.font = ui.__.__font;
10877
- drawCenter$1(stroke, 2, ui, out);
10952
+ drawCenter(stroke, 2, ui, out, renderOptions);
10878
10953
  out.blendMode = align === "outside" ? "destination-out" : "destination-in";
10879
- fillText(ui, out);
10954
+ Paint.fillText(ui, out, renderOptions);
10880
10955
  out.blendMode = "normal";
10881
10956
  LeafHelper.copyCanvasByWorld(ui, canvas, out);
10882
10957
  out.recycle(ui.__nowWorld);
10883
10958
  }
10884
- function drawTextStroke(ui, canvas) {
10959
+ function drawTextStroke(ui, canvas, _renderOptions) {
10885
10960
  let row, data = ui.__.__textDrawData;
10886
10961
  const {rows: rows, decorationY: decorationY} = data;
10887
10962
  for (let i = 0, len = rows.length; i < len; i++) {
@@ -10895,13 +10970,13 @@ var LeaferUI = function(exports) {
10895
10970
  rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
10896
10971
  }
10897
10972
  }
10898
- function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
10973
+ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
10899
10974
  let item;
10900
10975
  const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
10901
10976
  __hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
10902
10977
  for (let i = 0, len = strokes.length; i < len; i++) {
10903
10978
  item = strokes[i];
10904
- if (item.image && PaintImage.checkImage(ui, canvas, item, false)) continue;
10979
+ if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
10905
10980
  if (item.style) {
10906
10981
  if (__hasMultiStrokeStyle) {
10907
10982
  const {strokeStyle: strokeStyle} = item;
@@ -10909,69 +10984,14 @@ var LeaferUI = function(exports) {
10909
10984
  } else canvas.strokeStyle = item.style;
10910
10985
  if (item.blendMode) {
10911
10986
  canvas.saveBlendMode(item.blendMode);
10912
- isText ? drawTextStroke(ui, canvas) : canvas.stroke();
10987
+ isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
10913
10988
  canvas.restoreBlendMode();
10914
10989
  } else {
10915
- isText ? drawTextStroke(ui, canvas) : canvas.stroke();
10990
+ isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
10916
10991
  }
10917
10992
  }
10918
10993
  }
10919
10994
  }
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
10995
  const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
10976
10996
  const tempBounds$1 = {};
10977
10997
  function shape(ui, current, options) {
@@ -11120,80 +11140,108 @@ var LeaferUI = function(exports) {
11120
11140
  strokes: strokes,
11121
11141
  strokeText: strokeText,
11122
11142
  drawTextStroke: drawTextStroke,
11143
+ drawStrokesStyle: drawStrokesStyle,
11123
11144
  shape: shape
11124
11145
  };
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);
11146
+ let cache, box = new Bounds;
11147
+ const {isSame: isSame} = BoundsHelper;
11148
+ function image(ui, attrName, paint, boxBounds, firstUse) {
11149
+ let leafPaint, event;
11150
+ const image = ImageManager.get(paint);
11151
+ if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
11152
+ leafPaint = cache.leafPaint;
11153
+ } else {
11154
+ leafPaint = {
11155
+ type: paint.type,
11156
+ image: image
11157
+ };
11158
+ if (image.hasAlphaPixel) leafPaint.isTransparent = true;
11159
+ cache = image.use > 1 ? {
11160
+ leafPaint: leafPaint,
11161
+ paint: paint,
11162
+ boxBounds: box.set(boxBounds)
11163
+ } : null;
11152
11164
  }
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);
11165
+ if (firstUse || image.loading) event = {
11166
+ image: image,
11167
+ attrName: attrName,
11168
+ attrValue: paint
11169
+ };
11170
+ if (image.ready) {
11171
+ checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
11172
+ if (firstUse) {
11173
+ onLoad(ui, event);
11174
+ onLoadSuccess(ui, event);
11175
+ }
11176
+ } else if (image.error) {
11177
+ if (firstUse) onLoadError(ui, event, image.error);
11159
11178
  } 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;
11179
+ if (firstUse) {
11180
+ ignoreRender(ui, true);
11181
+ onLoad(ui, event);
11182
+ }
11183
+ leafPaint.loadId = image.load(() => {
11184
+ ignoreRender(ui, false);
11185
+ if (!ui.destroyed) {
11186
+ if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
11187
+ if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
11188
+ ui.forceUpdate("surface");
11180
11189
  }
11190
+ onLoadSuccess(ui, event);
11181
11191
  }
11192
+ leafPaint.loadId = undefined;
11193
+ }, error => {
11194
+ ignoreRender(ui, false);
11195
+ onLoadError(ui, event, error);
11196
+ leafPaint.loadId = undefined;
11197
+ });
11198
+ if (ui.placeholderColor) {
11199
+ if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
11200
+ if (!image.ready) {
11201
+ image.isPlacehold = true;
11202
+ ui.forceUpdate("surface");
11203
+ }
11204
+ }, ui.placeholderDelay);
11182
11205
  }
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
11206
  }
11188
- data.transform = transform;
11207
+ return leafPaint;
11189
11208
  }
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);
11209
+ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
11210
+ if (attrName === "fill" && !ui.__.__naturalWidth) {
11211
+ const data = ui.__;
11212
+ data.__naturalWidth = image.width / data.pixelRatio;
11213
+ data.__naturalHeight = image.height / data.pixelRatio;
11214
+ if (data.__autoSide) {
11215
+ ui.forceUpdate("width");
11216
+ if (ui.__proxyData) {
11217
+ ui.setProxyAttr("width", data.width);
11218
+ ui.setProxyAttr("height", data.height);
11219
+ }
11220
+ return false;
11221
+ }
11222
+ }
11223
+ if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
11224
+ return true;
11225
+ }
11226
+ function onLoad(ui, event) {
11227
+ emit(ui, ImageEvent.LOAD, event);
11228
+ }
11229
+ function onLoadSuccess(ui, event) {
11230
+ emit(ui, ImageEvent.LOADED, event);
11231
+ }
11232
+ function onLoadError(ui, event, error) {
11233
+ event.error = error;
11234
+ ui.forceUpdate("surface");
11235
+ emit(ui, ImageEvent.ERROR, event);
11236
+ }
11237
+ function emit(ui, type, data) {
11238
+ if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
11239
+ }
11240
+ function ignoreRender(ui, value) {
11241
+ const {leafer: leafer} = ui;
11242
+ if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
11195
11243
  }
11196
- const {get: get$2, translate: translate} = MatrixHelper;
11244
+ const {get: get$3, translate: translate$1} = MatrixHelper;
11197
11245
  const tempBox = new Bounds;
11198
11246
  const tempScaleData = {};
11199
11247
  const tempImage = {};
@@ -11202,12 +11250,12 @@ var LeaferUI = function(exports) {
11202
11250
  if (changeful) leafPaint.changeful = changeful;
11203
11251
  if (sync) leafPaint.sync = sync;
11204
11252
  if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
11205
- leafPaint.data = getPatternData(paint, box, image);
11253
+ leafPaint.data = PaintImage.getPatternData(paint, box, image);
11206
11254
  }
11207
11255
  function getPatternData(paint, box, image) {
11208
11256
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
11209
11257
  if (paint.mode === "strench") paint.mode = "stretch";
11210
- let {width: width, height: height} = image;
11258
+ const {width: width, height: height} = image;
11211
11259
  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
11260
  const sameBox = box.width === width && box.height === height;
11213
11261
  const data = {
@@ -11238,8 +11286,8 @@ var LeaferUI = function(exports) {
11238
11286
  case "stretch":
11239
11287
  if (!sameBox) {
11240
11288
  scaleX = box.width / width, scaleY = box.height / height;
11241
- stretchMode(data, box, scaleX, scaleY);
11242
- }
11289
+ PaintImage.stretchMode(data, box, scaleX, scaleY);
11290
+ } else if (scaleX) scaleX = scaleY = undefined;
11243
11291
  break;
11244
11292
 
11245
11293
  case "normal":
@@ -11247,13 +11295,13 @@ var LeaferUI = function(exports) {
11247
11295
  if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
11248
11296
  let clipScaleX, clipScaleY;
11249
11297
  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);
11298
+ PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
11251
11299
  if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
11252
11300
  }
11253
11301
  break;
11254
11302
 
11255
11303
  case "repeat":
11256
- if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
11304
+ if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
11257
11305
  if (!repeat) data.repeat = "repeat";
11258
11306
  const count = isObject(repeat);
11259
11307
  if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
@@ -11262,18 +11310,16 @@ var LeaferUI = function(exports) {
11262
11310
  case "fit":
11263
11311
  case "cover":
11264
11312
  default:
11265
- if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11313
+ if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11266
11314
  }
11267
11315
  if (!data.transform) {
11268
- if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
11316
+ if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
11269
11317
  }
11270
- data.width = width;
11271
- data.height = height;
11272
11318
  if (scaleX) {
11273
11319
  data.scaleX = scaleX;
11274
11320
  data.scaleY = scaleY;
11275
11321
  }
11276
- if (opacity) data.opacity = opacity;
11322
+ if (opacity && opacity < 1) data.opacity = opacity;
11277
11323
  if (filters) data.filters = filters;
11278
11324
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
11279
11325
  return data;
@@ -11292,221 +11338,180 @@ var LeaferUI = function(exports) {
11292
11338
  const value = auto ? remain / ((rows || Math.floor(totalSize / size)) - 1) : gap;
11293
11339
  return gap === "auto" ? value < 0 ? 0 : value : value;
11294
11340
  }
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;
11341
+ let origin = {}, tempMatrix$1 = getMatrixData();
11342
+ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
11343
+ function stretchMode(data, box, scaleX, scaleY) {
11344
+ const transform = get$2(), {x: x, y: y} = box;
11345
+ if (x || y) translate(transform, x, y); else transform.onlyScale = true;
11346
+ scaleHelper(transform, scaleX, scaleY);
11347
+ data.transform = transform;
11348
+ }
11349
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
11350
+ const transform = get$2();
11351
+ translate(transform, box.x + x, box.y + y);
11352
+ scaleHelper(transform, scaleX, scaleY);
11353
+ if (rotation) rotateOfOuter$1(transform, {
11354
+ x: box.x + box.width / 2,
11355
+ y: box.y + box.height / 2
11356
+ }, rotation);
11357
+ data.transform = transform;
11358
+ }
11359
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
11360
+ const transform = get$2();
11361
+ layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
11362
+ if (clipScaleX) {
11363
+ if (rotation || skew) {
11364
+ set(tempMatrix$1);
11365
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
11366
+ multiplyParent(transform, tempMatrix$1);
11367
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
11313
11368
  }
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);
11369
+ data.transform = transform;
11370
+ }
11371
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
11372
+ const transform = get$2();
11373
+ if (freeTransform) {
11374
+ layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
11327
11375
  } 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");
11376
+ if (rotation) {
11377
+ if (align === "center") {
11378
+ rotateOfOuter$1(transform, {
11379
+ x: width / 2,
11380
+ y: height / 2
11381
+ }, rotation);
11382
+ } else {
11383
+ rotate(transform, rotation);
11384
+ switch (rotation) {
11385
+ case 90:
11386
+ translate(transform, height, 0);
11387
+ break;
11388
+
11389
+ case 180:
11390
+ translate(transform, width, height);
11391
+ break;
11392
+
11393
+ case 270:
11394
+ translate(transform, 0, width);
11395
+ break;
11352
11396
  }
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
11397
  }
11369
- return false;
11370
11398
  }
11399
+ origin.x = box.x + x;
11400
+ origin.y = box.y + y;
11401
+ translate(transform, origin.x, origin.y);
11402
+ if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
11371
11403
  }
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));
11404
+ data.transform = transform;
11388
11405
  }
11389
- function ignoreRender(ui, value) {
11390
- const {leafer: leafer} = ui;
11391
- if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
11406
+ function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
11407
+ if (rotation) rotate(transform, rotation);
11408
+ if (skew) skewHelper(transform, skew.x, skew.y);
11409
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
11410
+ translate(transform, box.x + x, box.y + y);
11392
11411
  }
11393
11412
  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;
11413
+ const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
11414
+ function createPatternTask(paint, ui, canvas, renderOptions) {
11415
+ if (!paint.patternTask) {
11416
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
11417
+ paint.patternTask = null;
11418
+ if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
11419
+ ui.forceUpdate("surface");
11420
+ }), 300);
11421
+ }
11422
+ }
11423
+ function createPattern(paint, ui, canvas, renderOptions) {
11424
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
11398
11425
  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) {
11426
+ if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
11427
+ const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11428
+ let imageMatrix, xGap, yGap, {width: width, height: height} = image;
11429
+ if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
11430
+ width *= scaleX;
11431
+ height *= scaleY;
11432
+ if (gap) {
11433
+ xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
11434
+ yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
11435
+ }
11436
+ if (transform || scaleX !== 1 || scaleY !== 1) {
11437
+ scaleX *= getFloorScale(width + (xGap || 0));
11438
+ scaleY *= getFloorScale(height + (yGap || 0));
11445
11439
  imageMatrix = get$1();
11446
11440
  if (transform) copy$1(imageMatrix, transform);
11441
+ scale(imageMatrix, 1 / scaleX, 1 / scaleY);
11447
11442
  }
11448
- scale(imageMatrix, 1 / scaleX, 1 / scaleY);
11443
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11444
+ const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11445
+ paint.style = pattern;
11446
+ paint.patternId = id;
11449
11447
  }
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;
11448
+ }
11449
+ }
11450
+ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
11451
+ const {image: image} = paint;
11452
+ let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
11453
+ if (image.isSVG) {
11454
+ if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
11455
11455
  } else {
11456
- return false;
11456
+ if (maxSize > imageSize) maxSize = imageSize;
11457
11457
  }
11458
+ if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
11459
+ return fixScale;
11458
11460
  }
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) {
11461
+ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
11462
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
11463
+ const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
11464
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
11463
11465
  return false;
11464
11466
  } else {
11465
- if (allowDraw) {
11467
+ if (drawImage) {
11466
11468
  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;
11469
+ drawImage = false;
11470
+ } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
11471
+ drawImage = Platform.image.isLarge(image, scaleX, scaleY);
11477
11472
  }
11478
11473
  }
11479
- if (allowDraw) {
11474
+ if (drawImage) {
11480
11475
  if (ui.__.__isFastShadow) {
11481
11476
  canvas.fillStyle = paint.style || "#000";
11482
11477
  canvas.fill();
11483
11478
  }
11484
- drawImage(ui, canvas, paint, data);
11479
+ PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
11485
11480
  return true;
11486
11481
  } 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
- }
11482
+ if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
11498
11483
  return false;
11499
11484
  }
11500
11485
  }
11501
11486
  }
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();
11487
+ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
11488
+ const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
11489
+ let {width: width, height: height} = image, clipUI;
11490
+ if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
11491
+ canvas.save();
11492
+ clipUI && canvas.clipUI(ui);
11493
+ blendMode && (canvas.blendMode = blendMode);
11494
+ opacity && (canvas.opacity *= opacity);
11495
+ transform && canvas.transform(transform);
11496
+ canvas.drawImage(view, 0, 0, width, height);
11497
+ canvas.restore();
11498
+ } else {
11499
+ if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
11500
+ canvas.drawImage(view, 0, 0, width, height);
11501
+ }
11502
+ }
11503
+ function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
11504
+ const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
11505
+ if (canvas) {
11506
+ const {pixelRatio: pixelRatio} = canvas;
11507
+ scaleData.scaleX *= pixelRatio;
11508
+ scaleData.scaleY *= pixelRatio;
11509
+ }
11510
+ if (data && data.scaleX) {
11511
+ scaleData.scaleX *= Math.abs(data.scaleX);
11512
+ scaleData.scaleY *= Math.abs(data.scaleY);
11513
+ }
11514
+ return scaleData;
11510
11515
  }
11511
11516
  function recycleImage(attrName, data) {
11512
11517
  const paints = data["_" + attrName];
@@ -11536,8 +11541,12 @@ var LeaferUI = function(exports) {
11536
11541
  const PaintImageModule = {
11537
11542
  image: image,
11538
11543
  checkImage: checkImage,
11539
- createPattern: createPattern,
11544
+ drawImage: drawImage,
11545
+ getImageRenderScaleData: getImageRenderScaleData,
11540
11546
  recycleImage: recycleImage,
11547
+ createPatternTask: createPatternTask,
11548
+ createPattern: createPattern,
11549
+ getPatternFixScale: getPatternFixScale,
11541
11550
  createData: createData,
11542
11551
  getPatternData: getPatternData,
11543
11552
  stretchMode: stretchMode,
@@ -11924,10 +11933,8 @@ var LeaferUI = function(exports) {
11924
11933
  bounds = drawData.bounds;
11925
11934
  findMaxWidth = !bounds.width && !style.autoSizeAlign;
11926
11935
  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) {
11936
+ const {canvas: canvas} = Platform, {width: width} = bounds;
11937
+ if (style.__isCharMode) {
11931
11938
  const wrap = style.textWrap !== "none";
11932
11939
  const breakAll = style.textWrap === "break";
11933
11940
  paraStart = true;
@@ -12048,12 +12055,19 @@ var LeaferUI = function(exports) {
12048
12055
  function layoutChar(drawData, style, width, _height) {
12049
12056
  const {rows: rows} = drawData;
12050
12057
  const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
12051
- let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
12058
+ const justifyLast = width && textAlign.includes("both");
12059
+ const justify = justifyLast || width && textAlign.includes("justify");
12060
+ const justifyLetter = justify && textAlign.includes("letter");
12061
+ let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
12052
12062
  rows.forEach(row => {
12053
12063
  if (row.words) {
12054
12064
  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;
12065
+ if (justify) {
12066
+ canJustify = !row.paraEnd || justifyLast;
12067
+ remainingWidth = width - row.width - indentWidth;
12068
+ if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
12069
+ }
12070
+ mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
12057
12071
  if (row.isOverflow && !letterSpacing) row.textMode = true;
12058
12072
  if (mode === TextMode) {
12059
12073
  row.x += indentWidth;
@@ -12071,11 +12085,15 @@ var LeaferUI = function(exports) {
12071
12085
  charX = toWordChar(word.data, charX, wordChar);
12072
12086
  if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
12073
12087
  } else {
12074
- charX = toChar(word.data, charX, row.data, row.isOverflow);
12088
+ charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
12075
12089
  }
12076
- if (addWordWidth && (!row.paraEnd || textAlign === "both") && index !== wordsLength - 1) {
12077
- charX += addWordWidth;
12078
- row.width += addWordWidth;
12090
+ if (canJustify) {
12091
+ isLastWord = index === wordsLength - 1;
12092
+ if (addWordWidth) {
12093
+ if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
12094
+ } else if (addLetterWidth) {
12095
+ row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
12096
+ }
12079
12097
  }
12080
12098
  });
12081
12099
  }
@@ -12098,13 +12116,14 @@ var LeaferUI = function(exports) {
12098
12116
  });
12099
12117
  return charX;
12100
12118
  }
12101
- function toChar(data, charX, rowData, isOverflow) {
12119
+ function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
12102
12120
  data.forEach(char => {
12103
12121
  if (isOverflow || char.char !== " ") {
12104
12122
  char.x = charX;
12105
12123
  rowData.push(char);
12106
12124
  }
12107
12125
  charX += char.width;
12126
+ addLetterWidth && (charX += addLetterWidth);
12108
12127
  });
12109
12128
  return charX;
12110
12129
  }
@@ -12240,10 +12259,10 @@ var LeaferUI = function(exports) {
12240
12259
  let x = 0, y = 0;
12241
12260
  let width = style.__getInput("width") || 0;
12242
12261
  let height = style.__getInput("height") || 0;
12243
- const {textDecoration: textDecoration, __font: __font, __padding: padding} = style;
12262
+ const {__padding: padding} = style;
12244
12263
  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];
12264
+ if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
12265
+ if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
12247
12266
  }
12248
12267
  const drawData = {
12249
12268
  bounds: {
@@ -12254,14 +12273,14 @@ var LeaferUI = function(exports) {
12254
12273
  },
12255
12274
  rows: [],
12256
12275
  paraNumber: 0,
12257
- font: Platform.canvas.font = __font
12276
+ font: Platform.canvas.font = style.__font
12258
12277
  };
12259
12278
  createRows(drawData, content, style);
12260
12279
  if (padding) padAutoText(padding, drawData, style, width, height);
12261
12280
  layoutText(drawData, style);
12262
- layoutChar(drawData, style, width);
12281
+ if (style.__isCharMode) layoutChar(drawData, style, width);
12263
12282
  if (drawData.overflow) clipText(drawData, style, x, width);
12264
- if (textDecoration !== "none") decorationText(drawData, style);
12283
+ if (style.textDecoration !== "none") decorationText(drawData, style);
12265
12284
  return drawData;
12266
12285
  }
12267
12286
  function padAutoText(padding, drawData, style, width, height) {
@@ -12386,6 +12405,7 @@ var LeaferUI = function(exports) {
12386
12405
  exports.MyDragEvent = MyDragEvent;
12387
12406
  exports.MyImage = MyImage;
12388
12407
  exports.MyPointerEvent = MyPointerEvent;
12408
+ exports.MyTouchEvent = MyTouchEvent;
12389
12409
  exports.NeedConvertToCanvasCommandMap = NeedConvertToCanvasCommandMap;
12390
12410
  exports.OneRadian = OneRadian;
12391
12411
  exports.PI2 = PI2;