@leafer/worker 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.
@@ -1,43 +1,3 @@
1
- const Platform = {
2
- toURL(text, fileType) {
3
- let url = encodeURIComponent(text);
4
- if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
5
- return url;
6
- },
7
- image: {
8
- hitCanvasSize: 100,
9
- maxCacheSize: 2560 * 1600,
10
- maxPatternSize: 4096 * 2160,
11
- crossOrigin: "anonymous",
12
- getRealURL(url) {
13
- const {prefix: prefix, suffix: suffix} = Platform.image;
14
- if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
15
- if (prefix && url[0] === "/") url = prefix + url;
16
- return url;
17
- }
18
- }
19
- };
20
-
21
- const IncrementId = {
22
- RUNTIME: "runtime",
23
- LEAF: "leaf",
24
- TASK: "task",
25
- CNAVAS: "canvas",
26
- IMAGE: "image",
27
- types: {},
28
- create(typeName) {
29
- const {types: types} = I$2;
30
- if (types[typeName]) {
31
- return types[typeName]++;
32
- } else {
33
- types[typeName] = 1;
34
- return 0;
35
- }
36
- }
37
- };
38
-
39
- const I$2 = IncrementId;
40
-
41
1
  var Answer;
42
2
 
43
3
  (function(Answer) {
@@ -61,7 +21,7 @@ function isString(value) {
61
21
  return typeof value === "string";
62
22
  }
63
23
 
64
- const {isFinite: isFinite} = Number;
24
+ const {isFinite: isFinite$1} = Number;
65
25
 
66
26
  function isNumber(value) {
67
27
  return typeof value === "number";
@@ -247,9 +207,80 @@ class LeafData {
247
207
  }
248
208
  }
249
209
 
210
+ const {floor: floor$3, max: max$6} = Math;
211
+
212
+ const Platform = {
213
+ toURL(text, fileType) {
214
+ let url = encodeURIComponent(text);
215
+ if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
216
+ return url;
217
+ },
218
+ image: {
219
+ hitCanvasSize: 100,
220
+ maxCacheSize: 2560 * 1600,
221
+ maxPatternSize: 4096 * 2160,
222
+ crossOrigin: "anonymous",
223
+ isLarge(size, scaleX, scaleY, largeSize) {
224
+ return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image$1.maxCacheSize);
225
+ },
226
+ isSuperLarge(size, scaleX, scaleY) {
227
+ return image$1.isLarge(size, scaleX, scaleY, image$1.maxPatternSize);
228
+ },
229
+ getRealURL(url) {
230
+ const {prefix: prefix, suffix: suffix} = Platform.image;
231
+ if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
232
+ if (prefix && url[0] === "/") url = prefix + url;
233
+ return url;
234
+ },
235
+ resize(image, width, height, xGap, yGap, clip, smooth, opacity, _filters) {
236
+ const canvas = Platform.origin.createCanvas(max$6(floor$3(width + (xGap || 0)), 1), max$6(floor$3(height + (yGap || 0)), 1));
237
+ const ctx = canvas.getContext("2d");
238
+ if (opacity) ctx.globalAlpha = opacity;
239
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
240
+ if (clip) {
241
+ const scaleX = width / clip.width, scaleY = height / clip.height;
242
+ ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
243
+ ctx.drawImage(image, 0, 0, image.width, image.height);
244
+ } else ctx.drawImage(image, 0, 0, width, height);
245
+ return canvas;
246
+ },
247
+ setPatternTransform(pattern, transform, paint) {
248
+ try {
249
+ if (transform && pattern.setTransform) {
250
+ pattern.setTransform(transform);
251
+ transform = undefined;
252
+ }
253
+ } catch (_a) {}
254
+ if (paint) DataHelper.stintSet(paint, "transform", transform);
255
+ }
256
+ }
257
+ };
258
+
259
+ const {image: image$1} = Platform;
260
+
261
+ const IncrementId = {
262
+ RUNTIME: "runtime",
263
+ LEAF: "leaf",
264
+ TASK: "task",
265
+ CNAVAS: "canvas",
266
+ IMAGE: "image",
267
+ types: {},
268
+ create(typeName) {
269
+ const {types: types} = I$2;
270
+ if (types[typeName]) {
271
+ return types[typeName]++;
272
+ } else {
273
+ types[typeName] = 1;
274
+ return 0;
275
+ }
276
+ }
277
+ };
278
+
279
+ const I$2 = IncrementId;
280
+
250
281
  let tempA, tempB, tempTo;
251
282
 
252
- const {max: max$6} = Math, tempFour = [ 0, 0, 0, 0 ];
283
+ const {max: max$5} = Math, tempFour = [ 0, 0, 0, 0 ];
253
284
 
254
285
  const FourNumberHelper = {
255
286
  zero: [ ...tempFour ],
@@ -301,9 +332,9 @@ const FourNumberHelper = {
301
332
  return data;
302
333
  },
303
334
  max(t, other, change) {
304
- if (isNumber(t) && isNumber(other)) return max$6(t, other);
335
+ if (isNumber(t) && isNumber(other)) return max$5(t, other);
305
336
  toTempAB(t, other, change);
306
- return set$2(tempTo, max$6(tempA[0], tempB[0]), max$6(tempA[1], tempB[1]), max$6(tempA[2], tempB[2]), max$6(tempA[3], tempB[3]));
337
+ 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]));
307
338
  },
