mirage2d 1.1.13 → 1.1.15

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.
@@ -78820,8 +78820,8 @@ class toolbox {
78820
78820
  static randomHexColor() {
78821
78821
  return "#" + Math.random().toString(16).substring(2, 6).toUpperCase();
78822
78822
  }
78823
- static randomRgbColor() {
78824
- return toolbox.hexToRgba(toolbox.randomHexColor(), 1);
78823
+ static randomRgbColor(alpha = 1) {
78824
+ return toolbox.hexToRgba(toolbox.randomHexColor(), alpha);
78825
78825
  }
78826
78826
  static rgbToHex(rgb2) {
78827
78827
  var rRgba = /rgba?\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([.\d]+))?\)/, r2, g2, b2, a2, rsa = rgb2.replace(/\s+/g, "").match(rRgba);
@@ -78838,7 +78838,7 @@ class toolbox {
78838
78838
  return { hex: rgb2, alpha: 1 };
78839
78839
  }
78840
78840
  }
78841
- static hexToRgba(hex, al) {
78841
+ static hexToRgba(hex, alpha) {
78842
78842
  var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
78843
78843
  var sColor = hex.toLowerCase();
78844
78844
  if (sColor && reg.test(sColor)) {
@@ -78853,7 +78853,7 @@ class toolbox {
78853
78853
  for (var i2 = 1; i2 < 7; i2 += 2) {
78854
78854
  sColorChange.push(parseInt("0x" + sColor.slice(i2, i2 + 2)));
78855
78855
  }
78856
- return "rgba(" + sColorChange.join(",") + "," + al + ")";
78856
+ return "rgba(" + sColorChange.join(",") + "," + alpha + ")";
78857
78857
  } else {
78858
78858
  return sColor;
78859
78859
  }
@@ -80238,6 +80238,85 @@ class baseGraphicLayer extends baseLayer {
80238
80238
  feature2.setStyle(mStyle);
80239
80239
  });
80240
80240
  }
80241
+ setSymbolLevelColor(colorOption) {
80242
+ let arr = [];
80243
+ let max4 = 0;
80244
+ let average2 = 0;
80245
+ if (colorOption.autolevel === void 0 || colorOption.autolevel === null) {
80246
+ colorOption.autolevel = true;
80247
+ }
80248
+ let mLevelColor = [
80249
+ {
80250
+ maxnum: 0,
80251
+ fillcolor: "rgba(255,0,0,0.2)",
80252
+ strokecolor: "rgba(255, 255, 255,1)",
80253
+ strokewidth: 1
80254
+ },
80255
+ {
80256
+ maxnum: 0,
80257
+ fillcolor: "rgba(255,0,0,0.4)",
80258
+ strokecolor: "rgba(255, 255, 255,1)",
80259
+ strokewidth: 1
80260
+ },
80261
+ {
80262
+ maxnum: 0,
80263
+ fillcolor: "rgba(255,0,0,0.6)",
80264
+ strokecolor: "rgba(255, 255, 255,1)",
80265
+ strokewidth: 1
80266
+ },
80267
+ {
80268
+ maxnum: 0,
80269
+ fillcolor: "rgba(255,0,0,0.8)",
80270
+ strokecolor: "rgba(255, 255, 255,1)",
80271
+ strokewidth: 1
80272
+ },
80273
+ {
80274
+ maxnum: 0,
80275
+ fillcolor: "rgba(255,0,0,1)",
80276
+ strokecolor: "rgba(255, 255, 255,1)",
80277
+ strokewidth: 1
80278
+ }
80279
+ ];
80280
+ if (colorOption.levelColor) {
80281
+ mLevelColor = colorOption.levelColor;
80282
+ }
80283
+ if (colorOption.autolevel) {
80284
+ let level = mLevelColor.length;
80285
+ this._source.getFeatures().forEach((feature2) => {
80286
+ let data2 = feature2.get(colorOption.attributeName);
80287
+ if (data2) {
80288
+ arr.push(parseInt(data2));
80289
+ }
80290
+ });
80291
+ max4 = Math.max(...arr);
80292
+ average2 = max4 / level;
80293
+ this._source.getFeatures().forEach((feature2) => {
80294
+ let data2 = feature2.get(colorOption.attributeName);
80295
+ if (data2) {
80296
+ for (let i2 = 1; i2 <= level; i2++) {
80297
+ if (parseInt(data2) <= average2 * i2) {
80298
+ let mStyle = MirageDefaultStyle.getStyle(feature2.getGeometry().getType(), { fillcolor: mLevelColor[i2 - 1].fillcolor, strokecolor: mLevelColor[i2 - 1].strokecolor, strokewidth: mLevelColor[i2 - 1].strokewidth });
80299
+ feature2.setStyle(mStyle);
80300
+ break;
80301
+ }
80302
+ }
80303
+ }
80304
+ });
80305
+ } else {
80306
+ this._source.getFeatures().forEach((feature2) => {
80307
+ let data2 = feature2.get(colorOption.attributeName);
80308
+ if (data2) {
80309
+ mLevelColor.forEach((element) => {
80310
+ if (parseInt(data2) <= element.maxnum) {
80311
+ let mStyle = MirageDefaultStyle.getStyle(feature2.getGeometry().getType(), { fillcolor: element.fillcolor, strokecolor: element.strokecolor, strokewidth: element.strokewidth });
80312
+ feature2.setStyle(mStyle);
80313
+ return;
80314
+ }
80315
+ });
80316
+ }
80317
+ });
80318
+ }
80319
+ }
80241
80320
  setSymbolByClassname(classname, styleOptions, callback) {
80242
80321
  this._source.getFeatures().forEach((feature2) => {
80243
80322
  if (feature2.get("classname") == classname) {