Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(canvas): pad a moved float's landing like member damage
Josh Corbettd1aa01bdd171
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentComposite.browser.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentComposite.browser.test.tsindex 108f89591c..cc07dfc76a 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentComposite.browser.test.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentComposite.browser.test.ts@@ -486,26 +486,35 @@ describe('group-scoped previews and partial refresh', () => {expect(pixels).toEqual(allPixels(rebuilt.composite()));});- it('moves a floating selection inside a group by refreshing only the old and new landing', () => {+ it.each<[string, GroupedSceneOptions]>([+ ['an untransformed member', {}],+ [+ 'a member scaled 4x',+ {+ member: { transform: { rotation: 0, scaleX: 4, scaleY: 4, x: 0, y: 0 } },+ memberRect: { height: 16, width: 16, x: 0, y: 0 },+ },+ ],+ ])('moves a floating selection on %s by refreshing only the old and new landing', (_, options) => {const lifted = (scene: ReturnType<typeof groupedScene>['scene']) => {- const surface = scene.backend.createSurface(8, 8);+ const surface = scene.backend.createSurface(3, 3);surface.ctx.fillStyle = '#ffffff';- surface.ctx.fillRect(0, 0, 8, 8);+ surface.ctx.fillRect(0, 0, 3, 3);return surface;};const floatAt = (surface: RasterSurface, x: number) => ({- floatingSelection: { layerId: 'member', matrix: identity(), rect: { height: 8, width: 8, x, y: 20 }, surface },+ floatingSelection: { layerId: 'member', matrix: identity(), rect: { height: 3, width: 3, x, y: 5 }, surface },});- const dragged = groupedScene();+ const dragged = groupedScene(options);const surface = lifted(dragged.scene);- dragged.composite(floatAt(surface, 10));+ dragged.composite(floatAt(surface, 2));const before = dragged.diagnostics.snapshot();- const pixels = allPixels(dragged.composite(floatAt(surface, 30)));+ const pixels = allPixels(dragged.composite(floatAt(surface, 8)));const after = dragged.diagnostics.snapshot();expect(after.groupSurfaceRebuilds).toBe(before.groupSurfaceRebuilds);expect(after.groupSurfaceRefreshes).toBe(before.groupSurfaceRefreshes + 1);- const fresh = groupedScene();- expect(pixels).toEqual(allPixels(fresh.composite(floatAt(lifted(fresh.scene), 30))));+ const fresh = groupedScene(options);+ expect(pixels).toEqual(allPixels(fresh.composite(floatAt(lifted(fresh.scene), 8))));});});diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupSurfaceCache.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupSurfaceCache.tsindex dff364ca33..0ae54882b0 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupSurfaceCache.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupSurfaceCache.ts@@ -83,7 +83,7 @@ interface GroupSlot {interface DrawnFloat {readonly placement: string;- /** Document-space bounds the float covers. */+ /** Document-space bounds the float's resampled pixels can reach. */readonly landing: Rect;}@@ -185,9 +185,13 @@ export const createGroupSurfaceCache = (deps: GroupSurfaceDeps): GroupSurfaceCacconst float = content.float?.layerId === leaf.id ? content.float : null;let drawnFloat: DrawnFloat | null = null;if (float && !isEmpty(float.rect)) {- const landing = transformBounds(multiply(matrix, float.matrix), float.rect);+ const placed = multiply(matrix, float.matrix);+ const landing = transformBounds(placed, float.rect);bounds = bounds ? union(bounds, landing) : landing;- drawnFloat = { landing, placement: `${rectKey(float.rect)}*${matKey(float.matrix)}` };+ drawnFloat = {+ landing: transformBounds(placed, expand(float.rect, SOURCE_FILTER_RADIUS)),+ placement: `${rectKey(float.rect)}*${matKey(float.matrix)}`,+ };}drawn.push({ bounds, entry: preview ? null : entry, float: drawnFloat, leaf, matrix });}