Skip to content

Commit f77817c

Browse files
author
woytu
committed
allows
1 parent 656b2f2 commit f77817c

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

static/js/utils/color.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ const randomRGBColor = function () {
5252
return `rgb(${r},${g},${b})`;
5353
}
5454

55+
/**
56+
* 随机颜色十六进制值
57+
*
58+
* @returns {string}
59+
*/
60+
function randomColor() {
61+
let str = Math.ceil(Math.random() * 16777215).toString(16);
62+
if (str.length < 6) {
63+
str = `0${str}`;
64+
}
65+
// return `#${Math.floor(Math.random()*(2<<23)).toString(16)}`;
66+
return `#${str}`;
67+
}
68+
5569
/**
5670
* 随机颜色hsl
5771
*
@@ -68,15 +82,6 @@ const randomHSLColor = function () {
6882
return `hsl(${h},${s}%,${l}%)`;
6983
}
7084

71-
function randomColor() {
72-
let str = Math.ceil(Math.random() * 16777215).toString(16);
73-
if (str.length < 6) {
74-
str = `0${str}`;
75-
}
76-
// return `#${Math.floor(Math.random()*(2<<23)).toString(16)}`;
77-
return `#${str}`;
78-
}
79-
8085

8186
/**
8287
* 是否为css合法颜色值

0 commit comments

Comments
 (0)