- Implemented ComfyGenerateRequest type and associated functions for generating images using various architectures and modes. - Added functions for listing generation options and handling image uploads. - Created workflows for different generation modes including SDXL, Z-Image, Z-Image Turbo, and Anima. - Introduced GenerationJobStatus component to display the status of ongoing generation jobs. - Developed MaskControls for managing mask operations and displaying mask analysis. - Created palette items for tool selection, layer management, and generation settings.
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { applyMaskedContentModeToRgba } from "./inpaintPrep";
|
|
|
|
describe("inpaint prep", () => {
|
|
test("converts only masked original pixels to grayscale", () => {
|
|
const pixels = new Uint8ClampedArray([
|
|
255, 0, 0, 255,
|
|
0, 0, 255, 255,
|
|
]);
|
|
const mask = new Uint8ClampedArray([255, 0]);
|
|
|
|
const next = applyMaskedContentModeToRgba(pixels, 2, 1, mask, "original");
|
|
|
|
expect(next[0]).toBe(next[1]);
|
|
expect(next[1]).toBe(next[2]);
|
|
expect(Array.from(next.slice(4, 8))).toEqual([0, 0, 255, 255]);
|
|
});
|
|
|
|
test("uses an edge map inside the mask without recoloring unmasked context", () => {
|
|
const pixels = new Uint8ClampedArray([
|
|
255, 0, 0, 255,
|
|
0, 255, 0, 255,
|
|
0, 0, 255, 255,
|
|
255, 255, 0, 255,
|
|
]);
|
|
const mask = new Uint8ClampedArray([255, 0, 0, 0]);
|
|
|
|
const next = applyMaskedContentModeToRgba(pixels, 2, 2, mask, "edges");
|
|
|
|
expect(next[0]).toBe(next[1]);
|
|
expect(next[1]).toBe(next[2]);
|
|
expect(Array.from(next.slice(4, 8))).toEqual([0, 255, 0, 255]);
|
|
expect(Array.from(next.slice(8, 12))).toEqual([0, 0, 255, 255]);
|
|
expect(Array.from(next.slice(12, 16))).toEqual([255, 255, 0, 255]);
|
|
});
|
|
});
|