feat:2.6.1增加 数物对应 和 根据颜色画图形

This commit is contained in:
R524809
2025-12-23 13:35:19 +08:00
parent 9b6a0a26cc
commit 20496c3cc8
28 changed files with 940 additions and 277 deletions
+22
View File
@@ -127,6 +127,28 @@ export function getRandomNumberColor(): string {
return colors[Math.floor(Math.random() * colors.length)];
}
/**
* 从 NUMBER_COLORS 中随机获取指定数量的不重复颜色
* @param count 需要获取的颜色数量
* @returns 不重复的颜色数组
*/
export function getRandomUniqueNumberColors(count: number): string[] {
const allColors = getNumberColors();
if (count >= allColors.length) {
// 如果需要的数量大于等于总数,返回打乱后的所有颜色
return [...allColors].sort(() => Math.random() - 0.5);
}
// 使用 Set 确保不重复
const selectedColors = new Set<string>();
while (selectedColors.size < count) {
const randomIndex = Math.floor(Math.random() * allColors.length);
selectedColors.add(allColors[randomIndex]);
}
return Array.from(selectedColors);
}
export const PAPER_SIZE = {
A4: {
// width: 2480,