react-native-fiesta
Version:
A set of celebration animations powered by Skia. Engage more with your users by celebrating in your React Native application.
21 lines (15 loc) • 493 B
text/typescript
import { shuffleArray } from './array';
export function colorsFromTheme(theme: string[], itemsToRender: number) {
const newColors: string[] = [];
let colorToPushIndex = 0;
const randomisedColors = shuffleArray(theme);
new Array(itemsToRender).fill(0).map(() => {
if (colorToPushIndex === randomisedColors.length - 1) {
colorToPushIndex = 0;
} else {
colorToPushIndex++;
}
newColors.push(randomisedColors[colorToPushIndex]);
});
return newColors;
}