fix(pixelation): exclude external and transparent cells from color counting

This commit is contained in:
zihanjian
2025-12-26 17:49:36 +08:00
parent bd40428654
commit 8d0564a110
2 changed files with 7 additions and 5 deletions

View File

@@ -1,3 +1,5 @@
import { transparentColorData } from './pixelEditingUtils';
// 定义像素化模式
export enum PixelationMode {
Dominant = 'dominant', // 卡通模式(主色)
@@ -207,12 +209,12 @@ export function calculatePixelGrid(
const closestBead = findClosestPaletteColor(representativeRgb, palette);
finalCellColorData = { key: closestBead.key, color: closestBead.hex };
} else {
// 如果单元格为空或全透明,使用备用色
finalCellColorData = { key: t1FallbackColor.key, color: t1FallbackColor.hex };
// 如果单元格为空或全透明,标记为透明/外部
finalCellColorData = { ...transparentColorData };
}
mappedData[j][i] = finalCellColorData;
}
}
console.log(`Pixel grid calculation complete for mode: ${mode}`);
return mappedData;
}
}