-
-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
颜色生成 #90
Comments
function getRandomColor(){
return `#${Math.floor(Math.random() * 0xffffff).toString(16)}`
} |
function main(){
return `#${rand(250)}${rand(250)}${rand(250)}`;
function rand(n){
return (Math.floor(Math.random() * n) + 1).toString(16);
}
} |
'#'+Math.random().toString(16).substr(-6) |
Math.floor(Math.random()*16).toString(16) |
function color() {
const _color = () => {
let val = (Math.floor(Math.random() * 255) + 1).toString(16)
return val.padStart(2, '0')
}
return `#${_color()}${_color()}${_color()}`
} |
function getRandomColor() {
var color = "#";
for (var i = 0; i < 3; i++) {
var sub = Math.floor(Math.random() * 256).toString(2);
color += ("00"+sub).substr(sub.length);
}
return color;
}
function getRandomColor() {
var r = Math.floor(Math.random()*256); // 随机生成红色rgb值
var g = Math.floor(Math.random()*256); // 随机生成绿色rgb值
var b = Math.floor(Math.random()*256); // 随机生成蓝色rgb值
return "rgb(" + r + "," + g + "," + b + ")"; // 返回rgb(r, g, b)格式颜色
}
function getRandomColor() {
var h = Math.floor(Math.random() * 361);
var s = Math.floor(Math.random() * 101) + '%';
var l = Math.floor(Math.random() * 101) + '%';
return `hsl(${h}, ${s}, ${l})`;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: