@leafer/worker 1.9.12 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.0";
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(_image, 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,36 +11091,19 @@ 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) {
11099
+ function fills(fills, ui, canvas, renderOptions) {
11093
11100
  let item;
11094
11101
  for (let i = 0, len = fills.length; i < len; i++) {
11095
11102
  item = fills[i];
11096
11103
  if (item.image) {
11097
- if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font)) continue;
11104
+ if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
11098
11105
  if (!item.style) {
11099
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas, item.image);
11106
+ if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
11100
11107
  continue;
11101
11108
  }
11102
11109
  }
@@ -11109,60 +11116,137 @@ function fills(fills, ui, canvas) {
11109
11116
  if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
11110
11117
  }
11111
11118
  if (item.blendMode) canvas.blendMode = item.blendMode;
11112
- fillPathOrText(ui, canvas);
11119
+ fillPathOrText(ui, canvas, renderOptions);
11113
11120
  canvas.restore();
11114
11121
  } else {
11115
11122
  if (item.blendMode) {
11116
11123
  canvas.saveBlendMode(item.blendMode);
11117
- fillPathOrText(ui, canvas);
11124
+ fillPathOrText(ui, canvas, renderOptions);
11118
11125
  canvas.restoreBlendMode();
11119
- } else fillPathOrText(ui, canvas);
11126
+ } else fillPathOrText(ui, canvas, renderOptions);
11127
+ }
11128
+ }
11129
+ }
11130
+
11131
+ function fillPathOrText(ui, canvas, renderOptions) {
11132
+ ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
11133
+ }
11134
+
11135
+ function fillText(ui, canvas, _renderOptions) {
11136
+ const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
11137
+ if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
11138
+ let row;
11139
+ for (let i = 0, len = rows.length; i < len; i++) {
11140
+ row = rows[i];
11141
+ if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
11142
+ canvas.fillText(charData.char, charData.x, row.y);
11143
+ });
11144
+ }
11145
+ if (decorationY) {
11146
+ const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
11147
+ if (decorationColor) canvas.fillStyle = decorationColor;
11148
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
11149
+ }
11150
+ }
11151
+
11152
+ function stroke(stroke, ui, canvas, renderOptions) {
11153
+ const data = ui.__;
11154
+ if (!data.__strokeWidth) return;
11155
+ if (data.__font) {
11156
+ Paint.strokeText(stroke, ui, canvas, renderOptions);
11157
+ } else {
11158
+ switch (data.strokeAlign) {
11159
+ case "center":
11160
+ drawCenter$1(stroke, 1, ui, canvas, renderOptions);
11161
+ break;
11162
+
11163
+ case "inside":
11164
+ drawInside(stroke, ui, canvas, renderOptions);
11165
+ break;
11166
+
11167
+ case "outside":
11168
+ drawOutside(stroke, ui, canvas, renderOptions);
11169
+ break;
11120
11170
  }
11121
11171
  }
11122
11172
  }
11123
11173
 
11124
- function fillPathOrText(ui, canvas) {
11125
- ui.__.__font ? fillText(ui, canvas) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
11174
+ function strokes(strokes, ui, canvas, renderOptions) {
11175
+ Paint.stroke(strokes, ui, canvas, renderOptions);
11176
+ }
11177
+
11178
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
11179
+ const data = ui.__;
11180
+ if (isObject(stroke)) {
11181
+ Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
11182
+ } else {
11183
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
11184
+ canvas.stroke();
11185
+ }
11186
+ if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
11187
+ }
11188
+
11189
+ function drawInside(stroke, ui, canvas, renderOptions) {
11190
+ canvas.save();
11191
+ canvas.clipUI(ui);
11192
+ drawCenter$1(stroke, 2, ui, canvas, renderOptions);
11193
+ canvas.restore();
11194
+ }
11195
+
11196
+ function drawOutside(stroke, ui, canvas, renderOptions) {
11197
+ const data = ui.__;
11198
+ if (data.__fillAfterStroke) {
11199
+ drawCenter$1(stroke, 2, ui, canvas, renderOptions);
11200
+ } else {
11201
+ const {renderBounds: renderBounds} = ui.__layout;
11202
+ const out = canvas.getSameCanvas(true, true);
11203
+ ui.__drawRenderPath(out);
11204
+ drawCenter$1(stroke, 2, ui, out, renderOptions);
11205
+ out.clipUI(data);
11206
+ out.clearWorld(renderBounds);
11207
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
11208
+ out.recycle(ui.__nowWorld);
11209
+ }
11126
11210
  }
11127
11211
 