308
339
  add(t, other, change) {
309
340
  if (isNumber(t) && isNumber(other)) return t + other;
@@ -320,7 +351,7 @@ const FourNumberHelper = {
320
351
 
321
352
  const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
322
353
 
323
- const {round: round$6, pow: pow$2, PI: PI$4} = Math;
354
+ const {round: round$6, pow: pow$2, max: max$4, floor: floor$2, PI: PI$4} = Math;
324
355
 
325
356
  const MathHelper = {
326
357
  within(value, min, max) {
@@ -373,6 +404,9 @@ const MathHelper = {
373
404
  scaleData.scaleY = scale.y;
374
405
  }
375
406
  },
407
+ getFloorScale(num, min = 1) {
408
+ return max$4(floor$2(num), min) / num;
409
+ },
376
410
  randInt: randInt,
377
411
  randColor(opacity) {
378
412
  return `rgba(${randInt(255)},${randInt(255)},${randInt(255)},${opacity || 1})`;
@@ -1202,7 +1236,7 @@ const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1202
1236
 
1203
1237
  const {float: float$2, fourNumber: fourNumber$1} = MathHelper;
1204
1238
 
1205
- const {floor: floor$3, ceil: ceil$3} = Math;
1239
+ const {floor: floor$1, ceil: ceil$2} = Math;
1206
1240
 
1207
1241
  let right$4, bottom$3, boundsRight, boundsBottom;
1208
1242
 
@@ -1294,20 +1328,20 @@ const BoundsHelper = {
1294
1328
  toOuterOf(t, matrix, to) {
1295
1329
  to || (to = t);
1296
1330
  if (matrix.b === 0 && matrix.c === 0) {
1297
- const {a: a, d: d} = matrix;
1331
+ const {a: a, d: d, e: e, f: f} = matrix;
1298
1332
  if (a > 0) {
1299
1333
  to.width = t.width * a;
1300
- to.x = matrix.e + t.x * a;
1334
+ to.x = e + t.x * a;
1301
1335
  } else {
1302
1336
  to.width = t.width * -a;
1303
- to.x = matrix.e + t.x * a - to.width;
1337
+ to.x = e + t.x * a - to.width;
1304
1338
  }
1305
1339
  if (d > 0) {
1306
1340
  to.height = t.height * d;
1307
- to.y = matrix.f + t.y * d;
1341
+ to.y = f + t.y * d;
1308
1342
  } else {
1309
1343
  to.height = t.height * -d;
1310
- to.y = matrix.f + t.y * d - to.height;
1344
+ to.y = f + t.y * d - to.height;
1311
1345
  }
1312
1346
  } else {
1313
1347
  point$2.x = t.x;
@@ -1359,10 +1393,10 @@ const BoundsHelper = {
1359
1393
  },
1360
1394
  ceil(t) {
1361
1395
  const {x: x, y: y} = t;
1362
- t.x = floor$3(t.x);
1363
- t.y = floor$3(t.y);
1364
- t.width = x > t.x ? ceil$3(t.width + x - t.x) : ceil$3(t.width);
1365
- t.height = y > t.y ? ceil$3(t.height + y - t.y) : ceil$3(t.height);
1396
+ t.x = floor$1(t.x);
1397
+ t.y = floor$1(t.y);
1398
+ t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
1399
+ t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
1366
1400
  },
1367
1401
  unsign(t) {
1368
1402
  if (t.width < 0) {
@@ -2592,7 +2626,7 @@ const RectHelper = {
2592
2626
  }
2593
2627
  };
2594
2628
 
2595
- const {sin: sin$4, cos: cos$4, hypot: hypot, atan2: atan2$1, ceil: ceil$2, abs: abs$9, PI: PI$3, sqrt: sqrt$3, pow: pow$1} = Math;
2629
+ const {sin: sin$4, cos: cos$4, hypot: hypot, atan2: atan2$1, ceil: ceil$1, abs: abs$9, PI: PI$3, sqrt: sqrt$3, pow: pow$1} = Math;
2596
2630
 
2597
2631
  const {setPoint: setPoint$4, addPoint: addPoint$2} = TwoPointBoundsHelper;
2598
2632
 
@@ -2700,7 +2734,7 @@ const BezierHelper = {
2700
2734
  let totalRadian = endRadian - startRadian;
2701
2735
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2702
2736
  if (anticlockwise) totalRadian -= PI2;
2703
- const parts = ceil$2(abs$9(totalRadian / PI_2));
2737
+ const parts = ceil$1(abs$9(totalRadian / PI_2));
2704
2738
  const partRadian = totalRadian / parts;
2705
2739
  const partRadian4Sin = sin$4(partRadian / 4);
2706
2740
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$4(partRadian / 2);
@@ -3708,7 +3742,9 @@ class TaskItem {
3708
3742
  run() {
3709
3743
  return __awaiter(this, void 0, void 0, function*() {
3710
3744
  try {
3711
- if (this.task && !this.isComplete && this.parent.running) yield this.task();
3745
+ if (this.isComplete) return;
3746
+ if (this.canUse && !this.canUse()) return this.cancel();
3747
+ if (this.task && this.parent.running) yield this.task();
3712
3748
  } catch (error) {
3713
3749
  debug$c.error(error);
3714
3750
  }
@@ -3716,8 +3752,7 @@ class TaskItem {
3716
3752
  }
3717
3753
  complete() {
3718
3754
  this.isComplete = true;
3719
- this.parent = null;
3720
- this.task = null;
3755
+ this.parent = this.task = this.canUse = null;
3721
3756
  }
3722
3757
  cancel() {
3723
3758
  this.isCancel = true;
@@ -3760,7 +3795,7 @@ class TaskProcessor {
3760
3795
  if (config) DataHelper.assign(this.config, config);
3761
3796
  this.empty();
3762
3797
  }
3763
- add(taskCallback, options) {
3798
+ add(taskCallback, options, canUse) {
3764
3799
  let start, parallel, time, delay;
3765
3800
  const task = new TaskItem(taskCallback);
3766
3801
  task.parent = this;
@@ -3771,9 +3806,11 @@ class TaskProcessor {
3771
3806
  start = options.start;
3772
3807
  time = options.time;
3773
3808
  delay = options.delay;
3809
+ if (!canUse) canUse = options.canUse;
3774
3810
  }
3775
3811
  if (time) task.time = time;
3776
3812
  if (parallel === false) task.parallel = false;
3813
+ if (canUse) task.canUse = canUse;
3777
3814
  if (isUndefined(delay)) {
3778
3815
  this.push(task, start);
3779
3816
  } else {
@@ -3843,15 +3880,10 @@ class TaskProcessor {
3843
3880
  this.timer = setTimeout(() => this.nextTask());
3844
3881
  return;
3845
3882
  }
3846
- if (task.isCancel) {
3847
- this.index++;
3848
- this.runTask();
3849
- return;
3850
- }
3851
3883
  task.run().then(() => {
3852
3884
  this.onTask(task);
3853
3885
  this.index++;
3854
- this.nextTask();
3886
+ task.isCancel ? this.runTask() : this.nextTask();
3855
3887
  }).catch(error => {
3856
3888
  this.onError(error);
3857
3889
  });
@@ -4027,8 +4059,6 @@ const I$1 = ImageManager;
4027
4059
 
4028
4060
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
4029
4061
 
4030
- const {floor: floor$2, max: max$5} = Math;
4031
-
4032
4062
  class LeaferImage {
4033
4063
  get url() {
4034
4064
  return this.config.url;
@@ -4053,10 +4083,9 @@ class LeaferImage {
4053
4083
  load(onSuccess, onError) {
4054
4084
  if (!this.loading) {
4055
4085
  this.loading = true;
4056
- let {loadImage: loadImage, loadImageWithProgress: loadImageWithProgress} = Platform.origin, onProgress = this.config.showProgress && loadImageWithProgress && this.onProgress.bind(this);
4057
- if (onProgress) loadImage = loadImageWithProgress;
4086
+ const {crossOrigin: crossOrigin} = this.config;
4058
4087
  Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
4059
- return yield loadImage(this.url, onProgress).then(img => this.setView(img)).catch(e => {
4088
+ return yield Platform.origin.loadImage(this.url, isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin, this).then(img => this.setView(img)).catch(e => {
4060
4089
  this.error = e;
4061
4090
  this.onComplete(false);
4062
4091
  });
@@ -4082,9 +4111,6 @@ class LeaferImage {
4082
4111
  this.view = img;
4083
4112
  this.onComplete(true);
4084
4113
  }
4085
- onProgress(progress) {
4086
- this.progress = progress;
4087
- }
4088
4114
  onComplete(isSuccess) {
4089
4115
  let odd;
4090
4116
  this.waitComplete.forEach((item, index) => {
@@ -4103,7 +4129,7 @@ class LeaferImage {
4103
4129
  getFull(_filters) {
4104
4130
  return this.view;
4105
4131
  }
4106
- getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
4132
+ getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
4107
4133
  width || (width = this.width);
4108
4134
  height || (height = this.height);
4109
4135
  if (this.cache) {
@@ -4116,11 +4142,7 @@ class LeaferImage {
4116
4142
  }
4117
4143
  if (data) return data;
4118
4144
  }
4119
- const canvas = Platform.origin.createCanvas(max$5(floor$2(width + (xGap || 0)), 1), max$5(floor$2(height + (yGap || 0)), 1));
4120
- const ctx = canvas.getContext("2d");
4121
- if (opacity) ctx.globalAlpha = opacity;
4122
- ctx.imageSmoothingEnabled = smooth === false ? false : true;
4123
- ctx.drawImage(this.view, 0, 0, width, height);
4145
+ const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
4124
4146
  this.cache = this.use > 1 ? {
4125
4147
  data: canvas,
4126
4148
  params: arguments
@@ -4129,13 +4151,7 @@ class LeaferImage {
4129
4151
  }
4130
4152
  getPattern(canvas, repeat, transform, paint) {
4131
4153
  const pattern = Platform.canvas.createPattern(canvas, repeat);
4132
- try {
4133
- if (transform && pattern.setTransform) {
4134
- pattern.setTransform(transform);
4135
- transform = undefined;
4136
- }
4137
- } catch (_a) {}
4138
- if (paint) DataHelper.stintSet(paint, "transform", transform);
4154
+ Platform.image.setPatternTransform(pattern, transform, paint);
4139
4155
  return pattern;
4140
4156
  }
4141
4157
  destroy() {
@@ -5726,7 +5742,7 @@ const LeafDataProxy = {
5726
5742
  __setAttr(name, newValue, checkFiniteNumber) {
5727
5743
  if (this.leaferIsCreated) {
5728
5744
  const oldValue = this.__.__getInput(name);
5729
- if (checkFiniteNumber && !isFinite(newValue) && !isUndefined(newValue)) {
5745
+ if (checkFiniteNumber && !isFinite$1(newValue) && !isUndefined(newValue)) {
5730
5746
  debug$9.warn(this.innerName, name, newValue);
5731
5747
  newValue = undefined;
5732
5748
  }
@@ -5809,12 +5825,12 @@ const {toBounds: toBounds$1} = PathBounds;
5809
5825
 
5810
5826
  const LeafBounds = {
5811
5827
  __updateWorldBounds() {
5812
- const layout = this.__layout;
5813
- toOuterOf$2(layout.renderBounds, this.__world, this.__world);
5814
- if (layout.resized) {
5815
- if (layout.resized === "inner") this.__onUpdateSize();
5828
+ const {__layout: __layout, __world: __world} = this;
5829
+ toOuterOf$2(__layout.renderBounds, __world, __world);
5830
+ if (__layout.resized) {
5831
+ if (__layout.resized === "inner") this.__onUpdateSize();
5816
5832
  if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
5817
- layout.resized = undefined;
5833
+ __layout.resized = undefined;
5818
5834
  }
5819
5835
  if (this.__hasWorldEvent) BoundsEvent.emitWorld(this);
5820
5836
  },
@@ -6012,7 +6028,7 @@ const tempScaleData$1 = {};
6012
6028
 
6013
6029
  const {LEAF: LEAF, create: create} = IncrementId;
6014
6030
 
6015
- const {stintSet: stintSet$3} = DataHelper;
6031
+ const {stintSet: stintSet$4} = DataHelper;
6016
6032
 
6017
6033
  const {toInnerPoint: toInnerPoint, toOuterPoint: toOuterPoint, multiplyParent: multiplyParent$1} = MatrixHelper;
6018
6034
 
@@ -6295,8 +6311,8 @@ let Leaf = class Leaf {
6295
6311
  const cameraWorld = this.__cameraWorld, world = this.__world;
6296
6312
  multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
6297
6313
  toOuterOf$1(this.__layout.renderBounds, cameraWorld, cameraWorld);
6298
- stintSet$3(cameraWorld, "half", world.half);
6299
- stintSet$3(cameraWorld, "ignorePixelSnap", world.ignorePixelSnap);
6314
+ stintSet$4(cameraWorld, "half", world.half);
6315
+ stintSet$4(cameraWorld, "ignorePixelSnap", world.ignorePixelSnap);
6300
6316
  return cameraWorld;
6301
6317
  } else {
6302
6318
  return this.__world;
@@ -6819,7 +6835,7 @@ class LeafLevelList {
6819
6835
  }
6820
6836
  }
6821
6837
 
6822
- const version = "1.9.12";
6838
+ const version = "1.10.1";
6823
6839
 
6824
6840
  class LeaferCanvas extends LeaferCanvasBase {
6825
6841
  get allowBackgroundColor() {
@@ -7594,6 +7610,7 @@ class Picker {
7594
7610
  hit = child.__.hitRadius ? true : hitRadiusPoint$1(child.__world, point);
7595
7611
  if (child.isBranch) {
7596
7612
  if (hit || child.__ignoreHitWorld) {
7613
+ if (child.isBranchLeaf && child.__.__clipAfterFill && !child.__hitWorld(point)) continue;
7597
7614
  if (child.topChildren) this.eachFind(child.topChildren, false);
7598
7615
  this.eachFind(child.children, child.__onlyHitMask);
7599
7616
  if (child.isBranchLeaf) this.hitChild(child, point);
@@ -7786,7 +7803,7 @@ const Transition = {
7786
7803
 
7787
7804
  const {parse: parse, objectToCanvasData: objectToCanvasData} = PathConvert;
7788
7805
 
7789
- const {stintSet: stintSet$2} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
7806
+ const {stintSet: stintSet$3} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
7790
7807
 
7791
7808
  const emptyPaint = {};
7792
7809
 
@@ -7853,7 +7870,7 @@ class UIData extends LeafData {
7853
7870
  setFill(value) {
7854
7871
  if (this.__naturalWidth) this.__removeNaturalSize();
7855
7872
  if (isString(value) || !value) {
7856
- stintSet$2(this, "__isTransparentFill", hasTransparent$2(value));
7873
+ stintSet$3(this, "__isTransparentFill", hasTransparent$2(value));
7857
7874
  this.__isFills && this.__removePaint("fill", true);
7858
7875
  this._fill = value;
7859
7876
  } else if (isObject(value)) {
@@ -7862,7 +7879,7 @@ class UIData extends LeafData {
7862
7879
  }
7863
7880
  setStroke(value) {
7864
7881
  if (isString(value) || !value) {
7865
- stintSet$2(this, "__isTransparentStroke", hasTransparent$2(value));
7882
+ stintSet$3(this, "__isTransparentStroke", hasTransparent$2(value));
7866
7883
  this.__isStrokes && this.__removePaint("stroke", true);
7867
7884
  this._stroke = value;
7868
7885
  } else if (isObject(value)) {
@@ -7920,11 +7937,11 @@ class UIData extends LeafData {
7920
7937
  if (removeInput) this.__removeInput(attrName);
7921
7938
  PaintImage.recycleImage(attrName, this);
7922
7939
  if (attrName === "fill") {
7923
- stintSet$2(this, "__isAlphaPixelFill", undefined);
7940
+ stintSet$3(this, "__isAlphaPixelFill", undefined);
7924
7941
  this._fill = this.__isFills = undefined;
7925
7942
  } else {
7926
- stintSet$2(this, "__isAlphaPixelStroke", undefined);
7927
- stintSet$2(this, "__hasMultiStrokeStyle", undefined);
7943
+ stintSet$3(this, "__isAlphaPixelStroke", undefined);
7944
+ stintSet$3(this, "__hasMultiStrokeStyle", undefined);
7928
7945
  this._stroke = this.__isStrokes = undefined;
7929
7946
  }
7930
7947
  }
@@ -8073,7 +8090,7 @@ class CanvasData extends RectData {
8073
8090
  }
8074
8091
  }
8075
8092
 
8076
- const {max: max$4, add: add$1} = FourNumberHelper;
8093
+ const {max: max$3, add: add$1} = FourNumberHelper;
8077
8094
 
8078
8095
  const UIBounds = {
8079
8096
  __updateStrokeSpread() {
@@ -8089,7 +8106,7 @@ const UIBounds = {
8089
8106
  }
8090
8107
  if (data.__useArrow) spread += strokeWidth * 5;
8091
8108
  if (box) {
8092
- spread = max$4(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
8109
+ spread = max$3(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
8093
8110
  boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
8094
8111
  }
8095
8112
  this.__layout.strokeBoxSpread = boxSpread;
@@ -8099,35 +8116,35 @@ const UIBounds = {
8099
8116
  let spread = 0;
8100
8117
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
8101
8118
  if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
8102
- if (blur) spread = max$4(spread, blur);
8119
+ if (blur) spread = max$3(spread, blur);
8103
8120
  if (filter) spread = add$1(spread, Filter.getSpread(filter));
8104
8121
  if (renderSpread) spread = add$1(spread, renderSpread);
8105
8122
  if (strokeSpread) spread = add$1(spread, strokeSpread);
8106
8123
  let shapeSpread = spread;
8107
- if (innerShadow) shapeSpread = max$4(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
8108
- if (backgroundBlur) shapeSpread = max$4(shapeSpread, backgroundBlur);
8124
+ if (innerShadow) shapeSpread = max$3(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
8125
+ if (backgroundBlur) shapeSpread = max$3(shapeSpread, backgroundBlur);
8109
8126
  this.__layout.renderShapeSpread = shapeSpread;
8110
- return box ? max$4(box.__updateRenderSpread(), spread) : spread;
8127
+ return box ? max$3(box.__updateRenderSpread(), spread) : spread;
8111
8128
  }
8112
8129
  };
8113
8130
 
8114
- const {stintSet: stintSet$1} = DataHelper;
8131
+ const {stintSet: stintSet$2} = DataHelper;
8115
8132
 
8116
8133
  const UIRender = {
8117
8134
  __updateChange() {
8118
8135
  const data = this.__;
8119
8136
  if (data.__useStroke) {
8120
8137
  const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
8121
- stintSet$1(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
8122
- stintSet$1(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
8138
+ stintSet$2(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
8139
+ stintSet$2(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
8123
8140
  }
8124
8141
  if (data.__useEffect) {
8125
8142
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
8126
- 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"));
8143
+ 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"));
8127
8144
  data.__useEffect = !!(shadow || otherEffect);
8128
8145
  }
8129
8146
  data.__checkSingle();
8130
- stintSet$1(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
8147
+ stintSet$2(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
8131
8148
  },
8132
8149
  __drawFast(canvas, options) {
8133
8150
  drawFast(this, canvas, options);
@@ -8143,24 +8160,24 @@ const UIRender = {
8143
8160
  this.__nowWorld = this.__getNowWorld(options);
8144
8161
  const {shadow: shadow, innerShadow: innerShadow, filter: filter} = data;
8145
8162
  if (shadow) Effect.shadow(this, canvas, shape);
8146
- if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
8147
- if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
8163
+ if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
8164
+ if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
8148
8165
  if (__drawAfterFill) this.__drawAfterFill(canvas, options);
8149
8166
  if (innerShadow) Effect.innerShadow(this, canvas, shape);
8150
- if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
8167
+ if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
8151
8168
  if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
8152
8169
  if (shape.worldCanvas) shape.worldCanvas.recycle();
8153
8170
  shape.canvas.recycle();
8154
8171
  } else {
8155
- if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
8172
+ if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
8156
8173
  if (__isFastShadow) {
8157
8174
  const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
8158
8175
  canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
8159
8176
  }
8160
- if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
8177
+ if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
8161
8178
  if (__isFastShadow) canvas.restore();
8162
8179
  if (__drawAfterFill) this.__drawAfterFill(canvas, options);
8163
- if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
8180
+ if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
8164
8181
  }
8165
8182
  } else {
8166
8183
  if (data.__pathInputed) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
@@ -8169,9 +8186,9 @@ const UIRender = {
8169
8186
  __drawShape(canvas, options) {
8170
8187
  this.__drawRenderPath(canvas);
8171
8188
  const data = this.__, {fill: fill, stroke: stroke} = data;
8172
- if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill("#000000", this, canvas);
8189
+ if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas, options) : Paint.fill("#000000", this, canvas, options);
8173
8190
  if (data.__isCanvas) this.__drawAfterFill(canvas, options);
8174
- if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke("#000000", this, canvas);
8191
+ if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke("#000000", this, canvas, options);
8175
8192
  },
8176
8193
  __drawAfterFill(canvas, options) {
8177
8194
  if (this.__.__clipAfterFill) {
@@ -8186,10 +8203,10 @@ const UIRender = {
8186
8203
  function drawFast(ui, canvas, options) {
8187
8204
  const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke} = ui.__;
8188
8205
  ui.__drawRenderPath(canvas);
8189
- if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
8190
- if (fill) Paint.fill(fill, ui, canvas);
8206
+ if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
8207
+ if (fill) Paint.fill(fill, ui, canvas, options);
8191
8208
  if (__drawAfterFill) ui.__drawAfterFill(canvas, options);
8192
- if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
8209
+ if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
8193
8210
  }
8194
8211
 
8195
8212
  const RectRender = {
@@ -8327,8 +8344,8 @@ let UI = UI_1 = class UI extends Leaf {
8327
8344
  drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
8328
8345
  } else drawer.rect(x, y, width, height);
8329
8346
  }
8330
- drawImagePlaceholder(canvas, _image) {
8331
- Paint.fill(this.__.placeholderColor, this, canvas);
8347
+ drawImagePlaceholder(_paint, canvas, renderOptions) {
8348
+ Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
8332
8349
  }
8333
8350
  animate(keyframe, _options, _type, _isTemp) {
8334
8351
  this.set(keyframe);
@@ -9350,7 +9367,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
9350
9367
 
9351
9368
  Canvas = __decorate([ registerUI() ], Canvas);
9352
9369
 
9353
- const {copyAndSpread: copyAndSpread$2, includes: includes, spread: spread, setList: setList} = BoundsHelper;
9370
+ const {copyAndSpread: copyAndSpread$2, includes: includes, spread: spread, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
9354
9371
 
9355
9372
  let Text = class Text extends UI {
9356
9373
  get __tag() {
@@ -9362,13 +9379,14 @@ let Text = class Text extends UI {
9362
9379
  }
9363
9380
  __updateTextDrawData() {
9364
9381
  const data = this.__;
9365
- const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
9382
+ const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
9366
9383
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
9367
9384
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
9368
- data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
9369
9385
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
9370
9386
  data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
9371
- data.__clipText = textOverflow !== "show" && !data.__autoSize;
9387
+ stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
9388
+ stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
9389
+ stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
9372
9390
  data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
9373
9391
  }
9374
9392
  __updateBoxBounds() {
@@ -9776,7 +9794,7 @@ class UIEvent extends Event {
9776
9794
  }
9777
9795
  }
9778
9796
 
9779
- const {min: min, max: max$3, abs: abs$7} = Math, {float: float$1, sign: sign$2} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
9797
+ const {min: min, max: max$2, abs: abs$7} = Math, {float: float$1, sign: sign$2} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
9780
9798
 
9781
9799
  const tempContent = new Bounds, tempDragBounds = new Bounds;
9782
9800
 
@@ -9833,7 +9851,7 @@ const DragBoundsHelper = {
9833
9851
  bSize = float$1(tempDragBounds.maxX - tempContent.maxX);
9834
9852
  aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
9835
9853
  bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
9836
- correctScaleX *= max$3(aScale, bScale);
9854
+ correctScaleX *= max$2(aScale, bScale);
9837
9855
  } else {
9838
9856
  if (scale.x < 0) {
9839
9857
  if (float$1(minX(content) - minX(dragBounds)) <= 0 || float$1(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
@@ -9851,9 +9869,9 @@ const DragBoundsHelper = {
9851
9869
  bSize = float$1(tempDragBounds.maxY - tempContent.maxY);
9852
9870
  aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
9853
9871
  bScale = originBottomScale && bSize > 0 ? 1 + bSize / (originBottomScale * tempContent.height) : 1;
9854
- correctScaleY *= max$3(aScale, bScale);
9872
+ correctScaleY *= max$2(aScale, bScale);
9855
9873
  if (lockRatio) {
9856
- aScale = max$3(abs$7(correctScaleX), abs$7(correctScaleY));
9874
+ aScale = max$2(abs$7(correctScaleX), abs$7(correctScaleY));
9857
9875
  correctScaleX = sign$2(correctScaleX) * aScale;
9858
9876
  correctScaleY = sign$2(correctScaleY) * aScale;
9859
9877
  }
@@ -9868,8 +9886,8 @@ const DragBoundsHelper = {
9868
9886
  bScale = originBottomScale && bSize > 0 ? 1 - bSize / (originBottomScale * tempContent.height) : 1;
9869
9887
  correctScaleY *= min(aScale, bScale);
9870
9888
  }
9871
- scale.x *= isFinite(correctScaleX) ? correctScaleX : 1;
9872
- scale.y *= isFinite(correctScaleY) ? correctScaleY : 1;
9889
+ scale.x *= isFinite$1(correctScaleX) ? correctScaleX : 1;
9890
+ scale.y *= isFinite$1(correctScaleY) ? correctScaleY : 1;
9873
9891
  return scale;
9874
9892
  }
9875
9893
  };
@@ -10019,6 +10037,12 @@ MoveEvent.END = "move.end";
10019
10037
 
10020
10038
  MoveEvent = __decorate([ registerUIEvent() ], MoveEvent);
10021
10039
 
10040
+ let TouchEvent = class TouchEvent extends UIEvent {};
10041
+
10042
+ TouchEvent = __decorate([ registerUIEvent() ], TouchEvent);
10043
+
10044
+ const MyTouchEvent = TouchEvent;
10045
+
10022
10046
  let RotateEvent = class RotateEvent extends PointerEvent {};
10023
10047
 
10024
10048
  RotateEvent.BEFORE_ROTATE = "rotate.before_rotate";
@@ -11067,102 +11091,163 @@ canvas$1.hitPixel = function(radiusPoint, offset, scale = 1) {
11067
11091
  return data[3] > 0;
11068
11092
  };
11069
11093
 
11070
- function fillText(ui, canvas) {
11071
- const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
11072
- if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
11073
- let row;
11074
- for (let i = 0, len = rows.length; i < len; i++) {
11075
- row = rows[i];
11076
- if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
11077
- canvas.fillText(charData.char, charData.x, row.y);
11078
- });
11079
- }
11080
- if (decorationY) {
11081
- const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
11082
- if (decorationColor) canvas.fillStyle = decorationColor;
11083
- rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
11084
- }
11085
- }
11086
-
11087
- function fill(fill, ui, canvas) {
11094
+ function fill(fill, ui, canvas, renderOptions) {
11088
11095
  canvas.fillStyle = fill;
11089
- fillPathOrText(ui, canvas);
11096
+ fillPathOrText(ui, canvas, renderOptions);
11090
11097
  }
11091
11098
 
11092
- function fills(fills, ui, canvas) {
11093
- let item;
11099
+ function fills(fills, ui, canvas, renderOptions) {
11100
+ let item, originPaint, countImage;
11094
11101
  for (let i = 0, len = fills.length; i < len; i++) {
11095
- item = fills[i];
11102
+ item = fills[i], originPaint = item.originPaint;
11096
11103
  if (item.image) {
11097
- if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font)) continue;
11104
+ countImage ? countImage++ : countImage = 1;
11105
+ if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
11098
11106
  if (!item.style) {
11099
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas, item.image);
11107
+ if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
11100
11108
  continue;
11101
11109
  }
11102
11110
  }
11103
11111
  canvas.fillStyle = item.style;
11104
- if (item.transform || item.scaleFixed) {
11112
+ if (item.transform || originPaint.scaleFixed) {
11105
11113
  canvas.save();
11106
11114
  if (item.transform) canvas.transform(item.transform);
11107
- if (item.scaleFixed) {
11115
+ if (originPaint.scaleFixed) {
11108
11116
  const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
11109
- if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
11117
+ if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
11110
11118
  }
11111
- if (item.blendMode) canvas.blendMode = item.blendMode;
11112
- fillPathOrText(ui, canvas);
11119
+ if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
11120
+ fillPathOrText(ui, canvas, renderOptions);
11113
11121
  canvas.restore();
11114
11122
  } else {
11115
- if (item.blendMode) {
11116
- canvas.saveBlendMode(item.blendMode);
11117
- fillPathOrText(ui, canvas);
11123
+ if (originPaint.blendMode) {
11124
+ canvas.saveBlendMode(originPaint.blendMode);
11125
+ fillPathOrText(ui, canvas, renderOptions);
11118
11126
  canvas.restoreBlendMode();
11119
- } else fillPathOrText(ui, canvas);
11127
+ } else fillPathOrText(ui, canvas, renderOptions);
11128
+ }
11129
+ }
11130
+ }
11131
+
11132
+ function fillPathOrText(ui, canvas, renderOptions) {
11133
+ ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
11134
+ }
11135
+
11136
+ function fillText(ui, canvas, _renderOptions) {
11137
+ const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
11138
+ if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
11139
+ let row;
11140
+ for (let i = 0, len = rows.length; i < len; i++) {
11141
+ row = rows[i];
11142
+ if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
11143
+ canvas.fillText(charData.char, charData.x, row.y);
11144
+ });
11145
+ }
11146
+ if (decorationY) {
11147
+ const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
11148
+ if (decorationColor) canvas.fillStyle = decorationColor;
11149
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
11150
+ }
11151
+ }
11152
+
11153
+ function stroke(stroke, ui, canvas, renderOptions) {
11154
+ const data = ui.__;
11155
+ if (!data.__strokeWidth) return;
11156
+ if (data.__font) {
11157
+ Paint.strokeText(stroke, ui, canvas, renderOptions);
11158
+ } else {
11159
+ switch (data.strokeAlign) {
11160
+ case "center":
11161
+ drawCenter$1(stroke, 1, ui, canvas, renderOptions);
11162
+ break;
11163
+
11164
+ case "inside":
11165
+ drawInside(stroke, ui, canvas, renderOptions);
11166
+ break;
11167
+
11168
+ case "outside":
11169
+ drawOutside(stroke, ui, canvas, renderOptions);
11170
+ break;
11120
11171
  }
11121
11172
  }
11122
11173
  }
11123
11174
 
11124
- function fillPathOrText(ui, canvas) {
11125
- ui.__.__font ? fillText(ui, canvas) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
11175
+ function strokes(strokes, ui, canvas, renderOptions) {
11176
+ Paint.stroke(strokes, ui, canvas, renderOptions);
11177
+ }
11178
+
11179
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
11180
+ const data = ui.__;
11181
+ if (isObject(stroke)) {
11182
+ Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
11183
+ } else {
11184
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
11185
+ canvas.stroke();
11186
+ }
11187
+ if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
11188
+ }
11189
+
11190
+ function drawInside(stroke, ui, canvas, renderOptions) {
11191
+ canvas.save();
11192
+ canvas.clipUI(ui);
11193
+ drawCenter$1(stroke, 2, ui, canvas, renderOptions);
11194
+ canvas.restore();
11195
+ }
11196
+
11197
+ function drawOutside(stroke, ui, canvas, renderOptions) {
11198
+ const data = ui.__;
11199
+ if (data.__fillAfterStroke) {
11200
+ drawCenter$1(stroke, 2, ui, canvas, renderOptions);
11201
+ } else {
11202
+ const {renderBounds: renderBounds} = ui.__layout;
11203
+ const out = canvas.getSameCanvas(true, true);
11204
+ ui.__drawRenderPath(out);
11205
+ drawCenter$1(stroke, 2, ui, out, renderOptions);
11206
+ out.clipUI(data);
11207
+ out.clearWorld(renderBounds);
11208
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
11209
+ out.recycle(ui.__nowWorld);
11210
+ }
11126
11211
  }
11127
11212
 
11128
- function strokeText(stroke, ui, canvas) {
11213
+ function strokeText(stroke, ui, canvas, renderOptions) {
11129
11214
  switch (ui.__.strokeAlign) {
11130
11215
  case "center":
11131
- drawCenter$1(stroke, 1, ui, canvas);
11216
+ drawCenter(stroke, 1, ui, canvas, renderOptions);
11132
11217
  break;
11133
11218
 
11134
11219
  case "inside":
11135
- drawAlign(stroke, "inside", ui, canvas);
11220
+ drawAlign(stroke, "inside", ui, canvas, renderOptions);
11136
11221
  break;
11137
11222
 
11138
11223
  case "outside":
11139
- ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, "outside", ui, canvas);
11224
+ ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
11140
11225
  break;
11141
11226
  }
11142
11227
  }
11143
11228
 
11144
- function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
11229
+ function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
11145
11230
  const data = ui.__;
11146
11231
  if (isObject(stroke)) {
11147
- drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
11232
+ Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
11148
11233
  } else {
11149
11234
  canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
11150
- drawTextStroke(ui, canvas);
11235
+ Paint.drawTextStroke(ui, canvas, renderOptions);
11151
11236
  }
11152
11237
  }
11153
11238
 
11154
- function drawAlign(stroke, align, ui, canvas) {
11239
+ function drawAlign(stroke, align, ui, canvas, renderOptions) {
11155
11240
  const out = canvas.getSameCanvas(true, true);
11156
11241
  out.font = ui.__.__font;
11157
- drawCenter$1(stroke, 2, ui, out);
11242
+ drawCenter(stroke, 2, ui, out, renderOptions);
11158
11243
  out.blendMode = align === "outside" ? "destination-out" : "destination-in";
11159
- fillText(ui, out);
11244
+ Paint.fillText(ui, out, renderOptions);
11160
11245
  out.blendMode = "normal";
11161
11246
  LeafHelper.copyCanvasByWorld(ui, canvas, out);
11162
11247
  out.recycle(ui.__nowWorld);
11163
11248
  }
11164
11249
 
11165
- function drawTextStroke(ui, canvas) {
11250
+ function drawTextStroke(ui, canvas, _renderOptions) {
11166
11251
  let row, data = ui.__.__textDrawData;
11167
11252
  const {rows: rows, decorationY: decorationY} = data;
11168
11253
  for (let i = 0, len = rows.length; i < len; i++) {
@@ -11177,89 +11262,29 @@ function drawTextStroke(ui, canvas) {
11177
11262
  }
11178
11263
  }
11179
11264
 
11180
- function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
11265
+ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
11181
11266
  let item;
11182
11267
  const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
11183
11268
  __hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
11184
11269
  for (let i = 0, len = strokes.length; i < len; i++) {
11185
11270
  item = strokes[i];
11186
- if (item.image && PaintImage.checkImage(ui, canvas, item, false)) continue;
11271
+ if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
11187
11272
  if (item.style) {
11188
11273
  if (__hasMultiStrokeStyle) {
11189
11274
  const {strokeStyle: strokeStyle} = item;
11190
11275
  strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
11191
11276
  } else canvas.strokeStyle = item.style;
11192
- if (item.blendMode) {
11193
- canvas.saveBlendMode(item.blendMode);
11194
- isText ? drawTextStroke(ui, canvas) : canvas.stroke();
11277
+ if (item.originPaint.blendMode) {
11278
+ canvas.saveBlendMode(item.originPaint.blendMode);
11279
+ isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
11195
11280
  canvas.restoreBlendMode();
11196
11281
  } else {
11197
- isText ? drawTextStroke(ui, canvas) : canvas.stroke();
11282
+ isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
11198
11283
  }
11199
11284
  }
11200
11285
  }
11201
11286
  }
11202
11287
 
11203
- function stroke(stroke, ui, canvas) {
11204
- const data = ui.__;
11205
- if (!data.__strokeWidth) return;
11206
- if (data.__font) {
11207
- strokeText(stroke, ui, canvas);
11208
- } else {
11209
- switch (data.strokeAlign) {
11210
- case "center":
11211
- drawCenter(stroke, 1, ui, canvas);
11212
- break;
11213
-
11214
- case "inside":
11215
- drawInside(stroke, ui, canvas);
11216
- break;
11217
-
11218
- case "outside":
11219
- drawOutside(stroke, ui, canvas);
11220
- break;
11221
- }
11222
- }
11223
- }
11224
-
11225
- function strokes(strokes, ui, canvas) {
11226
- stroke(strokes, ui, canvas);
11227
- }
11228
-
11229
- function drawCenter(stroke, strokeWidthScale, ui, canvas) {
11230
- const data = ui.__;
11231
- if (isObject(stroke)) {
11232
- drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
11233
- } else {
11234
- canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
11235
- canvas.stroke();
11236
- }
11237
- if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas);
11238
- }
11239
-
11240
- function drawInside(stroke, ui, canvas) {
11241
- canvas.save();
11242
- canvas.clipUI(ui);
11243
- drawCenter(stroke, 2, ui, canvas);
11244
- canvas.restore();
11245
- }
11246
-
11247
- function drawOutside(stroke, ui, canvas) {
11248
- const data = ui.__;
11249
- if (data.__fillAfterStroke) {
11250
- drawCenter(stroke, 2, ui, canvas);
11251
- } else {
11252
- const {renderBounds: renderBounds} = ui.__layout;
11253
- const out = canvas.getSameCanvas(true, true);
11254
- ui.__drawRenderPath(out);
11255
- drawCenter(stroke, 2, ui, out);
11256
- out.clipUI(data);
11257
- out.clearWorld(renderBounds);
11258
- LeafHelper.copyCanvasByWorld(ui, canvas, out);
11259
- out.recycle(ui.__nowWorld);
11260
- }
11261
- }
11262
-
11263
11288
  const {getSpread: getSpread, copyAndSpread: copyAndSpread$1, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$7, getIntersectData: getIntersectData} = BoundsHelper;
11264
11289
 
11265
11290
  const tempBounds$1 = {};
@@ -11347,62 +11372,63 @@ function compute(attrName, ui) {
11347
11372
  if (leafPaints.some(item => item.image)) isAlphaPixel = true;
11348
11373
  isTransparent = true;
11349
11374
  }
11350
- }
11351
- if (attrName === "fill") {
11352
- stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
11353
- stintSet(data, "__isTransparentFill", isTransparent);
11375
+ if (attrName === "fill") {
11376
+ stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
11377
+ stintSet(data, "__isTransparentFill", isTransparent);
11378
+ } else {
11379
+ stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
11380
+ stintSet(data, "__isTransparentStroke", isTransparent);
11381
+ stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
11382
+ }
11354
11383
  } else {
11355
- stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
11356
- stintSet(data, "__isTransparentStroke", isTransparent);
11357
- stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
11384
+ data.__removePaint(attrName, false);
11358
11385
  }
11359
11386
  }
11360
11387
 
11361
11388
  function getLeafPaint(attrName, paint, ui) {
11362
11389
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
11363
- let data;
11390
+ let leafPaint;
11364
11391
  const {boxBounds: boxBounds} = ui.__layout;
11365
11392
  switch (paint.type) {
11366
11393
  case "image":
11367
- data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11394
+ leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11368
11395
  break;
11369
11396
 
11370
11397
  case "linear":
11371
- data = PaintGradient.linearGradient(paint, boxBounds);
11398
+ leafPaint = PaintGradient.linearGradient(paint, boxBounds);
11372
11399
  break;
11373
11400
 
11374
11401
  case "radial":
11375
- data = PaintGradient.radialGradient(paint, boxBounds);
11402
+ leafPaint = PaintGradient.radialGradient(paint, boxBounds);
11376
11403
  break;
11377
11404
 
11378
11405
  case "angular":
11379
- data = PaintGradient.conicGradient(paint, boxBounds);
11406
+ leafPaint = PaintGradient.conicGradient(paint, boxBounds);
11380
11407
  break;
11381
11408
 
11382
11409
  case "solid":
11383
11410
  const {type: type, color: color, opacity: opacity} = paint;
11384
- data = {
11411
+ leafPaint = {
11385
11412
  type: type,
11386
11413
  style: ColorConvert.string(color, opacity)
11387
11414
  };
11388
11415
  break;
11389
11416
 
11390
11417
  default:
11391
- if (!isUndefined(paint.r)) data = {
11418
+ if (!isUndefined(paint.r)) leafPaint = {
11392
11419
  type: "solid",
11393
11420
  style: ColorConvert.string(paint)
11394
11421
  };
11395
11422
  }
11396
- if (data) {
11397
- if (isString(data.style) && hasTransparent$1(data.style)) data.isTransparent = true;
11423
+ if (leafPaint) {
11424
+ leafPaint.originPaint = paint;
11425
+ if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
11398
11426
  if (paint.style) {
11399
11427
  if (paint.style.strokeWidth === 0) return undefined;
11400
- data.strokeStyle = paint.style;
11428
+ leafPaint.strokeStyle = paint.style;
11401
11429
  }
11402
- if (paint.editing) data.editing = paint.editing;
11403
- if (paint.blendMode) data.blendMode = paint.blendMode;
11404
11430
  }
11405
- return data;
11431
+ return leafPaint;
11406
11432
  }
11407
11433
 
11408
11434
  const PaintModule = {
@@ -11415,88 +11441,118 @@ const PaintModule = {
11415
11441
  strokes: strokes,
11416
11442
  strokeText: strokeText,
11417
11443
  drawTextStroke: drawTextStroke,
11444
+ drawStrokesStyle: drawStrokesStyle,
11418
11445
  shape: shape
11419
11446
  };
11420
11447
 
11421
- let origin$1 = {}, tempMatrix$1 = getMatrixData();
11422
-
11423
- const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper} = MatrixHelper;
11424
-
11425
- function stretchMode(data, box, scaleX, scaleY) {
11426
- const transform = get$3();
11427
- translate$1(transform, box.x, box.y);
11428
- if (scaleX) scaleHelper(transform, scaleX, scaleY);
11429
- data.transform = transform;
11430
- }
11448
+ let cache$1, box$1 = new Bounds;
11431
11449
 
11432
- function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
11433
- const transform = get$3();
11434
- translate$1(transform, box.x + x, box.y + y);
11435
- scaleHelper(transform, scaleX, scaleY);
11436
- if (rotation) rotateOfOuter$1(transform, {
11437
- x: box.x + box.width / 2,
11438
- y: box.y + box.height / 2
11439
- }, rotation);
11440
- data.transform = transform;
11441
- }
11450
+ const {isSame: isSame} = BoundsHelper;
11442
11451
 
11443
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
11444
- const transform = get$3();
11445
- layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew);
11446
- if (clipScaleX) {
11447
- if (rotation || skew) {
11448
- set(tempMatrix$1);
11449
- scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
11450
- multiplyParent(transform, tempMatrix$1);
11451
- } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
11452
+ function image(ui, attrName, paint, boxBounds, firstUse) {
11453
+ let leafPaint, event;
11454
+ const image = ImageManager.get(paint);
11455
+ if (cache$1 && paint === cache$1.paint && isSame(boxBounds, cache$1.boxBounds)) {
11456
+ leafPaint = cache$1.leafPaint;
11457
+ } else {
11458
+ leafPaint = {
11459
+ type: paint.type,
11460
+ image: image
11461
+ };
11462
+ if (image.hasAlphaPixel) leafPaint.isTransparent = true;
11463
+ cache$1 = image.use > 1 ? {
11464
+ leafPaint: leafPaint,
11465
+ paint: paint,
11466
+ boxBounds: box$1.set(boxBounds)
11467
+ } : null;
11452
11468
  }
11453
- data.transform = transform;
11454
- }
11455
-
11456
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
11457
- const transform = get$3();
11458
- if (freeTransform) {
11459
- layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew);
11469
+ if (firstUse || image.loading) event = {
11470
+ image: image,
11471
+ attrName: attrName,
11472
+ attrValue: paint
11473
+ };
11474
+ if (image.ready) {
11475
+ checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
11476
+ if (firstUse) {
11477
+ onLoad(ui, event);
11478
+ onLoadSuccess(ui, event);
11479
+ }
11480
+ } else if (image.error) {
11481
+ if (firstUse) onLoadError(ui, event, image.error);
11460
11482
  } else {
11461
- if (rotation) {
11462
- if (align === "center") {
11463
- rotateOfOuter$1(transform, {
11464
- x: width / 2,
11465
- y: height / 2
11466
- }, rotation);
11467
- } else {
11468
- rotate$2(transform, rotation);
11469
- switch (rotation) {
11470
- case 90:
11471
- translate$1(transform, height, 0);
11472
- break;
11473
-
11474
- case 180:
11475
- translate$1(transform, width, height);
11476
- break;
11477
-
11478
- case 270:
11479
- translate$1(transform, 0, width);
11480
- break;
11483
+ if (firstUse) {
11484
+ ignoreRender(ui, true);
11485
+ onLoad(ui, event);
11486
+ }
11487
+ leafPaint.loadId = image.load(() => {
11488
+ ignoreRender(ui, false);
11489
+ if (!ui.destroyed) {
11490
+ if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
11491
+ if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
11492
+ ui.forceUpdate("surface");
11481
11493
  }
11494
+ onLoadSuccess(ui, event);
11482
11495
  }
11496
+ leafPaint.loadId = undefined;
11497
+ }, error => {
11498
+ ignoreRender(ui, false);
11499
+ onLoadError(ui, event, error);
11500
+ leafPaint.loadId = undefined;
11501
+ });
11502
+ if (ui.placeholderColor) {
11503
+ if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
11504
+ if (!image.ready) {
11505
+ image.isPlacehold = true;
11506
+ ui.forceUpdate("surface");
11507
+ }
11508
+ }, ui.placeholderDelay);
11483
11509
  }
11484
- origin$1.x = box.x + x;
11485
- origin$1.y = box.y + y;
11486
- translate$1(transform, origin$1.x, origin$1.y);
11487
- if (scaleX) scaleOfOuter$1(transform, origin$1, scaleX, scaleY);
11488
11510
  }
11489
- data.transform = transform;
11511
+ return leafPaint;
11490
11512
  }
11491
11513
 
11492
- function layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew) {
11493
- if (rotation) rotate$2(transform, rotation);
11494
- if (skew) skewHelper(transform, skew.x, skew.y);
11495
- if (scaleX) scaleHelper(transform, scaleX, scaleY);
11496
- translate$1(transform, box.x + x, box.y + y);
11514
+ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
11515
+ if (attrName === "fill" && !ui.__.__naturalWidth) {
11516
+ const data = ui.__;
11517
+ data.__naturalWidth = image.width / data.pixelRatio;
11518
+ data.__naturalHeight = image.height / data.pixelRatio;
11519
+ if (data.__autoSide) {
11520
+ ui.forceUpdate("width");
11521
+ if (ui.__proxyData) {
11522
+ ui.setProxyAttr("width", data.width);
11523
+ ui.setProxyAttr("height", data.height);
11524
+ }
11525
+ return false;
11526
+ }
11527
+ }
11528
+ if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
11529
+ return true;
11530
+ }
11531
+
11532
+ function onLoad(ui, event) {
11533
+ emit(ui, ImageEvent.LOAD, event);
11534
+ }
11535
+
11536
+ function onLoadSuccess(ui, event) {
11537
+ emit(ui, ImageEvent.LOADED, event);
11538
+ }
11539
+
11540
+ function onLoadError(ui, event, error) {
11541
+ event.error = error;
11542
+ ui.forceUpdate("surface");
11543
+ emit(ui, ImageEvent.ERROR, event);
11544
+ }
11545
+
11546
+ function emit(ui, type, data) {
11547
+ if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
11548
+ }
11549
+
11550
+ function ignoreRender(ui, value) {
11551
+ const {leafer: leafer} = ui;
11552
+ if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
11497
11553
  }
11498
11554
 
11499
- const {get: get$2, translate: translate} = MatrixHelper;
11555
+ const {get: get$3, translate: translate$1} = MatrixHelper;
11500
11556
 
11501
11557
  const tempBox = new Bounds;
11502
11558
 
@@ -11505,17 +11561,13 @@ const tempScaleData = {};
11505
11561
  const tempImage = {};
11506
11562
 
11507
11563
  function createData(leafPaint, image, paint, box) {
11508
- const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
11509
- if (changeful) leafPaint.changeful = changeful;
11510
- if (sync) leafPaint.sync = sync;
11511
- if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
11512
- leafPaint.data = getPatternData(paint, box, image);
11564
+ leafPaint.data = PaintImage.getPatternData(paint, box, image);
11513
11565
  }
11514
11566
 
11515
11567
  function getPatternData(paint, box, image) {
11516
11568
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
11517
11569
  if (paint.mode === "strench") paint.mode = "stretch";
11518
- let {width: width, height: height} = image;
11570
+ const {width: width, height: height} = image;
11519
11571
  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;
11520
11572
  const sameBox = box.width === width && box.height === height;
11521
11573
  const data = {
@@ -11546,8 +11598,8 @@ function getPatternData(paint, box, image) {
11546
11598
  case "stretch":
11547
11599
  if (!sameBox) {
11548
11600
  scaleX = box.width / width, scaleY = box.height / height;
11549
- stretchMode(data, box, scaleX, scaleY);
11550
- }
11601
+ PaintImage.stretchMode(data, box, scaleX, scaleY);
11602
+ } else if (scaleX) scaleX = scaleY = undefined;
11551
11603
  break;
11552
11604
 
11553
11605
  case "normal":
@@ -11555,13 +11607,13 @@ function getPatternData(paint, box, image) {
11555
11607
  if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
11556
11608
  let clipScaleX, clipScaleY;
11557
11609
  if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
11558
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
11610
+ PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
11559
11611
  if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
11560
11612
  }
11561
11613
  break;
11562
11614
 
11563
11615
  case "repeat":
11564
- if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
11616
+ if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
11565
11617
  if (!repeat) data.repeat = "repeat";
11566
11618
  const count = isObject(repeat);
11567
11619
  if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
@@ -11570,18 +11622,16 @@ function getPatternData(paint, box, image) {
11570
11622
  case "fit":
11571
11623
  case "cover":
11572
11624
  default:
11573
- if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11625
+ if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11574
11626
  }
11575
11627
  if (!data.transform) {
11576
- if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
11628
+ if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
11577
11629
  }
11578
- data.width = width;
11579
- data.height = height;
11580
11630
  if (scaleX) {
11581
11631
  data.scaleX = scaleX;
11582
11632
  data.scaleY = scaleY;
11583
11633
  }
11584
- if (opacity) data.opacity = opacity;
11634
+ if (opacity && opacity < 1) data.opacity = opacity;
11585
11635
  if (filters) data.filters = filters;
11586
11636
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
11587
11637
  return data;
@@ -11603,234 +11653,194 @@ function getGapValue(gap, size, totalSize, rows) {
11603
11653
  return gap === "auto" ? value < 0 ? 0 : value : value;
11604
11654
  }
11605
11655
 
11606
- let cache$1, box$1 = new Bounds;
11656
+ let origin$1 = {}, tempMatrix$1 = getMatrixData();
11607
11657
 
11608
- const {isSame: isSame} = BoundsHelper;
11658
+ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper} = MatrixHelper;
11609
11659
 
11610
- function image(ui, attrName, paint, boxBounds, firstUse) {
11611
- let leafPaint, event;
11612
- const image = ImageManager.get(paint);
11613
- if (cache$1 && paint === cache$1.paint && isSame(boxBounds, cache$1.boxBounds)) {
11614
- leafPaint = cache$1.leafPaint;
11615
- } else {
11616
- leafPaint = {
11617
- type: paint.type,
11618
- image: image
11619
- };
11620
- if (image.hasAlphaPixel) leafPaint.isTransparent = true;
11621
- cache$1 = image.use > 1 ? {
11622
- leafPaint: leafPaint,
11623
- paint: paint,
11624
- boxBounds: box$1.set(boxBounds)
11625
- } : null;
11626
- }
11627
- if (firstUse || image.loading) event = {
11628
- image: image,
11629
- attrName: attrName,
11630
- attrValue: paint
11631
- };
11632
- if (image.ready) {
11633
- checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
11634
- if (firstUse) {
11635
- onLoad(ui, event);
11636
- onLoadSuccess(ui, event);
11637
- }
11638
- } else if (image.error) {
11639
- if (firstUse) onLoadError(ui, event, image.error);
11640
- } else {
11641
- if (firstUse) {
11642
- ignoreRender(ui, true);
11643
- onLoad(ui, event);
11644
- }
11645
- leafPaint.loadId = image.load(() => {
11646
- ignoreRender(ui, false);
11647
- if (!ui.destroyed) {
11648
- if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
11649
- if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
11650
- ui.forceUpdate("surface");
11651
- }
11652
- onLoadSuccess(ui, event);
11653
- }
11654
- leafPaint.loadId = undefined;
11655
- }, error => {
11656
- ignoreRender(ui, false);
11657
- onLoadError(ui, event, error);
11658
- leafPaint.loadId = undefined;
11659
- });
11660
- if (ui.placeholderColor) {
11661
- if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
11662
- if (!image.ready) {
11663
- image.isPlacehold = true;
11664
- ui.forceUpdate("surface");
11665
- }
11666
- }, ui.placeholderDelay);
11667
- }
11668
- }
11669
- return leafPaint;
11660
+ function stretchMode(data, box, scaleX, scaleY) {
11661
+ const transform = get$2(), {x: x, y: y} = box;
11662
+ if (x || y) translate(transform, x, y); else transform.onlyScale = true;
11663
+ scaleHelper(transform, scaleX, scaleY);
11664
+ data.transform = transform;
11670
11665
  }
11671
11666
 
11672
- function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
11673
- if (attrName === "fill" && !ui.__.__naturalWidth) {
11674
- const data = ui.__;
11675
- data.__naturalWidth = image.width / data.pixelRatio;
11676
- data.__naturalHeight = image.height / data.pixelRatio;
11677
- if (data.__autoSide) {
11678
- ui.forceUpdate("width");
11679
- if (ui.__proxyData) {
11680
- ui.setProxyAttr("width", data.width);
11681
- ui.setProxyAttr("height", data.height);
11682
- }
11683
- return false;
11684
- }
11685
- }
11686
- if (!leafPaint.data) createData(leafPaint, image, paint, boxBounds);
11687
- return true;
11667
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
11668
+ const transform = get$2();
11669
+ translate(transform, box.x + x, box.y + y);
11670
+ scaleHelper(transform, scaleX, scaleY);
11671
+ if (rotation) rotateOfOuter$1(transform, {
11672
+ x: box.x + box.width / 2,
11673
+ y: box.y + box.height / 2
11674
+ }, rotation);
11675
+ data.transform = transform;
11688
11676
  }
11689
11677
 
11690
- function onLoad(ui, event) {
11691
- emit(ui, ImageEvent.LOAD, event);
11678
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
11679
+ const transform = get$2();
11680
+ layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew);
11681
+ if (clipScaleX) {
11682
+ if (rotation || skew) {
11683
+ set(tempMatrix$1);
11684
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
11685
+ multiplyParent(transform, tempMatrix$1);
11686
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
11687
+ }
11688
+ data.transform = transform;
11692
11689
  }
11693
11690
 
11694
- function onLoadSuccess(ui, event) {
11695
- emit(ui, ImageEvent.LOADED, event);
11696
- }
11691
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
11692
+ const transform = get$2();
11693
+ if (freeTransform) {
11694
+ layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew);
11695
+ } else {
11696
+ if (rotation) {
11697
+ if (align === "center") {
11698
+ rotateOfOuter$1(transform, {
11699
+ x: width / 2,
11700
+ y: height / 2
11701
+ }, rotation);
11702
+ } else {
11703
+ rotate$2(transform, rotation);
11704
+ switch (rotation) {
11705
+ case 90:
11706
+ translate(transform, height, 0);
11707
+ break;
11697
11708
 
11698
- function onLoadError(ui, event, error) {
11699
- event.error = error;
11700
- ui.forceUpdate("surface");
11701
- emit(ui, ImageEvent.ERROR, event);
11702
- }
11709
+ case 180:
11710
+ translate(transform, width, height);
11711
+ break;
11703
11712
 
11704
- function emit(ui, type, data) {
11705
- if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
11713
+ case 270:
11714
+ translate(transform, 0, width);
11715
+ break;
11716
+ }
11717
+ }
11718
+ }
11719
+ origin$1.x = box.x + x;
11720
+ origin$1.y = box.y + y;
11721
+ translate(transform, origin$1.x, origin$1.y);
11722
+ if (scaleX) scaleOfOuter$1(transform, origin$1, scaleX, scaleY);
11723
+ }
11724
+ data.transform = transform;
11706
11725
  }
11707
11726
 
11708
- function ignoreRender(ui, value) {
11709
- const {leafer: leafer} = ui;
11710
- if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
11727
+ function layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew) {
11728
+ if (rotation) rotate$2(transform, rotation);
11729
+ if (skew) skewHelper(transform, skew.x, skew.y);
11730
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
11731
+ translate(transform, box.x + x, box.y + y);
11711
11732
  }
11712
11733
 
11713
11734
  const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
11714
11735
 
11715
- const {floor: floor$1, ceil: ceil$1, max: max$2, abs: abs$6} = Math;
11736
+ const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$6} = Math;
11737
+
11738
+ function createPatternTask(paint, ui, canvas, renderOptions) {
11739
+ if (!paint.patternTask) {
11740
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
11741
+ paint.patternTask = null;
11742
+ if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
11743
+ ui.forceUpdate("surface");
11744
+ }), 300);
11745
+ }
11746
+ }
11716
11747
 
11717
- function createPattern(ui, paint, pixelRatio) {
11718
- let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
11719
- const id = scaleX + "-" + scaleY + "-" + pixelRatio;
11748
+ function createPattern(paint, ui, canvas, renderOptions) {
11749
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
11720
11750
  if (paint.patternId !== id && !ui.destroyed) {
11721
- const {image: image, data: data} = paint;
11722
- let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
11723
- scaleX *= pixelRatio;
11724
- scaleY *= pixelRatio;
11725
- if (sx) {
11726
- sx = abs$6(sx);
11727
- sy = abs$6(sy);
11728
- imageMatrix = get$1();
11729
- copy$4(imageMatrix, transform);
11730
- scale$2(imageMatrix, 1 / sx, 1 / sy);
11731
- scaleX *= sx;
11732
- scaleY *= sy;
11733
- }
11734
- width *= scaleX;
11735
- height *= scaleY;
11736
- const size = width * height;
11737
- if (!repeat) {
11738
- if (size > Platform.image.maxCacheSize) return false;
11739
- }
11740
- let maxSize = Platform.image.maxPatternSize;
11741
- if (image.isSVG) {
11742
- const ws = width / image.width;
11743
- if (ws > 1) imageScale = ws / ceil$1(ws);
11744
- } else {
11745
- const imageSize = image.width * image.height;
11746
- if (maxSize > imageSize) maxSize = imageSize;
11747
- }
11748
- if (size > maxSize) imageScale = Math.sqrt(size / maxSize);
11749
- if (imageScale) {
11750
- scaleX /= imageScale;
11751
- scaleY /= imageScale;
11752
- width /= imageScale;
11753
- height /= imageScale;
11754
- }
11755
- if (sx) {
11756
- scaleX /= sx;
11757
- scaleY /= sy;
11758
- }
11759
- const xGap = gap && gap.x * scaleX;
11760
- const yGap = gap && gap.y * scaleY;
11761
- if (transform || scaleX !== 1 || scaleY !== 1) {
11762
- const canvasWidth = width + (xGap || 0);
11763
- const canvasHeight = height + (yGap || 0);
11764
- scaleX /= canvasWidth / max$2(floor$1(canvasWidth), 1);
11765
- scaleY /= canvasHeight / max$2(floor$1(canvasHeight), 1);
11766
- if (!imageMatrix) {
11751
+ if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
11752
+ const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11753
+ let imageMatrix, xGap, yGap, {width: width, height: height} = image;
11754
+ if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
11755
+ width *= scaleX;
11756
+ height *= scaleY;
11757
+ if (gap) {
11758
+ xGap = gap.x * scaleX / abs$6(data.scaleX || 1);
11759
+ yGap = gap.y * scaleY / abs$6(data.scaleY || 1);
11760
+ }
11761
+ if (transform || scaleX !== 1 || scaleY !== 1) {
11762
+ scaleX *= getFloorScale(width + (xGap || 0));
11763
+ scaleY *= getFloorScale(height + (yGap || 0));
11767
11764
  imageMatrix = get$1();
11768
11765
  if (transform) copy$4(imageMatrix, transform);
11766
+ scale$2(imageMatrix, 1 / scaleX, 1 / scaleY);
11769
11767
  }
11770
- scale$2(imageMatrix, 1 / scaleX, 1 / scaleY);
11768
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11769
+ const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11770
+ paint.style = pattern;
11771
+ paint.patternId = id;
11771
11772
  }
11772
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11773
- const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11774
- paint.style = pattern;
11775
- paint.patternId = id;
11776
- return true;
11773
+ }
11774
+ }
11775
+
11776
+ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
11777
+ const {image: image} = paint;
11778
+ let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
11779
+ if (image.isSVG) {
11780
+ if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
11777
11781
  } else {
11778
- return false;
11782
+ if (maxSize > imageSize) maxSize = imageSize;
11779
11783
  }
11784
+ if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
11785
+ return fixScale;
11780
11786
  }
11781
11787
 
11782
- function checkImage(ui, canvas, paint, allowDraw) {
11783
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
11784
- const {pixelRatio: pixelRatio} = canvas, {data: data} = paint;
11785
- if (!data || paint.patternId === scaleX + "-" + scaleY + "-" + pixelRatio && !Export.running) {
11788
+ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
11789
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
11790
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
11791
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
11786
11792
  return false;
11787
11793
  } else {
11788
- if (allowDraw) {
11794
+ if (drawImage) {
11789
11795
  if (data.repeat) {
11790
- allowDraw = false;
11791
- } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
11792
- let {width: width, height: height} = data;
11793
- width *= scaleX * pixelRatio;
11794
- height *= scaleY * pixelRatio;
11795
- if (data.scaleX) {
11796
- width *= data.scaleX;
11797
- height *= data.scaleY;
11798
- }
11799
- allowDraw = width * height > Platform.image.maxCacheSize;
11796
+ drawImage = false;
11797
+ } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
11798
+ drawImage = Platform.image.isLarge(image, scaleX, scaleY);
11800
11799
  }
11801
11800
  }
11802
- if (allowDraw) {
11801
+ if (drawImage) {
11803
11802
  if (ui.__.__isFastShadow) {
11804
11803
  canvas.fillStyle = paint.style || "#000";
11805
11804
  canvas.fill();
11806
11805
  }
11807
- drawImage(ui, canvas, paint, data);
11806
+ PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
11808
11807
  return true;
11809
11808
  } else {
11810
- if (!paint.style || paint.sync || Export.running) {
11811
- createPattern(ui, paint, pixelRatio);
11812
- } else {
11813
- if (!paint.patternTask) {
11814
- paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
11815
- paint.patternTask = null;
11816
- if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio);
11817
- ui.forceUpdate("surface");
11818
- }), 300);
11819
- }
11820
- }
11809
+ if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
11821
11810
  return false;
11822
11811
  }
11823
11812
  }
11824
11813
  }
11825
11814
 
11826
- function drawImage(ui, canvas, paint, data) {
11827
- canvas.save();
11828
- canvas.clipUI(ui);
11829
- if (paint.blendMode) canvas.blendMode = paint.blendMode;
11830
- if (data.opacity) canvas.opacity *= data.opacity;
11831
- if (data.transform) canvas.transform(data.transform);
11832
- canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
11833
- canvas.restore();
11815
+ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
11816
+ const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
11817
+ let {width: width, height: height} = image, clipUI;
11818
+ if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
11819
+ canvas.save();
11820
+ clipUI && canvas.clipUI(ui);
11821
+ blendMode && (canvas.blendMode = blendMode);
11822
+ opacity && (canvas.opacity *= opacity);
11823
+ transform && canvas.transform(transform);
11824
+ canvas.drawImage(view, 0, 0, width, height);
11825
+ canvas.restore();
11826
+ } else {
11827
+ if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
11828
+ canvas.drawImage(view, 0, 0, width, height);
11829
+ }
11830
+ }
11831
+
11832
+ function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
11833
+ const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
11834
+ if (canvas) {
11835
+ const {pixelRatio: pixelRatio} = canvas;
11836
+ scaleData.scaleX *= pixelRatio;
11837
+ scaleData.scaleY *= pixelRatio;
11838
+ }
11839
+ if (data && data.scaleX) {
11840
+ scaleData.scaleX *= Math.abs(data.scaleX);
11841
+ scaleData.scaleY *= Math.abs(data.scaleY);
11842
+ }
11843
+ return scaleData;
11834
11844
  }
11835
11845
 
11836
11846
  function recycleImage(attrName, data) {
@@ -11862,8 +11872,12 @@ function recycleImage(attrName, data) {
11862
11872
  const PaintImageModule = {
11863
11873
  image: image,
11864
11874
  checkImage: checkImage,
11865
- createPattern: createPattern,
11875
+ drawImage: drawImage,
11876
+ getImageRenderScaleData: getImageRenderScaleData,
11866
11877
  recycleImage: recycleImage,
11878
+ createPatternTask: createPatternTask,
11879
+ createPattern: createPattern,
11880
+ getPatternFixScale: getPatternFixScale,
11867
11881
  createData: createData,
11868
11882
  getPatternData: getPatternData,
11869
11883
  stretchMode: stretchMode,
@@ -12319,10 +12333,8 @@ function createRows(drawData, content, style) {
12319
12333
  bounds$3 = drawData.bounds;
12320
12334
  findMaxWidth = !bounds$3.width && !style.autoSizeAlign;
12321
12335
  const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
12322
- const {canvas: canvas} = Platform;
12323
- const {width: width, height: height} = bounds$3;
12324
- const charMode = width || height || __letterSpacing || textCase !== "none";
12325
- if (charMode) {
12336
+ const {canvas: canvas} = Platform, {width: width} = bounds$3;
12337
+ if (style.__isCharMode) {
12326
12338
  const wrap = style.textWrap !== "none";
12327
12339
  const breakAll = style.textWrap === "break";
12328
12340
  paraStart = true;
@@ -12451,12 +12463,19 @@ const TextMode = 2;
12451
12463
  function layoutChar(drawData, style, width, _height) {
12452
12464
  const {rows: rows} = drawData;
12453
12465
  const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
12454
- let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
12466
+ const justifyLast = width && textAlign.includes("both");
12467
+ const justify = justifyLast || width && textAlign.includes("justify");
12468
+ const justifyLetter = justify && textAlign.includes("letter");
12469
+ let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
12455
12470
  rows.forEach(row => {
12456
12471
  if (row.words) {
12457
12472
  indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
12458
- addWordWidth = width && (textAlign === "justify" || textAlign === "both") && wordsLength > 1 ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
12459
- mode = letterSpacing || row.isOverflow ? CharMode : addWordWidth > .01 ? WordMode : TextMode;
12473
+ if (justify) {
12474
+ canJustify = !row.paraEnd || justifyLast;
12475
+ remainingWidth = width - row.width - indentWidth;
12476
+ if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
12477
+ }
12478
+ mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
12460
12479
  if (row.isOverflow && !letterSpacing) row.textMode = true;
12461
12480
  if (mode === TextMode) {
12462
12481
  row.x += indentWidth;
@@ -12474,11 +12493,15 @@ function layoutChar(drawData, style, width, _height) {
12474
12493
  charX = toWordChar(word.data, charX, wordChar);
12475
12494
  if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
12476
12495
  } else {
12477
- charX = toChar(word.data, charX, row.data, row.isOverflow);
12496
+ charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
12478
12497
  }
12479
- if (addWordWidth && (!row.paraEnd || textAlign === "both") && index !== wordsLength - 1) {
12480
- charX += addWordWidth;
12481
- row.width += addWordWidth;
12498
+ if (canJustify) {
12499
+ isLastWord = index === wordsLength - 1;
12500
+ if (addWordWidth) {
12501
+ if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
12502
+ } else if (addLetterWidth) {
12503
+ row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
12504
+ }
12482
12505
  }
12483
12506
  });
12484
12507
  }
@@ -12504,13 +12527,14 @@ function toWordChar(data, charX, wordChar) {
12504
12527
  return charX;
12505
12528
  }
12506
12529
 
12507
- function toChar(data, charX, rowData, isOverflow) {
12530
+ function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
12508
12531
  data.forEach(char => {
12509
12532
  if (isOverflow || char.char !== " ") {
12510
12533
  char.x = charX;
12511
12534
  rowData.push(char);
12512
12535
  }
12513
12536
  charX += char.width;
12537
+ addLetterWidth && (charX += addLetterWidth);
12514
12538
  });
12515
12539
  return charX;
12516
12540
  }
@@ -12652,10 +12676,10 @@ function getDrawData$1(content, style) {
12652
12676
  let x = 0, y = 0;
12653
12677
  let width = style.__getInput("width") || 0;
12654
12678
  let height = style.__getInput("height") || 0;
12655
- const {textDecoration: textDecoration, __font: __font, __padding: padding} = style;
12679
+ const {__padding: padding} = style;
12656
12680
  if (padding) {
12657
- if (width) x = padding[left$3], width -= padding[right$3] + padding[left$3]; else if (!style.autoSizeAlign) x = padding[left$3];
12658
- if (height) y = padding[top$2], height -= padding[top$2] + padding[bottom$2]; else if (!style.autoSizeAlign) y = padding[top$2];
12681
+ if (width) x = padding[left$3], width -= padding[right$3] + padding[left$3], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left$3];
12682
+ if (height) y = padding[top$2], height -= padding[top$2] + padding[bottom$2], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top$2];
12659
12683
  }
12660
12684
  const drawData = {
12661
12685
  bounds: {
@@ -12666,14 +12690,14 @@ function getDrawData$1(content, style) {
12666
12690
  },
12667
12691
  rows: [],
12668
12692
  paraNumber: 0,
12669
- font: Platform.canvas.font = __font
12693
+ font: Platform.canvas.font = style.__font
12670
12694
  };
12671
12695
  createRows(drawData, content, style);
12672
12696
  if (padding) padAutoText(padding, drawData, style, width, height);
12673
12697
  layoutText(drawData, style);
12674
- layoutChar(drawData, style, width);
12698
+ if (style.__isCharMode) layoutChar(drawData, style, width);
12675
12699
  if (drawData.overflow) clipText(drawData, style, x, width);
12676
- if (textDecoration !== "none") decorationText(drawData, style);
12700
+ if (style.textDecoration !== "none") decorationText(drawData, style);
12677
12701
  return drawData;
12678
12702
  }
12679
12703
 
@@ -12905,8 +12929,8 @@ class Stroker extends UI {
12905
12929
  if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12906
12930
  data.strokeWidth = strokeWidth / abs$4(worldTransform.scaleX);
12907
12931
  }
12908
- if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
12909
- if (fill) isString(fill) ? Paint.fill(fill, this, canvas) : Paint.fills(fill, this, canvas);
12932
+ if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas, options) : Paint.strokes(stroke, this, canvas, options);
12933
+ if (fill) isString(fill) ? Paint.fill(fill, this, canvas, options) : Paint.fills(fill, this, canvas, options);
12910
12934
  }
12911
12935
  }
12912
12936
  data.strokeWidth = strokeWidth;
@@ -13324,6 +13348,8 @@ const EditDataHelper = {
13324
13348
  scaleX = sign$1(scaleX) * lockScale;
13325
13349
  scaleY = sign$1(scaleY) * lockScale;
13326
13350
  }
13351
+ isFinite(scaleX) || (scaleX = 1);
13352
+ isFinite(scaleY) || (scaleY = 1);
13327
13353
  return {
13328
13354
  origin: origin,
13329
13355
  scaleX: scaleX,
@@ -13654,9 +13680,10 @@ class EditBox extends Group {
13654
13680
  }
13655
13681
  load() {
13656
13682
  const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints, resizeLines: resizeLines} = this;
13657
- const {stroke: stroke, strokeWidth: strokeWidth, resizeLine: resizeLine, ignorePixelSnap: ignorePixelSnap} = mergeConfig;
13683
+ const {stroke: stroke, strokeWidth: strokeWidth, ignorePixelSnap: ignorePixelSnap} = mergeConfig;
13658
13684
  const pointsStyle = this.getPointsStyle();
13659
13685
  const middlePointsStyle = this.getMiddlePointsStyle();
13686
+ const resizeLinesStyle = this.getResizeLinesStyle();
13660
13687
  this.visible = !target.locked;
13661
13688
  let resizeP;
13662
13689
  for (let i = 0; i < 8; i++) {
@@ -13666,12 +13693,13 @@ class EditBox extends Group {
13666
13693
  if (i % 2) resizeLines[(i - 1) / 2].set(Object.assign({
13667
13694
  pointType: "resize",
13668
13695
  rotation: (i - 1) / 2 * 90
13669
- }, resizeLine || {}));
13696
+ }, resizeLinesStyle[(i - 1) / 2 % resizeLinesStyle.length] || {}));
13670
13697
  }
13671
13698
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
13672
13699
  rect.set(Object.assign({
13673
13700
  stroke: stroke,
13674
13701
  strokeWidth: strokeWidth,
13702
+ opacity: 1,
13675
13703
  editConfig: editConfig
13676
13704
  }, mergeConfig.rect || {}));
13677
13705
  const rectThrough = isNull(mergeConfig.rectThrough) ? single : mergeConfig.rectThrough;
@@ -13796,6 +13824,7 @@ class EditBox extends Group {
13796
13824
  strokeWidth: strokeWidth,
13797
13825
  around: "center",
13798
13826
  strokeAlign: "center",
13827
+ opacity: 1,
13799
13828
  width: pointSize,
13800
13829
  height: pointSize,
13801
13830
  cornerRadius: pointRadius,
@@ -13813,6 +13842,10 @@ class EditBox extends Group {
13813
13842
  const {middlePoint: middlePoint} = this.mergedConfig;
13814
13843
  return isArray(middlePoint) ? middlePoint : middlePoint ? [ middlePoint ] : this.getPointsStyle();
13815
13844
  }
13845
+ getResizeLinesStyle() {
13846
+ const {resizeLine: resizeLine} = this.mergedConfig;
13847
+ return isArray(resizeLine) ? resizeLine : [ resizeLine ];
13848
+ }
13816
13849
  onDragStart(e) {
13817
13850
  this.dragging = true;
13818
13851
  const point = this.dragPoint = e.current, {pointType: pointType} = point;
@@ -13847,7 +13880,7 @@ class EditBox extends Group {
13847
13880
  this.dragPoint = null;
13848
13881
  }
13849
13882
  onTransformStart(e) {
13850
- if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
13883
+ if (this.moving || this.gesturing) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
13851
13884
  if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
13852
13885
  const {dragStartData: dragStartData, target: target} = this;
13853
13886
  dragStartData.x = e.x;
@@ -13872,7 +13905,18 @@ class EditBox extends Group {
13872
13905
  e.stop();
13873
13906
  if (isString(this.mergedConfig.moveable)) {
13874
13907
  this.gesturing = this.moving = true;
13875
- e.type === MoveEvent.START ? this.onTransformStart(e) : this.transformTool.onMove(e);
13908
+ switch (e.type) {
13909
+ case MoveEvent.START:
13910
+ this.onTransformStart(e);
13911
+ break;
13912
+
13913
+ case MoveEvent.END:
13914
+ this.onTransformEnd(e);
13915
+ break;
13916
+
13917
+ default:
13918
+ this.transformTool.onMove(e);
13919
+ }
13876
13920
  }
13877
13921
  }
13878
13922
  }
@@ -13881,7 +13925,18 @@ class EditBox extends Group {
13881
13925
  e.stop();
13882
13926
  if (isString(this.mergedConfig.resizeable)) {
13883
13927
  this.gesturing = this.resizing = true;
13884
- e.type === ZoomEvent.START ? this.onTransformStart(e) : this.transformTool.onScale(e);
13928
+ switch (e.type) {
13929
+ case ZoomEvent.START:
13930
+ this.onTransformStart(e);
13931
+ break;
13932
+
13933
+ case ZoomEvent.END:
13934
+ this.onTransformEnd(e);
13935
+ break;
13936
+
13937
+ default:
13938
+ this.transformTool.onScale(e);
13939
+ }
13885
13940
  }
13886
13941
  }
13887
13942
  }
@@ -13890,16 +13945,21 @@ class EditBox extends Group {
13890
13945
  e.stop();
13891
13946
  if (isString(this.mergedConfig.rotateable)) {
13892
13947
  this.gesturing = this.rotating = true;
13893
- e.type === RotateEvent.START ? this.onTransformStart(e) : this.transformTool.onRotate(e);
13948
+ switch (e.type) {
13949
+ case ZoomEvent.START:
13950
+ this.onTransformStart(e);
13951
+ break;
13952
+
13953
+ case ZoomEvent.END:
13954
+ this.onTransformEnd(e);
13955
+ break;
13956
+
13957
+ default:
13958
+ this.transformTool.onRotate(e);
13959
+ }
13894
13960
  }
13895
13961
  }
13896
13962
  }
13897
- onGestureStart(e) {
13898
- if (this.canGesture && e.moveType !== "drag") this.onTransformStart(e);
13899
- }
13900
- onGestureEnd(e) {
13901
- if (this.canGesture && e.moveType !== "drag") this.onTransformEnd(e);
13902
- }
13903
13963
  isHoldRotateKey(e) {
13904
13964
  const {rotateKey: rotateKey} = this.mergedConfig;
13905
13965
  if (rotateKey) return e.isHoldKeys(rotateKey);
@@ -13969,7 +14029,7 @@ class EditBox extends Group {
13969
14029
  const {rect: rect, editor: editor, __eventIds: events} = this;
13970
14030
  events.push(rect.on_([ [ PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
13971
14031
  this.waitLeafer(() => {
13972
- events.push(editor.app.on_([ [ [ KeyEvent.HOLD, KeyEvent.UP ], this.onKey, this ], [ KeyEvent.DOWN, this.onArrow, this ], [ MoveEvent.BEFORE_MOVE, this.onMove, this, true ], [ ZoomEvent.BEFORE_ZOOM, this.onScale, this, true ], [ RotateEvent.BEFORE_ROTATE, this.onRotate, this, true ], [ [ MoveEvent.START, ZoomEvent.START, RotateEvent.START ], this.onGestureStart, this ], [ [ MoveEvent.END, ZoomEvent.END, RotateEvent.END ], this.onGestureEnd, this ] ]));
14032
+ events.push(editor.app.on_([ [ [ KeyEvent.HOLD, KeyEvent.UP ], this.onKey, this ], [ KeyEvent.DOWN, this.onArrow, this ], [ [ MoveEvent.START, MoveEvent.BEFORE_MOVE, MoveEvent.END ], this.onMove, this, true ], [ [ ZoomEvent.START, ZoomEvent.BEFORE_ZOOM, ZoomEvent.END ], this.onScale, this, true ], [ [ RotateEvent.START, RotateEvent.BEFORE_ROTATE, RotateEvent.END ], this.onRotate, this, true ] ]));
13973
14033
  });
13974
14034
  }
13975
14035
  __removeListenEvents() {
@@ -14722,6 +14782,9 @@ let Editor = class Editor extends Group {
14722
14782
  if (this.multiple) simulate(this);
14723
14783
  this.update();
14724
14784
  }
14785
+ getEditTool(name) {
14786
+ return this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14787
+ }
14725
14788
  updateEditTool() {
14726
14789
  this.unloadEditTool();
14727
14790
  if (this.editing) {
@@ -14736,7 +14799,7 @@ let Editor = class Editor extends Group {
14736
14799
  if (isString(check)) name = check; else if (check === false) return;
14737
14800
  }
14738
14801
  if (EditToolCreator.list[name]) {
14739
- const tool = this.editTool = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14802
+ const tool = this.editTool = this.getEditTool(name);
14740
14803
  this.editBox.load();
14741
14804
  tool.load();
14742
14805
  this.update();
@@ -14828,6 +14891,9 @@ let Editor = class Editor extends Group {
14828
14891
  this.emitEvent(event);
14829
14892
  if (group) group.emitEvent(event);
14830
14893
  }
14894
+ getInnerEditor(name) {
14895
+ return this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14896
+ }
14831
14897
  openInnerEditor(target, nameOrSelect, select) {
14832
14898
  let name;
14833
14899
  if (isString(nameOrSelect)) name = nameOrSelect; else if (!select) select = nameOrSelect;
@@ -14846,7 +14912,7 @@ let Editor = class Editor extends Group {
14846
14912
  if (EditToolCreator.list[name]) {
14847
14913
  this.editTool.unload();
14848
14914
  this.innerEditing = true;
14849
- this.innerEditor = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14915
+ this.innerEditor = this.getInnerEditor(name);
14850
14916
  this.innerEditor.editTarget = target;
14851
14917
  this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN);
14852
14918
  this.innerEditor.load();
@@ -16928,7 +16994,7 @@ UI.addAttr("endArrow", "none", arrowType);
16928
16994
  Object.assign(PathArrow, PathArrowModule);
16929
16995
 
16930
16996
  Object.assign(Paint, {
16931
- strokeArrow(_stroke, ui, canvas) {
16997
+ strokeArrow(_stroke, ui, canvas, _renderOptions) {
16932
16998
  if (ui.__.dashPattern) {
16933
16999
  canvas.beginPath();
16934
17000
  ui.__drawPathByData(canvas, ui.__.__pathForArrow);
@@ -19813,4 +19879,4 @@ Plugin.add("bright");
19813
19879
 
19814
19880
  UI.addAttr("bright", false, dimType);
19815
19881
 
19816
- export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, FourNumberHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
19882
+ export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, FourNumberHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };