@inweb/viewer-visualize 25.4.6 → 25.4.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.
@@ -14588,6 +14588,11 @@
14588
14588
  strokeScaleEnabled: false,
14589
14589
  dash: LineTypeSpecs.get(params.type) || [],
14590
14590
  });
14591
+ this._ref.on("transform", (e) => {
14592
+ const attrs = e.target.attrs;
14593
+ if (attrs.rotation !== this.getRotation())
14594
+ this.setRotation(attrs.rotation);
14595
+ });
14591
14596
  this._ref.id(this._ref._id.toString());
14592
14597
  }
14593
14598
  ref() {
@@ -14684,6 +14689,20 @@
14684
14689
  draggable: true,
14685
14690
  rotation: (_c = params.rotation) !== null && _c !== void 0 ? _c : 0,
14686
14691
  });
14692
+ this._ref.on("transform", (e) => {
14693
+ const attrs = e.target.attrs;
14694
+ if (attrs.rotation !== this.getRotation())
14695
+ this.setRotation(attrs.rotation);
14696
+ const newWidth = this._ref.width() * attrs.scaleX;
14697
+ const newHeight = this._ref.height() * attrs.scaleY;
14698
+ if (Math.abs(attrs.scaleX - 1) > 10e-6) {
14699
+ this.setFontSize(Math.round((this.getFontSize() * newWidth) / this._ref.width()));
14700
+ }
14701
+ if (Math.abs(attrs.scaleY - 1) > 10e-6) {
14702
+ this.setFontSize(Math.round((this.getFontSize() * newHeight) / this._ref.height()));
14703
+ }
14704
+ this._ref.scale({ x: 1, y: 1 });
14705
+ });
14687
14706
  this._ref.id(this._ref._id.toString());
14688
14707
  }
14689
14708
  ref() {
@@ -14762,6 +14781,20 @@
14762
14781
  draggable: true,
14763
14782
  strokeScaleEnabled: false,
14764
14783
  });
14784
+ this._ref.on("transform", (e) => {
14785
+ const attrs = e.target.attrs;
14786
+ if (attrs.rotation !== this.getRotation())
14787
+ this.setRotation(attrs.rotation);
14788
+ const newWidth = this._ref.width() * attrs.scaleX;
14789
+ const newHeight = this._ref.height() * attrs.scaleY;
14790
+ if (Math.abs(attrs.scaleX - 1) > 10e-6) {
14791
+ this.setWidth(newWidth);
14792
+ }
14793
+ if (Math.abs(attrs.scaleY - 1) > 10e-6) {
14794
+ this.setHeight(newHeight);
14795
+ }
14796
+ this._ref.scale({ x: 1, y: 1 });
14797
+ });
14765
14798
  this._ref.id(this._ref._id.toString());
14766
14799
  }
14767
14800
  getPosition() {
@@ -14846,6 +14879,20 @@
14846
14879
  draggable: true,
14847
14880
  strokeScaleEnabled: false,
14848
14881
  });
14882
+ this._ref.on("transform", (e) => {
14883
+ const attrs = e.target.attrs;
14884
+ if (attrs.rotation !== this.getRotation())
14885
+ this.setRotation(attrs.rotation);
14886
+ const newRadiusX = this._ref.radiusX() * attrs.scaleX;
14887
+ const newRadiusY = this._ref.radiusY() * attrs.scaleY;
14888
+ if (Math.abs(attrs.scaleX - 1) > 10e-6) {
14889
+ this.setRadiusX(newRadiusX);
14890
+ }
14891
+ if (Math.abs(attrs.scaleY - 1) > 10e-6) {
14892
+ this.setRadiusY(newRadiusY);
14893
+ }
14894
+ this._ref.scale({ x: 1, y: 1 });
14895
+ });
14849
14896
  this._ref.id(this._ref._id.toString());
14850
14897
  }
14851
14898
  getPosition() {
@@ -14858,13 +14905,13 @@
14858
14905
  return this._ref.radiusX();
14859
14906
  }
14860
14907
  setRadiusX(r) {
14861
- this._ref.radius({ x: r, y: this._ref.radiusY() });
14908
+ this._ref.radiusX(r);
14862
14909
  }
