@leafer-ui/worker 1.9.7 → 1.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -229,17 +229,32 @@ var LeaferUI = function(exports) {
229
229
  this.__input = this.__middle = null;
230
230
  }
231
231
  }
232
- const {round: round$3, pow: pow$1, PI: PI$3} = Math;
233
- const MathHelper = {
234
- within(value, min, max) {
235
- if (isObject(min)) max = min.max, min = min.min;
236
- if (!isUndefined(min) && value < min) value = min;
237
- if (!isUndefined(max) && value > max) value = max;
238
- return value;
232
+ let tempA, tempB, tempTo;
233
+ const {max: max$4} = Math, tempFour = [ 0, 0, 0, 0 ];
234
+ const FourNumberHelper = {
235
+ zero: [ ...tempFour ],
236
+ tempFour: tempFour,
237
+ set(to, top, right, bottom, left) {
238
+ if (right === undefined) right = bottom = left = top;
239
+ to[0] = top;
240
+ to[1] = right;
241
+ to[2] = bottom;
242
+ to[3] = left;
243
+ return to;
244
+ },
245
+ setTemp(top, right, bottom, left) {
246
+ return set$1(tempFour, top, right, bottom, left);
247
+ },
248
+ toTempAB(a, b, change) {
249
+ tempTo = change ? isNumber(a) ? b : a : [];
250
+ if (isNumber(a)) tempA = setTemp(a), tempB = b; else if (isNumber(b)) tempA = a,
251
+ tempB = setTemp(b); else tempA = a, tempB = b;
252
+ if (tempA.length !== 4) tempA = get$5(tempA);
253
+ if (tempB.length !== 4) tempB = get$5(tempB);
239
254
  },
240
- fourNumber(num, maxValue) {
255
+ get(num, maxValue) {
241
256
  let data;
242
- if (isArray(num)) {
257
+ if (!isNumber(num)) {
243
258
  switch (num.length) {
244
259
  case 4:
245
260
  data = isUndefined(maxValue) ? num : [ ...num ];
@@ -262,9 +277,36 @@ var LeaferUI = function(exports) {
262
277
  }
263
278
  }
264
279
  if (!data) data = [ num, num, num, num ];
265
- if (maxValue) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
280
+ if (!isUndefined(maxValue)) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
266
281
  return data;
267
282
  },
283
+ max(t, other, change) {
284
+ if (isNumber(t) && isNumber(other)) return max$4(t, other);
285
+ toTempAB(t, other, change);
286
+ return set$1(tempTo, max$4(tempA[0], tempB[0]), max$4(tempA[1], tempB[1]), max$4(tempA[2], tempB[2]), max$4(tempA[3], tempB[3]));
287
+ },
288
+ add(t, other, change) {
289
+ if (isNumber(t) && isNumber(other)) return t + other;
290
+ toTempAB(t, other, change);
291
+ return set$1(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
292
+ },
293
+ swapAndScale(t, scaleX, scaleY, change) {
294
+ if (isNumber(t)) return scaleX === scaleY ? t * scaleX : [ t * scaleY, t * scaleX ];
295
+ const to = change ? t : [];
296
+ const [top, right, bottom, left] = t.length === 4 ? t : get$5(t);
297
+ return set$1(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
298
+ }
299
+ };
300
+ const {set: set$1, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
301
+ const {round: round$3, pow: pow$1, PI: PI$3} = Math;
302
+ const MathHelper = {
303
+ within(value, min, max) {
304
+ if (isObject(min)) max = min.max, min = min.min;
305
+ if (!isUndefined(min) && value < min) value = min;
306
+ if (!isUndefined(max) && value > max) value = max;
307
+ return value;
308
+ },
309
+ fourNumber: FourNumberHelper.get,
268
310
  formatRotation(rotation, unsign) {
269
311
  rotation %= 360;
270
312
  if (unsign) {
@@ -973,7 +1015,7 @@ var LeaferUI = function(exports) {
973
1015
  MatrixHelper.reset(this);
974
1016
  }
975
1017
  }
976
- const tempMatrix$1 = new Matrix;
1018
+ const tempMatrix$2 = new Matrix;
977
1019
  const TwoPointBoundsHelper = {
978
1020
  tempPointBounds: {},
979
1021
  setPoint(t, minX, minY) {
@@ -1103,9 +1145,9 @@ var LeaferUI = function(exports) {
1103
1145
  let right$1, bottom$1, boundsRight, boundsBottom;
1104
1146
  const point = {};
1105
1147
  const toPoint$4 = {};
1106
- const tempBounds$2 = {};
1148
+ const tempBounds$3 = {};
1107
1149
  const BoundsHelper = {
1108
- tempBounds: tempBounds$2,
1150
+ tempBounds: tempBounds$3,
1109
1151
  set(t, x = 0, y = 0, width = 0, height = 0) {
1110
1152
  t.x = x;
1111
1153
  t.y = y;
@@ -1156,19 +1198,11 @@ var LeaferUI = function(exports) {
1156
1198
  B.move(t, x, y);
1157
1199
  return t;
1158
1200
  },
1159
- toOffsetOutBounds(t, to, parent) {
1160
- if (!to) {
1161
- to = t;
1162
- } else {
1163
- copy$9(to, t);
1164
- }
1165
- if (parent) {
1166
- to.offsetX = -(B.maxX(parent) - t.x);
1167
- to.offsetY = -(B.maxY(parent) - t.y);
1168
- } else {
1169
- to.offsetX = t.x + t.width;
1170
- to.offsetY = t.y + t.height;
1171
- }
1201
+ toOffsetOutBounds(t, to, offsetBounds) {
1202
+ if (!to) to = t; else copy$9(to, t);
1203
+ if (!offsetBounds) offsetBounds = t;
1204
+ to.offsetX = B.maxX(offsetBounds);
1205
+ to.offsetY = B.maxY(offsetBounds);
1172
1206
  B.move(to, -to.offsetX, -to.offsetY);
1173
1207
  },
1174
1208
  scale(t, scaleX, scaleY = scaleX, onlySize) {
@@ -1182,9 +1216,9 @@ var LeaferUI = function(exports) {
1182
1216
  t.height *= scaleY;
1183
1217
  },
1184
1218
  tempToOuterOf(t, matrix) {
1185
- B.copy(tempBounds$2, t);
1186
- B.toOuterOf(tempBounds$2, matrix);
1187
- return tempBounds$2;
1219
+ B.copy(tempBounds$3, t);
1220
+ B.toOuterOf(tempBounds$3, matrix);
1221
+ return tempBounds$3;
1188
1222
  },
1189
1223
  getOuterOf(t, matrix) {
1190
1224
  t = Object.assign({}, t);
@@ -1242,9 +1276,9 @@ var LeaferUI = function(exports) {
1242
1276
  put(t, put, align = "center", putScale = 1, changeSize = true, to) {
1243
1277
  to || (to = put);
1244
1278
  if (isString(putScale)) putScale = B.getFitScale(t, put, putScale === "cover");
1245
- tempBounds$2.width = changeSize ? put.width *= putScale : put.width * putScale;
1246
- tempBounds$2.height = changeSize ? put.height *= putScale : put.height * putScale;
1247
- AlignHelper.toPoint(align, tempBounds$2, t, to, true, true);
1279
+ tempBounds$3.width = changeSize ? put.width *= putScale : put.width * putScale;
1280
+ tempBounds$3.height = changeSize ? put.height *= putScale : put.height * putScale;
1281
+ AlignHelper.toPoint(align, tempBounds$3, t, to, true, true);
1248
1282
  },
1249
1283
  getSpread(t, spread, side) {
1250
1284
  const n = {};
@@ -1314,7 +1348,7 @@ var LeaferUI = function(exports) {
1314
1348
  first = false;
1315
1349
  if (!addMode) copy$9(t, bounds);
1316
1350
  } else {
1317
- add$1(t, bounds);
1351
+ add$2(t, bounds);
1318
1352
  }
1319
1353
  }
1320
1354
  }
@@ -1328,7 +1362,7 @@ var LeaferUI = function(exports) {
1328
1362
  B.set(t, point.x, point.y);
1329
1363
  },
1330
1364
  addPoint(t, point) {
1331
- add$1(t, point, true);
1365
+ add$2(t, point, true);
1332
1366
  },
1333
1367
  getPoints(t) {
1334
1368
  const {x: x, y: y, width: width, height: height} = t;
@@ -1397,7 +1431,7 @@ var LeaferUI = function(exports) {
1397
1431
  }
1398
1432
  };
1399
1433
  const B = BoundsHelper;
1400
- const {add: add$1, copy: copy$9} = B;
1434
+ const {add: add$2, copy: copy$9} = B;
1401
1435
  class Bounds {
1402
1436
  get minX() {
1403
1437
  return BoundsHelper.minX(this);
@@ -1540,7 +1574,7 @@ var LeaferUI = function(exports) {
1540
1574
  BoundsHelper.reset(this);
1541
1575
  }
1542
1576
  }
1543
- const tempBounds$1 = new Bounds;
1577
+ const tempBounds$2 = new Bounds;
1544
1578
  class AutoBounds {
1545
1579
  constructor(top, right, bottom, left, width, height) {
1546
1580
  isObject(top) ? this.copy(top) : this.set(top, right, bottom, left, width, height);
@@ -2103,7 +2137,7 @@ var LeaferUI = function(exports) {
2103
2137
  const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
2104
2138
  if (parentMatrix) multiplyParent$4(matrix, parentMatrix, w);
2105
2139
  pixelScale(matrix, pixelRatio, w);
2106
- if (pixelSnap) {
2140
+ if (pixelSnap && !matrix.ignorePixelSnap) {
2107
2141
  if (matrix.half && matrix.half * pixelRatio % 2) w.e = round$1(w.e - .5) + .5, w.f = round$1(w.f - .5) + .5; else w.e = round$1(w.e),
2108
2142
  w.f = round$1(w.f);
2109
2143
  }
@@ -3753,7 +3787,7 @@ var LeaferUI = function(exports) {
3753
3787
  };
3754
3788
  const I$1 = ImageManager;
3755
3789
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
3756
- const {floor: floor$1, max: max$1} = Math;
3790
+ const {floor: floor$1, max: max$3} = Math;
3757
3791
  class LeaferImage {
3758
3792
  get url() {
3759
3793
  return this.config.url;
@@ -3841,7 +3875,7 @@ var LeaferUI = function(exports) {
3841
3875
  }
3842
3876
  if (data) return data;
3843
3877
  }
3844
- const canvas = Platform.origin.createCanvas(max$1(floor$1(width + (xGap || 0)), 1), max$1(floor$1(height + (yGap || 0)), 1));
3878
+ const canvas = Platform.origin.createCanvas(max$3(floor$1(width + (xGap || 0)), 1), max$3(floor$1(height + (yGap || 0)), 1));
3845
3879
  const ctx = canvas.getContext("2d");
3846
3880
  if (opacity) ctx.globalAlpha = opacity;
3847
3881
  ctx.imageSmoothingEnabled = smooth === false ? false : true;
@@ -4573,7 +4607,7 @@ var LeaferUI = function(exports) {
4573
4607
  }
4574
4608
  };
4575
4609
  const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2} = LeafHelper;
4576
- const {toOuterOf: toOuterOf$2, getPoints: getPoints, copy: copy$5} = BoundsHelper;
4610
+ const {toOuterOf: toOuterOf$3, getPoints: getPoints, copy: copy$5} = BoundsHelper;
4577
4611
  const localContent = "_localContentBounds";
4578
4612
  const worldContent = "_worldContentBounds", worldBox = "_worldBoxBounds", worldStroke = "_worldStrokeBounds";
4579
4613
  class LeafLayout {
@@ -4593,7 +4627,7 @@ var LeaferUI = function(exports) {
4593
4627
  this._renderBounds = bounds;
4594
4628
  }
4595
4629
  get localContentBounds() {
4596
- toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {}));
4630
+ toOuterOf$3(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {}));
4597
4631
  return this[localContent];
4598
4632
  }
4599
4633
  get localStrokeBounds() {
@@ -4603,15 +4637,15 @@ var LeaferUI = function(exports) {
4603
4637
  return this._localRenderBounds || this;
4604
4638
  }
4605
4639
  get worldContentBounds() {
4606
- toOuterOf$2(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {}));
4640
+ toOuterOf$3(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {}));
4607
4641
  return this[worldContent];
4608
4642
  }
4609
4643
  get worldBoxBounds() {
4610
- toOuterOf$2(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {}));
4644
+ toOuterOf$3(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {}));
4611
4645
  return this[worldBox];
4612
4646
  }
4613
4647
  get worldStrokeBounds() {
4614
- toOuterOf$2(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {}));
4648
+ toOuterOf$3(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {}));
4615
4649
  return this[worldStroke];
4616
4650
  }
4617
4651
  get a() {
@@ -5382,12 +5416,12 @@ var LeaferUI = function(exports) {
5382
5416
  };
5383
5417
  const {updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2} = LeafHelper;
5384
5418
  const {updateBounds: updateBounds$1} = BranchHelper;
5385
- const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4} = BoundsHelper;
5419
+ const {toOuterOf: toOuterOf$2, copyAndSpread: copyAndSpread$2, copy: copy$4} = BoundsHelper;
5386
5420
  const {toBounds: toBounds} = PathBounds;
5387
5421
  const LeafBounds = {
5388
5422
  __updateWorldBounds() {
5389
5423
  const layout = this.__layout;
5390
- toOuterOf$1(layout.renderBounds, this.__world, this.__world);
5424
+ toOuterOf$2(layout.renderBounds, this.__world, this.__world);
5391
5425
  if (layout.resized) {
5392
5426
  if (layout.resized === "inner") this.__onUpdateSize();
5393
5427
  if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
@@ -5443,13 +5477,13 @@ var LeaferUI = function(exports) {
5443
5477
  __updateLocalBoxBounds() {
5444
5478
  if (this.__hasMotionPath) this.__updateMotionPath();
5445
5479
  if (this.__hasAutoLayout) this.__updateAutoLayout();
5446
- toOuterOf$1(this.__layout.boxBounds, this.__local, this.__local);
5480
+ toOuterOf$2(this.__layout.boxBounds, this.__local, this.__local);
5447
5481
  },
5448
5482
  __updateLocalStrokeBounds() {
5449
- toOuterOf$1(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5483
+ toOuterOf$2(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5450
5484
  },
5451
5485
  __updateLocalRenderBounds() {
5452
- toOuterOf$1(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5486
+ toOuterOf$2(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5453
5487
  },
5454
5488
  __updateBoxBounds(_secondLayout, _bounds) {
5455
5489
  const b = this.__layout.boxBounds;
@@ -5487,11 +5521,11 @@ var LeaferUI = function(exports) {
5487
5521
  },
5488
5522
  __updateStrokeBounds(_bounds) {
5489
5523
  const layout = this.__layout;
5490
- copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5524
+ copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5491
5525
  },
5492
5526
  __updateRenderBounds(_bounds) {
5493
- const layout = this.__layout;
5494
- layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$4(layout.renderBounds, layout.strokeBounds);
5527
+ const layout = this.__layout, {renderSpread: renderSpread} = layout;
5528
+ isNumber(renderSpread) && renderSpread <= 0 ? copy$4(layout.renderBounds, layout.strokeBounds) : copyAndSpread$2(layout.renderBounds, layout.boxBounds, renderSpread);
5495
5529
  }
5496
5530
  };
5497
5531
  const LeafRender = {
@@ -5583,9 +5617,10 @@ var LeaferUI = function(exports) {
5583
5617
  };
5584
5618
  const tempScaleData$1 = {};
5585
5619
  const {LEAF: LEAF, create: create} = IncrementId;
5620
+ const {stintSet: stintSet$3} = DataHelper;
5586
5621
  const {toInnerPoint: toInnerPoint, toOuterPoint: toOuterPoint, multiplyParent: multiplyParent$1} = MatrixHelper;
5587
- const {toOuterOf: toOuterOf} = BoundsHelper;
5588
- const {copy: copy$3, move: move} = PointHelper;
5622
+ const {toOuterOf: toOuterOf$1} = BoundsHelper;
5623
+ const {copy: copy$3, move: move$2} = PointHelper;
5589
5624
  const {moveLocal: moveLocal, zoomOfLocal: zoomOfLocal, rotateOfLocal: rotateOfLocal, skewOfLocal: skewOfLocal, moveWorld: moveWorld, zoomOfWorld: zoomOfWorld, rotateOfWorld: rotateOfWorld, skewOfWorld: skewOfWorld, transform: transform, transformWorld: transformWorld, setTransform: setTransform, getFlipTransform: getFlipTransform, getLocalOrigin: getLocalOrigin, getRelativeWorld: getRelativeWorld, drop: drop} = LeafHelper;
5590
5625
  exports.Leaf = class Leaf {
5591
5626
  get tag() {
@@ -5859,8 +5894,9 @@ var LeaferUI = function(exports) {
5859
5894
  if (!this.__cameraWorld) this.__cameraWorld = {};
5860
5895
  const cameraWorld = this.__cameraWorld, world = this.__world;
5861
5896
  multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
5862
- toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
5863
- cameraWorld.half !== world.half && (cameraWorld.half = world.half);
5897
+ toOuterOf$1(this.__layout.renderBounds, cameraWorld, cameraWorld);
5898
+ stintSet$3(cameraWorld, "half", world.half);
5899
+ stintSet$3(cameraWorld, "ignorePixelSnap", world.ignorePixelSnap);
5864
5900
  return cameraWorld;
5865
5901
  } else {
5866
5902
  return this.__world;
@@ -5894,7 +5930,7 @@ var LeaferUI = function(exports) {
5894
5930
  getWorldBounds(inner, relative, change) {
5895
5931
  const matrix = relative ? getRelativeWorld(this, relative) : this.worldTransform;
5896
5932
  const to = change ? inner : {};
5897
- toOuterOf(inner, matrix, to);
5933
+ toOuterOf$1(inner, matrix, to);
5898
5934
  return to;
5899
5935
  }
5900
5936
  worldToLocal(world, to, distance, relative) {
@@ -5927,7 +5963,7 @@ var LeaferUI = function(exports) {
5927
5963
  }
5928
5964
  getBoxPointByInner(inner, _relative, _distance, change) {
5929
5965
  const point = change ? inner : Object.assign({}, inner), {x: x, y: y} = this.boxBounds;
5930
- move(point, -x, -y);
5966
+ move$2(point, -x, -y);
5931
5967
  return point;
5932
5968
  }
5933
5969
  getInnerPoint(world, relative, distance, change) {
@@ -5937,7 +5973,7 @@ var LeaferUI = function(exports) {
5937
5973
  }
5938
5974
  getInnerPointByBox(box, _relative, _distance, change) {
5939
5975
  const point = change ? box : Object.assign({}, box), {x: x, y: y} = this.boxBounds;
5940
- move(point, x, y);
5976
+ move$2(point, x, y);
5941
5977
  return point;
5942
5978
  }
5943
5979
  getInnerPointByLocal(local, _relative, distance, change) {
@@ -6373,7 +6409,7 @@ var LeaferUI = function(exports) {
6373
6409
  this.levelMap = null;
6374
6410
  }
6375
6411
  }
6376
- const version = "1.9.7";
6412
+ const version = "1.9.9";
6377
6413
  class LeaferCanvas extends LeaferCanvasBase {
6378
6414
  get allowBackgroundColor() {
6379
6415
  return true;
@@ -6771,6 +6807,7 @@ var LeaferUI = function(exports) {
6771
6807
  usePartRender: true,
6772
6808
  maxFPS: 120
6773
6809
  };
6810
+ this.frames = [];
6774
6811
  this.target = target;
6775
6812
  this.canvas = canvas;
6776
6813
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -6923,12 +6960,15 @@ var LeaferUI = function(exports) {
6923
6960
  const target = this.target;
6924
6961
  if (this.requestTime || !target) return;
6925
6962
  if (target.parentApp) return target.parentApp.requestRender(false);
6926
- const requestTime = this.requestTime = Date.now();
6963
+ this.requestTime = this.frameTime || Date.now();
6927
6964
  const render = () => {
6928
- const nowFPS = 1e3 / (Date.now() - requestTime);
6965
+ const nowFPS = 1e3 / ((this.frameTime = Date.now()) - this.requestTime);
6929
6966
  const {maxFPS: maxFPS} = this.config;
6930
- if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
6931
- this.FPS = Math.min(120, Math.ceil(nowFPS));
6967
+ if (maxFPS && nowFPS > maxFPS) return Platform.requestRender(render);
6968
+ const {frames: frames} = this;
6969
+ if (frames.length > 30) frames.shift();
6970
+ frames.push(nowFPS);
6971
+ this.FPS = Math.round(frames.reduce((a, b) => a + b, 0) / frames.length);
6932
6972
  this.requestTime = 0;
6933
6973
  this.checkRender();
6934
6974
  };
@@ -7538,39 +7578,40 @@ var LeaferUI = function(exports) {
7538
7578
  return data;
7539
7579
  }
7540
7580
  }
7581
+ const {max: max$2, add: add$1} = FourNumberHelper;
7541
7582
  const UIBounds = {
7542
7583
  __updateStrokeSpread() {
7543
- let width = 0, boxWidth = 0;
7584
+ let spread = 0, boxSpread = 0;
7544
7585
  const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
7545
7586
  if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
7546
- boxWidth = width = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
7587
+ boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
7547
7588
  if (!data.__boxStroke) {
7548
- const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * width;
7589
+ const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
7549
7590
  const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
7550
- width += Math.max(miterLimitAddWidth, storkeCapAddWidth);
7591
+ spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
7551
7592
  }
7552
7593
  }
7553
- if (data.__useArrow) width += strokeWidth * 5;
7594
+ if (data.__useArrow) spread += strokeWidth * 5;
7554
7595
  if (box) {
7555
- width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
7556
- boxWidth = box.__layout.strokeBoxSpread;
7596
+ spread = max$2(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
7597
+ boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
7557
7598
  }
7558
- this.__layout.strokeBoxSpread = boxWidth;
7559
- return width;
7599
+ this.__layout.strokeBoxSpread = boxSpread;
7600
+ return spread;
7560
7601
  },
7561
7602
  __updateRenderSpread() {
7562
- let width = 0;
7563
- const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7564
- if (shadow) width = Effect.getShadowSpread(this, shadow);
7565
- if (blur) width = Math.max(width, blur);
7566
- if (filter) width += Filter.getSpread(filter);
7567
- if (renderSpread) width += renderSpread;
7568
- let shapeWidth = width = Math.ceil(width);
7569
- if (innerShadow) innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
7570
- if (backgroundBlur) shapeWidth = Math.max(shapeWidth, backgroundBlur);
7571
- this.__layout.renderShapeSpread = shapeWidth;
7572
- width += this.__layout.strokeSpread || 0;
7573
- return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
7603
+ let spread = 0;
7604
+ const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
7605
+ if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
7606
+ if (blur) spread = max$2(spread, blur);
7607
+ if (filter) spread = add$1(spread, Filter.getSpread(filter));
7608
+ if (renderSpread) spread = add$1(spread, renderSpread);
7609
+ if (strokeSpread) spread = add$1(spread, strokeSpread);
7610
+ let shapeSpread = spread;
7611
+ if (innerShadow) shapeSpread = max$2(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
7612
+ if (backgroundBlur) shapeSpread = max$2(shapeSpread, backgroundBlur);
7613
+ this.__layout.renderShapeSpread = shapeSpread;
7614
+ return box ? max$2(box.__updateRenderSpread(), spread) : spread;
7574
7615
  }
7575
7616
  };
7576
7617
  const {float: float} = MathHelper;
@@ -8712,7 +8753,7 @@ var LeaferUI = function(exports) {
8712
8753
  __decorate([ dataType(false) ], exports.Canvas.prototype, "safeResize", void 0);
8713
8754
  __decorate([ resizeType() ], exports.Canvas.prototype, "contextSettings", void 0);
8714
8755
  exports.Canvas = __decorate([ registerUI() ], exports.Canvas);
8715
- const {copyAndSpread: copyAndSpread, includes: includes, spread: spread, setList: setList} = BoundsHelper;
8756
+ const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
8716
8757
  exports.Text = class Text extends exports.UI {
8717
8758
  get __tag() {
8718
8759
  return "Text";
@@ -8758,13 +8799,13 @@ var LeaferUI = function(exports) {
8758
8799
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
8759
8800
  }
8760
8801
  __updateRenderSpread() {
8761
- let width = super.__updateRenderSpread();
8762
- if (!width) width = this.isOverflow ? 1 : 0;
8763
- return width;
8802
+ let spread = super.__updateRenderSpread();
8803
+ if (!spread) spread = this.isOverflow ? 1 : 0;
8804
+ return spread;
8764
8805
  }
8765
8806
  __updateRenderBounds() {
8766
8807
  const {renderBounds: renderBounds, renderSpread: renderSpread} = this.__layout;
8767
- copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
8808
+ copyAndSpread$1(renderBounds, this.__.__textBoxBounds, renderSpread);
8768
8809
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
8769
8810
  }
8770
8811
  __updateChange() {
@@ -9123,9 +9164,9 @@ var LeaferUI = function(exports) {
9123
9164
  static setData(data) {
9124
9165
  this.data = data;
9125
9166
  }
9126
- static getValidMove(leaf, start, total, checkLimit = true) {
9127
- const move = leaf.getLocalPoint(total, null, true);
9128
- PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
9167
+ static getValidMove(leaf, localStart, worldTotal, checkLimit = true) {
9168
+ const move = leaf.getLocalPoint(worldTotal, null, true);
9169
+ PointHelper.move(move, localStart.x - leaf.x, localStart.y - leaf.y);
9129
9170
  if (checkLimit) this.limitMove(leaf, move);
9130
9171
  DragBoundsHelper.axisMove(leaf, move);
9131
9172
  return move;
@@ -10079,8 +10120,8 @@ var LeaferUI = function(exports) {
10079
10120
  if (isHitPixel) {
10080
10121
  const {renderBounds: renderBounds} = this.__layout;
10081
10122
  const size = Platform.image.hitCanvasSize;
10082
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10083
- const {x: x, y: y, width: width, height: height} = tempBounds$1.set(renderBounds).scale(scale);
10123
+ const scale = h.hitScale = tempBounds$2.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10124
+ const {x: x, y: y, width: width, height: height} = tempBounds$2.set(renderBounds).scale(scale);
10084
10125
  h.resize({
10085
10126
  width: width,
10086
10127
  height: height,
@@ -10167,8 +10208,8 @@ var LeaferUI = function(exports) {
10167
10208
  canvas.hitPixel = function(radiusPoint, offset, scale = 1) {
10168
10209
  let {x: x, y: y, radiusX: radiusX, radiusY: radiusY} = radiusPoint;
10169
10210
  if (offset) x -= offset.x, y -= offset.y;
10170
- tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
10171
- const {data: data} = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
10211
+ tempBounds$2.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
10212
+ const {data: data} = this.context.getImageData(tempBounds$2.x, tempBounds$2.y, tempBounds$2.width || 1, tempBounds$2.height || 1);
10172
10213
  for (let i = 0, len = data.length; i < len; i += 4) {
10173
10214
  if (data[i + 3] > 0) return true;
10174
10215
  }
@@ -10353,23 +10394,27 @@ var LeaferUI = function(exports) {
10353
10394
  out.recycle(ui.__nowWorld);
10354
10395
  }
10355
10396
  }
10356
- const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = BoundsHelper;
10397
+ const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
10398
+ const tempBounds$1 = {};
10357
10399
  function shape(ui, current, options) {
10358
10400
  const canvas = current.getSameCanvas();
10359
- const nowWorld = ui.__nowWorld, currentBounds = current.bounds;
10360
- let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
10401
+ const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
10402
+ const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
10403
+ toOuterOf(layout.strokeSpread ? (copyAndSpread(tempBounds$1, layout.boxBounds, layout.strokeSpread),
10404
+ tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
10405
+ let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
10361
10406
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
10362
- if (currentBounds.includes(nowWorld)) {
10407
+ if (currentBounds.includes(nowWorldShapeBounds)) {
10363
10408
  worldCanvas = canvas;
10364
- bounds = shapeBounds = nowWorld;
10409
+ bounds = shapeBounds = nowWorldShapeBounds;
10410
+ renderBounds = nowWorld;
10365
10411
  } else {
10366
- const {renderShapeSpread: spread} = ui.__layout;
10367
10412
  let worldClipBounds;
10368
10413
  if (Platform.fullImageShadow) {
10369
- worldClipBounds = nowWorld;
10414
+ worldClipBounds = nowWorldShapeBounds;
10370
10415
  } else {
10371
- const spreadBounds = spread ? getSpread(currentBounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : currentBounds;
10372
- worldClipBounds = getIntersectData(spreadBounds, nowWorld);
10416
+ const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds;
10417
+ worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds);
10373
10418
  }
10374
10419
  fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
10375
10420
  let {a: fitScaleX, d: fitScaleY} = fitMatrix;
@@ -10379,8 +10424,10 @@ var LeaferUI = function(exports) {
10379
10424
  scaleX *= fitScaleX;
10380
10425
  scaleY *= fitScaleY;
10381
10426
  }
10382
- shapeBounds = getOuterOf(nowWorld, fitMatrix);
10427
+ shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix);
10383
10428
  bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
10429
+ renderBounds = getOuterOf(nowWorld, fitMatrix);
10430
+ move$1(renderBounds, -fitMatrix.e, -fitMatrix.f);
10384
10431
  const userMatrix = options.matrix;
10385
10432
  if (userMatrix) {
10386
10433
  matrix = new Matrix(fitMatrix);
@@ -10399,6 +10446,7 @@ var LeaferUI = function(exports) {
10399
10446
  matrix: matrix,
10400
10447
  fitMatrix: fitMatrix,
10401
10448
  bounds: bounds,
10449
+ renderBounds: renderBounds,
10402
10450
  worldCanvas: worldCanvas,
10403
10451
  shapeBounds: shapeBounds,
10404
10452
  scaleX: scaleX,
@@ -10496,7 +10544,7 @@ var LeaferUI = function(exports) {
10496
10544
  drawTextStroke: drawTextStroke,
10497
10545
  shape: shape
10498
10546
  };
10499
- let origin = {}, tempMatrix = getMatrixData();
10547
+ let origin = {}, tempMatrix$1 = getMatrixData();
10500
10548
  const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
10501
10549
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10502
10550
  const transform = get$3();
@@ -10508,12 +10556,12 @@ var LeaferUI = function(exports) {
10508
10556
  }, rotation);
10509
10557
  data.transform = transform;
10510
10558
  }
10511
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
10559
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
10512
10560
  const transform = get$3();
10513
10561
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
10514
- if (clipSize) {
10515
- tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
10516
- multiplyParent(transform, tempMatrix);
10562
+ if (clipScaleX) {
10563
+ tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
10564
+ multiplyParent(transform, tempMatrix$1);
10517
10565
  }
10518
10566
  data.transform = transform;
10519
10567
  }
@@ -10606,7 +10654,12 @@ var LeaferUI = function(exports) {
10606
10654
 
10607
10655
  case "normal":
10608
10656
  case "clip":
10609
- if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
10657
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
10658
+ let clipScaleX, clipScaleY;
10659
+ if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
10660
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
10661
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
10662
+ }
10610
10663
  break;
10611
10664
 
10612
10665
  case "repeat":
@@ -10751,7 +10804,7 @@ var LeaferUI = function(exports) {
10751
10804
  if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
10752
10805
  }
10753
10806
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
10754
- const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
10807
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
10755
10808
  function createPattern(ui, paint, pixelRatio) {
10756
10809
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
10757
10810
  const id = scaleX + "-" + scaleY + "-" + pixelRatio;
@@ -10799,8 +10852,8 @@ var LeaferUI = function(exports) {
10799
10852
  if (transform || scaleX !== 1 || scaleY !== 1) {
10800
10853
  const canvasWidth = width + (xGap || 0);
10801
10854
  const canvasHeight = height + (yGap || 0);
10802
- scaleX /= canvasWidth / max(floor(canvasWidth), 1);
10803
- scaleY /= canvasHeight / max(floor(canvasHeight), 1);
10855
+ scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
10856
+ scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
10804
10857
  if (!imageMatrix) {
10805
10858
  imageMatrix = get$1();
10806
10859
  if (transform) copy$1(imageMatrix, transform);
@@ -10825,17 +10878,15 @@ var LeaferUI = function(exports) {
10825
10878
  if (allowDraw) {
10826
10879
  if (data.repeat) {
10827
10880
  allowDraw = false;
10828
- } else {
10829
- if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
10830
- let {width: width, height: height} = data;
10831
- width *= scaleX * pixelRatio;
10832
- height *= scaleY * pixelRatio;
10833
- if (data.scaleX) {
10834
- width *= data.scaleX;
10835
- height *= data.scaleY;
10836
- }
10837
- allowDraw = width * height > Platform.image.maxCacheSize;
10881
+ } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
10882
+ let {width: width, height: height} = data;
10883
+ width *= scaleX * pixelRatio;
10884
+ height *= scaleY * pixelRatio;
10885
+ if (data.scaleX) {
10886
+ width *= data.scaleX;
10887
+ height *= data.scaleY;
10838
10888
  }
10889
+ allowDraw = width * height > Platform.image.maxCacheSize;
10839
10890
  }
10840
10891
  }
10841
10892
  if (allowDraw) {
@@ -10993,81 +11044,87 @@ var LeaferUI = function(exports) {
10993
11044
  conicGradient: conicGradient,
10994
11045
  getTransform: getTransform
10995
11046
  };
10996
- const {copy: copy, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper;
10997
- const tempBounds = {};
11047
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
11048
+ const tempBounds = {}, tempMatrix = new Matrix;
10998
11049
  const offsetOutBounds$1 = {};
10999
11050
  function shadow(ui, current, shape) {
11000
- let copyBounds, spreadScale;
11001
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
11051
+ let copyBounds, transform;
11052
+ const {__nowWorld: nowWorld} = ui;
11002
11053
  const {shadow: shadow} = ui.__;
11003
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11054
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11004
11055
  const other = current.getSameCanvas();
11005
11056
  const end = shadow.length - 1;
11006
- toOffsetOutBounds$1(bounds, offsetOutBounds$1);
11057
+ toOffsetOutBounds$1(bounds, offsetOutBounds$1, renderBounds);
11007
11058
  shadow.forEach((item, index) => {
11008
11059
  let otherScale = 1;
11009
11060
  if (item.scaleFixed) {
11010
11061
  const sx = Math.abs(nowWorld.scaleX);
11011
11062
  if (sx > 1) otherScale = 1 / sx;
11012
11063
  }
11013
- other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
11014
- spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
11015
- drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
11016
- copyBounds = bounds;
11064
+ other.setWorldShadow(offsetOutBounds$1.offsetX + (item.x || 0) * scaleX * otherScale, offsetOutBounds$1.offsetY + (item.y || 0) * scaleY * otherScale, (item.blur || 0) * scaleX * otherScale, ColorConvert.string(item.color));
11065
+ transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
11066
+ if (transform) other.setTransform(transform);
11067
+ drawWorldShadow(other, offsetOutBounds$1, shape);
11068
+ if (transform) other.resetTransform();
11069
+ copyBounds = renderBounds;
11017
11070
  if (item.box) {
11018
11071
  other.restore();
11019
11072
  other.save();
11020
11073
  if (worldCanvas) {
11021
- other.copyWorld(other, bounds, nowWorld, "copy");
11074
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
11022
11075
  copyBounds = nowWorld;
11023
11076
  }
11024
11077
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
11025
11078
  }
11026
- if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11079
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11027
11080
  if (end && index < end) other.clearWorld(copyBounds);
11028
11081
  });
11029
11082
  other.recycle(copyBounds);
11030
11083
  }
11031
- function getShadowSpread(_ui, shadow) {
11032
- let width = 0;
11033
- shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
11034
- return width;
11084
+ function getShadowRenderSpread(_ui, shadow) {
11085
+ let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
11086
+ shadow.forEach(item => {
11087
+ x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
11088
+ top = max(top, spread + blur - y);
11089
+ right = max(right, spread + blur + x);
11090
+ bottom = max(bottom, spread + blur + y);
11091
+ left = max(left, spread + blur - x);
11092
+ });
11093
+ return top === right && right === bottom && bottom === left ? top : [ top, right, bottom, left ];
11094
+ }
11095
+ function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
11096
+ if (shadow.spread) {
11097
+ const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
11098
+ tempMatrix.set().scaleOfOuter({
11099
+ x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
11100
+ y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
11101
+ }, spreadScale);
11102
+ return tempMatrix;
11103
+ }
11104
+ return undefined;
11035
11105
  }
11036
- function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
11037
- const {bounds: bounds, shapeBounds: shapeBounds} = shape;
11106
+ function drawWorldShadow(canvas, outBounds, shape) {
11107
+ const {shapeBounds: shapeBounds} = shape;
11108
+ let from, to;
11038
11109
  if (Platform.fullImageShadow) {
11039
11110
  copy(tempBounds, canvas.bounds);
11040
- tempBounds.x += outBounds.x - shapeBounds.x;
11041
- tempBounds.y += outBounds.y - shapeBounds.y;
11042
- if (spreadScale) {
11043
- const {fitMatrix: fitMatrix} = shape;
11044
- tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
11045
- tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
11046
- tempBounds.width *= spreadScale;
11047
- tempBounds.height *= spreadScale;
11048
- }
11049
- canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
11111
+ move(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
11112
+ from = canvas.bounds, to = tempBounds;
11050
11113
  } else {
11051
- if (spreadScale) {
11052
- copy(tempBounds, outBounds);
11053
- tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
11054
- tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
11055
- tempBounds.width *= spreadScale;
11056
- tempBounds.height *= spreadScale;
11057
- }
11058
- canvas.copyWorld(shape.canvas, shapeBounds, spreadScale ? tempBounds : outBounds);
11114
+ from = shapeBounds, to = outBounds;
11059
11115
  }
11116
+ canvas.copyWorld(shape.canvas, from, to);
11060
11117
  }
11061
11118
  const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
11062
11119
  const offsetOutBounds = {};
11063
11120
  function innerShadow(ui, current, shape) {
11064
- let copyBounds, spreadScale;
11065
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
11121
+ let copyBounds, transform;
11122
+ const {__nowWorld: nowWorld} = ui;
11066
11123
  const {innerShadow: innerShadow} = ui.__;
11067
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11124
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11068
11125
  const other = current.getSameCanvas();
11069
11126
  const end = innerShadow.length - 1;
11070
- toOffsetOutBounds(bounds, offsetOutBounds);
11127
+ toOffsetOutBounds(bounds, offsetOutBounds, renderBounds);
11071
11128
  innerShadow.forEach((item, index) => {
11072
11129
  let otherScale = 1;
11073
11130
  if (item.scaleFixed) {
@@ -11075,17 +11132,18 @@ var LeaferUI = function(exports) {
11075
11132
  if (sx > 1) otherScale = 1 / sx;
11076
11133
  }
11077
11134
  other.save();
11078
- other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
11079
- spreadScale = item.spread ? 1 - item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
11080
- drawWorldShadow(other, offsetOutBounds, spreadScale, shape);
11135
+ other.setWorldShadow(offsetOutBounds.offsetX + (item.x || 0) * scaleX * otherScale, offsetOutBounds.offsetY + (item.y || 0) * scaleY * otherScale, (item.blur || 0) * scaleX * otherScale);
11136
+ transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
11137
+ if (transform) other.setTransform(transform);
11138
+ drawWorldShadow(other, offsetOutBounds, shape);
11081
11139
  other.restore();
11082
11140
  if (worldCanvas) {
11083
- other.copyWorld(other, bounds, nowWorld, "copy");
11141
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
11084
11142
  other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
11085
11143
  copyBounds = nowWorld;
11086
11144
  } else {
11087
11145
  other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
11088
- copyBounds = bounds;
11146
+ copyBounds = renderBounds;
11089
11147
  }
11090
11148
  other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
11091
11149
  LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
@@ -11093,6 +11151,7 @@ var LeaferUI = function(exports) {
11093
11151
  });
11094
11152
  other.recycle(copyBounds);
11095
11153
  }
11154
+ const getInnerShadowSpread = getShadowRenderSpread;
11096
11155
  function blur(ui, current, origin) {
11097
11156
  const {blur: blur} = ui.__;
11098
11157
  origin.setWorldBlur(blur * ui.__nowWorld.a);
@@ -11105,10 +11164,12 @@ var LeaferUI = function(exports) {
11105
11164
  innerShadow: innerShadow,
11106
11165
  blur: blur,
11107
11166
  backgroundBlur: backgroundBlur,
11108
- getShadowSpread: getShadowSpread,
11167
+ getShadowRenderSpread: getShadowRenderSpread,
11168
+ getShadowTransform: getShadowTransform,
11109
11169
  isTransformShadow(_shadow) {
11110
11170
  return undefined;
11111
- }
11171
+ },
11172
+ getInnerShadowSpread: getInnerShadowSpread
11112
11173
  };
11113
11174
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
11114
11175
  let usedGrayscaleAlpha;
@@ -11122,6 +11183,7 @@ var LeaferUI = function(exports) {
11122
11183
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
11123
11184
  maskCanvas = contentCanvas = null;
11124
11185
  }
11186
+ if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
11125
11187
  maskOpacity = child.__.opacity;
11126
11188
  usedGrayscaleAlpha = false;
11127
11189
  if (mask === "path" || mask === "clipping-path") {
@@ -11139,7 +11201,6 @@ var LeaferUI = function(exports) {
11139
11201
  if (!contentCanvas) contentCanvas = getCanvas(canvas);
11140
11202
  child.__render(maskCanvas, options);
11141
11203
  }
11142
- if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
11143
11204
  continue;
11144
11205
  }
11145
11206
  const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
@@ -11646,6 +11707,7 @@ var LeaferUI = function(exports) {
11646
11707
  getDrawData: getDrawData
11647
11708
  };
11648
11709
  function string(color, opacity) {
11710
+ if (!color) return "#000";
11649
11711
  const doOpacity = isNumber(opacity) && opacity < 1;
11650
11712
  if (isString(color)) {
11651
11713
  if (doOpacity && ColorConvert.object) color = ColorConvert.object(color); else return color;
@@ -11699,6 +11761,7 @@ var LeaferUI = function(exports) {
11699
11761
  exports.Export = Export;
11700
11762
  exports.FileHelper = FileHelper;
11701
11763
  exports.Filter = Filter;
11764
+ exports.FourNumberHelper = FourNumberHelper;
11702
11765
  exports.FrameData = FrameData;
11703
11766
  exports.GroupData = GroupData;
11704
11767
  exports.HitCanvasManager = HitCanvasManager;
@@ -11847,8 +11910,8 @@ var LeaferUI = function(exports) {
11847
11910
  exports.sortType = sortType;
11848
11911
  exports.strokeType = strokeType;
11849
11912
  exports.surfaceType = surfaceType;
11850
- exports.tempBounds = tempBounds$1;
11851
- exports.tempMatrix = tempMatrix$1;
11913
+ exports.tempBounds = tempBounds$2;
11914
+ exports.tempMatrix = tempMatrix$2;
11852
11915
  exports.tempPoint = tempPoint$2;
11853
11916
  exports.tryToNumber = tryToNumber;
11854
11917
  exports.useCanvas = useCanvas;