@inweb/viewer-visualize 26.5.1 → 26.5.3

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.
@@ -17086,7 +17086,7 @@
17086
17086
 
17087
17087
  class KonvaEllipse {
17088
17088
  constructor(params, ref = null, worldTransformer = new WorldTransform) {
17089
- var _a, _b;
17089
+ var _a, _b, _c;
17090
17090
  this._worldTransformer = worldTransformer;
17091
17091
  if (ref) {
17092
17092
  this._ref = ref;
@@ -17119,6 +17119,10 @@
17119
17119
  y: 0
17120
17120
  };
17121
17121
  if (params.position2) {
17122
+ (_a = params.radius) !== null && _a !== undefined ? _a : params.radius = {
17123
+ x: 0,
17124
+ y: 0
17125
+ };
17122
17126
  params.radius.x = getDistanceIn2D(params.position, params.position2);
17123
17127
  if (params.position3) params.radius.y = getDistanceIn2D(params.position, params.position3); else params.radius.x = params.radius.y;
17124
17128
  } else {
@@ -17128,8 +17132,8 @@
17128
17132
  };
17129
17133
  }
17130
17134
  this._ref = new Konva.Ellipse({
17131
- stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
17132
- strokeWidth: (_b = params.lineWidth) !== null && _b !== undefined ? _b : 4,
17135
+ stroke: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
17136
+ strokeWidth: (_c = params.lineWidth) !== null && _c !== undefined ? _c : 4,
17133
17137
  globalCompositeOperation: "source-over",
17134
17138
  lineCap: "round",
17135
17139
  lineJoin: "round",
@@ -17565,13 +17569,13 @@
17565
17569
  this._ref.width(params.maxHeight / this._ratio);
17566
17570
  this._ref.height(params.maxHeight);
17567
17571
  }
17568
- const wcsEnd = this._worldTransformer.screenToWorld({
17569
- x: params.position.x + this._ref.width(),
17570
- y: params.position.y + this._ref.height()
17571
- });
17572
- this._ref.setAttr("wcsEnd", wcsEnd);
17573
17572
  }
17574
17573
  }
17574
+ const wcsEnd = this._worldTransformer.screenToWorld({
17575
+ x: params.position.x + this._ref.width(),
17576
+ y: params.position.y + this._ref.height()
17577
+ });
17578
+ this._ref.setAttr("wcsEnd", wcsEnd);
17575
17579
  };
17576
17580
  this._canvasImage.onerror = () => {
17577
17581
  this._canvasImage.onerror = function() {};
@@ -17790,7 +17794,10 @@
17790
17794
  };
17791
17795
  }
17792
17796
  }
