支持画布生图选择抠图背景色
新增画布生图背景色选项并在角色、图标和 UI 素材提取入口展示选择控件。 将 screenColor 贯穿前端提交、后端请求解析、prompt 构建和生成后本地后处理调用。 保留角色动作旧绿幕路径,避免影响既有动画生成流程。 补充相关前后端单元测试和编辑器文档说明。
This commit is contained in:
@@ -97,8 +97,20 @@ export const DEFAULT_ICON_DESCRIPTIONS = [
|
||||
'原图按钮',
|
||||
'冻结按钮',
|
||||
];
|
||||
export const EDITOR_GENERATION_BACKGROUND_COLOR_OPTIONS = [
|
||||
{ label: '浅雾蓝', value: '#CFEFFF' },
|
||||
{ label: '浅钢蓝', value: '#B0C2E0' },
|
||||
{ label: '暖浅桃色', value: '#FFD6C2' },
|
||||
{ label: '淡薰衣草紫', value: '#E6D8FF' },
|
||||
{ label: '浅粉灰', value: '#F4D8E8' },
|
||||
{ label: '中度天蓝', value: '#7FB3FF' },
|
||||
] as const;
|
||||
export type EditorGenerationBackgroundColorValue =
|
||||
(typeof EDITOR_GENERATION_BACKGROUND_COLOR_OPTIONS)[number]['value'];
|
||||
export const DEFAULT_EDITOR_GENERATION_BACKGROUND_COLOR =
|
||||
EDITOR_GENERATION_BACKGROUND_COLOR_OPTIONS[0].value;
|
||||
export const UI_DESIGN_ASSET_EXTRACTION_PROMPT =
|
||||
'仅提取被红色框框选的素材并整理成spritesheet,图集背景必须使用单一纯绿色 #00FF00 / RGB(0,255,0) 绿幕。绿幕背景必须平整无纹理、无渐变、无阴影、无地面、无环境、无道具,方便后续扣除背景;素材自身不要出现绿色描边、绿色底板、绿色投影或绿色反光。';
|
||||
'仅提取被红色框框选的素材并整理成spritesheet,图集背景必须使用所选单一纯色抠图背景。纯色背景必须平整无纹理、无渐变、无阴影、无地面、无环境、无道具,方便后续扣除背景;素材自身不要出现与背景色相同或相近的描边、底板、投影或反光。';
|
||||
export const QUICK_EDIT_SIZE_PRESETS = [
|
||||
'1024x1024',
|
||||
'1536x1024',
|
||||
@@ -547,6 +559,36 @@ export function getEditorImageModelDisplayName(
|
||||
);
|
||||
}
|
||||
|
||||
export function normalizeEditorGenerationBackgroundColor(
|
||||
value: string | null | undefined,
|
||||
): EditorGenerationBackgroundColorValue {
|
||||
const normalizedValue = value?.trim().toUpperCase();
|
||||
const normalizedHexValue = normalizedValue?.match(/#[0-9A-F]{6}/)?.[0];
|
||||
const matched = EDITOR_GENERATION_BACKGROUND_COLOR_OPTIONS.find(
|
||||
(option) =>
|
||||
option.value === normalizedValue || option.value === normalizedHexValue,
|
||||
);
|
||||
return matched?.value ?? DEFAULT_EDITOR_GENERATION_BACKGROUND_COLOR;
|
||||
}
|
||||
|
||||
export function getEditorGenerationBackgroundColorOption(
|
||||
value: string | null | undefined,
|
||||
) {
|
||||
const normalizedValue = normalizeEditorGenerationBackgroundColor(value);
|
||||
return (
|
||||
EDITOR_GENERATION_BACKGROUND_COLOR_OPTIONS.find(
|
||||
(option) => option.value === normalizedValue,
|
||||
) ?? EDITOR_GENERATION_BACKGROUND_COLOR_OPTIONS[0]
|
||||
);
|
||||
}
|
||||
|
||||
export function formatEditorGenerationBackgroundColor(
|
||||
value: string | null | undefined,
|
||||
) {
|
||||
const option = getEditorGenerationBackgroundColorOption(value);
|
||||
return `${option.label} ${option.value}`;
|
||||
}
|
||||
|
||||
export function buildQuickEditModelOptions(currentModel: string) {
|
||||
const normalizedCurrentModel = normalizeEditorImageModel(currentModel);
|
||||
const options = [...QUICK_EDIT_MODEL_OPTIONS];
|
||||
@@ -1077,9 +1119,16 @@ export function buildCharacterGenerationInputs(
|
||||
prompt: string,
|
||||
specReference: CharacterReferenceImage | null | undefined,
|
||||
references: CharacterReferenceImage[] | undefined,
|
||||
screenColor?: string,
|
||||
): CanvasGenerationInputs {
|
||||
return {
|
||||
fields: createGenerationInputField('角色设定', prompt),
|
||||
fields: [
|
||||
...createGenerationInputField('角色设定', prompt),
|
||||
...createGenerationInputField(
|
||||
'抠图背景色',
|
||||
formatEditorGenerationBackgroundColor(screenColor),
|
||||
),
|
||||
],
|
||||
references: [
|
||||
...(specReference
|
||||
? createGenerationInputReference('角色规范', specReference)
|
||||
@@ -1184,6 +1233,7 @@ export function buildIconGenerationInputs(
|
||||
iconDescriptions: string[],
|
||||
specReference: CharacterReferenceImage,
|
||||
references?: CharacterReferenceImage[],
|
||||
screenColor?: string,
|
||||
): CanvasGenerationInputs {
|
||||
return {
|
||||
fields: [
|
||||
@@ -1191,6 +1241,10 @@ export function buildIconGenerationInputs(
|
||||
title: '素材描述',
|
||||
value: iconDescriptions.join('\n'),
|
||||
},
|
||||
...createGenerationInputField(
|
||||
'抠图背景色',
|
||||
formatEditorGenerationBackgroundColor(screenColor),
|
||||
),
|
||||
],
|
||||
references: [
|
||||
...createGenerationInputReference('图标规范', specReference),
|
||||
@@ -1204,12 +1258,19 @@ export function buildIconGenerationInputs(
|
||||
export function buildUiDesignAssetExtractionGenerationInputs(
|
||||
sourceLayer: CanvasLayer,
|
||||
references?: CharacterReferenceImage[],
|
||||
screenColor?: string,
|
||||
): CanvasGenerationInputs {
|
||||
return {
|
||||
fields: createGenerationInputField(
|
||||
'提取提示词',
|
||||
UI_DESIGN_ASSET_EXTRACTION_PROMPT,
|
||||
),
|
||||
fields: [
|
||||
...createGenerationInputField(
|
||||
'提取提示词',
|
||||
UI_DESIGN_ASSET_EXTRACTION_PROMPT,
|
||||
),
|
||||
...createGenerationInputField(
|
||||
'抠图背景色',
|
||||
formatEditorGenerationBackgroundColor(screenColor),
|
||||
),
|
||||
],
|
||||
references: [
|
||||
...createLayerGenerationInputReference('UI设计图', sourceLayer),
|
||||
...(references ?? []).flatMap((reference, index) =>
|
||||
|
||||
Reference in New Issue
Block a user