File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff 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合法颜色值
You can’t perform that action at this time.
0 commit comments