|
@@ -72,17 +72,48 @@ const getRandomColor = function () {
|
|
|
return "#" + rgb.join("");
|
|
|
};
|
|
|
|
|
|
-const getRGBColor = () => {
|
|
|
- let rgb = [];
|
|
|
-
|
|
|
- for (let i = 0; i < 2; ++i) {
|
|
|
- let color = Math.floor(Math.random() * 256);
|
|
|
-
|
|
|
- rgb.push(color);
|
|
|
+/**
|
|
|
+ * 生成随机色
|
|
|
+ * rootNumber 色彩基数 默认200
|
|
|
+ * colorsNumber 跳跃基数 默认16
|
|
|
+ * forLength 避免死循环(限制迭代次数)
|
|
|
+ */
|
|
|
+const getRGBColor = (rootNumber, colorsNumber) => {
|
|
|
+ // if (forLength < 10) {
|
|
|
+ forLength++;
|
|
|
+ // 色彩基数
|
|
|
+ let _rootNumber = 200;
|
|
|
+ // 跳跃基数
|
|
|
+ let _colorsNumber = 16;
|
|
|
+ // rgb格式定义
|
|
|
+ let rgbColor = [0, 0, 0];
|
|
|
+ let rgbColorStr = "rgb(";
|
|
|
+ if (rootNumber) {
|
|
|
+ _rootNumber = rootNumber;
|
|
|
}
|
|
|
-
|
|
|
- return `rgb(${rgb[0]},${rgb[1]},1)`;
|
|
|
-};
|
|
|
+ if (colorsNumber) {
|
|
|
+ _colorsNumber = colorsNumber;
|
|
|
+ }
|
|
|
+ rgbColor.forEach((item, index) => {
|
|
|
+ if (index === 0) {
|
|
|
+ rgbColorStr += _rootNumber + Math.round((Math.random() * (255 - _rootNumber)) / _colorsNumber) * _colorsNumber;
|
|
|
+ } else {
|
|
|
+ let rgbColor = _rootNumber + Math.round((Math.random() * (255 - _rootNumber)) / _colorsNumber) * _colorsNumber;
|
|
|
+ rgbColorStr += "," + rgbColor;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ rgbColorStr += ")";
|
|
|
+ return rgbColorStr;
|
|
|
+ // 去重
|
|
|
+ // if (this.rgbColorList.indexOf(rgbColorStr) >= 0) {
|
|
|
+ // this.getRGBColor(rootNumber, colorsNumber, forLength);
|
|
|
+ // } else {
|
|
|
+ // this.rgbColorList.push(rgbColorStr);
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // this.$message.info("getColors 请重试!");
|
|
|
+ // }
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* 获取geoJSON格式的数据 -- 目前仅供标记疑点相关内容使用(圆也存为面);
|
|
@@ -227,4 +258,5 @@ export default {
|
|
|
standardGeojson,
|
|
|
convertTree,
|
|
|
latLngsToReverse,
|
|
|
+ getRGBColor
|
|
|
};
|