Files
solidtime/resources/js/utils/color.ts
2024-05-21 18:40:03 +02:00

34 lines
639 B
TypeScript

import Prando from '@/utils/random';
export const colors = [
'#ef5350',
'#ec407a',
'#ab47bc',
'#7e57c2',
'#5c6bc0',
'#42a5f5',
'#29b6f6',
'#26c6da',
'#26a69a',
'#66bb6a',
'#9ccc65',
'#d4e157',
'#ffee58',
'#ffca28',
'#ffa726',
'#ff7043',
'#8d6e63',
'#bdbdbd',
'#78909c',
];
export function getRandomColor() {
return colors[Math.floor(Math.random() * colors.length)];
}
export function getRandomColorWithSeed(seed: string) {
const pseudoRandom = new Prando(seed);
const index = pseudoRandom.nextInt(0, colors.length - 1);
return colors[index];
}