function randomIntInRange(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
rgb颜色生成
function rgb(){//rgb颜色随机
const r = Math.floor(Math.random()*256);
const g = Math.floor(Math.random()*256);
const b = Math.floor(Math.random()*256);
return `rgb(${r},${g},${b})`;
}
十六进制颜色生成
function color16(){//十六进制颜色随机
const r = Math.floor(Math.random()*256);
const g = Math.floor(Math.random()*256);
const b = Math.floor(Math.random()*256);
const color = `#${r.toString(16)}${g.toString(16)}${b.toString(16)}`;
return color;
}