feat: implement inpainting functionality with mask handling
- Added `createMaskedPixelReplacementSource` function to handle pixel replacement using inpainting. - Introduced `buildInpaintBundle` to prepare inpainting data including mask generation and validation. - Created utility functions for mask operations such as `applyMaskedContentModeToRgba`, `expandRectWithinBounds`, and others for mask manipulation. - Developed tests for inpainting preparation and mask raster utilities to ensure functionality and correctness. - Implemented mask raster operations including inversion, feathering, blurring, and more.
This commit is contained in:
@@ -27,6 +27,7 @@ export type MagicWandMode = "replace" | "add" | "subtract";
|
||||
export type GenerateMode = "text-to-image" | "image-to-image" | "inpaint" | "outpaint";
|
||||
|
||||
export type GenerateModel = string;
|
||||
export type InpaintMaskedContent = "neutral" | "original" | "originalColor" | "edges";
|
||||
|
||||
export type GenerateSettings = {
|
||||
mode: GenerateMode;
|
||||
@@ -48,6 +49,17 @@ export type GenerateSettings = {
|
||||
bottom: number;
|
||||
feathering: number;
|
||||
};
|
||||
inpaint: {
|
||||
maskedAreaOnly: boolean;
|
||||
cropPadding: number;
|
||||
maskPolarity: "hidden" | "revealed";
|
||||
maskedContent: InpaintMaskedContent;
|
||||
growMaskBy: number;
|
||||
maskExpand: number;
|
||||
maskFeather: number;
|
||||
maskBlur: number;
|
||||
maskDespeckle: number;
|
||||
};
|
||||
};
|
||||
|
||||
export type MagicWandSettings = {
|
||||
@@ -74,7 +86,22 @@ export const initialToolState: ToolState = {
|
||||
brush: { color: "#111827", size: 8, hardness: 100 },
|
||||
chromaKey: { color: "#00ff00", tolerance: 32, softness: 24, feather: 0, choke: 0, despeckle: 0, spill: 50 },
|
||||
magicWand: { tolerance: 32, feather: 0, choke: 0, despeckle: 0, contiguous: true, mode: "replace" },
|
||||
generate: { mode: "text-to-image", model: "auto", prompt: "", negativePrompt: "", strength: 75, steps: 30, cfg: 7, seed: -1, sampler: "euler", scheduler: "normal", width: 1024, height: 1024, outpaint: { left: 128, top: 128, right: 128, bottom: 128, feathering: 32 } },
|
||||
generate: {
|
||||
mode: "text-to-image",
|
||||
model: "auto",
|
||||
prompt: "",
|
||||
negativePrompt: "",
|
||||
strength: 75,
|
||||
steps: 30,
|
||||
cfg: 7,
|
||||
seed: -1,
|
||||
sampler: "euler",
|
||||
scheduler: "normal",
|
||||
width: 1024,
|
||||
height: 1024,
|
||||
outpaint: { left: 128, top: 128, right: 128, bottom: 128, feathering: 32 },
|
||||
inpaint: { maskedAreaOnly: true, cropPadding: 96, maskPolarity: "hidden", maskedContent: "neutral", growMaskBy: 6, maskExpand: 0, maskFeather: 0, maskBlur: 0, maskDespeckle: 0 },
|
||||
},
|
||||
};
|
||||
|
||||
export function isPanInteractionMode(interactionMode: InteractionMode): boolean {
|
||||
|
||||
Reference in New Issue
Block a user