17793
- const ARC_RADIUS = 16;
17797
+ const ARC_RADIUS = 8;
17798
+ const ARC_LENGTH = 15;
17799
+ const MIN_CLOUD_WIDTH = 50;
17800
+ const MIN_CLOUD_HEIGHT = 50;
17794
17801
  this._ref = new Konva.Shape({
17795
17802
  x: params.position.x,
17796
17803
  y: params.position.y,
@@ -17802,63 +17809,76 @@
17802
17809
  strokeScaleEnabled: false,
17803
17810
  globalCompositeOperation: "source-over",
17804
17811
  sceneFunc: (context, shape) => {
17805
- function calculateMidpoint(position, width, height) {
17806
- const midX = position.x + width / 2;
17807
- const midY = position.y + height / 2;
17808
- return {
17809
- x: midX,
17810
- y: midY
17811
- };
17812
- }
17812
+ const width = this._ref.width();
17813
+ const height = this._ref.height();
17813
17814
  const points = [ {
17814
17815
  x: 0,
17815
17816
  y: 0
17816
17817
  }, {
17817
- x: 0 + this._ref.width(),
17818
+ x: 0 + width,
17818
17819
  y: 0
17819
17820
  }, {
17820
- x: 0 + this._ref.width(),
17821
- y: 0 + this._ref.height()
17821
+ x: 0 + width,
17822
+ y: 0 + height
17822
17823
  }, {
17823
17824
  x: 0,
17824
- y: 0 + this._ref.height()
17825
+ y: 0 + height
17825
17826
  }, {
17826
17827
  x: 0,
17827
17828
  y: 0
17828
17829
  } ];
17829
- const midPoint = calculateMidpoint({
17830
- x: 0,
17831
- y: 0
17832
- }, this._ref.width(), this._ref.height());
17833
- const baseArcLength = 30;
17834
- context.beginPath();
17835
- for (let iPoint = 0; iPoint < points.length - 1; iPoint++) {
17836
- let approxArcLength = baseArcLength;
17837
- const dx = points[iPoint + 1].x - points[iPoint].x;
17838
- const dy = points[iPoint + 1].y - points[iPoint].y;
17839
- const length = Math.sqrt(dx * dx + dy * dy);
17840
- const arcCount = Math.floor(length / approxArcLength);
17841
- const lengthMod = length % approxArcLength;
17842
- approxArcLength = baseArcLength + arcCount / lengthMod;
17843
- let pX = points[iPoint].x + dx / arcCount / 2;
17844
- let pY = points[iPoint].y + dy / arcCount / 2;
17845
- const pEndX = points[iPoint + 1].x;
17846
- const pEndY = points[iPoint + 1].y;
17847
- const endAngle = Math.atan((pEndY - pY) / (pEndX - pX));
17848
- const startAngle = endAngle + Math.PI;
17849
- const counterClockwise = pX > midPoint.x && pY > midPoint.y;
17850
- for (let iArc = 0; iArc < arcCount; iArc++) {
17851
- if (counterClockwise) {
17852
- context.arc(pX, pY, ARC_RADIUS, endAngle, startAngle);
17853
- } else {
17854
- context.arc(pX, pY, ARC_RADIUS, startAngle, endAngle);
17830
+ if (width >= MIN_CLOUD_WIDTH - 1 || height >= MIN_CLOUD_HEIGHT - 1) drawCloud(ARC_RADIUS, ARC_LENGTH); else if (width >= MIN_CLOUD_WIDTH / 2 || height >= MIN_CLOUD_HEIGHT / 2) drawCloud(ARC_RADIUS / 2, ARC_LENGTH / 2); else drawRectangle();
17831
+ function calculateMidpoint(position) {
17832
+ const midX = position.x + width / 2;
17833
+ const midY = position.y + height / 2;
17834
+ return {
17835
+ x: midX,
17836
+ y: midY
17837
+ };
17838
+ }
17839
+ function drawCloud(arcRadius, arcLength) {
17840
+ const midPoint = calculateMidpoint({
17841
+ x: 0,
17842
+ y: 0
17843
+ });
17844
+ context.beginPath();
17845
+ for (let iPoint = 0; iPoint < points.length - 1; iPoint++) {
17846
+ let approxArcLength = arcLength;
17847
+ const dx = points[iPoint + 1].x - points[iPoint].x;
17848
+ const dy = points[iPoint + 1].y - points[iPoint].y;
17849
+ const length = Math.sqrt(dx * dx + dy * dy);
17850
+ const arcCount = Math.floor(length / approxArcLength);
17851
+ const lengthMod = length % approxArcLength;
17852
+ approxArcLength = arcLength + arcCount / lengthMod;
17853
+ let pX = points[iPoint].x + dx / arcCount / 2;
17854
+ let pY = points[iPoint].y + dy / arcCount / 2;
17855
+ const pEndX = points[iPoint + 1].x;
17856
+ const pEndY = points[iPoint + 1].y;
17857
+ const endAngle = Math.atan((pEndY - pY) / (pEndX - pX));
17858
+ const startAngle = endAngle + Math.PI;
17859
+ const counterClockwise = pX > midPoint.x && pY > midPoint.y;
17860
+ for (let iArc = 0; iArc < arcCount; iArc++) {
17861
+ if (counterClockwise) {
17862
+ context.arc(pX, pY, arcRadius, endAngle, startAngle);
17863
+ } else {
17864
+ context.arc(pX, pY, arcRadius, startAngle, endAngle);
17865
+ }
17866
+ pX += dx / arcCount;
17867
+ pY += dy / arcCount;
17855
17868
  }
17856
- pX += dx / arcCount;
17857
- pY += dy / arcCount;
17858
17869
  }
17870
+ context.closePath();
17871
+ context.fillStrokeShape(shape);
17872
+ }
17873
+ function drawRectangle() {
17874
+ context.beginPath();
17875
+ context.lineTo(points[1].x, points[1].y);
17876
+ context.lineTo(points[2].x, points[2].y);
17877
+ context.lineTo(points[3].x, points[3].y);
17878
+ context.lineTo(points[4].x, points[4].y);
17879
+ context.closePath();
17880
+ context.fillStrokeShape(shape);
17859
17881
  }
17860
- context.closePath();
17861
- context.fillStrokeShape(shape);
17862
17882
  }
17863
17883
  });
17864
17884
  this._ref.className = "Cloud";
@@ -17878,10 +17898,8 @@
17878
17898
  if (scaleByX) newWidth *= attrs.scaleX;
17879
17899
  let newHeight = this._ref.height();
17880
17900
  if (scaleByY) newHeight *= attrs.scaleY;
17881
- const minWidth = 100;
17882
- const minHeight = 100;
17883
- if (newWidth < minWidth) newWidth = minWidth;
17884
- if (newHeight < minHeight) newHeight = minHeight;
17901
+ if (newWidth < MIN_CLOUD_WIDTH) newWidth = MIN_CLOUD_WIDTH;
17902
+ if (newHeight < MIN_CLOUD_HEIGHT) newHeight = MIN_CLOUD_HEIGHT;
17885
17903
  if (scaleByX) {
17886
17904
  this._ref.width(newWidth);
17887
17905
  }