14863
14910
  getRadiusY() {
14864
14911
  return this._ref.radiusY();
14865
14912
  }
14866
14913
  setRadiusY(r) {
14867
- this._ref.radius({ x: this._ref.radiusX(), y: r });
14914
+ this._ref.radiusY(r);
14868
14915
  }
14869
14916
  getLineWidth() {
14870
14917
  return this._ref.strokeWidth();
@@ -14929,6 +14976,11 @@
14929
14976
  draggable: true,
14930
14977
  strokeScaleEnabled: false,
14931
14978
  });
14979
+ this._ref.on("transform", (e) => {
14980
+ const attrs = e.target.attrs;
14981
+ if (attrs.rotation !== this.getRotation())
14982
+ this.setRotation(attrs.rotation);
14983
+ });
14932
14984
  this._ref.id(this._ref._id.toString());
14933
14985
  }
14934
14986
  ref() {
@@ -14948,6 +15000,7 @@
14948
15000
  }
14949
15001
  setColor(hex) {
14950
15002
  this._ref.stroke(hex);
15003
+ this._ref.fill(hex);
14951
15004
  }
14952
15005
  getRotation() {
14953
15006
  return this._ref.rotation();
@@ -15026,6 +15079,20 @@
15026
15079
  this._ratio = this._ref.height() === 0 || this._ref.width() === 0 ? 1 : this._ref.height() / this._ref.width();
15027
15080
  };
15028
15081
  this._canvasImage.src = params.src;
15082
+ this._ref.on("transform", (e) => {
15083
+ const attrs = e.target.attrs;
15084
+ if (attrs.rotation !== this.getRotation())
15085
+ this.setRotation(attrs.rotation);
15086
+ const newWidth = this._ref.width() * attrs.scaleX;
15087
+ const newHeight = this._ref.height() * attrs.scaleY;
15088
+ if (Math.abs(attrs.scaleX - 1) > 10e-6) {
15089
+ this.setWidth(newWidth);
15090
+ }
15091
+ if (Math.abs(attrs.scaleY - 1) > 10e-6) {
15092
+ this.setHeight(newHeight);
15093
+ }
15094
+ this._ref.scale({ x: 1, y: 1 });
15095
+ });
15029
15096
  this._ref.id(this._ref._id.toString());
15030
15097
  }
15031
15098
  getSrc() {
@@ -15060,13 +15127,6 @@
15060
15127
  type() {
15061
15128
  return "image";
15062
15129
  }
15063
- // we can break Liskov Substitution Principle, need to use separate IColorable
15064
- // getColor(): string {
15065
- // return this._ref.fill();
15066
- // }
15067
- // setColor(hex: string) {
15068
- // this._ref.fill(hex);
15069
- // }
15070
15130
  getRotation() {
15071
15131
  return this._ref.rotation();
15072
15132
  }
@@ -15162,19 +15222,21 @@
15162
15222
  this._ref.className = "Cloud";
15163
15223
  this._ref.on("transform", (e) => {
15164
15224
  const attrs = e.target.attrs;
15165
- const minWidth = 100;
15166
- const minHeight = 100;
15225
+ if (attrs.rotation !== this.getRotation())
15226
+ this.setRotation(attrs.rotation);
15167
15227
  const newWidth = this._ref.width() * attrs.scaleX;
15168
15228
  const newHeight = this._ref.height() * attrs.scaleY;
15229
+ const minWidth = 100;
15230
+ const minHeight = 100;
15169
15231
  if (newWidth < minWidth || newHeight < minHeight) {
15170
15232
  this._ref.scale({ x: 1, y: 1 });
15171
15233
  return;
15172
15234
  }
15173
15235
  if (Math.abs(attrs.scaleX - 1) > 10e-6) {
15174
- this._ref.width(newWidth);
15236
+ this.setWidth(newWidth);
15175
15237
  }
15176
15238
  if (Math.abs(attrs.scaleY - 1) > 10e-6) {
15177
- this._ref.height(newHeight);
15239
+ this.setHeight(newHeight);
15178
15240
  }
15179
15241
  this._ref.scale({ x: 1, y: 1 });
15180
15242
  });