mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-14 23:17:33 +08:00
19 lines
459 B
TypeScript
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;
|
|
}
|