leafer-draw 2.0.5 → 2.0.7

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.
@@ -2896,6 +2896,32 @@ const BezierHelper = {
2896
2896
  getDerivative(t, fromV, v1, v2, toV) {
2897
2897
  const o = 1 - t;
2898
2898
  return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
2899
+ },
2900
+ cut(t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
2901
+ if (t <= 0) return {
2902
+ left: null,
2903
+ right: [ x1, y1, x2, y2, toX, toY ]
2904
+ }; else if (t >= 1) return {
2905
+ left: [ x1, y1, x2, y2, toX, toY ],
2906
+ right: null
2907
+ };
2908
+ const u = 1 - t;
2909
+ const leftX1 = fromX * u + x1 * t;
2910
+ const leftY1 = fromY * u + y1 * t;
2911
+ const P12x = x1 * u + x2 * t;
2912
+ const P12y = y1 * u + y2 * t;
2913
+ const rightX2 = x2 * u + toX * t;
2914
+ const rightY2 = y2 * u + toY * t;
2915
+ const leftX2 = leftX1 * u + P12x * t;
2916
+ const leftY2 = leftY1 * u + P12y * t;
2917
+ const rightX1 = P12x * u + rightX2 * t;
2918
+ const rightY1 = P12y * u + rightY2 * t;
2919
+ const leftX = leftX2 * u + rightX1 * t;
2920
+ const leftY = leftY2 * u + rightY1 * t;
2921
+ return {
2922
+ left: [ leftX1, leftY1, leftX2, leftY2, leftX, leftY ],
2923
+ right: [ rightX1, rightY1, rightX2, rightY2, toX, toY ]
2924
+ };
2899
2925
  }
2900
2926
  };
2901
2927
 
@@ -7053,7 +7079,7 @@ class LeafLevelList {
7053
7079
  }
7054
7080
  }
7055
7081
 
7056
- const version = "2.0.5";
7082
+ const version = "2.0.7";
7057
7083
 
7058
7084
  const debug$4 = Debug.get("LeaferCanvas");
7059
7085
 
@@ -7349,7 +7375,6 @@ defineKey(Platform, "devicePixelRatio", {
7349
7375
  const {userAgent: userAgent} = navigator;
7350
7376
 
7351
7377
  if (userAgent.indexOf("Firefox") > -1) {
7352
- Platform.conicGradientRotate90 = true;
7353
7378
  Platform.intWheelDeltaY = true;
7354
7379
  Platform.syncDomFont = true;
7355
7380
  } else if (/iPhone|iPad|iPod/.test(navigator.userAgent) || /Macintosh/.test(navigator.userAgent) && /Version\/[\d.]+.*Safari/.test(navigator.userAgent)) {
@@ -8537,6 +8562,7 @@ let UI = UI_1 = class UI extends Leaf {
8537
8562
  createProxyData() {
8538
8563
  return undefined;
8539
8564
  }
8565
+ clearProxyData() {}
8540
8566
  find(_condition, _options) {
8541
8567
  return Plugin.need("find");
8542
8568
  }
@@ -8577,7 +8603,7 @@ let UI = UI_1 = class UI extends Leaf {
8577
8603
  __updateRenderPath(updateCache) {
8578
8604
  const data = this.__;
8579
8605
  if (data.path) {
8580
- data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8606
+ data.__pathForRender = data.cornerRadius || data.path.radius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8581
8607
  if (data.__useArrow) PathArrow.addArrows(this, updateCache);
8582
8608
  } else data.__pathForRender && (data.__pathForRender = undefined);
8583
8609
  }
@@ -9410,7 +9436,7 @@ let Ellipse = class Ellipse extends UI {
9410
9436
  }
9411
9437
  }
9412
9438
  if (!open) closePath$2(path);
9413
- if (Platform.ellipseToCurve || data.__useArrow) data.path = this.getPath(true);
9439
+ if (Platform.ellipseToCurve || data.__useArrow || data.cornerRadius) data.path = this.getPath(true);
9414
9440
  }
9415
9441
  };
9416
9442
 
@@ -9436,7 +9462,7 @@ let Polygon = class Polygon extends UI {
9436
9462
  const data = this.__;
9437
9463
  const path = data.path = [];
9438
9464
  if (data.points) {
9439
- drawPoints$1(path, data.points, data.curve, true);
9465
+ drawPoints$1(path, data.points, data.curve, data.closed);
9440
9466
  } else {
9441
9467
  const {width: width, height: height, sides: sides} = data;
9442
9468
  const rx = width / 2, ry = height / 2;
@@ -10288,17 +10314,19 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10288
10314
  }
10289
10315
 
10290
10316
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
10317
+ let needUpdate = true;
10291
10318
  const data = ui.__;
10292
10319
  if (attrName === "fill" && !data.__naturalWidth) {
10293
10320
  data.__naturalWidth = image.width / data.pixelRatio;
10294
10321
  data.__naturalHeight = image.height / data.pixelRatio;
10295
10322
  if (data.__autoSide) {
10296
10323
  ui.forceUpdate("width");
10324
+ LeafHelper.updateBounds(ui);
10297
10325
  if (ui.__proxyData) {
10298
10326
  ui.setProxyAttr("width", data.width);
10299
10327
  ui.setProxyAttr("height", data.height);
10300
10328
  }
10301
- return false;
10329
+ needUpdate = false;
10302
10330
  }
10303
10331
  }
10304
10332
  if (!leafPaint.data) {
@@ -10308,7 +10336,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
10308
10336
  if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
10309
10337
  }
10310
10338
  if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
10311
- return true;
10339
+ return needUpdate;
10312
10340
  }
10313
10341
 
10314
10342
  function onLoad(ui, event) {
@@ -10758,10 +10786,10 @@ const realFrom = {};
10758
10786
  const realTo = {};
10759
10787
 
10760
10788
  function conicGradient(paint, box) {
10761
- let {from: from, to: to, type: type, opacity: opacity, stretch: stretch} = paint;
10789
+ let {from: from, to: to, type: type, opacity: opacity, rotation: rotation, stretch: stretch} = paint;
10762
10790
  toPoint(from || "center", box, realFrom);
10763
10791
  toPoint(to || "bottom", box, realTo);
10764
- const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
10792
+ const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(rotation ? rotation * OneRadian : 0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
10765
10793
  const data = {
10766
10794
  type: type,
10767
10795
  style: style