@leafer-draw/worker 1.6.7 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -46,7 +46,7 @@ var LeaferUI = (function (exports) {
46
46
  };
47
47
  const I$1 = IncrementId;
48
48
 
49
- const { round: round$3, pow: pow$1, PI: PI$4 } = Math;
49
+ const { round: round$3, pow: pow$1, PI: PI$3 } = Math;
50
50
  const MathHelper = {
51
51
  within(value, min, max) {
52
52
  if (typeof min === 'object')
@@ -142,9 +142,9 @@ var LeaferUI = (function (exports) {
142
142
  function randInt(num) {
143
143
  return Math.round(Math.random() * num);
144
144
  }
145
- const OneRadian = PI$4 / 180;
146
- const PI2 = PI$4 * 2;
147
- const PI_2 = PI$4 / 2;
145
+ const OneRadian = PI$3 / 180;
146
+ const PI2 = PI$3 * 2;
147
+ const PI_2 = PI$3 / 2;
148
148
  function getPointData() { return { x: 0, y: 0 }; }
149
149
  function getBoundsData() { return { x: 0, y: 0, width: 0, height: 0 }; }
150
150
  function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
@@ -439,7 +439,7 @@ var LeaferUI = (function (exports) {
439
439
  const M$6 = MatrixHelper;
440
440
 
441
441
  const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
442
- const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2, PI: PI$3 } = Math;
442
+ const { sin: sin$4, cos: cos$4, abs: abs$3, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2 } = Math;
443
443
  const PointHelper = {
444
444
  defaultPoint: getPointData(),
445
445
  tempPoint: {},
@@ -534,8 +534,8 @@ var LeaferUI = (function (exports) {
534
534
  return getDistanceFrom(t.x, t.y, point.x, point.y);
535
535
  },
536
536
  getDistanceFrom(x1, y1, x2, y2) {
537
- const x = abs$4(x2 - x1);
538
- const y = abs$4(y2 - y1);
537
+ const x = abs$3(x2 - x1);
538
+ const y = abs$3(y2 - y1);
539
539
  return sqrt$2(x * x + y * y);
540
540
  },
541
541
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
@@ -552,10 +552,11 @@ var LeaferUI = (function (exports) {
552
552
  getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
553
553
  if (toOriginX === undefined)
554
554
  toOriginX = originX, toOriginY = originY;
555
- let fromAngle = atan2$2(fromY - originY, fromX - originX);
556
- let toAngle = atan2$2(toY - toOriginY, toX - toOriginX);
557
- const radian = toAngle - fromAngle;
558
- return radian < -PI$3 ? radian + PI2 : radian;
555
+ const a = fromX - originX;
556
+ const b = fromY - originY;
557
+ const c = toX - toOriginX;
558
+ const d = toY - toOriginY;
559
+ return Math.atan2(a * d - b * c, a * c + b * d);
559
560
  },
560
561
  getAtan2(t, to) {
561
562
  return atan2$2(to.y - t.y, to.x - t.x);
@@ -765,7 +766,7 @@ var LeaferUI = (function (exports) {
765
766
  MatrixHelper.reset(this);
766
767
  }
767
768
  }
768
- const tempMatrix = new Matrix();
769
+ const tempMatrix$1 = new Matrix();
769
770
 
770
771
  const TwoPointBoundsHelper = {
771
772
  tempPointBounds: {},
@@ -862,6 +863,12 @@ var LeaferUI = (function (exports) {
862
863
  }
863
864
  if (!onlyBoxSize)
864
865
  to.x += box.x, to.y += box.y;
866
+ },
867
+ getPoint(around, box, to) {
868
+ if (!to)
869
+ to = {};
870
+ AroundHelper.toPoint(around, box, to, true);
871
+ return to;
865
872
  }
866
873
  };
867
874
  function get$4(around) {
@@ -1790,10 +1797,13 @@ var LeaferUI = (function (exports) {
1790
1797
  return (target, key) => {
1791
1798
  if (!realName)
1792
1799
  realName = key;
1793
- Object.defineProperty(target, key, {
1800
+ const property = {
1794
1801
  get() { return this.context[realName]; },
1795
1802
  set(value) { this.context[realName] = value; }
1796
- });
1803
+ };
1804
+ if (key === 'strokeCap')
1805
+ property.set = function (value) { this.context[realName] = value === 'none' ? 'butt' : value; };
1806
+ Object.defineProperty(target, key, property);
1797
1807
  };
1798
1808
  }
1799
1809
  const contextMethodNameList = [];
@@ -2069,15 +2079,15 @@ var LeaferUI = (function (exports) {
2069
2079
  contextMethod()
2070
2080
  ], Canvas.prototype, "strokeText", null);
2071
2081
 
2072
- const { copy: copy$8, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$1 } = Math;
2082
+ const { copy: copy$8, multiplyParent: multiplyParent$4 } = MatrixHelper, { round: round$1 } = Math;
2073
2083
  const minSize = { width: 1, height: 1, pixelRatio: 1 };
2074
2084
  const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
2075
2085
  class LeaferCanvasBase extends Canvas {
2076
2086
  get width() { return this.size.width; }
2077
2087
  get height() { return this.size.height; }
2078
2088
  get pixelRatio() { return this.size.pixelRatio; }
2079
- get pixelWidth() { return this.width * this.pixelRatio; }
2080
- get pixelHeight() { return this.height * this.pixelRatio; }
2089
+ get pixelWidth() { return this.width * this.pixelRatio || 0; }
2090
+ get pixelHeight() { return this.height * this.pixelRatio || 0; }
2081
2091
  get pixelSnap() { return this.config.pixelSnap; }
2082
2092
  set pixelSnap(value) { this.config.pixelSnap = value; }
2083
2093
  get allowBackgroundColor() { return this.view && this.parentView; }
@@ -2142,7 +2152,7 @@ var LeaferUI = (function (exports) {
2142
2152
  setWorld(matrix, parentMatrix) {
2143
2153
  const { pixelRatio, pixelSnap } = this, w = this.worldTransform;
2144
2154
  if (parentMatrix)
2145
- multiplyParent$3(matrix, parentMatrix, w);
2155
+ multiplyParent$4(matrix, parentMatrix, w);
2146
2156
  w.a = matrix.a * pixelRatio;
2147
2157
  w.b = matrix.b * pixelRatio;
2148
2158
  w.c = matrix.c * pixelRatio;
@@ -2164,20 +2174,33 @@ var LeaferUI = (function (exports) {
2164
2174
  if (w)
2165
2175
  this.setTransform(w.a, w.b, w.c, w.d, w.e, w.f);
2166
2176
  }
2167
- setStroke(color, strokeWidth, options) {
2177
+ setStroke(color, strokeWidth, options, childOptions) {
2168
2178
  if (strokeWidth)
2169
2179
  this.strokeWidth = strokeWidth;
2170
2180
  if (color)
2171
2181
  this.strokeStyle = color;
2172
2182
  if (options)
2173
- this.setStrokeOptions(options);
2174
- }
2175
- setStrokeOptions(options) {
2176
- this.strokeCap = options.strokeCap === 'none' ? 'butt' : options.strokeCap;
2177
- this.strokeJoin = options.strokeJoin;
2178
- this.dashPattern = options.dashPattern;
2179
- this.dashOffset = options.dashOffset;
2180
- this.miterLimit = options.miterLimit;
2183
+ this.setStrokeOptions(options, childOptions);
2184
+ }
2185
+ setStrokeOptions(options, childOptions) {
2186
+ let { strokeCap, strokeJoin, dashPattern, dashOffset, miterLimit } = options;
2187
+ if (childOptions) {
2188
+ if (childOptions.strokeCap)
2189
+ strokeCap = childOptions.strokeCap;
2190
+ if (childOptions.strokeJoin)
2191
+ strokeJoin = childOptions.strokeJoin;
2192
+ if (childOptions.dashPattern !== undefined)
2193
+ dashPattern = childOptions.dashPattern;
2194
+ if (childOptions.dashOffset !== undefined)
2195
+ dashOffset = childOptions.dashOffset;
2196
+ if (childOptions.miterLimit)
2197
+ miterLimit = childOptions.miterLimit;
2198
+ }
2199
+ this.strokeCap = strokeCap;
2200
+ this.strokeJoin = strokeJoin;
2201
+ this.dashPattern = dashPattern;
2202
+ this.dashOffset = dashOffset;
2203
+ this.miterLimit = miterLimit;
2181
2204
  }
2182
2205
  saveBlendMode(blendMode) {
2183
2206
  this.savedBlendMode = this.blendMode;
@@ -2411,7 +2434,7 @@ var LeaferUI = (function (exports) {
2411
2434
  }
2412
2435
  };
2413
2436
 
2414
- const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2437
+ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2415
2438
  const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
2416
2439
  const { set, toNumberPoints } = PointHelper;
2417
2440
  const { M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5 } = PathCommandMap;
@@ -2486,7 +2509,7 @@ var LeaferUI = (function (exports) {
2486
2509
  let totalRadian = endRadian - startRadian;
2487
2510
  if (totalRadian < 0)
2488
2511
  totalRadian += PI2;
2489
- if (totalRadian === PI$2 || (abs$3(BAx + BAy) < 1.e-12) || (abs$3(CBx + CBy) < 1.e-12)) {
2512
+ if (totalRadian === PI$2 || (abs$2(BAx + BAy) < 1.e-12) || (abs$2(CBx + CBy) < 1.e-12)) {
2490
2513
  if (data)
2491
2514
  data.push(L$6, x1, y1);
2492
2515
  if (setPointBounds) {
@@ -2528,7 +2551,7 @@ var LeaferUI = (function (exports) {
2528
2551
  totalRadian -= PI2;
2529
2552
  if (anticlockwise)
2530
2553
  totalRadian -= PI2;
2531
- const parts = ceil$1(abs$3(totalRadian / PI_2));
2554
+ const parts = ceil$1(abs$2(totalRadian / PI_2));
2532
2555
  const partRadian = totalRadian / parts;
2533
2556
  const partRadian4Sin = sin$3(partRadian / 4);
2534
2557
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -2973,7 +2996,7 @@ var LeaferUI = (function (exports) {
2973
2996
 
2974
2997
  const { M: M$3, L: L$4, C: C$2, Q: Q$2, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$3, O: O$2, P: P$2, U: U$2 } = PathCommandMap;
2975
2998
  const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2976
- const { tan, min, abs: abs$2 } = Math;
2999
+ const { tan, min, abs: abs$1 } = Math;
2977
3000
  const startPoint = {};
2978
3001
  const PathCommandDataHelper = {
2979
3002
  beginPath(data) {
@@ -3036,7 +3059,7 @@ var LeaferUI = (function (exports) {
3036
3059
  arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3037
3060
  if (lastX !== undefined) {
3038
3061
  const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3039
- radius = min(radius, min(d / 2, d / 2 * abs$2(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3062
+ radius = min(radius, min(d / 2, d / 2 * abs$1(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3040
3063
  }
3041
3064
  data.push(U$2, x1, y1, x2, y2, radius);
3042
3065
  },
@@ -3342,7 +3365,7 @@ var LeaferUI = (function (exports) {
3342
3365
  const { arcTo } = PathCommandDataHelper;
3343
3366
  const PathCorner = {
3344
3367
  smooth(data, cornerRadius, _cornerSmoothing) {
3345
- let command, commandLen;
3368
+ let command, lastCommand, commandLen;
3346
3369
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3347
3370
  const len = data.length;
3348
3371
  const smooth = [];
@@ -3380,8 +3403,10 @@ var LeaferUI = (function (exports) {
3380
3403
  lastY = y;
3381
3404
  break;
3382
3405
  case Z:
3383
- arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3384
- smooth.push(Z);
3406
+ if (lastCommand !== Z) {
3407
+ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3408
+ smooth.push(Z);
3409
+ }
3385
3410
  i += 1;
3386
3411
  break;
3387
3412
  default:
@@ -3390,6 +3415,7 @@ var LeaferUI = (function (exports) {
3390
3415
  smooth.push(data[i + j]);
3391
3416
  i += commandLen;
3392
3417
  }
3418
+ lastCommand = command;
3393
3419
  }
3394
3420
  if (command !== Z) {
3395
3421
  smooth[1] = startX;
@@ -3886,12 +3912,12 @@ var LeaferUI = (function (exports) {
3886
3912
  try {
3887
3913
  if (transform && pattern.setTransform) {
3888
3914
  pattern.setTransform(transform);
3889
- transform = null;
3915
+ transform = undefined;
3890
3916
  }
3891
3917
  }
3892
3918
  catch (_a) { }
3893
3919
  if (paint)
3894
- paint.transform = transform;
3920
+ DataHelper.stintSet(paint, 'transform', transform);
3895
3921
  return pattern;
3896
3922
  }
3897
3923
  destroy() {
@@ -3909,6 +3935,13 @@ var LeaferUI = (function (exports) {
3909
3935
  function getDescriptor(object, name) {
3910
3936
  return Object.getOwnPropertyDescriptor(object, name);
3911
3937
  }
3938
+ function createDescriptor(key, defaultValue) {
3939
+ const privateKey = '_' + key;
3940
+ return {
3941
+ get() { const v = this[privateKey]; return v === undefined ? defaultValue : v; },
3942
+ set(value) { this[privateKey] = value; }
3943
+ };
3944
+ }
3912
3945
  function getNames(object) {
3913
3946
  return Object.getOwnPropertyNames(object);
3914
3947
  }
@@ -3996,10 +4029,14 @@ var LeaferUI = (function (exports) {
3996
4029
  }));
3997
4030
  }
3998
4031
  const pathType = boundsType;
3999
- function affectStrokeBoundsType(defaultValue) {
4032
+ function affectStrokeBoundsType(defaultValue, useStroke) {
4000
4033
  return decorateLeafAttr(defaultValue, (key) => attr({
4001
4034
  set(value) {
4002
- this.__setAttr(key, value) && doStrokeType(this);
4035
+ if (this.__setAttr(key, value)) {
4036
+ doStrokeType(this);
4037
+ if (useStroke)
4038
+ this.__.__useStroke = true;
4039
+ }
4003
4040
  }
4004
4041
  }));
4005
4042
  }
@@ -4137,15 +4174,7 @@ var LeaferUI = (function (exports) {
4137
4174
  const data = target.__DataProcessor.prototype;
4138
4175
  const computedKey = '_' + key;
4139
4176
  const setMethodName = getSetMethodName(key);
4140
- const property = {
4141
- get() {
4142
- const v = this[computedKey];
4143
- return v === undefined ? defaultValue : v;
4144
- },
4145
- set(value) {
4146
- this[computedKey] = value;
4147
- }
4148
- };
4177
+ const property = createDescriptor(key, defaultValue);
4149
4178
  if (defaultValue === undefined) {
4150
4179
  property.get = function () { return this[computedKey]; };
4151
4180
  }
@@ -4260,7 +4289,7 @@ var LeaferUI = (function (exports) {
4260
4289
  };
4261
4290
  }
4262
4291
 
4263
- const { copy: copy$6, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
4292
+ const { copy: copy$6, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$3, divideParent, getLayout } = MatrixHelper;
4264
4293
  const matrix = {}, { round } = Math;
4265
4294
  const LeafHelper = {
4266
4295
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
@@ -4332,6 +4361,14 @@ var LeaferUI = (function (exports) {
4332
4361
  }
4333
4362
  return true;
4334
4363
  },
4364
+ copyCanvasByWorld(leaf, currentCanvas, fromCanvas, fromWorld, blendMode, onlyResetTransform) {
4365
+ if (!fromWorld)
4366
+ fromWorld = leaf.__nowWorld;
4367
+ if (leaf.__worldFlipped || Platform.fullImageShadow)
4368
+ currentCanvas.copyWorldByReset(fromCanvas, fromWorld, leaf.__nowWorld, blendMode, onlyResetTransform);
4369
+ else
4370
+ currentCanvas.copyWorldToInner(fromCanvas, fromWorld, leaf.__layout.renderBounds, blendMode);
4371
+ },
4335
4372
  moveWorld(t, x, y = 0, isInnerPoint, transition) {
4336
4373
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4337
4374
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
@@ -4391,14 +4428,14 @@ var LeaferUI = (function (exports) {
4391
4428
  },
4392
4429
  transformWorld(t, transform, resize, transition) {
4393
4430
  copy$6(matrix, t.worldTransform);
4394
- multiplyParent$2(matrix, transform);
4431
+ multiplyParent$3(matrix, transform);
4395
4432
  if (t.parent)
4396
4433
  divideParent(matrix, t.parent.worldTransform);
4397
4434
  L.setTransform(t, matrix, resize, transition);
4398
4435
  },
4399
4436
  transform(t, transform, resize, transition) {
4400
4437
  copy$6(matrix, t.localTransform);
4401
- multiplyParent$2(matrix, transform);
4438
+ multiplyParent$3(matrix, transform);
4402
4439
  L.setTransform(t, matrix, resize, transition);
4403
4440
  },
4404
4441
  setTransform(t, transform, resize, transition) {
@@ -5260,17 +5297,18 @@ var LeaferUI = (function (exports) {
5260
5297
  }
5261
5298
  };
5262
5299
 
5263
- const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
5300
+ const { setLayout, multiplyParent: multiplyParent$2, translateInner, defaultWorld } = MatrixHelper;
5264
5301
  const { toPoint: toPoint$3, tempPoint } = AroundHelper;
5265
5302
  const LeafMatrix = {
5266
5303
  __updateWorldMatrix() {
5267
- multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
5304
+ const { parent, __layout } = this;
5305
+ multiplyParent$2(this.__local || __layout, parent ? parent.__world : defaultWorld, this.__world, !!__layout.affectScaleOrRotation, this.__, parent && (parent.scrollY || parent.scrollX) && parent.__);
5268
5306
  },
5269
5307
  __updateLocalMatrix() {
5270
5308
  if (this.__local) {
5271
5309
  const layout = this.__layout, local = this.__local, data = this.__;
5272
5310
  if (layout.affectScaleOrRotation) {
5273
- if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
5311
+ if ((layout.scaleChanged && (layout.resized || (layout.resized = 'scale'))) || layout.rotationChanged) {
5274
5312
  setLayout(local, data, null, null, layout.affectRotation);
5275
5313
  layout.scaleChanged = layout.rotationChanged = undefined;
5276
5314
  }
@@ -5425,6 +5463,8 @@ var LeaferUI = (function (exports) {
5425
5463
 
5426
5464
  const LeafRender = {
5427
5465
  __render(canvas, options) {
5466
+ if (options.shape)
5467
+ return this.__renderShape(canvas, options);
5428
5468
  if (this.__worldOpacity) {
5429
5469
  const data = this.__;
5430
5470
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
@@ -5434,12 +5474,7 @@ var LeaferUI = (function (exports) {
5434
5474
  return this.__renderEraser(canvas, options);
5435
5475
  const tempCanvas = canvas.getSameCanvas(true, true);
5436
5476
  this.__draw(tempCanvas, options, canvas);
5437
- if (this.__worldFlipped) {
5438
- canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
5439
- }
5440
- else {
5441
- canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
5442
- }
5477
+ LeafHelper.copyCanvasByWorld(this, canvas, tempCanvas, this.__nowWorld, data.__blendMode, true);
5443
5478
  tempCanvas.recycle(this.__nowWorld);
5444
5479
  }
5445
5480
  else {
@@ -5449,6 +5484,12 @@ var LeaferUI = (function (exports) {
5449
5484
  Debug.drawBounds(this, canvas, options);
5450
5485
  }
5451
5486
  },
5487
+ __renderShape(canvas, options) {
5488
+ if (this.__worldOpacity) {
5489
+ canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5490
+ this.__drawShape(canvas, options);
5491
+ }
5492
+ },
5452
5493
  __clip(canvas, options) {
5453
5494
  if (this.__worldOpacity) {
5454
5495
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
@@ -5481,7 +5522,7 @@ var LeaferUI = (function (exports) {
5481
5522
  options.dimOpacity = data.dim === true ? 0.2 : data.dim;
5482
5523
  else if (data.dimskip)
5483
5524
  options.dimOpacity && (options.dimOpacity = 0);
5484
- if (data.__single) {
5525
+ if (data.__single && !this.isBranchLeaf) {
5485
5526
  if (data.eraser === 'path')
5486
5527
  return this.__renderEraser(canvas, options);
5487
5528
  const tempCanvas = canvas.getSameCanvas(false, true);
@@ -5503,9 +5544,7 @@ var LeaferUI = (function (exports) {
5503
5544
  else {
5504
5545
  const { children } = this;
5505
5546
  for (let i = 0, len = children.length; i < len; i++) {
5506
- if (excludeRenderBounds$1(children[i], options))
5507
- continue;
5508
- children[i].__render(canvas, options);
5547
+ excludeRenderBounds$1(children[i], options) || children[i].__render(canvas, options);
5509
5548
  }
5510
5549
  }
5511
5550
  },
@@ -5513,16 +5552,15 @@ var LeaferUI = (function (exports) {
5513
5552
  if (this.__worldOpacity) {
5514
5553
  const { children } = this;
5515
5554
  for (let i = 0, len = children.length; i < len; i++) {
5516
- if (excludeRenderBounds$1(children[i], options))
5517
- continue;
5518
- children[i].__clip(canvas, options);
5555
+ excludeRenderBounds$1(children[i], options) || children[i].__clip(canvas, options);
5519
5556
  }
5520
5557
  }
5521
5558
  }
5522
5559
  };
5523
5560
 
5561
+ const tempScaleData$1 = {};
5524
5562
  const { LEAF, create } = IncrementId;
5525
- const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
5563
+ const { toInnerPoint, toOuterPoint, multiplyParent: multiplyParent$1 } = MatrixHelper;
5526
5564
  const { toOuterOf } = BoundsHelper;
5527
5565
  const { copy: copy$3, move } = PointHelper;
5528
5566
  const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
@@ -5704,7 +5742,7 @@ var LeaferUI = (function (exports) {
5704
5742
  if (!this.__cameraWorld)
5705
5743
  this.__cameraWorld = {};
5706
5744
  const cameraWorld = this.__cameraWorld, world = this.__world;
5707
- multiplyParent(world, options.matrix, cameraWorld, undefined, world);
5745
+ multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
5708
5746
  toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
5709
5747
  cameraWorld.half !== world.half && (cameraWorld.half = world.half);
5710
5748
  return cameraWorld;
@@ -5713,6 +5751,22 @@ var LeaferUI = (function (exports) {
5713
5751
  return this.__world;
5714
5752
  }
5715
5753
  }
5754
+ getClampRenderScale() {
5755
+ let { scaleX } = this.__nowWorld || this.__world;
5756
+ if (scaleX < 0)
5757
+ scaleX = -scaleX;
5758
+ return scaleX > 1 ? scaleX : 1;
5759
+ }
5760
+ getRenderScaleData(abs, scaleFixed) {
5761
+ const { scaleX, scaleY } = ImageManager.patternLocked ? this.__world : this.__nowWorld;
5762
+ if (scaleFixed)
5763
+ tempScaleData$1.scaleX = tempScaleData$1.scaleY = 1;
5764
+ else if (abs)
5765
+ tempScaleData$1.scaleX = scaleX < 0 ? -scaleX : scaleX, tempScaleData$1.scaleY = scaleY < 0 ? -scaleY : scaleY;
5766
+ else
5767
+ tempScaleData$1.scaleX = scaleX, tempScaleData$1.scaleY = scaleY;
5768
+ return tempScaleData$1;
5769
+ }
5716
5770
  getTransform(relative) {
5717
5771
  return this.__layout.getTransform(relative || 'local');
5718
5772
  }
@@ -5868,7 +5922,8 @@ var LeaferUI = (function (exports) {
5868
5922
  __drawFast(_canvas, _options) { }
5869
5923
  __draw(_canvas, _options, _originCanvas) { }
5870
5924
  __clip(_canvas, _options) { }
5871
- __renderShape(_canvas, _options, _ignoreFill, _ignoreStroke) { }
5925
+ __renderShape(_canvas, _options) { }
5926
+ __drawShape(_canvas, _options) { }
5872
5927
  __updateWorldOpacity() { }
5873
5928
  __updateChange() { }
5874
5929
  __drawPath(_canvas) { }
@@ -6236,7 +6291,7 @@ var LeaferUI = (function (exports) {
6236
6291
  }
6237
6292
  }
6238
6293
 
6239
- const version = "1.6.7";
6294
+ const version = "1.8.0";
6240
6295
 
6241
6296
  class LeaferCanvas extends LeaferCanvasBase {
6242
6297
  get allowBackgroundColor() { return true; }
@@ -6927,6 +6982,11 @@ var LeaferUI = (function (exports) {
6927
6982
  });
6928
6983
  };
6929
6984
  }
6985
+ function createAttr(defaultValue) {
6986
+ return (target, key) => {
6987
+ defineKey(target, key, createDescriptor(key, defaultValue));
6988
+ };
6989
+ }
6930
6990
 
6931
6991
  function hasTransparent$3(color) {
6932
6992
  if (!color || color.length === 7 || color.length === 4)
@@ -6984,26 +7044,9 @@ var LeaferUI = (function (exports) {
6984
7044
  const debug$1 = Debug.get('UIData');
6985
7045
  class UIData extends LeafData {
6986
7046
  get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
6987
- get __strokeWidth() {
6988
- const { strokeWidth, strokeWidthFixed } = this;
6989
- if (strokeWidthFixed) {
6990
- const ui = this.__leaf;
6991
- let { scaleX } = ui.__nowWorld || ui.__world;
6992
- if (scaleX < 0)
6993
- scaleX = -scaleX;
6994
- return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
6995
- }
6996
- else
6997
- return strokeWidth;
6998
- }
6999
- get __hasStroke() { return this.stroke && this.strokeWidth; }
7000
- get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
7001
- get __hasMultiPaint() {
7002
- const t = this;
7003
- if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
7004
- return true;
7005
- return t.fill && this.__hasStroke;
7006
- }
7047
+ get __strokeWidth() { return this.__getRealStrokeWidth(); }
7048
+ get __maxStrokeWidth() { const t = this; return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth; }
7049
+ get __hasMultiPaint() { const t = this; return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect; }
7007
7050
  get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
7008
7051
  get __hasSurface() { const t = this; return (t.fill || t.stroke); }
7009
7052
  get __autoWidth() { return !this._width; }
@@ -7085,6 +7128,21 @@ var LeaferUI = (function (exports) {
7085
7128
  Paint.compute('stroke', this.__leaf);
7086
7129
  this.__needComputePaint = undefined;
7087
7130
  }
7131
+ __getRealStrokeWidth(childStyle) {
7132
+ let { strokeWidth, strokeWidthFixed } = this;
7133
+ if (childStyle) {
7134
+ if (childStyle.strokeWidth)
7135
+ strokeWidth = childStyle.strokeWidth;
7136
+ if (childStyle.strokeWidthFixed !== undefined)
7137
+ strokeWidthFixed = childStyle.strokeWidthFixed;
7138
+ }
7139
+ if (strokeWidthFixed) {
7140
+ const scale = this.__leaf.getClampRenderScale();
7141
+ return scale > 1 ? strokeWidth / scale : strokeWidth;
7142
+ }
7143
+ else
7144
+ return strokeWidth;
7145
+ }
7088
7146
  __setPaint(attrName, value) {
7089
7147
  this.__setInput(attrName, value);
7090
7148
  const layout = this.__leaf.__layout;
@@ -7109,6 +7167,7 @@ var LeaferUI = (function (exports) {
7109
7167
  }
7110
7168
  else {
7111
7169
  stintSet$2(this, '__isAlphaPixelStroke', undefined);
7170
+ stintSet$2(this, '__hasMultiStrokeStyle', undefined);
7112
7171
  this._stroke = this.__isStrokes = undefined;
7113
7172
  }
7114
7173
  }
@@ -7130,8 +7189,8 @@ var LeaferUI = (function (exports) {
7130
7189
 
7131
7190
  class BoxData extends GroupData {
7132
7191
  get __boxStroke() { return !this.__pathInputed; }
7133
- get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
7134
- get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
7192
+ get __drawAfterFill() { const t = this; return t.__single || t.__clipAfterFill; }
7193
+ get __clipAfterFill() { const t = this; return t.overflow === 'hide' && t.__leaf.children.length && (t.__leaf.isOverflow || super.__clipAfterFill); }
7135
7194
  }
7136
7195
 
7137
7196
  class LeaferData extends GroupData {
@@ -7251,7 +7310,7 @@ var LeaferUI = (function (exports) {
7251
7310
  const UIBounds = {
7252
7311
  __updateStrokeSpread() {
7253
7312
  let width = 0, boxWidth = 0;
7254
- const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
7313
+ const data = this.__, { strokeAlign, __maxStrokeWidth: strokeWidth } = data, box = this.__box;
7255
7314
  if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
7256
7315
  boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
7257
7316
  if (!data.__boxStroke) {
@@ -7271,13 +7330,15 @@ var LeaferUI = (function (exports) {
7271
7330
  },
7272
7331
  __updateRenderSpread() {
7273
7332
  let width = 0;
7274
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7333
+ const { shadow, innerShadow, blur, backgroundBlur, filter, renderSpread } = this.__;
7275
7334
  if (shadow)
7276
7335
  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));
7277
7336
  if (blur)
7278
7337
  width = Math.max(width, blur);
7279
7338
  if (filter)
7280
7339
  width += Filter.getSpread(filter);
7340
+ if (renderSpread)
7341
+ width += renderSpread;
7281
7342
  let shapeWidth = width = Math.ceil(width);
7282
7343
  if (innerShadow)
7283
7344
  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));
@@ -7293,15 +7354,18 @@ var LeaferUI = (function (exports) {
7293
7354
  const UIRender = {
7294
7355
  __updateChange() {
7295
7356
  const data = this.__;
7357
+ if (data.__useStroke) {
7358
+ const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
7359
+ stintSet$1(this.__world, 'half', useStroke && data.strokeAlign === 'center' && data.strokeWidth % 2);
7360
+ stintSet$1(data, '__fillAfterStroke', useStroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7361
+ }
7296
7362
  if (data.__useEffect) {
7297
7363
  const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7298
- stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
7364
+ stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
7299
7365
  data.__useEffect = !!(shadow || otherEffect);
7300
7366
  }
7301
- stintSet$1(this.__world, 'half', data.__hasHalf);
7302
- stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7303
7367
  data.__checkSingle();
7304
- stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7368
+ stintSet$1(data, '__complex', (data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect));
7305
7369
  },
7306
7370
  __drawFast(canvas, options) {
7307
7371
  drawFast(this, canvas, options);
@@ -7359,18 +7423,15 @@ var LeaferUI = (function (exports) {
7359
7423
  this.__drawFast(canvas, options);
7360
7424
  }
7361
7425
  },
7362
- __renderShape(canvas, options, ignoreFill, ignoreStroke) {
7363
- if (this.__worldOpacity) {
7364
- canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
7365
- const { fill, stroke } = this.__;
7366
- this.__drawRenderPath(canvas);
7367
- if (fill && !ignoreFill)
7368
- this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7369
- if (this.__.__isCanvas)
7370
- this.__drawAfterFill(canvas, options);
7371
- if (stroke && !ignoreStroke)
7372
- this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7373
- }
7426
+ __drawShape(canvas, options) {
7427
+ this.__drawRenderPath(canvas);
7428
+ const data = this.__, { fill, stroke } = data;
7429
+ if (fill && !options.ignoreFill)
7430
+ data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7431
+ if (data.__isCanvas)
7432
+ this.__drawAfterFill(canvas, options);
7433
+ if (stroke && !options.ignoreStroke)
7434
+ data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7374
7435
  },
7375
7436
  __drawAfterFill(canvas, options) {
7376
7437
  if (this.__.__clipAfterFill) {
@@ -7407,17 +7468,17 @@ var LeaferUI = (function (exports) {
7407
7468
  if (__drawAfterFill)
7408
7469
  this.__drawAfterFill(canvas, options);
7409
7470
  if (stroke) {
7410
- const { strokeAlign, __strokeWidth } = this.__;
7411
- if (!__strokeWidth)
7471
+ const { strokeAlign, __strokeWidth: strokeWidth } = this.__;
7472
+ if (!strokeWidth)
7412
7473
  return;
7413
- canvas.setStroke(stroke, __strokeWidth, this.__);
7414
- const half = __strokeWidth / 2;
7474
+ canvas.setStroke(stroke, strokeWidth, this.__);
7475
+ const half = strokeWidth / 2;
7415
7476
  switch (strokeAlign) {
7416
7477
  case 'center':
7417
7478
  canvas.strokeRect(0, 0, width, height);
7418
7479
  break;
7419
7480
  case 'inside':
7420
- width -= __strokeWidth, height -= __strokeWidth;
7481
+ width -= strokeWidth, height -= strokeWidth;
7421
7482
  if (width < 0 || height < 0) {
7422
7483
  canvas.save();
7423
7484
  this.__clip(canvas, options);
@@ -7428,7 +7489,7 @@ var LeaferUI = (function (exports) {
7428
7489
  canvas.strokeRect(x + half, y + half, width, height);
7429
7490
  break;
7430
7491
  case 'outside':
7431
- canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
7492
+ canvas.strokeRect(x - half, y - half, width + strokeWidth, height + strokeWidth);
7432
7493
  break;
7433
7494
  }
7434
7495
  }
@@ -7441,6 +7502,8 @@ var LeaferUI = (function (exports) {
7441
7502
  get isFrame() { return false; }
7442
7503
  set scale(value) { MathHelper.assignScale(this, value); }
7443
7504
  get scale() { return this.__.scale; }
7505
+ get isAutoWidth() { const t = this.__; return t.__autoWidth || t.autoWidth; }
7506
+ get isAutoHeight() { const t = this.__; return t.__autoHeight || t.autoHeight; }
7444
7507
  get pen() {
7445
7508
  const { path } = this.__;
7446
7509
  pen.set(this.path = path || []);
@@ -7495,12 +7558,14 @@ var LeaferUI = (function (exports) {
7495
7558
  }
7496
7559
  }
7497
7560
  __updateRenderPath() {
7498
- if (this.__.path) {
7499
- const data = this.__;
7561
+ const data = this.__;
7562
+ if (data.path) {
7500
7563
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
7501
7564
  if (data.__useArrow)
7502
7565
  PathArrow.addArrows(this, !data.cornerRadius);
7503
7566
  }
7567
+ else
7568
+ data.__pathForRender && (data.__pathForRender = undefined);
7504
7569
  }
7505
7570
  __drawRenderPath(canvas) {
7506
7571
  canvas.beginPath();
@@ -7653,6 +7718,9 @@ var LeaferUI = (function (exports) {
7653
7718
  __decorate([
7654
7719
  naturalBoundsType(1)
7655
7720
  ], exports.UI.prototype, "pixelRatio", void 0);
7721
+ __decorate([
7722
+ affectRenderBoundsType(0)
7723
+ ], exports.UI.prototype, "renderSpread", void 0);
7656
7724
  __decorate([
7657
7725
  pathInputType()
7658
7726
  ], exports.UI.prototype, "path", void 0);
@@ -7711,13 +7779,13 @@ var LeaferUI = (function (exports) {
7711
7779
  surfaceType()
7712
7780
  ], exports.UI.prototype, "fill", void 0);
7713
7781
  __decorate([
7714
- strokeType()
7782
+ strokeType(undefined, true)
7715
7783
  ], exports.UI.prototype, "stroke", void 0);
7716
7784
  __decorate([
7717
7785
  strokeType('inside')
7718
7786
  ], exports.UI.prototype, "strokeAlign", void 0);
7719
7787
  __decorate([
7720
- strokeType(1)
7788
+ strokeType(1, true)
7721
7789
  ], exports.UI.prototype, "strokeWidth", void 0);
7722
7790
  __decorate([
7723
7791
  strokeType(false)
@@ -7809,7 +7877,8 @@ var LeaferUI = (function (exports) {
7809
7877
  }
7810
7878
  toJSON(options) {
7811
7879
  const data = super.toJSON(options);
7812
- data.children = this.children.map(child => child.toJSON(options));
7880
+ if (!this.childlessJSON)
7881
+ data.children = this.children.map(child => child.toJSON(options));
7813
7882
  return data;
7814
7883
  }
7815
7884
  pick(_hitPoint, _options) { return undefined; }
@@ -8144,7 +8213,7 @@ var LeaferUI = (function (exports) {
8144
8213
  list.push(item);
8145
8214
  this.requestRender();
8146
8215
  }
8147
- zoom(_zoomType, _padding, _fixedScale, _transition) {
8216
+ zoom(_zoomType, _optionsOrPadding, _scroll, _transition) {
8148
8217
  return Plugin.need('view');
8149
8218
  }
8150
8219
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
@@ -8189,7 +8258,7 @@ var LeaferUI = (function (exports) {
8189
8258
  Leafer_1.list.remove(this);
8190
8259
  try {
8191
8260
  this.stop();
8192
- this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
8261
+ this.emitLeafer(LeaferEvent.END);
8193
8262
  this.__removeListenEvents();
8194
8263
  this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
8195
8264
  this.__controllers.length = 0;
@@ -8256,8 +8325,8 @@ var LeaferUI = (function (exports) {
8256
8325
  __updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
8257
8326
  __updateRectBoxBounds() { }
8258
8327
  __updateBoxBounds(_secondLayout) {
8259
- const data = this.__;
8260
8328
  if (this.children.length && !this.pathInputed) {
8329
+ const data = this.__;
8261
8330
  if (data.__autoSide) {
8262
8331
  if (data.__hasSurface)
8263
8332
  this.__extraUpdate();
@@ -8284,20 +8353,26 @@ var LeaferUI = (function (exports) {
8284
8353
  __updateStrokeBounds() { }
8285
8354
  __updateRenderBounds() {
8286
8355
  let isOverflow;
8287
- const { renderBounds } = this.__layout;
8288
8356
  if (this.children.length) {
8357
+ const data = this.__, { renderBounds, boxBounds } = this.__layout;
8289
8358
  super.__updateRenderBounds();
8290
8359
  copy$2(childrenRenderBounds, renderBounds);
8291
8360
  this.__updateRectRenderBounds();
8292
- isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8293
- if (isOverflow && this.__.overflow !== 'hide')
8361
+ if (data.scrollY || data.scrollX) {
8362
+ childrenRenderBounds.x += data.scrollX;
8363
+ childrenRenderBounds.y += data.scrollY;
8364
+ }
8365
+ isOverflow = !includes$1(boxBounds, childrenRenderBounds);
8366
+ if (isOverflow && data.overflow !== 'hide')
8294
8367
  add(renderBounds, childrenRenderBounds);
8295
8368
  }
8296
8369
  else
8297
8370
  this.__updateRectRenderBounds();
8298
8371
  DataHelper.stintSet(this, 'isOverflow', isOverflow);
8372
+ this.__updateScrollBar();
8299
8373
  }
8300
8374
  __updateRectRenderBounds() { }
8375
+ __updateScrollBar() { }
8301
8376
  __updateRectChange() { }
8302
8377
  __updateChange() {
8303
8378
  super.__updateChange();
@@ -8314,10 +8389,12 @@ var LeaferUI = (function (exports) {
8314
8389
  if (this.children.length)
8315
8390
  this.__renderGroup(canvas, options);
8316
8391
  }
8392
+ if (this.scrollBar)
8393
+ this.scrollBar.__render(canvas, options);
8317
8394
  }
8318
8395
  __drawContent(canvas, options) {
8319
8396
  this.__renderGroup(canvas, options);
8320
- if (this.__.__hasStroke) {
8397
+ if (this.__.__useStroke || this.__.__useEffect) {
8321
8398
  canvas.setWorld(this.__nowWorld);
8322
8399
  this.__drawRenderPath(canvas);
8323
8400
  }
@@ -8537,8 +8614,8 @@ var LeaferUI = (function (exports) {
8537
8614
  for (let i = 1; i < sides; i++) {
8538
8615
  lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
8539
8616
  }
8617
+ closePath$1(path);
8540
8618
  }
8541
- closePath$1(path);
8542
8619
  }
8543
8620
  __updateRenderPath() { }
8544
8621
  __updateBoxBounds() { }
@@ -8776,6 +8853,11 @@ var LeaferUI = (function (exports) {
8776
8853
  return;
8777
8854
  super.__draw(canvas, options, originCanvas);
8778
8855
  }
8856
+ __drawShape(canvas, options) {
8857
+ if (options.shape)
8858
+ this.__box && this.__box.__drawShape(canvas, options);
8859
+ super.__drawShape(canvas, options);
8860
+ }
8779
8861
  destroy() {
8780
8862
  if (this.boxStyle)
8781
8863
  this.boxStyle = null;
@@ -8971,9 +9053,14 @@ var LeaferUI = (function (exports) {
8971
9053
  }
8972
9054
  }
8973
9055
  canvas.fillStyle = item.style;
8974
- if (item.transform) {
9056
+ if (item.transform || item.scaleFixed) {
8975
9057
  canvas.save();
8976
- canvas.transform(item.transform);
9058
+ if (item.transform)
9059
+ canvas.transform(item.transform);
9060
+ if (item.scaleFixed) {
9061
+ const { scaleX, scaleY } = ui.getRenderScaleData(true);
9062
+ canvas.scale(1 / scaleX, 1 / scaleY);
9063
+ }
8977
9064
  if (item.blendMode)
8978
9065
  canvas.blendMode = item.blendMode;
8979
9066
  fillPathOrText(ui, canvas);
@@ -9009,8 +9096,13 @@ var LeaferUI = (function (exports) {
9009
9096
  }
9010
9097
  function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
9011
9098
  const data = ui.__;
9012
- canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
9013
- data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
9099
+ if (typeof stroke === 'object') {
9100
+ drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
9101
+ }
9102
+ else {
9103
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
9104
+ drawTextStroke(ui, canvas);
9105
+ }
9014
9106
  }
9015
9107
  function drawAlign(stroke, align, ui, canvas) {
9016
9108
  const out = canvas.getSameCanvas(true, true);
@@ -9019,15 +9111,9 @@ var LeaferUI = (function (exports) {
9019
9111
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
9020
9112
  fillText(ui, out);
9021
9113
  out.blendMode = 'normal';
9022
- copyWorld(canvas, out, ui);
9114
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
9023
9115
  out.recycle(ui.__nowWorld);
9024
9116
  }
9025
- function copyWorld(canvas, out, ui) {
9026
- if (ui.__worldFlipped || Platform.fullImageShadow)
9027
- canvas.copyWorldByReset(out, ui.__nowWorld);
9028
- else
9029
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
9030
- }
9031
9117
  function drawTextStroke(ui, canvas) {
9032
9118
  let row, data = ui.__.__textDrawData;
9033
9119
  const { rows, decorationY } = data;
@@ -9043,14 +9129,21 @@ var LeaferUI = (function (exports) {
9043
9129
  rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
9044
9130
  }
9045
9131
  }
9046
- function drawStrokesStyle(strokes, isText, ui, canvas) {
9132
+ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
9047
9133
  let item;
9134
+ const data = ui.__, { __hasMultiStrokeStyle } = data;
9135
+ __hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
9048
9136
  for (let i = 0, len = strokes.length; i < len; i++) {
9049
9137
  item = strokes[i];
9050
9138
  if (item.image && PaintImage.checkImage(ui, canvas, item, false))
9051
9139
  continue;
9052
9140
  if (item.style) {
9053
- canvas.strokeStyle = item.style;
9141
+ if (__hasMultiStrokeStyle) {
9142
+ const { strokeStyle } = item;
9143
+ strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
9144
+ }
9145
+ else
9146
+ canvas.strokeStyle = item.style;
9054
9147
  if (item.blendMode) {
9055
9148
  canvas.saveBlendMode(item.blendMode);
9056
9149
  isText ? drawTextStroke(ui, canvas) : canvas.stroke();
@@ -9089,8 +9182,13 @@ var LeaferUI = (function (exports) {
9089
9182
  }
9090
9183
  function drawCenter(stroke, strokeWidthScale, ui, canvas) {
9091
9184
  const data = ui.__;
9092
- canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
9093
- data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
9185
+ if (typeof stroke === 'object') {
9186
+ drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
9187
+ }
9188
+ else {
9189
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
9190
+ canvas.stroke();
9191
+ }
9094
9192
  if (data.__useArrow)
9095
9193
  Paint.strokeArrow(stroke, ui, canvas);
9096
9194
  }
@@ -9112,7 +9210,7 @@ var LeaferUI = (function (exports) {
9112
9210
  drawCenter(stroke, 2, ui, out);
9113
9211
  out.clipUI(data);
9114
9212
  out.clearWorld(renderBounds);
9115
- copyWorld(canvas, out, ui);
9213
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
9116
9214
  out.recycle(ui.__nowWorld);
9117
9215
  }
9118
9216
  }
@@ -9167,8 +9265,16 @@ var LeaferUI = (function (exports) {
9167
9265
  if (!(paints instanceof Array))
9168
9266
  paints = [paints];
9169
9267
  recycleMap = PaintImage.recycleImage(attrName, data);
9268
+ let maxChildStrokeWidth;
9170
9269
  for (let i = 0, len = paints.length, item; i < len; i++) {
9171
- (item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
9270
+ if (item = getLeafPaint(attrName, paints[i], ui)) {
9271
+ leafPaints.push(item);
9272
+ if (item.strokeStyle) {
9273
+ maxChildStrokeWidth || (maxChildStrokeWidth = 1);
9274
+ if (item.strokeStyle.strokeWidth)
9275
+ maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
9276
+ }
9277
+ }
9172
9278
  }
9173
9279
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
9174
9280
  if (leafPaints.length) {
@@ -9185,6 +9291,7 @@ var LeaferUI = (function (exports) {
9185
9291
  else {
9186
9292
  stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
9187
9293
  stintSet(data, '__isTransparentStroke', isTransparent);
9294
+ stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
9188
9295
  }
9189
9296
  }
9190
9297
  function getLeafPaint(attrName, paint, ui) {
@@ -9216,6 +9323,11 @@ var LeaferUI = (function (exports) {
9216
9323
  if (data) {
9217
9324
  if (typeof data.style === 'string' && hasTransparent$1(data.style))
9218
9325
  data.isTransparent = true;
9326
+ if (paint.style) {
9327
+ if (paint.style.strokeWidth === 0)
9328
+ return undefined;
9329
+ data.strokeStyle = paint.style;
9330
+ }
9219
9331
  if (paint.blendMode)
9220
9332
  data.blendMode = paint.blendMode;
9221
9333
  }
@@ -9235,8 +9347,8 @@ var LeaferUI = (function (exports) {
9235
9347
  shape
9236
9348
  };
9237
9349
 
9238
- let origin = {};
9239
- const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
9350
+ let origin = {}, tempMatrix = getMatrixData();
9351
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
9240
9352
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
9241
9353
  const transform = get$3();
9242
9354
  translate$1(transform, box.x + x, box.y + y);
@@ -9245,13 +9357,19 @@ var LeaferUI = (function (exports) {
9245
9357
  rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
9246
9358
  data.transform = transform;
9247
9359
  }
9248
- function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
9360
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
9249
9361
  const transform = get$3();
9250
- translate$1(transform, box.x + x, box.y + y);
9251
- if (scaleX)
9252
- scaleHelper(transform, scaleX, scaleY);
9253
9362
  if (rotation)
9254
9363
  rotate(transform, rotation);
9364
+ if (skew)
9365
+ skewHelper(transform, skew.x, skew.y);
9366
+ if (scaleX)
9367
+ scaleHelper(transform, scaleX, scaleY);
9368
+ translate$1(transform, box.x + x, box.y + y);
9369
+ if (clipSize) {
9370
+ tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
9371
+ multiplyParent(transform, tempMatrix);
9372
+ }
9255
9373
  data.transform = transform;
9256
9374
  }
9257
9375
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -9288,11 +9406,15 @@ var LeaferUI = (function (exports) {
9288
9406
  const tempScaleData = {};
9289
9407
  const tempImage = {};
9290
9408
  function createData(leafPaint, image, paint, box) {
9291
- const { changeful, sync } = paint;
9409
+ const { changeful, sync, editing, scaleFixed } = paint;
9292
9410
  if (changeful)
9293
9411
  leafPaint.changeful = changeful;
9294
9412
  if (sync)
9295
9413
  leafPaint.sync = sync;
9414
+ if (editing)
9415
+ leafPaint.editing = editing;
9416
+ if (scaleFixed)
9417
+ leafPaint.scaleFixed = scaleFixed;
9296
9418
  leafPaint.data = getPatternData(paint, box, image);
9297
9419
  }
9298
9420
  function getPatternData(paint, box, image) {
@@ -9301,7 +9423,7 @@ var LeaferUI = (function (exports) {
9301
9423
  if (paint.mode === 'strench')
9302
9424
  paint.mode = 'stretch';
9303
9425
  let { width, height } = image;
9304
- const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
9426
+ const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
9305
9427
  const sameBox = box.width === width && box.height === height;
9306
9428
  const data = { mode };
9307
9429
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -9335,8 +9457,8 @@ var LeaferUI = (function (exports) {
9335
9457
  break;
9336
9458
  case 'normal':
9337
9459
  case 'clip':
9338
- if (tempImage.x || tempImage.y || scaleX || rotation)
9339
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
9460
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
9461
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
9340
9462
  break;
9341
9463
  case 'repeat':
9342
9464
  if (!sameBox || scaleX || rotation)
@@ -9413,11 +9535,11 @@ var LeaferUI = (function (exports) {
9413
9535
  }
9414
9536
  onLoadSuccess(ui, event);
9415
9537
  }
9416
- leafPaint.loadId = null;
9538
+ leafPaint.loadId = undefined;
9417
9539
  }, (error) => {
9418
9540
  ignoreRender(ui, false);
9419
9541
  onLoadError(ui, event, error);
9420
- leafPaint.loadId = null;
9542
+ leafPaint.loadId = undefined;
9421
9543
  });
9422
9544
  if (ui.placeholderColor) {
9423
9545
  if (!ui.placeholderDelay)
@@ -9473,16 +9595,16 @@ var LeaferUI = (function (exports) {
9473
9595
  }
9474
9596
 
9475
9597
  const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
9476
- const { ceil, abs: abs$1 } = Math;
9598
+ const { ceil, abs } = Math;
9477
9599
  function createPattern(ui, paint, pixelRatio) {
9478
- let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
9600
+ let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
9479
9601
  const id = scaleX + '-' + scaleY + '-' + pixelRatio;
9480
9602
  if (paint.patternId !== id && !ui.destroyed) {
9481
- scaleX = abs$1(scaleX);
9482
- scaleY = abs$1(scaleY);
9483
9603
  const { image, data } = paint;
9484
9604
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
9485
9605
  if (sx) {
9606
+ sx = abs(sx);
9607
+ sy = abs(sy);
9486
9608
  imageMatrix = get$1();
9487
9609
  copy$1(imageMatrix, transform);
9488
9610
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -9535,9 +9657,8 @@ var LeaferUI = (function (exports) {
9535
9657
  }
9536
9658
  }
9537
9659
 
9538
- const { abs } = Math;
9539
9660
  function checkImage(ui, canvas, paint, allowDraw) {
9540
- const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
9661
+ const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
9541
9662
  const { pixelRatio } = canvas, { data } = paint;
9542
9663
  if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
9543
9664
  return false;
@@ -9550,8 +9671,8 @@ var LeaferUI = (function (exports) {
9550
9671
  else {
9551
9672
  if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
9552
9673
  let { width, height } = data;
9553
- width *= abs(scaleX) * pixelRatio;
9554
- height *= abs(scaleY) * pixelRatio;
9674
+ width *= scaleX * pixelRatio;
9675
+ height *= scaleY * pixelRatio;
9555
9676
  if (data.scaleX) {
9556
9677
  width *= data.scaleX;
9557
9678
  height *= data.scaleY;
@@ -9561,6 +9682,10 @@ var LeaferUI = (function (exports) {
9561
9682
  }
9562
9683
  }
9563
9684
  if (allowDraw) {
9685
+ if (ui.__.__isFastShadow) {
9686
+ canvas.fillStyle = paint.style || '#000';
9687
+ canvas.fill();
9688
+ }
9564
9689
  drawImage(ui, canvas, paint, data);
9565
9690
  return true;
9566
9691
  }
@@ -9749,10 +9874,7 @@ var LeaferUI = (function (exports) {
9749
9874
  }
9750
9875
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
9751
9876
  }
9752
- if (ui.__worldFlipped)
9753
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
9754
- else
9755
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
9877
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9756
9878
  if (end && index < end)
9757
9879
  other.clearWorld(copyBounds, true);
9758
9880
  });
@@ -9811,10 +9933,7 @@ var LeaferUI = (function (exports) {
9811
9933
  copyBounds = bounds;
9812
9934
  }
9813
9935
  other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
9814
- if (ui.__worldFlipped)
9815
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
9816
- else
9817
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
9936
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9818
9937
  if (end && index < end)
9819
9938
  other.clearWorld(copyBounds, true);
9820
9939
  });
@@ -9870,12 +9989,11 @@ var LeaferUI = (function (exports) {
9870
9989
  contentCanvas = getCanvas(canvas);
9871
9990
  child.__render(maskCanvas, options);
9872
9991
  }
9873
- if (!(mask === 'clipping' || mask === 'clipping-path'))
9874
- continue;
9875
- }
9876
- if (excludeRenderBounds(child, options))
9992
+ if (mask === 'clipping' || mask === 'clipping-path')
9993
+ excludeRenderBounds(child, options) || child.__render(canvas, options);
9877
9994
  continue;
9878
- child.__render(contentCanvas || canvas, options);
9995
+ }
9996
+ excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
9879
9997
  }
9880
9998
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
9881
9999
  };
@@ -10570,6 +10688,8 @@ var LeaferUI = (function (exports) {
10570
10688
  exports.boundsType = boundsType;
10571
10689
  exports.canvasPatch = canvasPatch;
10572
10690
  exports.canvasSizeAttrs = canvasSizeAttrs;
10691
+ exports.createAttr = createAttr;
10692
+ exports.createDescriptor = createDescriptor;
10573
10693
  exports.cursorType = cursorType;
10574
10694
  exports.dataProcessor = dataProcessor;
10575
10695
  exports.dataType = dataType;
@@ -10608,7 +10728,7 @@ var LeaferUI = (function (exports) {
10608
10728
  exports.strokeType = strokeType;
10609
10729
  exports.surfaceType = surfaceType;
10610
10730
  exports.tempBounds = tempBounds$1;
10611
- exports.tempMatrix = tempMatrix;
10731
+ exports.tempMatrix = tempMatrix$1;
10612
10732
  exports.tempPoint = tempPoint$2;
10613
10733
  exports.useCanvas = useCanvas;
10614
10734
  exports.useModule = useModule;