在获取随机颜色的时候我们不希望某个颜色段出现
/**
* 获取rgb随机颜色,排除深色范围
* @param { Array } scope rgb颜色范围
*/
const getRandomColor = (scope: number[] = [80, 255]) => {
const randomFrom = (startNumber: number, endNumber: number) => {
return Math.floor(Math.random() * (startNumber - endNumber + 1) + endNumber)
}
return 'rgb(' + [
randomFrom(scope[0], scope[1]),
randomFrom(scope[0], scope[1]),
randomFrom(scope[0], scope[1]),
].join(',') + ')';
}