@leafer-draw/miniapp 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$1;
30
- if (types[typeName]) {
31
- return types[typeName]++;
32
- } else {
33
- types[typeName] = 1;
34
- return 0;
35
- }
36
- }
37
- };
38
-
39
- const I$1 = IncrementId;
40
-
41
1
  var Answer;
42
2
 
43
3
  (function(Answer) {
@@ -247,9 +207,80 @@ class LeafData {
247
207
  }
248
208
  }
249
209
 
210
+ const {floor: floor$2, max: max$4} = 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$4(floor$2(width + (xGap || 0)), 1), max$4(floor$2(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$1;
270
+ if (types[typeName]) {
271
+ return types[typeName]++;
272
+ } else {
273
+ types[typeName] = 1;
274
+ return 0;
275
+ }
276
+ }
277
+ };
278
+
279
+ const I$1 = IncrementId;
280
+
250
281
  let tempA, tempB, tempTo;
251
282
 
252
- const {max: max$4} = Math, tempFour = [ 0, 0, 0, 0 ];
283
+ const {max: max$3} = 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$4(t, other);
335
+ if (isNumber(t) && isNumber(other)) return max$3(t, other);
305
336
  toTempAB(t, other, change);
306
- return set$2(tempTo, max$4(tempA[0], tempB[0]), max$4(tempA[1], tempB[1]), max$4(tempA[2], tempB[2]), max$4(tempA[3], tempB[3]));
337
+ return set$2(tempTo, max$3(tempA[0], tempB[0]), max$3(tempA[1], tempB[1]), max$3(tempA[2], tempB[2]), max$3(tempA[3], tempB[3]));
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$3, pow: pow$1, PI: PI$3} = Math;
354
+ const {round: round$3, pow: pow$1, max: max$2, floor: floor$1, PI: PI$3} = 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$2(floor$1(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, fourNumber: fourNumber} = MathHelper;
1204
1238
 
1205
- const {floor: floor$2, ceil: ceil$2} = Math;
1239
+ const {floor: floor, ceil: ceil$1} = Math;
1206
1240
 
1207
1241
  let right$1, bottom$1, 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.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$2(t.x);
1363
- t.y = floor$2(t.y);
1364
- t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
1365
- t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
1396
+ t.x = floor(t.x);
1397
+ t.y = floor(t.y);
1398
+ t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
1399
+ t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(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$3, cos: cos$3, hypot: hypot, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
2629
+ const {sin: sin$3, cos: cos$3, hypot: hypot, atan2: atan2$1, ceil: ceil, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
2596
2630
 
2597
2631
  const {setPoint: setPoint$1, addPoint: addPoint$1} = 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$1(abs$3(totalRadian / PI_2));
2737
+ const parts = ceil(abs$3(totalRadian / PI_2));
2704
2738
  const partRadian = totalRadian / parts;
2705
2739
  const partRadian4Sin = sin$3(partRadian / 4);
2706
2740
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(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$8.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 = ImageManager;
4027
4059
 
4028
4060
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
4029
4061
 
4030
- const {floor: floor$1, max: max$3} = 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$3(floor$1(width + (xGap || 0)), 1), max$3(floor$1(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() {
@@ -5809,12 +5825,12 @@ const {toBounds: toBounds} = 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() {
@@ -7744,7 +7760,7 @@ const Transition = {
7744
7760
 
7745
7761
  const {parse: parse, objectToCanvasData: objectToCanvasData} = PathConvert;
7746
7762
 
7747
- const {stintSet: stintSet$2} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
7763
+ const {stintSet: stintSet$3} = DataHelper, {hasTransparent: hasTransparent$2} = ColorConvert;
7748
7764
 
7749
7765
  const emptyPaint = {};
7750
7766
 
@@ -7811,7 +7827,7 @@ class UIData extends LeafData {
7811
7827
  setFill(value) {
7812
7828
  if (this.__naturalWidth) this.__removeNaturalSize();
7813
7829
  if (isString(value) || !value) {
7814
- stintSet$2(this, "__isTransparentFill", hasTransparent$2(value));
7830
+ stintSet$3(this, "__isTransparentFill", hasTransparent$2(value));
7815
7831
  this.__isFills && this.__removePaint("fill", true);
7816
7832
  this._fill = value;
7817
7833
  } else if (isObject(value)) {
@@ -7820,7 +7836,7 @@ class UIData extends LeafData {
7820
7836
  }
7821
7837
  setStroke(value) {
7822
7838
  if (isString(value) || !value) {
7823
- stintSet$2(this, "__isTransparentStroke", hasTransparent$2(value));
7839
+ stintSet$3(this, "__isTransparentStroke", hasTransparent$2(value));
7824
7840
  this.__isStrokes && this.__removePaint("stroke", true);
7825
7841
  this._stroke = value;
7826
7842
  } else if (isObject(value)) {
@@ -7878,11 +7894,11 @@ class UIData extends LeafData {
7878
7894
  if (removeInput) this.__removeInput(attrName);
7879
7895
  PaintImage.recycleImage(attrName, this);
7880
7896
  if (attrName === "fill") {
7881
- stintSet$2(this, "__isAlphaPixelFill", undefined);
7897
+ stintSet$3(this, "__isAlphaPixelFill", undefined);
7882
7898
  this._fill = this.__isFills = undefined;
7883
7899
  } else {
7884
- stintSet$2(this, "__isAlphaPixelStroke", undefined);
7885
- stintSet$2(this, "__hasMultiStrokeStyle", undefined);
7900
+ stintSet$3(this, "__isAlphaPixelStroke", undefined);
7901
+ stintSet$3(this, "__hasMultiStrokeStyle", undefined);
7886
7902
  this._stroke = this.__isStrokes = undefined;
7887
7903
  }
7888
7904
  }
@@ -8031,7 +8047,7 @@ class CanvasData extends RectData {
8031
8047
  }
8032
8048
  }
8033
8049
 
8034
- const {max: max$2, add: add$1} = FourNumberHelper;
8050
+ const {max: max$1, add: add$1} = FourNumberHelper;
8035
8051
 
8036
8052
  const UIBounds = {
8037
8053
  __updateStrokeSpread() {
@@ -8047,7 +8063,7 @@ const UIBounds = {
8047
8063
  }
8048
8064
  if (data.__useArrow) spread += strokeWidth * 5;
8049
8065
  if (box) {
8050
- spread = max$2(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
8066
+ spread = max$1(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
8051
8067
  boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
8052
8068
  }
8053
8069
  this.__layout.strokeBoxSpread = boxSpread;
@@ -8057,35 +8073,35 @@ const UIBounds = {
8057
8073
  let spread = 0;
8058
8074
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
8059
8075
  if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
8060
- if (blur) spread = max$2(spread, blur);
8076
+ if (blur) spread = max$1(spread, blur);
8061
8077
  if (filter) spread = add$1(spread, Filter.getSpread(filter));
8062
8078
  if (renderSpread) spread = add$1(spread, renderSpread);
8063
8079
  if (strokeSpread) spread = add$1(spread, strokeSpread);
8064
8080
  let shapeSpread = spread;
8065
- if (innerShadow) shapeSpread = max$2(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
8066
- if (backgroundBlur) shapeSpread = max$2(shapeSpread, backgroundBlur);
8081
+ if (innerShadow) shapeSpread = max$1(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
8082
+ if (backgroundBlur) shapeSpread = max$1(shapeSpread, backgroundBlur);
8067
8083
  this.__layout.renderShapeSpread = shapeSpread;
8068
- return box ? max$2(box.__updateRenderSpread(), spread) : spread;
8084
+ return box ? max$1(box.__updateRenderSpread(), spread) : spread;
8069
8085
  }
8070
8086
  };
8071
8087
 
8072
- const {stintSet: stintSet$1} = DataHelper;
8088
+ const {stintSet: stintSet$2} = DataHelper;
8073
8089
 
8074
8090
  const UIRender = {
8075
8091
  __updateChange() {
8076
8092
  const data = this.__;
8077
8093
  if (data.__useStroke) {
8078
8094
  const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
8079
- stintSet$1(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
8080
- stintSet$1(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
8095
+ stintSet$2(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
8096
+ stintSet$2(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
8081
8097
  }
8082
8098
  if (data.__useEffect) {
8083
8099
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
8084
- 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"));
8100
+ 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"));
8085
8101
  data.__useEffect = !!(shadow || otherEffect);
8086
8102
  }
8087
8103
  data.__checkSingle();
8088
- stintSet$1(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
8104
+ stintSet$2(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
8089
8105
  },
8090
8106
  __drawFast(canvas, options) {
8091
8107
  drawFast(this, canvas, options);
@@ -8101,24 +8117,24 @@ const UIRender = {
8101
8117
  this.__nowWorld = this.__getNowWorld(options);
8102
8118
  const {shadow: shadow, innerShadow: innerShadow, filter: filter} = data;
8103
8119
  if (shadow) Effect.shadow(this, canvas, shape);
8104
- if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
8105
- if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
8120
+ if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
8121
+ if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
8106
8122
  if (__drawAfterFill) this.__drawAfterFill(canvas, options);
8107
8123
  if (innerShadow) Effect.innerShadow(this, canvas, shape);
8108
- if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
8124
+ if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
8109
8125
  if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
8110
8126
  if (shape.worldCanvas) shape.worldCanvas.recycle();
8111
8127
  shape.canvas.recycle();
8112
8128
  } else {
8113
- if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
8129
+ if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
8114
8130
  if (__isFastShadow) {
8115
8131
  const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
8116
8132
  canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
8117
8133
  }
8118
- if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
8134
+ if (fill) data.__isFills ? Paint.fills(fill, this, canvas, options) : Paint.fill(fill, this, canvas, options);
8119
8135
  if (__isFastShadow) canvas.restore();
8120
8136
  if (__drawAfterFill) this.__drawAfterFill(canvas, options);
8121
- if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
8137
+ if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
8122
8138
  }
8123
8139
  } else {
8124
8140
  if (data.__pathInputed) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
@@ -8127,9 +8143,9 @@ const UIRender = {
8127
8143
  __drawShape(canvas, options) {
8128
8144
  this.__drawRenderPath(canvas);
8129
8145
  const data = this.__, {fill: fill, stroke: stroke} = data;
8130
- if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill("#000000", this, canvas);
8146
+ if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas, options) : Paint.fill("#000000", this, canvas, options);
8131
8147
  if (data.__isCanvas) this.__drawAfterFill(canvas, options);
8132
- if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke("#000000", this, canvas);
8148
+ if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke("#000000", this, canvas, options);
8133
8149
  },
8134
8150
  __drawAfterFill(canvas, options) {
8135
8151
  if (this.__.__clipAfterFill) {
@@ -8144,10 +8160,10 @@ const UIRender = {
8144
8160
  function drawFast(ui, canvas, options) {
8145
8161
  const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke} = ui.__;
8146
8162
  ui.__drawRenderPath(canvas);
8147
- if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
8148
- if (fill) Paint.fill(fill, ui, canvas);
8163
+ if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
8164
+ if (fill) Paint.fill(fill, ui, canvas, options);
8149
8165
  if (__drawAfterFill) ui.__drawAfterFill(canvas, options);
8150
- if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
8166
+ if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas, options);
8151
8167
  }
8152
8168
 
8153
8169
  const RectRender = {
@@ -8285,8 +8301,8 @@ let UI = UI_1 = class UI extends Leaf {
8285
8301
  drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
8286
8302
  } else drawer.rect(x, y, width, height);
8287
8303
  }
8288
- drawImagePlaceholder(canvas, _image) {
8289
- Paint.fill(this.__.placeholderColor, this, canvas);
8304
+ drawImagePlaceholder(_image, canvas, renderOptions) {
8305
+ Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
8290
8306
  }
8291
8307
  animate(keyframe, _options, _type, _isTemp) {
8292
8308
  this.set(keyframe);
@@ -9308,7 +9324,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
9308
9324
 
9309
9325
  Canvas = __decorate([ registerUI() ], Canvas);
9310
9326
 
9311
- const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
9327
+ const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
9312
9328
 
9313
9329
  let Text = class Text extends UI {
9314
9330
  get __tag() {
@@ -9320,13 +9336,14 @@ let Text = class Text extends UI {
9320
9336
  }
9321
9337
  __updateTextDrawData() {
9322
9338
  const data = this.__;
9323
- const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
9339
+ const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
9324
9340
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
9325
9341
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
9326
- data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
9327
9342
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
9328
9343
  data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
9329
- data.__clipText = textOverflow !== "show" && !data.__autoSize;
9344
+ stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
9345
+ stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
9346
+ stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
9330
9347
  data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
9331
9348
  }
9332
9349
  __updateBoxBounds() {
@@ -9536,36 +9553,19 @@ function penPathType() {
9536
9553
  };
9537
9554
  }
9538
9555
 
9539
- function fillText(ui, canvas) {
9540
- const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
9541
- if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
9542
- let row;
9543
- for (let i = 0, len = rows.length; i < len; i++) {
9544
- row = rows[i];
9545
- if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
9546
- canvas.fillText(charData.char, charData.x, row.y);
9547
- });
9548
- }
9549
- if (decorationY) {
9550
- const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
9551
- if (decorationColor) canvas.fillStyle = decorationColor;
9552
- rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
9553
- }
9554
- }
9555
-
9556
- function fill(fill, ui, canvas) {
9556
+ function fill(fill, ui, canvas, renderOptions) {
9557
9557
  canvas.fillStyle = fill;
9558
- fillPathOrText(ui, canvas);
9558
+ fillPathOrText(ui, canvas, renderOptions);
9559
9559
  }
9560
9560
 
9561
- function fills(fills, ui, canvas) {
9561
+ function fills(fills, ui, canvas, renderOptions) {
9562
9562
  let item;
9563
9563
  for (let i = 0, len = fills.length; i < len; i++) {
9564
9564
  item = fills[i];
9565
9565
  if (item.image) {
9566
- if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font)) continue;
9566
+ if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
9567
9567
  if (!item.style) {
9568
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas, item.image);
9568
+ if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
9569
9569
  continue;
9570
9570
  }
9571
9571
  }
@@ -9578,60 +9578,137 @@ function fills(fills, ui, canvas) {
9578
9578
  if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
9579
9579
  }
9580
9580
  if (item.blendMode) canvas.blendMode = item.blendMode;
9581
- fillPathOrText(ui, canvas);
9581
+ fillPathOrText(ui, canvas, renderOptions);
9582
9582
  canvas.restore();
9583
9583
  } else {
9584
9584
  if (item.blendMode) {
9585
9585
  canvas.saveBlendMode(item.blendMode);
9586
- fillPathOrText(ui, canvas);
9586
+ fillPathOrText(ui, canvas, renderOptions);
9587
9587
  canvas.restoreBlendMode();
9588
- } else fillPathOrText(ui, canvas);
9588
+ } else fillPathOrText(ui, canvas, renderOptions);
9589
+ }
9590
+ }
9591
+ }
9592
+
9593
+ function fillPathOrText(ui, canvas, renderOptions) {
9594
+ ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
9595
+ }
9596
+
9597
+ function fillText(ui, canvas, _renderOptions) {
9598
+ const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
9599
+ if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
9600
+ let row;
9601
+ for (let i = 0, len = rows.length; i < len; i++) {
9602
+ row = rows[i];
9603
+ if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
9604
+ canvas.fillText(charData.char, charData.x, row.y);
9605
+ });
9606
+ }
9607
+ if (decorationY) {
9608
+ const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
9609
+ if (decorationColor) canvas.fillStyle = decorationColor;
9610
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
9611
+ }
9612
+ }
9613
+
9614
+ function stroke(stroke, ui, canvas, renderOptions) {
9615
+ const data = ui.__;
9616
+ if (!data.__strokeWidth) return;
9617
+ if (data.__font) {
9618
+ Paint.strokeText(stroke, ui, canvas, renderOptions);
9619
+ } else {
9620
+ switch (data.strokeAlign) {
9621
+ case "center":
9622
+ drawCenter$1(stroke, 1, ui, canvas, renderOptions);
9623
+ break;
9624
+
9625
+ case "inside":
9626
+ drawInside(stroke, ui, canvas, renderOptions);
9627
+ break;
9628
+
9629
+ case "outside":
9630
+ drawOutside(stroke, ui, canvas, renderOptions);
9631
+ break;
9589
9632
  }
9590
9633
  }
9591
9634
  }
9592
9635
 
9593
- function fillPathOrText(ui, canvas) {
9594
- ui.__.__font ? fillText(ui, canvas) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
9636
+ function strokes(strokes, ui, canvas, renderOptions) {
9637
+ Paint.stroke(strokes, ui, canvas, renderOptions);
9638
+ }
9639
+
9640
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas, renderOptions) {
9641
+ const data = ui.__;
9642
+ if (isObject(stroke)) {
9643
+ Paint.drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas, renderOptions);
9644
+ } else {
9645
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
9646
+ canvas.stroke();
9647
+ }
9648
+ if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas, renderOptions);
9649
+ }
9650
+
9651
+ function drawInside(stroke, ui, canvas, renderOptions) {
9652
+ canvas.save();
9653
+ canvas.clipUI(ui);
9654
+ drawCenter$1(stroke, 2, ui, canvas, renderOptions);
9655
+ canvas.restore();
9656
+ }
9657
+
9658
+ function drawOutside(stroke, ui, canvas, renderOptions) {
9659
+ const data = ui.__;
9660
+ if (data.__fillAfterStroke) {
9661
+ drawCenter$1(stroke, 2, ui, canvas, renderOptions);
9662
+ } else {
9663
+ const {renderBounds: renderBounds} = ui.__layout;
9664
+ const out = canvas.getSameCanvas(true, true);
9665
+ ui.__drawRenderPath(out);
9666
+ drawCenter$1(stroke, 2, ui, out, renderOptions);
9667
+ out.clipUI(data);
9668
+ out.clearWorld(renderBounds);
9669
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
9670
+ out.recycle(ui.__nowWorld);
9671
+ }
9595
9672
  }
9596
9673
 
9597
- function strokeText(stroke, ui, canvas) {
9674
+ function strokeText(stroke, ui, canvas, renderOptions) {
9598
9675
  switch (ui.__.strokeAlign) {
9599
9676
  case "center":
9600
- drawCenter$1(stroke, 1, ui, canvas);
9677
+ drawCenter(stroke, 1, ui, canvas, renderOptions);
9601
9678
  break;
9602
9679
 
9603
9680
  case "inside":
9604
- drawAlign(stroke, "inside", ui, canvas);
9681
+ drawAlign(stroke, "inside", ui, canvas, renderOptions);
9605
9682
  break;
9606
9683
 
9607
9684
  case "outside":
9608
- ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, "outside", ui, canvas);
9685
+ ui.__.__fillAfterStroke ? drawCenter(stroke, 2, ui, canvas, renderOptions) : drawAlign(stroke, "outside", ui, canvas, renderOptions);
9609
9686
  break;
9610
9687
  }
9611
9688
  }
9612
9689
 
9613
- function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
9690
+ function drawCenter(stroke, strokeWidthScale, ui, canvas, renderOptions) {
9614
9691
  const data = ui.__;
9615
9692
  if (isObject(stroke)) {
9616
- drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
9693
+ Paint.drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas, renderOptions);
9617
9694
  } else {
9618
9695
  canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
9619
- drawTextStroke(ui, canvas);
9696
+ Paint.drawTextStroke(ui, canvas, renderOptions);
9620
9697
  }
9621
9698
  }
9622
9699
 
9623
- function drawAlign(stroke, align, ui, canvas) {
9700
+ function drawAlign(stroke, align, ui, canvas, renderOptions) {
9624
9701
  const out = canvas.getSameCanvas(true, true);
9625
9702
  out.font = ui.__.__font;
9626
- drawCenter$1(stroke, 2, ui, out);
9703
+ drawCenter(stroke, 2, ui, out, renderOptions);
9627
9704
  out.blendMode = align === "outside" ? "destination-out" : "destination-in";
9628
- fillText(ui, out);
9705
+ Paint.fillText(ui, out, renderOptions);
9629
9706
  out.blendMode = "normal";
9630
9707
  LeafHelper.copyCanvasByWorld(ui, canvas, out);
9631
9708
  out.recycle(ui.__nowWorld);
9632
9709
  }
9633
9710
 
9634
- function drawTextStroke(ui, canvas) {
9711
+ function drawTextStroke(ui, canvas, _renderOptions) {
9635
9712
  let row, data = ui.__.__textDrawData;
9636
9713
  const {rows: rows, decorationY: decorationY} = data;
9637
9714
  for (let i = 0, len = rows.length; i < len; i++) {
@@ -9646,13 +9723,13 @@ function drawTextStroke(ui, canvas) {
9646
9723
  }
9647
9724
  }
9648
9725
 
9649
- function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
9726
+ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderOptions) {
9650
9727
  let item;
9651
9728
  const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
9652
9729
  __hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
9653
9730
  for (let i = 0, len = strokes.length; i < len; i++) {
9654
9731
  item = strokes[i];
9655
- if (item.image && PaintImage.checkImage(ui, canvas, item, false)) continue;
9732
+ if (item.image && PaintImage.checkImage(item, false, ui, canvas, renderOptions)) continue;
9656
9733
  if (item.style) {
9657
9734
  if (__hasMultiStrokeStyle) {
9658
9735
  const {strokeStyle: strokeStyle} = item;
@@ -9660,75 +9737,15 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
9660
9737
  } else canvas.strokeStyle = item.style;
9661
9738
  if (item.blendMode) {
9662
9739
  canvas.saveBlendMode(item.blendMode);
9663
- isText ? drawTextStroke(ui, canvas) : canvas.stroke();
9740
+ isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
9664
9741
  canvas.restoreBlendMode();
9665
9742
  } else {
9666
- isText ? drawTextStroke(ui, canvas) : canvas.stroke();
9743
+ isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
9667
9744
  }
9668
9745
  }
9669
9746
  }
9670
9747
  }
9671
9748
 
9672
- function stroke(stroke, ui, canvas) {
9673
- const data = ui.__;
9674
- if (!data.__strokeWidth) return;
9675
- if (data.__font) {
9676
- strokeText(stroke, ui, canvas);
9677
- } else {
9678
- switch (data.strokeAlign) {
9679
- case "center":
9680
- drawCenter(stroke, 1, ui, canvas);
9681
- break;
9682
-
9683
- case "inside":
9684
- drawInside(stroke, ui, canvas);
9685
- break;
9686
-
9687
- case "outside":
9688
- drawOutside(stroke, ui, canvas);
9689
- break;
9690
- }
9691
- }
9692
- }
9693
-
9694
- function strokes(strokes, ui, canvas) {
9695
- stroke(strokes, ui, canvas);
9696
- }
9697
-
9698
- function drawCenter(stroke, strokeWidthScale, ui, canvas) {
9699
- const data = ui.__;
9700
- if (isObject(stroke)) {
9701
- drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
9702
- } else {
9703
- canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
9704
- canvas.stroke();
9705
- }
9706
- if (data.__useArrow) Paint.strokeArrow(stroke, ui, canvas);
9707
- }
9708
-
9709
- function drawInside(stroke, ui, canvas) {
9710
- canvas.save();
9711
- canvas.clipUI(ui);
9712
- drawCenter(stroke, 2, ui, canvas);
9713
- canvas.restore();
9714
- }
9715
-
9716
- function drawOutside(stroke, ui, canvas) {
9717
- const data = ui.__;
9718
- if (data.__fillAfterStroke) {
9719
- drawCenter(stroke, 2, ui, canvas);
9720
- } else {
9721
- const {renderBounds: renderBounds} = ui.__layout;
9722
- const out = canvas.getSameCanvas(true, true);
9723
- ui.__drawRenderPath(out);
9724
- drawCenter(stroke, 2, ui, out);
9725
- out.clipUI(data);
9726
- out.clearWorld(renderBounds);
9727
- LeafHelper.copyCanvasByWorld(ui, canvas, out);
9728
- out.recycle(ui.__nowWorld);
9729
- }
9730
- }
9731
-
9732
9749
  const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
9733
9750
 
9734
9751
  const tempBounds$1 = {};
@@ -9884,88 +9901,118 @@ const PaintModule = {
9884
9901
  strokes: strokes,
9885
9902
  strokeText: strokeText,
9886
9903
  drawTextStroke: drawTextStroke,
9904
+ drawStrokesStyle: drawStrokesStyle,
9887
9905
  shape: shape
9888
9906
  };
9889
9907
 
9890
- let origin = {}, tempMatrix$1 = getMatrixData();
9891
-
9892
- const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
9893
-
9894
- function stretchMode(data, box, scaleX, scaleY) {
9895
- const transform = get$3();
9896
- translate$1(transform, box.x, box.y);
9897
- if (scaleX) scaleHelper(transform, scaleX, scaleY);
9898
- data.transform = transform;
9899
- }
9900
-
9901
- function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
9902
- const transform = get$3();
9903
- translate$1(transform, box.x + x, box.y + y);
9904
- scaleHelper(transform, scaleX, scaleY);
9905
- if (rotation) rotateOfOuter$1(transform, {
9906
- x: box.x + box.width / 2,
9907
- y: box.y + box.height / 2
9908
- }, rotation);
9909
- data.transform = transform;
9910
- }
9908
+ let cache, box = new Bounds;
9911
9909
 
9912
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
9913
- const transform = get$3();
9914
- layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
9915
- if (clipScaleX) {
9916
- if (rotation || skew) {
9917
- set(tempMatrix$1);
9918
- scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
9919
- multiplyParent(transform, tempMatrix$1);
9920
- } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
9921
- }
9922
- data.transform = transform;
9923
- }
9910
+ const {isSame: isSame} = BoundsHelper;
9924
9911
 
9925
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
9926
- const transform = get$3();
9927
- if (freeTransform) {
9928
- layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
9929
- } else {
9930
- if (rotation) {
9931
- if (align === "center") {
9932
- rotateOfOuter$1(transform, {
9933
- x: width / 2,
9934
- y: height / 2
9935
- }, rotation);
9936
- } else {
9937
- rotate(transform, rotation);
9938
- switch (rotation) {
9939
- case 90:
9940
- translate$1(transform, height, 0);
9941
- break;
9942
-
9943
- case 180:
9944
- translate$1(transform, width, height);
9945
- break;
9946
-
9947
- case 270:
9948
- translate$1(transform, 0, width);
9949
- break;
9912
+ function image(ui, attrName, paint, boxBounds, firstUse) {
9913
+ let leafPaint, event;
9914
+ const image = ImageManager.get(paint);
9915
+ if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
9916
+ leafPaint = cache.leafPaint;
9917
+ } else {
9918
+ leafPaint = {
9919
+ type: paint.type,
9920
+ image: image
9921
+ };
9922
+ if (image.hasAlphaPixel) leafPaint.isTransparent = true;
9923
+ cache = image.use > 1 ? {
9924
+ leafPaint: leafPaint,
9925
+ paint: paint,
9926
+ boxBounds: box.set(boxBounds)
9927
+ } : null;
9928
+ }
9929
+ if (firstUse || image.loading) event = {
9930
+ image: image,
9931
+ attrName: attrName,
9932
+ attrValue: paint
9933
+ };
9934
+ if (image.ready) {
9935
+ checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
9936
+ if (firstUse) {
9937
+ onLoad(ui, event);
9938
+ onLoadSuccess(ui, event);
9939
+ }
9940
+ } else if (image.error) {
9941
+ if (firstUse) onLoadError(ui, event, image.error);
9942
+ } else {
9943
+ if (firstUse) {
9944
+ ignoreRender(ui, true);
9945
+ onLoad(ui, event);
9946
+ }
9947
+ leafPaint.loadId = image.load(() => {
9948
+ ignoreRender(ui, false);
9949
+ if (!ui.destroyed) {
9950
+ if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
9951
+ if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
9952
+ ui.forceUpdate("surface");
9950
9953
  }
9954
+ onLoadSuccess(ui, event);
9951
9955
  }
9956
+ leafPaint.loadId = undefined;
9957
+ }, error => {
9958
+ ignoreRender(ui, false);
9959
+ onLoadError(ui, event, error);
9960
+ leafPaint.loadId = undefined;
9961
+ });
9962
+ if (ui.placeholderColor) {
9963
+ if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
9964
+ if (!image.ready) {
9965
+ image.isPlacehold = true;
9966
+ ui.forceUpdate("surface");
9967
+ }
9968
+ }, ui.placeholderDelay);
9952
9969
  }
9953
- origin.x = box.x + x;
9954
- origin.y = box.y + y;
9955
- translate$1(transform, origin.x, origin.y);
9956
- if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
9957
9970
  }
9958
- data.transform = transform;
9971
+ return leafPaint;
9959
9972
  }
9960
9973
 
9961
- function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
9962
- if (rotation) rotate(transform, rotation);
9963
- if (skew) skewHelper(transform, skew.x, skew.y);
9964
- if (scaleX) scaleHelper(transform, scaleX, scaleY);
9965
- translate$1(transform, box.x + x, box.y + y);
9974
+ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
9975
+ if (attrName === "fill" && !ui.__.__naturalWidth) {
9976
+ const data = ui.__;
9977
+ data.__naturalWidth = image.width / data.pixelRatio;
9978
+ data.__naturalHeight = image.height / data.pixelRatio;
9979
+ if (data.__autoSide) {
9980
+ ui.forceUpdate("width");
9981
+ if (ui.__proxyData) {
9982
+ ui.setProxyAttr("width", data.width);
9983
+ ui.setProxyAttr("height", data.height);
9984
+ }
9985
+ return false;
9986
+ }
9987
+ }
9988
+ if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
9989
+ return true;
9990
+ }
9991
+
9992
+ function onLoad(ui, event) {
9993
+ emit(ui, ImageEvent.LOAD, event);
9994
+ }
9995
+
9996
+ function onLoadSuccess(ui, event) {
9997
+ emit(ui, ImageEvent.LOADED, event);
9998
+ }
9999
+
10000
+ function onLoadError(ui, event, error) {
10001
+ event.error = error;
10002
+ ui.forceUpdate("surface");
10003
+ emit(ui, ImageEvent.ERROR, event);
10004
+ }
10005
+
10006
+ function emit(ui, type, data) {
10007
+ if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
9966
10008
  }
9967
10009
 
9968
- const {get: get$2, translate: translate} = MatrixHelper;
10010
+ function ignoreRender(ui, value) {
10011
+ const {leafer: leafer} = ui;
10012
+ if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
10013
+ }
10014
+
10015
+ const {get: get$3, translate: translate$1} = MatrixHelper;
9969
10016
 
9970
10017
  const tempBox = new Bounds;
9971
10018
 
@@ -9978,13 +10025,13 @@ function createData(leafPaint, image, paint, box) {
9978
10025
  if (changeful) leafPaint.changeful = changeful;
9979
10026
  if (sync) leafPaint.sync = sync;
9980
10027
  if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
9981
- leafPaint.data = getPatternData(paint, box, image);
10028
+ leafPaint.data = PaintImage.getPatternData(paint, box, image);
9982
10029
  }
9983
10030
 
9984
10031
  function getPatternData(paint, box, image) {
9985
10032
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
9986
10033
  if (paint.mode === "strench") paint.mode = "stretch";
9987
- let {width: width, height: height} = image;
10034
+ const {width: width, height: height} = image;
9988
10035
  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;
9989
10036
  const sameBox = box.width === width && box.height === height;
9990
10037
  const data = {
@@ -10015,8 +10062,8 @@ function getPatternData(paint, box, image) {
10015
10062
  case "stretch":
10016
10063
  if (!sameBox) {
10017
10064
  scaleX = box.width / width, scaleY = box.height / height;
10018
- stretchMode(data, box, scaleX, scaleY);
10019
- }
10065
+ PaintImage.stretchMode(data, box, scaleX, scaleY);
10066
+ } else if (scaleX) scaleX = scaleY = undefined;
10020
10067
  break;
10021
10068
 
10022
10069
  case "normal":
@@ -10024,13 +10071,13 @@ function getPatternData(paint, box, image) {
10024
10071
  if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
10025
10072
  let clipScaleX, clipScaleY;
10026
10073
  if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
10027
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
10074
+ PaintImage.clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
10028
10075
  if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
10029
10076
  }
10030
10077
  break;
10031
10078
 
10032
10079
  case "repeat":
10033
- if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
10080
+ if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
10034
10081
  if (!repeat) data.repeat = "repeat";
10035
10082
  const count = isObject(repeat);
10036
10083
  if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
@@ -10039,18 +10086,16 @@ function getPatternData(paint, box, image) {
10039
10086
  case "fit":
10040
10087
  case "cover":
10041
10088
  default:
10042
- if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10089
+ if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10043
10090
  }
10044
10091
  if (!data.transform) {
10045
- if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
10092
+ if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
10046
10093
  }
10047
- data.width = width;
10048
- data.height = height;
10049
10094
  if (scaleX) {
10050
10095
  data.scaleX = scaleX;
10051
10096
  data.scaleY = scaleY;
10052
10097
  }
10053
- if (opacity) data.opacity = opacity;
10098
+ if (opacity && opacity < 1) data.opacity = opacity;
10054
10099
  if (filters) data.filters = filters;
10055
10100
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
10056
10101
  return data;
@@ -10072,234 +10117,194 @@ function getGapValue(gap, size, totalSize, rows) {
10072
10117
  return gap === "auto" ? value < 0 ? 0 : value : value;
10073
10118
  }
10074
10119
 
10075
- let cache, box = new Bounds;
10120
+ let origin = {}, tempMatrix$1 = getMatrixData();
10076
10121
 
10077
- const {isSame: isSame} = BoundsHelper;
10122
+ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
10078
10123
 
10079
- function image(ui, attrName, paint, boxBounds, firstUse) {
10080
- let leafPaint, event;
10081
- const image = ImageManager.get(paint);
10082
- if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
10083
- leafPaint = cache.leafPaint;
10084
- } else {
10085
- leafPaint = {
10086
- type: paint.type,
10087
- image: image
10088
- };
10089
- if (image.hasAlphaPixel) leafPaint.isTransparent = true;
10090
- cache = image.use > 1 ? {
10091
- leafPaint: leafPaint,
10092
- paint: paint,
10093
- boxBounds: box.set(boxBounds)
10094
- } : null;
10095
- }
10096
- if (firstUse || image.loading) event = {
10097
- image: image,
10098
- attrName: attrName,
10099
- attrValue: paint
10100
- };
10101
- if (image.ready) {
10102
- checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
10103
- if (firstUse) {
10104
- onLoad(ui, event);
10105
- onLoadSuccess(ui, event);
10106
- }
10107
- } else if (image.error) {
10108
- if (firstUse) onLoadError(ui, event, image.error);
10109
- } else {
10110
- if (firstUse) {
10111
- ignoreRender(ui, true);
10112
- onLoad(ui, event);
10113
- }
10114
- leafPaint.loadId = image.load(() => {
10115
- ignoreRender(ui, false);
10116
- if (!ui.destroyed) {
10117
- if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
10118
- if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
10119
- ui.forceUpdate("surface");
10120
- }
10121
- onLoadSuccess(ui, event);
10122
- }
10123
- leafPaint.loadId = undefined;
10124
- }, error => {
10125
- ignoreRender(ui, false);
10126
- onLoadError(ui, event, error);
10127
- leafPaint.loadId = undefined;
10128
- });
10129
- if (ui.placeholderColor) {
10130
- if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
10131
- if (!image.ready) {
10132
- image.isPlacehold = true;
10133
- ui.forceUpdate("surface");
10134
- }
10135
- }, ui.placeholderDelay);
10136
- }
10137
- }
10138
- return leafPaint;
10124
+ function stretchMode(data, box, scaleX, scaleY) {
10125
+ const transform = get$2(), {x: x, y: y} = box;
10126
+ if (x || y) translate(transform, x, y); else transform.onlyScale = true;
10127
+ scaleHelper(transform, scaleX, scaleY);
10128
+ data.transform = transform;
10139
10129
  }
10140
10130
 
10141
- function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
10142
- if (attrName === "fill" && !ui.__.__naturalWidth) {
10143
- const data = ui.__;
10144
- data.__naturalWidth = image.width / data.pixelRatio;
10145
- data.__naturalHeight = image.height / data.pixelRatio;
10146
- if (data.__autoSide) {
10147
- ui.forceUpdate("width");
10148
- if (ui.__proxyData) {
10149
- ui.setProxyAttr("width", data.width);
10150
- ui.setProxyAttr("height", data.height);
10151
- }
10152
- return false;
10153
- }
10154
- }
10155
- if (!leafPaint.data) createData(leafPaint, image, paint, boxBounds);
10156
- return true;
10131
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10132
+ const transform = get$2();
10133
+ translate(transform, box.x + x, box.y + y);
10134
+ scaleHelper(transform, scaleX, scaleY);
10135
+ if (rotation) rotateOfOuter$1(transform, {
10136
+ x: box.x + box.width / 2,
10137
+ y: box.y + box.height / 2
10138
+ }, rotation);
10139
+ data.transform = transform;
10157
10140
  }
10158
10141
 
10159
- function onLoad(ui, event) {
10160
- emit(ui, ImageEvent.LOAD, event);
10142
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
10143
+ const transform = get$2();
10144
+ layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
10145
+ if (clipScaleX) {
10146
+ if (rotation || skew) {
10147
+ set(tempMatrix$1);
10148
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
10149
+ multiplyParent(transform, tempMatrix$1);
10150
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
10151
+ }
10152
+ data.transform = transform;
10161
10153
  }
10162
10154
 
10163
- function onLoadSuccess(ui, event) {
10164
- emit(ui, ImageEvent.LOADED, event);
10165
- }
10155
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
10156
+ const transform = get$2();
10157
+ if (freeTransform) {
10158
+ layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
10159
+ } else {
10160
+ if (rotation) {
10161
+ if (align === "center") {
10162
+ rotateOfOuter$1(transform, {
10163
+ x: width / 2,
10164
+ y: height / 2
10165
+ }, rotation);
10166
+ } else {
10167
+ rotate(transform, rotation);
10168
+ switch (rotation) {
10169
+ case 90:
10170
+ translate(transform, height, 0);
10171
+ break;
10166
10172
 
10167
- function onLoadError(ui, event, error) {
10168
- event.error = error;
10169
- ui.forceUpdate("surface");
10170
- emit(ui, ImageEvent.ERROR, event);
10171
- }
10173
+ case 180:
10174
+ translate(transform, width, height);
10175
+ break;
10172
10176
 
10173
- function emit(ui, type, data) {
10174
- if (ui.hasEvent(type)) ui.emitEvent(new ImageEvent(type, data));
10177
+ case 270:
10178
+ translate(transform, 0, width);
10179
+ break;
10180
+ }
10181
+ }
10182
+ }
10183
+ origin.x = box.x + x;
10184
+ origin.y = box.y + y;
10185
+ translate(transform, origin.x, origin.y);
10186
+ if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
10187
+ }
10188
+ data.transform = transform;
10175
10189
  }
10176
10190
 
10177
- function ignoreRender(ui, value) {
10178
- const {leafer: leafer} = ui;
10179
- if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
10191
+ function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
10192
+ if (rotation) rotate(transform, rotation);
10193
+ if (skew) skewHelper(transform, skew.x, skew.y);
10194
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
10195
+ translate(transform, box.x + x, box.y + y);
10180
10196
  }
10181
10197
 
10182
10198
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
10183
10199
 
10184
- const {floor: floor, ceil: ceil, max: max$1, abs: abs$1} = Math;
10200
+ const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
10201
+
10202
+ function createPatternTask(paint, ui, canvas, renderOptions) {
10203
+ if (!paint.patternTask) {
10204
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
10205
+ paint.patternTask = null;
10206
+ if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
10207
+ ui.forceUpdate("surface");
10208
+ }), 300);
10209
+ }
10210
+ }
10185
10211
 
10186
- function createPattern(ui, paint, pixelRatio) {
10187
- let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
10188
- const id = scaleX + "-" + scaleY + "-" + pixelRatio;
10212
+ function createPattern(paint, ui, canvas, renderOptions) {
10213
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
10189
10214
  if (paint.patternId !== id && !ui.destroyed) {
10190
- const {image: image, data: data} = paint;
10191
- let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
10192
- scaleX *= pixelRatio;
10193
- scaleY *= pixelRatio;
10194
- if (sx) {
10195
- sx = abs$1(sx);
10196
- sy = abs$1(sy);
10197
- imageMatrix = get$1();
10198
- copy$1(imageMatrix, transform);
10199
- scale(imageMatrix, 1 / sx, 1 / sy);
10200
- scaleX *= sx;
10201
- scaleY *= sy;
10202
- }
10203
- width *= scaleX;
10204
- height *= scaleY;
10205
- const size = width * height;
10206
- if (!repeat) {
10207
- if (size > Platform.image.maxCacheSize) return false;
10208
- }
10209
- let maxSize = Platform.image.maxPatternSize;
10210
- if (image.isSVG) {
10211
- const ws = width / image.width;
10212
- if (ws > 1) imageScale = ws / ceil(ws);
10213
- } else {
10214
- const imageSize = image.width * image.height;
10215
- if (maxSize > imageSize) maxSize = imageSize;
10216
- }
10217
- if (size > maxSize) imageScale = Math.sqrt(size / maxSize);
10218
- if (imageScale) {
10219
- scaleX /= imageScale;
10220
- scaleY /= imageScale;
10221
- width /= imageScale;
10222
- height /= imageScale;
10223
- }
10224
- if (sx) {
10225
- scaleX /= sx;
10226
- scaleY /= sy;
10227
- }
10228
- const xGap = gap && gap.x * scaleX;
10229
- const yGap = gap && gap.y * scaleY;
10230
- if (transform || scaleX !== 1 || scaleY !== 1) {
10231
- const canvasWidth = width + (xGap || 0);
10232
- const canvasHeight = height + (yGap || 0);
10233
- scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
10234
- scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
10235
- if (!imageMatrix) {
10215
+ if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
10216
+ const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
10217
+ let imageMatrix, xGap, yGap, {width: width, height: height} = image;
10218
+ if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
10219
+ width *= scaleX;
10220
+ height *= scaleY;
10221
+ if (gap) {
10222
+ xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
10223
+ yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
10224
+ }
10225
+ if (transform || scaleX !== 1 || scaleY !== 1) {
10226
+ scaleX *= getFloorScale(width + (xGap || 0));
10227
+ scaleY *= getFloorScale(height + (yGap || 0));
10236
10228
  imageMatrix = get$1();
10237
10229
  if (transform) copy$1(imageMatrix, transform);
10230
+ scale(imageMatrix, 1 / scaleX, 1 / scaleY);
10238
10231
  }
10239
- scale(imageMatrix, 1 / scaleX, 1 / scaleY);
10232
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
10233
+ const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
10234
+ paint.style = pattern;
10235
+ paint.patternId = id;
10240
10236
  }
10241
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
10242
- const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
10243
- paint.style = pattern;
10244
- paint.patternId = id;
10245
- return true;
10237
+ }
10238
+ }
10239
+
10240
+ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
10241
+ const {image: image} = paint;
10242
+ let fixScale, maxSize = Platform.image.maxPatternSize, imageSize = image.width * image.height;
10243
+ if (image.isSVG) {
10244
+ if (imageScaleX > 1) fixScale = Math.ceil(imageScaleX) / imageScaleX;
10246
10245
  } else {
10247
- return false;
10246
+ if (maxSize > imageSize) maxSize = imageSize;
10248
10247
  }
10248
+ if ((imageSize *= imageScaleX * imageScaleY) > maxSize) fixScale = Math.sqrt(maxSize / imageSize);
10249
+ return fixScale;
10249
10250
  }
10250
10251
 
10251
- function checkImage(ui, canvas, paint, allowDraw) {
10252
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
10253
- const {pixelRatio: pixelRatio} = canvas, {data: data} = paint;
10254
- if (!data || paint.patternId === scaleX + "-" + scaleY + "-" + pixelRatio && !Export.running) {
10252
+ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10253
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
10254
+ const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
10255
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
10255
10256
  return false;
10256
10257
  } else {
10257
- if (allowDraw) {
10258
+ if (drawImage) {
10258
10259
  if (data.repeat) {
10259
- allowDraw = false;
10260
- } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
10261
- let {width: width, height: height} = data;
10262
- width *= scaleX * pixelRatio;
10263
- height *= scaleY * pixelRatio;
10264
- if (data.scaleX) {
10265
- width *= data.scaleX;
10266
- height *= data.scaleY;
10267
- }
10268
- allowDraw = width * height > Platform.image.maxCacheSize;
10260
+ drawImage = false;
10261
+ } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10262
+ drawImage = Platform.image.isLarge(image, scaleX, scaleY);
10269
10263
  }
10270
10264
  }
10271
- if (allowDraw) {
10265
+ if (drawImage) {
10272
10266
  if (ui.__.__isFastShadow) {
10273
10267
  canvas.fillStyle = paint.style || "#000";
10274
10268
  canvas.fill();
10275
10269
  }
10276
- drawImage(ui, canvas, paint, data);
10270
+ PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
10277
10271
  return true;
10278
10272
  } else {
10279
- if (!paint.style || paint.sync || Export.running) {
10280
- createPattern(ui, paint, pixelRatio);
10281
- } else {
10282
- if (!paint.patternTask) {
10283
- paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
10284
- paint.patternTask = null;
10285
- if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio);
10286
- ui.forceUpdate("surface");
10287
- }), 300);
10288
- }
10289
- }
10273
+ if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
10290
10274
  return false;
10291
10275
  }
10292
10276
  }
10293
10277
  }
10294
10278
 
10295
- function drawImage(ui, canvas, paint, data) {
10296
- canvas.save();
10297
- canvas.clipUI(ui);
10298
- if (paint.blendMode) canvas.blendMode = paint.blendMode;
10299
- if (data.opacity) canvas.opacity *= data.opacity;
10300
- if (data.transform) canvas.transform(data.transform);
10301
- canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
10302
- canvas.restore();
10279
+ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
10280
+ const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
10281
+ let {width: width, height: height} = image, clipUI;
10282
+ if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
10283
+ canvas.save();
10284
+ clipUI && canvas.clipUI(ui);
10285
+ blendMode && (canvas.blendMode = blendMode);
10286
+ opacity && (canvas.opacity *= opacity);
10287
+ transform && canvas.transform(transform);
10288
+ canvas.drawImage(view, 0, 0, width, height);
10289
+ canvas.restore();
10290
+ } else {
10291
+ if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
10292
+ canvas.drawImage(view, 0, 0, width, height);
10293
+ }
10294
+ }
10295
+
10296
+ function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
10297
+ const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
10298
+ if (canvas) {
10299
+ const {pixelRatio: pixelRatio} = canvas;
10300
+ scaleData.scaleX *= pixelRatio;
10301
+ scaleData.scaleY *= pixelRatio;
10302
+ }
10303
+ if (data && data.scaleX) {
10304
+ scaleData.scaleX *= Math.abs(data.scaleX);
10305
+ scaleData.scaleY *= Math.abs(data.scaleY);
10306
+ }
10307
+ return scaleData;
10303
10308
  }
10304
10309
 
10305
10310
  function recycleImage(attrName, data) {
@@ -10331,8 +10336,12 @@ function recycleImage(attrName, data) {
10331
10336
  const PaintImageModule = {
10332
10337
  image: image,
10333
10338
  checkImage: checkImage,
10334
- createPattern: createPattern,
10339
+ drawImage: drawImage,
10340
+ getImageRenderScaleData: getImageRenderScaleData,
10335
10341
  recycleImage: recycleImage,
10342
+ createPatternTask: createPatternTask,
10343
+ createPattern: createPattern,
10344
+ getPatternFixScale: getPatternFixScale,
10336
10345
  createData: createData,
10337
10346
  getPatternData: getPatternData,
10338
10347
  stretchMode: stretchMode,
@@ -10788,10 +10797,8 @@ function createRows(drawData, content, style) {
10788
10797
  bounds = drawData.bounds;
10789
10798
  findMaxWidth = !bounds.width && !style.autoSizeAlign;
10790
10799
  const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
10791
- const {canvas: canvas} = Platform;
10792
- const {width: width, height: height} = bounds;
10793
- const charMode = width || height || __letterSpacing || textCase !== "none";
10794
- if (charMode) {
10800
+ const {canvas: canvas} = Platform, {width: width} = bounds;
10801
+ if (style.__isCharMode) {
10795
10802
  const wrap = style.textWrap !== "none";
10796
10803
  const breakAll = style.textWrap === "break";
10797
10804
  paraStart = true;
@@ -10920,12 +10927,19 @@ const TextMode = 2;
10920
10927
  function layoutChar(drawData, style, width, _height) {
10921
10928
  const {rows: rows} = drawData;
10922
10929
  const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
10923
- let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
10930
+ const justifyLast = width && textAlign.includes("both");
10931
+ const justify = justifyLast || width && textAlign.includes("justify");
10932
+ const justifyLetter = justify && textAlign.includes("letter");
10933
+ let charX, remainingWidth, addWordWidth, addLetterWidth, indentWidth, mode, wordChar, wordsLength, isLastWord, canJustify;
10924
10934
  rows.forEach(row => {
10925
10935
  if (row.words) {
10926
10936
  indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
10927
- addWordWidth = width && (textAlign === "justify" || textAlign === "both") && wordsLength > 1 ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
10928
- mode = letterSpacing || row.isOverflow ? CharMode : addWordWidth > .01 ? WordMode : TextMode;
10937
+ if (justify) {
10938
+ canJustify = !row.paraEnd || justifyLast;
10939
+ remainingWidth = width - row.width - indentWidth;
10940
+ if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
10941
+ }
10942
+ mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
10929
10943
  if (row.isOverflow && !letterSpacing) row.textMode = true;
10930
10944
  if (mode === TextMode) {
10931
10945
  row.x += indentWidth;
@@ -10943,11 +10957,15 @@ function layoutChar(drawData, style, width, _height) {
10943
10957
  charX = toWordChar(word.data, charX, wordChar);
10944
10958
  if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
10945
10959
  } else {
10946
- charX = toChar(word.data, charX, row.data, row.isOverflow);
10960
+ charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
10947
10961
  }
10948
- if (addWordWidth && (!row.paraEnd || textAlign === "both") && index !== wordsLength - 1) {
10949
- charX += addWordWidth;
10950
- row.width += addWordWidth;
10962
+ if (canJustify) {
10963
+ isLastWord = index === wordsLength - 1;
10964
+ if (addWordWidth) {
10965
+ if (!isLastWord) charX += addWordWidth, row.width += addWordWidth;
10966
+ } else if (addLetterWidth) {
10967
+ row.width += addLetterWidth * (word.data.length - (isLastWord ? 1 : 0));
10968
+ }
10951
10969
  }
10952
10970
  });
10953
10971
  }
@@ -10973,13 +10991,14 @@ function toWordChar(data, charX, wordChar) {
10973
10991
  return charX;
10974
10992
  }
10975
10993
 
10976
- function toChar(data, charX, rowData, isOverflow) {
10994
+ function toChar(data, charX, rowData, isOverflow, addLetterWidth) {
10977
10995
  data.forEach(char => {
10978
10996
  if (isOverflow || char.char !== " ") {
10979
10997
  char.x = charX;
10980
10998
  rowData.push(char);
10981
10999
  }
10982
11000
  charX += char.width;
11001
+ addLetterWidth && (charX += addLetterWidth);
10983
11002
  });
10984
11003
  return charX;
10985
11004
  }
@@ -11121,10 +11140,10 @@ function getDrawData(content, style) {
11121
11140
  let x = 0, y = 0;
11122
11141
  let width = style.__getInput("width") || 0;
11123
11142
  let height = style.__getInput("height") || 0;
11124
- const {textDecoration: textDecoration, __font: __font, __padding: padding} = style;
11143
+ const {__padding: padding} = style;
11125
11144
  if (padding) {
11126
- if (width) x = padding[left], width -= padding[right] + padding[left]; else if (!style.autoSizeAlign) x = padding[left];
11127
- if (height) y = padding[top], height -= padding[top] + padding[bottom]; else if (!style.autoSizeAlign) y = padding[top];
11145
+ if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
11146
+ if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
11128
11147
  }
11129
11148
  const drawData = {
11130
11149
  bounds: {
@@ -11135,14 +11154,14 @@ function getDrawData(content, style) {
11135
11154
  },
11136
11155
  rows: [],
11137
11156
  paraNumber: 0,
11138
- font: Platform.canvas.font = __font
11157
+ font: Platform.canvas.font = style.__font
11139
11158
  };
11140
11159
  createRows(drawData, content, style);
11141
11160
  if (padding) padAutoText(padding, drawData, style, width, height);
11142
11161
  layoutText(drawData, style);
11143
- layoutChar(drawData, style, width);
11162
+ if (style.__isCharMode) layoutChar(drawData, style, width);
11144
11163
  if (drawData.overflow) clipText(drawData, style, x, width);
11145
- if (textDecoration !== "none") decorationText(drawData, style);
11164
+ if (style.textDecoration !== "none") decorationText(drawData, style);
11146
11165
  return drawData;
11147
11166
  }
11148
11167