11128
- function strokeText(stroke, ui, canvas) {
11212
+ function strokeText(stroke, ui, canvas, renderOptions) {
11129
11213
  switch (ui.__.strokeAlign) {
11130
11214
  case "center":
11131
- drawCenter$1(stroke, 1, ui, canvas);
11215
+ drawCenter(stroke, 1, ui, canvas, renderOptions);
11132
11216
  break;
11133
11217
 
11134
11218
  case "inside":
11135
- drawAlign(stroke, "inside", ui, canvas);
11219
+ drawAlign(stroke, "inside", ui, canvas, renderOptions);
11136
11220
  break;
11137
11221
 
11138
11222
  case "outside":
11139
- ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, "outside", ui, canvas);
11223
+ ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
11140
11224
  break;
11141
11225
  }
11142
11226
  }
11143
11227
 
11144
- function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
11228
+ function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
11145
11229
  const data = ui.__;
11146
11230
  if (isObject(stroke)) {
11147
- drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
11231
+ Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
11148
11232
  } else {
11149
11233
  canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
11150
- drawTextStroke(ui, canvas);
11234
+ Paint.drawTextStroke(ui, canvas, renderOptions);
11151
11235
  }
11152
11236
  }
11153
11237
 
11154
- function drawAlign(stroke, align, ui, canvas) {
11238
+ function drawAlign(stroke, align, ui, canvas, renderOptions) {
11155
11239
  const out = canvas.getSameCanvas(true, true);
11156
11240
  out.font = ui.__.__font;
11157
- drawCenter$1(stroke, 2, ui, out);
11241
+ drawCenter(stroke, 2, ui, out, renderOptions);
11158
11242
  out.blendMode = align === "outside" ? "destination-out" : "destination-in";
11159
- fillText(ui, out);
11243
+ Paint.fillText(ui, out, renderOptions);
11160
11244
  out.blendMode = "normal";
11161
11245
  LeafHelper.copyCanvasByWorld(ui, canvas, out);
11162
11246
  out.recycle(ui.__nowWorld);
11163
11247
  }
11164
11248
 
11165
- function drawTextStroke(ui, canvas) {
11249
+ function drawTextStroke(ui, canvas, _renderOptions) {
11166
11250
  let row, data = ui.__.__textDrawData;
11167
11251
  const {rows: rows, decorationY: decorationY} = data;
11168
11252
  for (let i = 0, len = rows.length; i < len; i++) {
@@ -11177,13 +11261,13 @@ function drawTextStroke(ui, canvas) {
11177
11261
  }
11178
11262
  }
11179
11263
 
11180
- function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
11264
+ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
11181
11265
  let item;
11182
11266
  const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
11183
11267
  __hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
11184
11268
  for (let i = 0, len = strokes.length; i < len; i++) {
11185
11269
  item = strokes[i];
11186
- if (item.image && PaintImage.checkImage(ui, canvas, item, false)) continue;
11270
+ if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
11187
11271
  if (item.style) {
11188
11272
  if (__hasMultiStrokeStyle) {
11189
11273
  const {strokeStyle: strokeStyle} = item;
@@ -11191,75 +11275,15 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
11191
11275
  } else canvas.strokeStyle = item.style;
11192
11276
  if (item.blendMode) {
11193
11277
  canvas.saveBlendMode(item.blendMode);
11194
- isText ? drawTextStroke(ui, canvas) : canvas.stroke();
11278
+ isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
11195
11279
  canvas.restoreBlendMode();
11196
11280
  } else {
11197
- isText ? drawTextStroke(ui, canvas) : canvas.stroke();
11281
+ isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
11198
11282
  }
11199
11283
  }
11200
11284
  }
11201
11285
  }
11202
11286
 
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
11287
  const {getSpread: getSpread, copyAndSpread: copyAndSpread$1, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$7, getIntersectData: getIntersectData} = BoundsHelper;
11264
11288
 
11265
11289
  const tempBounds$1 = {};
@@ -11415,88 +11439,118 @@ const PaintModule = {
11415
11439
  strokes: strokes,
11416
11440
  strokeText: strokeText,
11417
11441
  drawTextStroke: drawTextStroke,
11442
+ drawStrokesStyle: drawStrokesStyle,
11418
11443
  shape: shape
11419
11444
  };
11420
11445
 
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
- }
11431
-
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
- }
11446
+ let cache$1, box$1 = new Bounds;
11442
11447
 
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
- }
11453
- data.transform = transform;
11454
- }
11448
+ const {isSame: isSame} = BoundsHelper;
11455
11449
 
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);
11460
- } 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;
11450
+ function image(ui, attrName, paint, boxBounds, firstUse) {
11451
+ let leafPaint, event;
11452
+ const image = ImageManager.get(paint);
11453
+ if (cache$1 && paint === cache$1.paint && isSame(boxBounds, cache$1.boxBounds)) {
11454
+ leafPaint = cache$1.leafPaint;
11455
+ } else {
11456
+ leafPaint = {
11457
+ type: paint.type,
11458
+ image: image
11459
+ };
11460
+ if (image.hasAlphaPixel) leafPaint.isTransparent = true;
11461
+ cache$1 = image.use > 1 ? {
11462
+ leafPaint: leafPaint,
11463
+ paint: paint,
11464
+ boxBounds: box$1.set(boxBounds)
11465
+ } : null;
11466
+ }
11467
+ if (firstUse || image.loading) event = {
11468
+ image: image,
11469
+ attrName: attrName,
11470
+ attrValue: paint
11471
+ };
11472
+ if (image.ready) {
11473
+ checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
11474
+ if (firstUse) {
11475
+ onLoad(ui, event);
11476
+ onLoadSuccess(ui, event);
11477
+ }
11478
+ } else if (image.error) {
11479
+ if (firstUse) onLoadError(ui, event, image.error);
11480
+ } else {
11481
+ if (firstUse) {
11482
+ ignoreRender(ui, true);
11483
+ onLoad(ui, event);
11484
+ }
11485
+ leafPaint.loadId = image.load(() => {
11486
+ ignoreRender(ui, false);
11487
+ if (!ui.destroyed) {
11488
+ if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
11489
+ if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
11490
+ ui.forceUpdate("surface");
11481
11491
  }
11492
+ onLoadSuccess(ui, event);
11482
11493
  }
11494
+ leafPaint.loadId = undefined;
11495
+ }, error => {
11496
+ ignoreRender(ui, false);
11497
+ onLoadError(ui, event, error);
11498
+ leafPaint.loadId = undefined;
11499
+ });
11500
+ if (ui.placeholderColor) {
11501
+ if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
11502
+ if (!image.ready) {
11503
+ image.isPlacehold = true;
11504
+ ui.forceUpdate("surface");
11505
+ }
11506
+ }, ui.placeholderDelay);
11483
11507
  }
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
11508
  }
