Files
ezbookkeeping/src/lib/color.ts
T
2024-12-30 00:56:48 +08:00

19 lines
459 B
TypeScript

import type { ColorValue, ColorInfo } from '@/core/color.ts';
export function getColorsInRows(allColorValues: ColorValue[], itemPerRow: number): ColorInfo[][] {
const ret: ColorInfo[][] = [];
let rowCount = -1;
for (let i = 0; i < allColorValues.length; i++) {
if (i % itemPerRow === 0) {
ret[++rowCount] = [];
}
ret[rowCount].push({
color: allColorValues[i]
});
}
return ret;
}