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): sharpen layer and brush feedback
Josh Corbett3aa6109d50b2
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/overlayRenderer.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/overlayRenderer.test.tsindex 06a3f9eac0..86ef52653e 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/overlayRenderer.test.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/overlayRenderer.test.ts@@ -77,6 +77,16 @@ describe('renderOverlay', () => {expect(arc!.args.slice(0, 3)).toEqual([100, 100, 20]);});+ it('outlines the brush cursor in dark and light for contrast on any background', () => {+ const backend = createTestStubRasterBackend();+ const target = backend.createSurface(200, 200);+ renderOverlay(target, baseState({ cursor: { point: { x: 50, y: 50 }, radiusDoc: 10 }, showBbox: false }));++ expect(findSet(target.callLog, 'strokeStyle')).toEqual(['#000000', '#ffffff']);+ expect(findSet(target.callLog, 'lineWidth')).toEqual([3, 1]);+ expect(target.callLog.filter((entry) => entry.op === 'stroke')).toHaveLength(2);+ });+it('omits the cursor ring when cursor is null', () => {const backend = createTestStubRasterBackend();const target = backend.createSurface(200, 200);diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/overlayRenderer.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/overlayRenderer.tsindex 105fff768f..80ff680cde 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/overlayRenderer.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/overlayRenderer.ts@@ -30,7 +30,10 @@ const BBOX_DASH: readonly number[] = [4, 4];/** The bbox-overlay dim fill (legacy `CanvasBboxToolModule` overlayRect parity). */const BBOX_OVERLAY_FILL = 'hsl(220 12% 10% / 0.8)';const GRID_COLOR = 'rgba(128, 128, 128, 0.25)';-const CURSOR_COLOR = '#ffffff';+const CURSOR_DARK = '#000000';+const CURSOR_LIGHT = '#ffffff';+const CURSOR_OUTER_WIDTH_PX = 3;+const CURSOR_INNER_WIDTH_PX = 1;/** Side length (screen px) of a drawn bbox resize handle. */const BBOX_HANDLE_DRAW_PX = 8;const BBOX_HANDLE_FILL = '#ffffff';@@ -206,11 +209,16 @@ const drawCursor = (ctx: Ctx, state: OverlayState): void => {const center = applyToPoint(state.view, cursor.point);const radius = cursor.radiusDoc * getScale(state.view);ctx.save();- ctx.strokeStyle = CURSOR_COLOR;- ctx.lineWidth = 1;ctx.setLineDash([]);ctx.beginPath();ctx.arc(center.x, center.y, Math.max(0, radius), 0, Math.PI * 2);+ // A dark outer ring plus a light inner ring stays legible over either end of+ // the value range without sampling pixels or relying on blend-mode support.+ ctx.strokeStyle = CURSOR_DARK;+ ctx.lineWidth = CURSOR_OUTER_WIDTH_PX;+ ctx.stroke();+ ctx.strokeStyle = CURSOR_LIGHT;+ ctx.lineWidth = CURSOR_INNER_WIDTH_PX;ctx.stroke();ctx.restore();};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.browser.test.tsxindex c854c9916a..1dd8fafcbe 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.browser.test.tsx@@ -196,6 +196,17 @@ afterEach(async () => {});describe('LayerListItem accessibility', () => {+ it('keeps layer-row background feedback nearly immediate', async () => {+ await renderHarness();++ const row = selectionButton('First layer').parentElement;+ expect(row).not.toBeNull();+ const style = getComputedStyle(row!);++ expect(style.transitionProperty).toBe('background');+ expect(style.transitionDuration).toBe('0.04s');+ });+it('keeps the sortable control free of interactive descendants', async () => {await renderHarness();diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsxindex 99c2e60a50..7e73544ca8 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsx@@ -37,6 +37,7 @@ const ROW_SELECTION_FOCUS = {outlineColor: 'accent.solid',outlineOffset: '-2px',};+const LAYER_ROW_BACKGROUND_TRANSITION = 'background min(40ms, var(--wb-motion-duration-fast)) ease-out';const VISIBILITY_DOT_BASE = {borderRadius: 'full',borderWidth: '1px',@@ -272,6 +273,7 @@ export const LayerListItem = ({gap="1.5"p="1.5"position="relative"+ transition={LAYER_ROW_BACKGROUND_TRANSITION}onContextMenu={handleContextMenu}>{/*