11489
- data.transform = transform;
11509
+ return leafPaint;
11490
11510
  }
11491
11511
 
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);
11512
+ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
11513
+ if (attrName === "fill" && !ui.__.__naturalWidth) {
11514
+ const data = ui.__;
11515
+ data.__naturalWidth = image.width / data.pixelRatio;
11516
+ data.__naturalHeight = image.height / data.pixelRatio;
11517
+ if (data.__autoSide) {
11518
+ ui.forceUpdate("width");
11519
+ if (ui.__proxyData) {
11520
+ ui.setProxyAttr("width", data.width);
11521
+ ui.setProxyAttr("height", data.height);
11522
+ }
11523
+ return false;
11524
+ }
11525
+ }
11526
+ if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
11527
+ return true;
11528
+ }
11529
+
11530
+ function onLoad(ui, event) {
11531
+ emit(ui, ImageEvent.LOAD, event);
11532
+ }
11533
+
11534
+ function onLoadSuccess(ui, event) {
11535
+ emit(ui, ImageEvent.LOADED, event);
11536
+ }
11537
+
11538
+ function onLoadError(ui, event, error) {
11539
+ event.error = error;
11540
+ ui.forceUpdate("surface");
11541
+ emit(ui, ImageEvent.ERROR, event);
11542
+ }
11543
+
11544
+ function emit(ui, type, data) {
11545
+ if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
11546
+ }
11547
+
11548
+ function ignoreRender(ui, value) {
11549
+ const {leafer: leafer} = ui;
11550
+ if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
11497
11551
  }
11498
11552
 
11499
- const {get: get$2, translate: translate} = MatrixHelper;
11553
+ const {get: get$3, translate: translate$1} = MatrixHelper;
11500
11554
 
11501
11555
  const tempBox = new Bounds;
11502
11556
 
@@ -11509,13 +11563,13 @@ function createData(leafPaint, image, paint, box) {
11509
11563
  if (changeful) leafPaint.changeful = changeful;
11510
11564
  if (sync) leafPaint.sync = sync;
11511
11565
  if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
11512
- leafPaint.data = getPatternData(paint, box, image);
11566
+ leafPaint.data = PaintImage.getPatternData(paint, box, image);
11513
11567
  }
11514
11568
 
