@leafer/core 1.12.1 → 1.12.2

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/lib/core.cjs CHANGED
@@ -454,7 +454,7 @@ function getMatrixData() {
454
454
 
455
455
  const {sin: sin$3, cos: cos$3, acos: acos, sqrt: sqrt$3} = Math;
456
456
 
457
- const {float: float$1} = MathHelper;
457
+ const {float: float$2} = MathHelper;
458
458
 
459
459
  const tempPoint$3 = {};
460
460
 
@@ -705,12 +705,12 @@ const MatrixHelper = {
705
705
  const cosR = c / scaleY;
706
706
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
707
707
  }
708
- const cosR = float$1(cos$3(rotation));
708
+ const cosR = float$2(cos$3(rotation));
709
709
  const sinR = sin$3(rotation);
710
- scaleX = float$1(scaleX), scaleY = float$1(scaleY);
711
- skewX = cosR ? float$1((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
712
- skewY = cosR ? float$1((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
713
- rotation = float$1(rotation / OneRadian);
710
+ scaleX = float$2(scaleX), scaleY = float$2(scaleY);
711
+ skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
712
+ skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
713
+ rotation = float$2(rotation / OneRadian);
714
714
  } else {
715
715
  scaleX = a;
716
716
  scaleY = d;
@@ -754,6 +754,8 @@ const MatrixHelper = {
754
754
 
755
755
  const M$6 = MatrixHelper;
756
756
 
757
+ const {float: float$1} = MathHelper;
758
+
757
759
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
758
760
 
759
761
  const {sin: sin$2, cos: cos$2, abs: abs$2, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2} = Math;
@@ -821,6 +823,11 @@ const PointHelper = {
821
823
  P$5.toInnerRadiusPointOf(t, matrix, temp);
822
824
  return temp;
823
825
  },
826
+ copyRadiusPoint(t, point, x, y) {
827
+ copy$7(t, point);
828
+ setRadius(t, x, y);
829
+ return t;
830
+ },
824
831
  toInnerRadiusPointOf(t, matrix, to) {
825
832
  to || (to = t);
826
833
  toInnerPoint$2(matrix, t, to);
@@ -888,7 +895,7 @@ const PointHelper = {
888
895
  return points;
889
896
  },
890
897
  isSame(t, point) {
891
- return t.x === point.x && t.y === point.y;
898
+ return float$1(t.x) === float$1(point.x) && float$1(t.y) === float$1(point.y);
892
899
  },
893
900
  reset(t) {
894
901
  P$5.reset(t);
@@ -897,7 +904,7 @@ const PointHelper = {
897
904
 
898
905
  const P$5 = PointHelper;
899
906
 
900
- const {getDistanceFrom: getDistanceFrom, copy: copy$7, getAtan2: getAtan2} = P$5;
907
+ const {getDistanceFrom: getDistanceFrom, copy: copy$7, setRadius: setRadius, getAtan2: getAtan2} = P$5;
901
908
 
902
909
  class Point {
903
910
  constructor(x, y) {
@@ -2400,7 +2407,7 @@ class LeaferCanvasBase extends Canvas {
2400
2407
  const {pixelRatio: pixelRatio} = this;
2401
2408
  this.filter = `blur(${blur * pixelRatio}px)`;
2402
2409
  }
2403
- copyWorld(canvas, from, to, blendMode, ceilPixel = true) {
2410
+ copyWorld(canvas, from, to, blendMode, ceilPixel) {
2404
2411
  if (blendMode) this.blendMode = blendMode;
2405
2412
  if (from) {
2406
2413
  this.setTempPixelBounds(from, ceilPixel);
@@ -2411,7 +2418,7 @@ class LeaferCanvasBase extends Canvas {
2411
2418
  }
2412
2419
  if (blendMode) this.blendMode = "source-over";
2413
2420
  }
2414
- copyWorldToInner(canvas, fromWorld, toInnerBounds, blendMode, ceilPixel = true) {
2421
+ copyWorldToInner(canvas, fromWorld, toInnerBounds, blendMode, ceilPixel) {
2415
2422
  if (fromWorld.b || fromWorld.c) {
2416
2423
  this.save();
2417
2424
  this.resetTransform();
@@ -2424,7 +2431,7 @@ class LeaferCanvasBase extends Canvas {
2424
2431
  if (blendMode) this.blendMode = "source-over";
2425
2432
  }
2426
2433
  }
2427
- copyWorldByReset(canvas, from, to, blendMode, onlyResetTransform, ceilPixel = true) {
2434
+ copyWorldByReset(canvas, from, to, blendMode, onlyResetTransform, ceilPixel) {
2428
2435
  this.resetTransform();
2429
2436
  this.copyWorld(canvas, from, to, blendMode, ceilPixel);
2430
2437
  if (!onlyResetTransform) this.useWorldTransform();
@@ -2651,7 +2658,7 @@ const BezierHelper = {
2651
2658
  data.push(M$5, points[0], points[1]);
2652
2659
  if (curve && points.length > 5) {
2653
2660
  let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
2654
- let ba, cb, d, len = points.length;
2661
+ let baX, baY, ba, cb, d, len = points.length;
2655
2662
  const t = curve === true ? .5 : curve;
2656
2663
  if (close) {
2657
2664
  points = [ points[len - 2], points[len - 1], ...points, points[0], points[1], points[2], points[3] ];
@@ -2664,7 +2671,9 @@ const BezierHelper = {
2664
2671
  bY = points[i + 1];
2665
2672
  cX = points[i + 2];
2666
2673
  cY = points[i + 3];
2667
- ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
2674
+ baX = bX - aX;
2675
+ baY = bY - aY;
2676
+ ba = sqrt$1(pow(baX, 2) + pow(baY, 2));
2668
2677
  cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
2669
2678
  if (!ba && !cb) continue;
2670
2679
  d = ba + cb;
@@ -2677,7 +2686,7 @@ const BezierHelper = {
2677
2686
  if (i === 2) {
2678
2687
  if (!close) data.push(Q$4, c1X, c1Y, bX, bY);
2679
2688
  } else {
2680
- data.push(C$4, c2X, c2Y, c1X, c1Y, bX, bY);
2689
+ if (baX || baY) data.push(C$4, c2X, c2Y, c1X, c1Y, bX, bY);
2681
2690
  }
2682
2691
  c2X = bX + cb * cX;
2683
2692
  c2Y = bY + cb * cY;
@@ -3262,6 +3271,7 @@ const PathCommandDataHelper = {
3262
3271
  }
3263
3272
  },
3264
3273
  ellipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
3274
+ if (radiusX === radiusY) return arc$2(data, x, y, radiusX, startAngle, endAngle, anticlockwise);
3265
3275
  if (isNull(rotation)) {
3266
3276
  data.push(F$3, x, y, radiusX, radiusY);
3267
3277
  } else {
@@ -3274,6 +3284,7 @@ const PathCommandDataHelper = {
3274
3284
  if (isNull(startAngle)) {
3275
3285
  data.push(P$2, x, y, radius);
3276
3286
  } else {
3287
+ if (isNull(startAngle)) startAngle = 0;
3277
3288
  if (isNull(endAngle)) endAngle = 360;
3278
3289
  data.push(O$2, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
3279
3290
  }
@@ -3624,6 +3635,7 @@ const PathCorner = {
3624
3635
  smooth(data, cornerRadius, _cornerSmoothing) {
3625
3636
  let command, lastCommand, commandLen;
3626
3637
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3638
+ if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
3627
3639
  const len = data.length;
3628
3640
  const smooth = [];
3629
3641
  while (i < len) {
@@ -4039,7 +4051,9 @@ const R = Resource;
4039
4051
  const ImageManager = {
4040
4052
  maxRecycled: 10,
4041
4053
  recycledList: [],
4042
- patternTasker: new TaskProcessor,
4054
+ patternTasker: new TaskProcessor({
4055
+ parallel: 1
4056
+ }),
4043
4057
  get(config) {
4044
4058
  let image = Resource.get(config.url);
4045
4059
  if (!image) Resource.set(config.url, image = Creator.image(config));
@@ -6916,7 +6930,7 @@ class LeafLevelList {
6916
6930
  }
6917
6931
  }
6918
6932
 
6919
- const version = "1.12.1";
6933
+ const version = "1.12.2";
6920
6934
 
6921
6935
  exports.AlignHelper = AlignHelper;
6922
6936
 
package/lib/core.esm.js CHANGED
@@ -452,7 +452,7 @@ function getMatrixData() {
452
452
 
453
453
  const {sin: sin$3, cos: cos$3, acos: acos, sqrt: sqrt$3} = Math;
454
454
 
455
- const {float: float$1} = MathHelper;
455
+ const {float: float$2} = MathHelper;
456
456
 
457
457
  const tempPoint$3 = {};
458
458
 
@@ -703,12 +703,12 @@ const MatrixHelper = {
703
703
  const cosR = c / scaleY;
704
704
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
705
705
  }
706
- const cosR = float$1(cos$3(rotation));
706
+ const cosR = float$2(cos$3(rotation));
707
707
  const sinR = sin$3(rotation);
708
- scaleX = float$1(scaleX), scaleY = float$1(scaleY);
709
- skewX = cosR ? float$1((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
710
- skewY = cosR ? float$1((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
711
- rotation = float$1(rotation / OneRadian);
708
+ scaleX = float$2(scaleX), scaleY = float$2(scaleY);
709
+ skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
710
+ skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
711
+ rotation = float$2(rotation / OneRadian);
712
712
  } else {
713
713
  scaleX = a;
714
714
  scaleY = d;
@@ -752,6 +752,8 @@ const MatrixHelper = {
752
752
 
753
753
  const M$6 = MatrixHelper;
754
754
 
755
+ const {float: float$1} = MathHelper;
756
+
755
757
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
756
758
 
757
759
  const {sin: sin$2, cos: cos$2, abs: abs$2, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2} = Math;
@@ -819,6 +821,11 @@ const PointHelper = {
819
821
  P$5.toInnerRadiusPointOf(t, matrix, temp);
820
822
  return temp;
821
823
  },
824
+ copyRadiusPoint(t, point, x, y) {
825
+ copy$7(t, point);
826
+ setRadius(t, x, y);
827
+ return t;
828
+ },
822
829
  toInnerRadiusPointOf(t, matrix, to) {
823
830
  to || (to = t);
824
831
  toInnerPoint$2(matrix, t, to);
@@ -886,7 +893,7 @@ const PointHelper = {
886
893
  return points;
887
894
  },
888
895
  isSame(t, point) {
889
- return t.x === point.x && t.y === point.y;
896
+ return float$1(t.x) === float$1(point.x) && float$1(t.y) === float$1(point.y);
890
897
  },
891
898
  reset(t) {
892
899
  P$5.reset(t);
@@ -895,7 +902,7 @@ const PointHelper = {
895
902
 
896
903
  const P$5 = PointHelper;
897
904
 
898
- const {getDistanceFrom: getDistanceFrom, copy: copy$7, getAtan2: getAtan2} = P$5;
905
+ const {getDistanceFrom: getDistanceFrom, copy: copy$7, setRadius: setRadius, getAtan2: getAtan2} = P$5;
899
906
 
900
907
  class Point {
901
908
  constructor(x, y) {
@@ -2398,7 +2405,7 @@ class LeaferCanvasBase extends Canvas {
2398
2405
  const {pixelRatio: pixelRatio} = this;
2399
2406
  this.filter = `blur(${blur * pixelRatio}px)`;
2400
2407
  }
2401
- copyWorld(canvas, from, to, blendMode, ceilPixel = true) {
2408
+ copyWorld(canvas, from, to, blendMode, ceilPixel) {
2402
2409
  if (blendMode) this.blendMode = blendMode;
2403
2410
  if (from) {
2404
2411
  this.setTempPixelBounds(from, ceilPixel);
@@ -2409,7 +2416,7 @@ class LeaferCanvasBase extends Canvas {
2409
2416
  }
2410
2417
  if (blendMode) this.blendMode = "source-over";
2411
2418
  }
2412
- copyWorldToInner(canvas, fromWorld, toInnerBounds, blendMode, ceilPixel = true) {
2419
+ copyWorldToInner(canvas, fromWorld, toInnerBounds, blendMode, ceilPixel) {
2413
2420
  if (fromWorld.b || fromWorld.c) {
2414
2421
  this.save();
2415
2422
  this.resetTransform();
@@ -2422,7 +2429,7 @@ class LeaferCanvasBase extends Canvas {
2422
2429
  if (blendMode) this.blendMode = "source-over";
2423
2430
  }
2424
2431
  }
2425
- copyWorldByReset(canvas, from, to, blendMode, onlyResetTransform, ceilPixel = true) {
2432
+ copyWorldByReset(canvas, from, to, blendMode, onlyResetTransform, ceilPixel) {
2426
2433
  this.resetTransform();
2427
2434
  this.copyWorld(canvas, from, to, blendMode, ceilPixel);
2428
2435
  if (!onlyResetTransform) this.useWorldTransform();
@@ -2649,7 +2656,7 @@ const BezierHelper = {
2649
2656
  data.push(M$5, points[0], points[1]);
2650
2657
  if (curve && points.length > 5) {
2651
2658
  let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
2652
- let ba, cb, d, len = points.length;
2659
+ let baX, baY, ba, cb, d, len = points.length;
2653
2660
  const t = curve === true ? .5 : curve;
2654
2661
  if (close) {
2655
2662
  points = [ points[len - 2], points[len - 1], ...points, points[0], points[1], points[2], points[3] ];
@@ -2662,7 +2669,9 @@ const BezierHelper = {
2662
2669
  bY = points[i + 1];
2663
2670
  cX = points[i + 2];
2664
2671
  cY = points[i + 3];
2665
- ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
2672
+ baX = bX - aX;
2673
+ baY = bY - aY;
2674
+ ba = sqrt$1(pow(baX, 2) + pow(baY, 2));
2666
2675
  cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
2667
2676
  if (!ba && !cb) continue;
2668
2677
  d = ba + cb;
@@ -2675,7 +2684,7 @@ const BezierHelper = {
2675
2684
  if (i === 2) {
2676
2685
  if (!close) data.push(Q$4, c1X, c1Y, bX, bY);
2677
2686
  } else {
2678
- data.push(C$4, c2X, c2Y, c1X, c1Y, bX, bY);
2687
+ if (baX || baY) data.push(C$4, c2X, c2Y, c1X, c1Y, bX, bY);
2679
2688
  }
2680
2689
  c2X = bX + cb * cX;
2681
2690
  c2Y = bY + cb * cY;
@@ -3260,6 +3269,7 @@ const PathCommandDataHelper = {
3260
3269
  }
3261
3270
  },
3262
3271
  ellipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
3272
+ if (radiusX === radiusY) return arc$2(data, x, y, radiusX, startAngle, endAngle, anticlockwise);
3263
3273
  if (isNull(rotation)) {
3264
3274
  data.push(F$3, x, y, radiusX, radiusY);
3265
3275
  } else {
@@ -3272,6 +3282,7 @@ const PathCommandDataHelper = {
3272
3282
  if (isNull(startAngle)) {
3273
3283
  data.push(P$2, x, y, radius);
3274
3284
  } else {
3285
+ if (isNull(startAngle)) startAngle = 0;
3275
3286
  if (isNull(endAngle)) endAngle = 360;
3276
3287
  data.push(O$2, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
3277
3288
  }
@@ -3622,6 +3633,7 @@ const PathCorner = {
3622
3633
  smooth(data, cornerRadius, _cornerSmoothing) {
3623
3634
  let command, lastCommand, commandLen;
3624
3635
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3636
+ if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
3625
3637
  const len = data.length;
3626
3638
  const smooth = [];
3627
3639
  while (i < len) {
@@ -4037,7 +4049,9 @@ const R = Resource;
4037
4049
  const ImageManager = {
4038
4050
  maxRecycled: 10,
4039
4051
  recycledList: [],
4040
- patternTasker: new TaskProcessor,
4052
+ patternTasker: new TaskProcessor({
4053
+ parallel: 1
4054
+ }),
4041
4055
  get(config) {
4042
4056
  let image = Resource.get(config.url);
4043
4057
  if (!image) Resource.set(config.url, image = Creator.image(config));
@@ -6914,6 +6928,6 @@ class LeafLevelList {
6914
6928
  }
6915
6929
  }
6916
6930
 
6917
- const version = "1.12.1";
6931
+ const version = "1.12.2";
6918
6932
 
6919
6933
  export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, FourNumberHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useModule, version, visibleType };