11515
11569
  function getPatternData(paint, box, image) {
11516
11570
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
11517
11571
  if (paint.mode === "strench") paint.mode = "stretch";
11518
- let {width: width, height: height} = image;
11572
+ const {width: width, height: height} = image;
11519
11573
  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
11574
  const sameBox = box.width === width && box.height === height;
11521
11575
  const data = {
@@ -11546,8 +11600,8 @@ function getPatternData(paint, box, image) {
11546
11600
  case "stretch":
11547
11601
  if (!sameBox) {
11548
11602
  scaleX = box.width / width, scaleY = box.height / height;
11549
- stretchMode(data, box, scaleX, scaleY);
11550
- }
11603
+ PaintImage.stretchMode(data, box, scaleX, scaleY);
11604
+ } else if (scaleX) scaleX = scaleY = undefined;
11551
11605
  break;
11552
11606
 
11553
11607
  case "normal":
@@ -11555,13 +11609,13 @@ function getPatternData(paint, box, image) {
11555
11609
  if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
11556
11610
  let clipScaleX, clipScaleY;
11557
11611
  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);
11612
+ PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
11559
11613
  if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
11560
11614
  }
11561
11615
  break;
11562
11616
 
11563
11617
  case "repeat":
11564
- if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
11618
+ if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
11565
11619
  if (!repeat) data.repeat = "repeat";
11566
11620
  const count = isObject(repeat);
11567
11621
  if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
@@ -11570,18 +11624,16 @@ function getPatternData(paint, box, image) {
11570
11624
  case "fit":
11571
11625
  case "cover":
11572
11626
  default:
11573
- if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11627
+ if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11574
11628
  }
11575
11629
  if (!data.transform) {
11576
- if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
11630
+ if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
11577
11631
  }
11578
- data.width = width;
11579
- data.height = height;
11580
11632
  if (scaleX) {
11581
11633
  data.scaleX = scaleX;
11582
11634
  data.scaleY = scaleY;
11583
11635
  }
11584
- if (opacity) data.opacity = opacity;
11636
+ if (opacity && opacity < 1) data.opacity = opacity;
11585
11637
  if (filters) data.filters = filters;
11586
11638
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
11587
11639
  return data;
@@ -11603,234 +11655,194 @@ function getGapValue(gap, size, totalSize, rows) {
11603
11655
  return gap === "auto" ? value < 0 ? 0 : value : value;
11604
11656
  }
11605
11657
 
11606
- let cache$1, box$1 = new Bounds;
11658
+ let origin$1 = {}, tempMatrix$1 = getMatrixData();
11607
11659
 
11608
- const {isSame: isSame} = BoundsHelper;
11660
+ 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
11661
 
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;
11662
+ function stretchMode(data, box, scaleX, scaleY) {
11663
+ const transform = get$2(), {x: x, y: y} = box;
11664
+ if (x || y) translate(transform, x, y); else transform.onlyScale = true;
11665
+ scaleHelper(transform, scaleX, scaleY);
11666
+ data.transform = transform;
11670
11667
  }
11671
11668
 
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;
11669
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
11670
+ const transform = get$2();
11671
+ translate(transform, box.x + x, box.y + y);
11672
+ scaleHelper(transform, scaleX, scaleY);
11673
+ if (rotation) rotateOfOuter$1(transform, {
11674
+ x: box.x + box.width / 2,
11675
+ y: box.y + box.height / 2
11676
+ }, rotation);
11677
+ data.transform = transform;
11688
11678
  }
11689
11679
 
11690
- function onLoad(ui, event) {
11691
- emit(ui, ImageEvent.LOAD, event);
11680
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
11681
+ const transform = get$2();
11682
+ layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew);
11683
+ if (clipScaleX) {
11684
+ if (rotation || skew) {
11685
+ set(tempMatrix$1);
11686
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
11687
+ multiplyParent(transform, tempMatrix$1);
11688
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
11689
+ }
11690
+ data.transform = transform;
11692
11691
  }
11693
11692
 
11694
- function onLoadSuccess(ui, event) {
11695
- emit(ui, ImageEvent.LOADED, event);
11696
- }
11693
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
11694
+ const transform = get$2();
11695
+ if (freeTransform) {
11696
+ layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew);
11697
+ } else {
11698
+ if (rotation) {
11699
+ if (align === "center") {
11700
+ rotateOfOuter$1(transform, {
11701
+ x: width / 2,
11702
+ y: height / 2
11703
+ }, rotation);
11704
+ } else {
11705
+ rotate$2(transform, rotation);
11706
+ switch (rotation) {
11707
+ case 90:
11708
+ translate(transform, height, 0);
11709
+ break;
11697
11710
 
11698
- function onLoadError(ui, event, error) {
11699
- event.error = error;
11700
- ui.forceUpdate("surface");
11701
- emit(ui, ImageEvent.ERROR, event);
11702
- }
11711
+ case 180:
11712
+ translate(transform, width, height);
11713
+ break;
11703
11714
 
11704
- function emit(ui, type, data) {
11705
- if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
11715
+ case 270:
11716
+ translate(transform, 0, width);
11717
+ break;
11718
+ }
11719
+ }
11720
+ }
11721
+ origin$1.x = box.x + x;
11722
+ origin$1.y = box.y + y;
11723
+ translate(transform, origin$1.x, origin$1.y);
11724
+ if (scaleX) scaleOfOuter$1(transform, origin$1, scaleX, scaleY);
11725
+ }
11726
+ data.transform = transform;
11706
11727
  }
11707
11728
 
11708
- function ignoreRender(ui, value) {
11709
- const {leafer: leafer} = ui;
11710
- if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
11729
+ function layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew) {
11730
+ if (rotation) rotate$2(transform, rotation);
11731
+ if (skew) skewHelper(transform, skew.x, skew.y);
11732
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
11733
+ translate(transform, box.x + x, box.y + y);
11711
11734
  }
11712
11735
 
11713
11736
  const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
11714
11737
 
11715
- const {floor: floor$1, ceil: ceil$1, max: max$2, abs: abs$6} = Math;
11738
+ const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$6} = Math;
11739
+
11740
+ function createPatternTask(paint, ui, canvas, renderOptions) {
11741
+ if (!paint.patternTask) {
11742
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
11743
+ paint.patternTask = null;
11744
+ if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
11745
+ ui.forceUpdate("surface");
11746
+ }), 300);
11747
+ }
11748
+ }
11716
11749
 
11717
- function createPattern(ui, paint, pixelRatio) {
11718
- let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
11719
- const id = scaleX + "-" + scaleY + "-" + pixelRatio;
11750
+ function createPattern(paint, ui, canvas, renderOptions) {
11751
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
11720
11752
  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) {
11753
+ if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
11754
+ const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11755
+ let imageMatrix, xGap, yGap, {width: width, height: height} = image;
11756
+ if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
11757
+ width *= scaleX;
11758
+ height *= scaleY;
11759
+ if (gap) {
11760
+ xGap = gap.x * scaleX / abs$6(data.scaleX || 1);
11761
+ yGap = gap.y * scaleY / abs$6(data.scaleY || 1);
11762
+ }
11763
+ if (transform || scaleX !== 1 || scaleY !== 1) {
11764
+ scaleX *= getFloorScale(width + (xGap || 0));
11765
+ scaleY *= getFloorScale(height + (yGap || 0));
11767
11766
  imageMatrix = get$1();
11768
11767
  if (transform) copy$4(imageMatrix, transform);
11768
+ scale$2(imageMatrix, 1 / scaleX, 1 / scaleY);
11769
11769
  }
11770
- scale$2(imageMatrix, 1 / scaleX, 1 / scaleY);
11770
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11771
+ const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11772
+ paint.style = pattern;
11773
+ paint.patternId = id;
11771
11774
  }
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;
11775
+ }
11776
+ }
11777
+
11778
+ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
11779
+ const {image: image} = paint;
11780
+ let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
11781
+ if (image.isSVG) {
11782
+ if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
11777
11783
  } else {
11778
- return false;
11784
+ if (maxSize > imageSize) maxSize = imageSize;
11779
11785
  }
11786
+ if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
11787
+ return fixScale;
11780
11788
  }
11781
11789
 
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) {
11790
+ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
11791
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
11792
+ const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
11793
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
11786
11794
  return false;
11787
11795
  } else {
11788
- if (allowDraw) {
11796
+ if (drawImage) {
11789
11797
  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;
11798
+ drawImage = false;
11799
+ } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
11800
+ drawImage = Platform.image.isLarge(image, scaleX, scaleY);
11800
11801
  }
11801
11802
  }
11802
- if (allowDraw) {
11803
+ if (drawImage) {
11803
11804
  if (ui.__.__isFastShadow) {
11804
11805
  canvas.fillStyle = paint.style || "#000";
11805
11806
  canvas.fill();
11806
11807
  }
11807
- drawImage(ui, canvas, paint, data);
11808
+ PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
11808
11809
  return true;
11809
11810
  } 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
- }
11811
+ if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
11821
11812
  return false;
11822
11813
  }
11823
11814
  }
11824
11815
  }
11825
11816
 
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();
11817
+ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
11818
+ const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
11819
+ let {width: width, height: height} = image, clipUI;
11820
+ if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
11821
+ canvas.save();
11822
+ clipUI && canvas.clipUI(ui);
11823
+ blendMode && (canvas.blendMode = blendMode);
11824
+ opacity && (canvas.opacity *= opacity);
11825
+ transform && canvas.transform(transform);
11826
+ canvas.drawImage(view, 0, 0, width, height);
11827
+ canvas.restore();
11828
+ } else {
11829
+ if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
11830
+ canvas.drawImage(view, 0, 0, width, height);
11831
+ }
11832
+ }
11833
+
11834
+ function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
11835
+ const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
11836
+ if (canvas) {
11837
+ const {pixelRatio: pixelRatio} = canvas;
11838
+ scaleData.scaleX *= pixelRatio;
11839
+ scaleData.scaleY *= pixelRatio;
11840
+ }
11841
+ if (data && data.scaleX) {
11842
+ scaleData.scaleX *= Math.abs(data.scaleX);
11843
+ scaleData.scaleY *= Math.abs(data.scaleY);
11844
+ }
11845
+ return scaleData;
11834
11846
  }
11835
11847
 
11836
11848
  function recycleImage(attrName, data) {
@@ -11862,8 +11874,12 @@ function recycleImage(attrName, data) {
11862
11874
  const PaintImageModule = {
11863
11875
  image: image,
11864
11876
  checkImage: checkImage,
11865
- createPattern: createPattern,
11877
+ drawImage: drawImage,
11878
+ getImageRenderScaleData: getImageRenderScaleData,
11866
11879
  recycleImage: recycleImage,
11880
+ createPatternTask: createPatternTask,
11881
+ createPattern: createPattern,
11882
+ getPatternFixScale: getPatternFixScale,
11867
11883
  createData: createData,
11868
11884
  getPatternData: getPatternData,
11869
11885
  stretchMode: stretchMode,
@@ -12319,10 +12335,8 @@ function createRows(drawData, content, style) {
12319
12335
  bounds$3 = drawData.bounds;
12320
12336
  findMaxWidth = !bounds$3.width && !style.autoSizeAlign;
12321
12337
  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) {
12338
+ const {canvas: canvas} = Platform, {width: width} = bounds$3;
12339
+ if (style.__isCharMode) {
12326
12340
  const wrap = style.textWrap !== "none";
12327
12341
  const breakAll = style.textWrap === "break";
12328
12342
  paraStart = true;
@@ -12451,12 +12465,19 @@ const TextMode = 2;
12451
12465
  function layoutChar(drawData, style, width, _height) {
12452
12466
  const {rows: rows} = drawData;
12453
12467
  const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
12454
- let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
12468
+ const justifyLast = width && textAlign.includes("both");
12469
+ const justify = justifyLast || width && textAlign.includes("justify");
12470
+ const justifyLetter = justify && textAlign.includes("letter");
12471
+ let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
12455
12472
  rows.forEach(row => {
12456
12473
  if (row.words) {
12457
12474
  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;
12475
+ if (justify) {
12476
+ canJustify = !row.paraEnd || justifyLast;
12477
+ remainingWidth = width - row.width - indentWidth;
12478
+ if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
12479
+ }
12480
+ mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
12460
12481
  if (row.isOverflow && !letterSpacing) row.textMode = true;
12461
12482
  if (mode === TextMode) {
12462
12483
  row.x += indentWidth;
@@ -12474,11 +12495,15 @@ function layoutChar(drawData, style, width, _height) {
12474
12495
  charX = toWordChar(word.data, charX, wordChar);
12475
12496
  if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
12476
12497
  } else {
12477
- charX = toChar(word.data, charX, row.data, row.isOverflow);
12498
+ charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
12478
12499
  }
12479
- if (addWordWidth && (!row.paraEnd || textAlign === "both") && index !== wordsLength - 1) {
12480
- charX += addWordWidth;
12481
- row.width += addWordWidth;
12500
+ if (canJustify) {
12501
+ isLastWord = index === wordsLength - 1;
12502
+ if (addWordWidth) {
12503
+ if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
12504
+ } else if (addLetterWidth) {
12505
+ row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
12506
+ }
12482
12507
  }
12483
12508
  });
12484
12509
  }
@@ -12504,13 +12529,14 @@ function toWordChar(data, charX, wordChar) {
12504
12529
  return charX;
12505
12530
  }
12506
12531
 
12507
- function toChar(data, charX, rowData, isOverflow) {
12532
+ function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
12508
12533
  data.forEach(char => {
12509
12534
  if (isOverflow || char.char !== " ") {
12510
12535
  char.x = charX;
12511
12536
  rowData.push(char);
12512
12537
  }
12513
12538
  charX += char.width;
12539
+ addLetterWidth && (charX += addLetterWidth);
12514
12540
  });
12515
12541
  return charX;
12516
12542
  }
@@ -12652,10 +12678,10 @@ function getDrawData$1(content, style) {
12652
12678
  let x = 0, y = 0;
12653
12679
  let width = style.__getInput("width") || 0;
12654
12680
  let height = style.__getInput("height") || 0;
12655
- const {textDecoration: textDecoration, __font: __font, __padding: padding} = style;
12681
+ const {__padding: padding} = style;
12656
12682
  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];
12683
+ if (width) x = padding[left$3], width -= padding[right$3] + padding[left$3], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left$3];
12684
+ 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
12685
  }
12660
12686
  const drawData = {
12661
12687
  bounds: {
@@ -12666,14 +12692,14 @@ function getDrawData$1(content, style) {
12666
12692
  },
12667
12693
  rows: [],
12668
12694
  paraNumber: 0,
12669
- font: Platform.canvas.font = __font
12695
+ font: Platform.canvas.font = style.__font
12670
12696
  };
12671
12697
  createRows(drawData, content, style);
12672
12698
  if (padding) padAutoText(padding, drawData, style, width, height);
12673
12699
  layoutText(drawData, style);
12674
- layoutChar(drawData, style, width);
12700
+ if (style.__isCharMode) layoutChar(drawData, style, width);
12675
12701
  if (drawData.overflow) clipText(drawData, style, x, width);
12676
- if (textDecoration !== "none") decorationText(drawData, style);
12702
+ if (style.textDecoration !== "none") decorationText(drawData, style);
12677
12703
  return drawData;
12678
12704
  }
12679
12705
 
@@ -12905,8 +12931,8 @@ class Stroker extends UI {
12905
12931
  if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12906
12932
  data.strokeWidth = strokeWidth / abs$4(worldTransform.scaleX);
12907
12933
  }
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);
12934
+ if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas, options) : Paint.strokes(stroke, this, canvas, options);
12935
+ if (fill) isString(fill) ? Paint.fill(fill, this, canvas, options) : Paint.fills(fill, this, canvas, options);
12910
12936
  }
12911
12937
  }
12912
12938
  data.strokeWidth = strokeWidth;
@@ -13324,6 +13350,8 @@ const EditDataHelper = {
13324
13350
  scaleX = sign$1(scaleX) * lockScale;
13325
13351
  scaleY = sign$1(scaleY) * lockScale;
13326
13352
  }
13353
+ isFinite(scaleX) || (scaleX = 1);
13354
+ isFinite(scaleY) || (scaleY = 1);
13327
13355
  return {
13328
13356
  origin: origin,
13329
13357
  scaleX: scaleX,
@@ -13654,9 +13682,10 @@ class EditBox extends Group {
13654
13682
  }
13655
13683
  load() {
13656
13684
  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;
13685
+ const {stroke: stroke, strokeWidth: strokeWidth, ignorePixelSnap: ignorePixelSnap} = mergeConfig;
13658
13686
  const pointsStyle = this.getPointsStyle();
13659
13687
  const middlePointsStyle = this.getMiddlePointsStyle();
13688
+ const resizeLinesStyle = this.getResizeLinesStyle();
13660
13689
  this.visible = !target.locked;
13661
13690
  let resizeP;
13662
13691
  for (let i = 0; i < 8; i++) {
@@ -13666,12 +13695,13 @@ class EditBox extends Group {
13666
13695
  if (i % 2) resizeLines[(i - 1) / 2].set(Object.assign({
13667
13696
  pointType: "resize",
13668
13697
  rotation: (i - 1) / 2 * 90
13669
- }, resizeLine || {}));
13698
+ }, resizeLinesStyle[(i - 1) / 2 % resizeLinesStyle.length] || {}));
13670
13699
  }
13671
13700
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
13672
13701
  rect.set(Object.assign({
13673
13702
  stroke: stroke,
13674
13703
  strokeWidth: strokeWidth,
13704
+ opacity: 1,
13675
13705
  editConfig: editConfig
13676
13706
  }, mergeConfig.rect || {}));
13677
13707
  const rectThrough = isNull(mergeConfig.rectThrough) ? single : mergeConfig.rectThrough;
@@ -13796,6 +13826,7 @@ class EditBox extends Group {
13796
13826
  strokeWidth: strokeWidth,
13797
13827
  around: "center",
13798
13828
  strokeAlign: "center",
13829
+ opacity: 1,
13799
13830
  width: pointSize,
13800
13831
  height: pointSize,
13801
13832
  cornerRadius: pointRadius,
@@ -13813,6 +13844,10 @@ class EditBox extends Group {
13813
13844
  const {middlePoint: middlePoint} = this.mergedConfig;
13814
13845
  return isArray(middlePoint) ? middlePoint : middlePoint ? [ middlePoint ] : this.getPointsStyle();
13815
13846
  }
13847
+ getResizeLinesStyle() {
13848
+ const {resizeLine: resizeLine} = this.mergedConfig;
13849
+ return isArray(resizeLine) ? resizeLine : [ resizeLine ];
13850
+ }
13816
13851
  onDragStart(e) {
13817
13852
  this.dragging = true;
13818
13853
  const point = this.dragPoint = e.current, {pointType: pointType} = point;
@@ -13847,7 +13882,7 @@ class EditBox extends Group {
13847
13882
  this.dragPoint = null;
13848
13883
  }
13849
13884
  onTransformStart(e) {
13850
- if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
13885
+ if (this.moving || this.gesturing) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
13851
13886
  if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
13852
13887
  const {dragStartData: dragStartData, target: target} = this;
13853
13888
  dragStartData.x = e.x;
@@ -13872,7 +13907,18 @@ class EditBox extends Group {
13872
13907
  e.stop();
13873
13908
  if (isString(this.mergedConfig.moveable)) {
13874
13909
  this.gesturing = this.moving = true;
13875
- e.type === MoveEvent.START ? this.onTransformStart(e) : this.transformTool.onMove(e);
13910
+ switch (e.type) {
13911
+ case MoveEvent.START:
13912
+ this.onTransformStart(e);
13913
+ break;
13914
+
13915
+ case MoveEvent.END:
13916
+ this.onTransformEnd(e);
13917
+ break;
13918
+
13919
+ default:
13920
+ this.transformTool.onMove(e);
13921
+ }
13876
13922
  }
13877
13923
  }
13878
13924
  }
@@ -13881,7 +13927,18 @@ class EditBox extends Group {
13881
13927
  e.stop();
13882
13928
  if (isString(this.mergedConfig.resizeable)) {
13883
13929
  this.gesturing = this.resizing = true;
13884
- e.type === ZoomEvent.START ? this.onTransformStart(e) : this.transformTool.onScale(e);
13930
+ switch (e.type) {
13931
+ case ZoomEvent.START:
13932
+ this.onTransformStart(e);
13933
+ break;
13934
+
13935
+ case ZoomEvent.END:
13936
+ this.onTransformEnd(e);
13937
+ break;
13938
+
13939
+ default:
13940
+ this.transformTool.onScale(e);
13941
+ }
13885
13942
  }
13886
13943
  }
13887
13944
  }
@@ -13890,16 +13947,21 @@ class EditBox extends Group {
13890
13947
  e.stop();
13891
13948
  if (isString(this.mergedConfig.rotateable)) {
13892
13949
  this.gesturing = this.rotating = true;
13893
- e.type === RotateEvent.START ? this.onTransformStart(e) : this.transformTool.onRotate(e);
13950
+ switch (e.type) {
13951
+ case ZoomEvent.START:
13952
+ this.onTransformStart(e);
13953
+ break;
13954
+
13955
+ case ZoomEvent.END:
13956
+ this.onTransformEnd(e);
13957
+ break;
13958
+
13959
+ default:
13960
+ this.transformTool.onRotate(e);
13961
+ }
13894
13962
  }
13895
13963
  }
13896
13964
  }
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
13965
  isHoldRotateKey(e) {
13904
13966
  const {rotateKey: rotateKey} = this.mergedConfig;
13905
13967
  if (rotateKey) return e.isHoldKeys(rotateKey);
@@ -13969,7 +14031,7 @@ class EditBox extends Group {
13969
14031
  const {rect: rect, editor: editor, __eventIds: events} = this;
13970
14032
  events.push(rect.on_([ [ PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
13971
14033
  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 ] ]));
14034
+ 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
14035
  });
13974
14036
  }
13975
14037
  __removeListenEvents() {
@@ -14722,6 +14784,9 @@ let Editor = class Editor extends Group {
14722
14784
  if (this.multiple) simulate(this);
14723
14785
  this.update();
14724
14786
  }
14787
+ getEditTool(name) {
14788
+ return this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14789
+ }
14725
14790
  updateEditTool() {
14726
14791
  this.unloadEditTool();
14727
14792
  if (this.editing) {
@@ -14736,7 +14801,7 @@ let Editor = class Editor extends Group {
14736
14801
  if (isString(check)) name = check; else if (check === false) return;
14737
14802
  }
14738
14803
  if (EditToolCreator.list[name]) {
14739
- const tool = this.editTool = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14804
+ const tool = this.editTool = this.getEditTool(name);
14740
14805
  this.editBox.load();
14741
14806
  tool.load();
14742
14807
  this.update();
@@ -14828,6 +14893,9 @@ let Editor = class Editor extends Group {
14828
14893
  this.emitEvent(event);
14829
14894
  if (group) group.emitEvent(event);
14830
14895
  }
14896
+ getInnerEditor(name) {
14897
+ return this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14898
+ }
14831
14899
  openInnerEditor(target, nameOrSelect, select) {
14832
14900
  let name;
14833
14901
  if (isString(nameOrSelect)) name = nameOrSelect; else if (!select) select = nameOrSelect;
@@ -14846,7 +14914,7 @@ let Editor = class Editor extends Group {
14846
14914
  if (EditToolCreator.list[name]) {
14847
14915
  this.editTool.unload();
14848
14916
  this.innerEditing = true;
14849
- this.innerEditor = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14917
+ this.innerEditor = this.getInnerEditor(name);
14850
14918
  this.innerEditor.editTarget = target;
14851
14919
  this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN);
14852
14920
  this.innerEditor.load();
@@ -16928,7 +16996,7 @@ UI.addAttr("endArrow", "none", arrowType);
16928
16996
  Object.assign(PathArrow, PathArrowModule);
16929
16997
 
16930
16998
  Object.assign(Paint, {
16931
- strokeArrow(_stroke, ui, canvas) {
16999
+ strokeArrow(_stroke, ui, canvas, _renderOptions) {
16932
17000
  if (ui.__.dashPattern) {
16933
17001
  canvas.beginPath();
16934
17002
  ui.__drawPathByData(canvas, ui.__.__pathForArrow);
@@ -19813,4 +19881,4 @@ Plugin.add("bright");
19813
19881
 
19814
19882
  UI.addAttr("bright", false, dimType);
19815
19883
 
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 };
19884
+ 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 };