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
feat(canvas): brush and eraser hardness with a live stroke preview
Josh Corbettdd321ac2bd02
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.jsonindex 2e9012e602..fb4af8d5a6 100644--- a/invokeai/frontend/webv2/performance/browser-baseline.json+++ b/invokeai/frontend/webv2/performance/browser-baseline.json@@ -25,13 +25,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 120.3999999910593,+ "domContentLoadedMedianMs": 116.70000000298023,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 120.59999999403954,- "longestTaskMaxMs": 70,+ "loadMedianMs": 116.79999999701977,+ "longestTaskMaxMs": 68,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -41,24 +41,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746376,- "otherRawBytes": 160278,+ "otherRawBytes": 160353,"requestCount": 38,- "scriptRawBytes": 1635387,+ "scriptRawBytes": 1636323,"scriptRequestCount": 34,- "totalRawBytes": 1821488+ "totalRawBytes": 1822499},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 753840,- "otherRawBytes": 161881,+ "otherRawBytes": 161957,"requestCount": 38,- "scriptRawBytes": 1651741,+ "scriptRawBytes": 1652687,"scriptRequestCount": 34,- "totalRawBytes": 1839703+ "totalRawBytes": 1840724},- "routeReadyMedianMs": 262.5,+ "routeReadyMedianMs": 262,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "empty"},@@ -85,13 +85,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 121.29999999701977,+ "domContentLoadedMedianMs": 116.59999999403954,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 121.3999999910593,- "longestTaskMaxMs": 75,+ "loadMedianMs": 116.69999998807907,+ "longestTaskMaxMs": 68,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -101,24 +101,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746376,- "otherRawBytes": 160278,+ "otherRawBytes": 160353,"requestCount": 38,- "scriptRawBytes": 1635387,+ "scriptRawBytes": 1636323,"scriptRequestCount": 34,- "totalRawBytes": 1821488+ "totalRawBytes": 1822499},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 753840,- "otherRawBytes": 161881,+ "otherRawBytes": 161957,"requestCount": 38,- "scriptRawBytes": 1651741,+ "scriptRawBytes": 1652687,"scriptRequestCount": 34,- "totalRawBytes": 1839703+ "totalRawBytes": 1840724},- "routeReadyMedianMs": 308.09999999403954,+ "routeReadyMedianMs": 279.79999999701977,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "representative"},@@ -145,15 +145,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 116.8999999910593,+ "domContentLoadedMedianMs": 117.19999998807907,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 117,- "longestTaskMaxMs": 102,+ "loadMedianMs": 117.29999999701977,+ "longestTaskMaxMs": 99,"owner": "workbench",- "projectSwitchMedianMs": 38.29999999701977,+ "projectSwitchMedianMs": 37.099999994039536,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -161,24 +161,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 160278,+ "otherRawBytes": 160353,"requestCount": 115,- "scriptRawBytes": 3279305,+ "scriptRawBytes": 3281315,"scriptRequestCount": 110,- "totalRawBytes": 3621782+ "totalRawBytes": 3623867},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 161881,+ "otherRawBytes": 161957,"requestCount": 115,- "scriptRawBytes": 3312099,+ "scriptRawBytes": 3314129,"scriptRequestCount": 110,- "totalRawBytes": 3658000+ "totalRawBytes": 3660106},- "routeReadyMedianMs": 668,+ "routeReadyMedianMs": 657.8999999910593,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -205,15 +205,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 117.59999999403954,+ "domContentLoadedMedianMs": 121.29999999701977,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 117.79999999701977,- "longestTaskMaxMs": 193,+ "loadMedianMs": 121.3999999910593,+ "longestTaskMaxMs": 180,"owner": "workbench",- "projectSwitchMedianMs": 72.5,+ "projectSwitchMedianMs": 70.1000000089407,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -221,24 +221,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 160278,+ "otherRawBytes": 160353,"requestCount": 115,- "scriptRawBytes": 3279305,+ "scriptRawBytes": 3281315,"scriptRequestCount": 110,- "totalRawBytes": 3621782+ "totalRawBytes": 3623867},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 161881,+ "otherRawBytes": 161957,"requestCount": 115,- "scriptRawBytes": 3312099,+ "scriptRawBytes": 3314129,"scriptRequestCount": 110,- "totalRawBytes": 3658000+ "totalRawBytes": 3660106},- "routeReadyMedianMs": 449.09999999403954,+ "routeReadyMedianMs": 437.29999999701977,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"},@@ -247,31 +247,31 @@"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 290332,+ "largestAssetRawBytes": 293834,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 449111,+ "scriptRawBytes": 451425,"scriptRequestCount": 7,- "totalRawBytes": 449111+ "totalRawBytes": 451425},"activatedResourceLimits": {"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 293236,+ "largestAssetRawBytes": 296773,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 453603,+ "scriptRawBytes": 455940,"scriptRequestCount": 7,- "totalRawBytes": 453603+ "totalRawBytes": 455940},- "domContentLoadedMedianMs": 117,+ "domContentLoadedMedianMs": 114,"id": "editor-canvas","layoutAckMedianMs": 2,- "layoutReturnSwitchMedianMs": 56.400000005960464,- "layoutSwitchMedianMs": 96.79999999701977,- "loadMedianMs": 117.19999998807907,- "longestTaskMaxMs": 142,+ "layoutReturnSwitchMedianMs": 52.5,+ "layoutSwitchMedianMs": 89.8999999910593,+ "loadMedianMs": 114.1000000089407,+ "longestTaskMaxMs": 118,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -281,24 +281,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 160278,+ "otherRawBytes": 160353,"requestCount": 122,- "scriptRawBytes": 3728416,+ "scriptRawBytes": 3732740,"scriptRequestCount": 117,- "totalRawBytes": 4070893+ "totalRawBytes": 4075292},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 161881,+ "otherRawBytes": 161957,"requestCount": 122,- "scriptRawBytes": 3765701,+ "scriptRawBytes": 3770068,"scriptRequestCount": 117,- "totalRawBytes": 4111602+ "totalRawBytes": 4116045},- "routeReadyMedianMs": 1057.2000000029802,+ "routeReadyMedianMs": 1046.3999999910593,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "empty"},@@ -307,31 +307,31 @@"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 290332,+ "largestAssetRawBytes": 293834,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 449111,+ "scriptRawBytes": 451425,"scriptRequestCount": 7,- "totalRawBytes": 449111+ "totalRawBytes": 451425},"activatedResourceLimits": {"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 293236,+ "largestAssetRawBytes": 296773,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 453603,+ "scriptRawBytes": 455940,"scriptRequestCount": 7,- "totalRawBytes": 453603+ "totalRawBytes": 455940},- "domContentLoadedMedianMs": 118.69999998807907,+ "domContentLoadedMedianMs": 115.8999999910593,"id": "editor-canvas",- "layoutAckMedianMs": 2.4000000059604645,- "layoutReturnSwitchMedianMs": 45.400000005960464,- "layoutSwitchMedianMs": 82.3999999910593,- "loadMedianMs": 118.8999999910593,- "longestTaskMaxMs": 180,+ "layoutAckMedianMs": 2.7000000029802322,+ "layoutReturnSwitchMedianMs": 43.5,+ "layoutSwitchMedianMs": 86.40000000596046,+ "loadMedianMs": 116,+ "longestTaskMaxMs": 181,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -341,24 +341,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 160278,+ "otherRawBytes": 160353,"requestCount": 122,- "scriptRawBytes": 3728416,+ "scriptRawBytes": 3732740,"scriptRequestCount": 117,- "totalRawBytes": 4070893+ "totalRawBytes": 4075292},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 161881,+ "otherRawBytes": 161957,"requestCount": 122,- "scriptRawBytes": 3765701,+ "scriptRawBytes": 3770068,"scriptRequestCount": 117,- "totalRawBytes": 4111602+ "totalRawBytes": 4116045},- "routeReadyMedianMs": 1151.5,+ "routeReadyMedianMs": 1132,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "representative"},@@ -385,13 +385,13 @@"scriptRequestCount": 6,"totalRawBytes": 383461},- "domContentLoadedMedianMs": 117.79999999701977,+ "domContentLoadedMedianMs": 114.5,"id": "editor-workflow",- "layoutAckMedianMs": 2.3999999910593033,- "layoutReturnSwitchMedianMs": 33,- "layoutSwitchMedianMs": 90,- "loadMedianMs": 117.79999999701977,- "longestTaskMaxMs": 99,+ "layoutAckMedianMs": 2.199999988079071,+ "layoutReturnSwitchMedianMs": 32.79999999701977,+ "layoutSwitchMedianMs": 91.09999999403954,+ "loadMedianMs": 114.6000000089407,+ "longestTaskMaxMs": 94,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -401,24 +401,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 160278,+ "otherRawBytes": 160353,"requestCount": 122,- "scriptRawBytes": 3643556,+ "scriptRawBytes": 3645566,"scriptRequestCount": 116,- "totalRawBytes": 4001446+ "totalRawBytes": 4003531},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 161881,+ "otherRawBytes": 161957,"requestCount": 122,- "scriptRawBytes": 3679992,+ "scriptRawBytes": 3682022,"scriptRequestCount": 116,- "totalRawBytes": 4041461+ "totalRawBytes": 4043567},- "routeReadyMedianMs": 1056.2000000029802,+ "routeReadyMedianMs": 1044.2000000029802,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "empty"},@@ -445,13 +445,13 @@"scriptRequestCount": 6,"totalRawBytes": 383461},- "domContentLoadedMedianMs": 119.19999998807907,+ "domContentLoadedMedianMs": 121.09999999403954,"id": "editor-workflow","layoutAckMedianMs": 2.5,- "layoutReturnSwitchMedianMs": 41.19999998807907,- "layoutSwitchMedianMs": 127.40000000596046,- "loadMedianMs": 119.29999999701977,- "longestTaskMaxMs": 351,+ "layoutReturnSwitchMedianMs": 40.70000000298023,+ "layoutSwitchMedianMs": 125.5,+ "loadMedianMs": 121.20000000298023,+ "longestTaskMaxMs": 348,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -461,24 +461,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 160278,+ "otherRawBytes": 160353,"requestCount": 122,- "scriptRawBytes": 3643556,+ "scriptRawBytes": 3645566,"scriptRequestCount": 116,- "totalRawBytes": 4001446+ "totalRawBytes": 4003531},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 161881,+ "otherRawBytes": 161957,"requestCount": 122,- "scriptRawBytes": 3679992,+ "scriptRawBytes": 3682022,"scriptRequestCount": 116,- "totalRawBytes": 4041461+ "totalRawBytes": 4043567},- "routeReadyMedianMs": 1178.2999999970198,+ "routeReadyMedianMs": 1193.7000000029802,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "representative"},@@ -505,13 +505,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 119,+ "domContentLoadedMedianMs": 115.90000000596046,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 25.30000001192093,- "loadMedianMs": 119.1000000089407,- "longestTaskMaxMs": 100,+ "layoutSwitchMedianMs": 25.700000002980232,+ "loadMedianMs": 116,+ "longestTaskMaxMs": 99,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -521,24 +521,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 160278,+ "otherRawBytes": 160353,"requestCount": 115,- "scriptRawBytes": 3279305,+ "scriptRawBytes": 3281315,"scriptRequestCount": 110,- "totalRawBytes": 3621782+ "totalRawBytes": 3623867},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 161881,+ "otherRawBytes": 161957,"requestCount": 115,- "scriptRawBytes": 3312099,+ "scriptRawBytes": 3314129,"scriptRequestCount": 110,- "totalRawBytes": 3658000+ "totalRawBytes": 3660106},- "routeReadyMedianMs": 1271.6000000089407,+ "routeReadyMedianMs": 1267.7000000029802,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -565,13 +565,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 116.90000000596046,+ "domContentLoadedMedianMs": 115.90000000596046,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 89.5,- "loadMedianMs": 117.20000000298023,- "longestTaskMaxMs": 179,+ "layoutSwitchMedianMs": 83.79999999701977,+ "loadMedianMs": 116,+ "longestTaskMaxMs": 170,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -581,24 +581,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 160278,+ "otherRawBytes": 160353,"requestCount": 115,- "scriptRawBytes": 3279305,+ "scriptRawBytes": 3281315,"scriptRequestCount": 110,- "totalRawBytes": 3621782+ "totalRawBytes": 3623867},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 161881,+ "otherRawBytes": 161957,"requestCount": 115,- "scriptRawBytes": 3312099,+ "scriptRawBytes": 3314129,"scriptRequestCount": 110,- "totalRawBytes": 3658000+ "totalRawBytes": 3660106},- "routeReadyMedianMs": 1450.6000000089407,+ "routeReadyMedianMs": 1417.2999999970198,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"}diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 915c41d239..bf26e365c1 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -2389,6 +2389,8 @@"toolOptions": {"brushColor": "Brush color","brushSize": "Brush size",+ "hardness": "Hardness",+ "strokePreview": "Stroke preview","deselect": "Deselect","eraseSelection": "Erase","eraserSize": "Eraser size",diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/engineStores.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/engineStores.tsindex b734a78de4..671ae6e321 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/engineStores.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/engineStores.ts@@ -31,6 +31,8 @@ export interface BrushOptions {color: string;/** Per-stroke opacity in [0, 1]. */opacity: number;+ /** Edge hardness in [0, 1]: 1 is a crisp edge, lower feathers the silhouette. */+ hardness: number;/** Whether pen pressure modulates the stroke width. */pressureAffectsWidth: boolean;/**@@ -48,6 +50,8 @@ export interface EraserOptions {size: number;/** Per-stroke erase strength in [0, 1]. */opacity: number;+ /** Edge hardness in [0, 1]: 1 is a crisp edge, lower feathers the silhouette. */+ hardness: number;}/** Lasso (selection) tool options: how the path is drawn, and the op it applies. */@@ -216,6 +220,7 @@ export const DEFAULT_COLOR_PAIR_STATE: ActiveColorPairState = { background: '#ff/** Sensible starting brush options. */export const DEFAULT_BRUSH_OPTIONS: BrushOptions = {color: '#000000',+ hardness: 1,opacity: 1,pressureAffectsOpacity: false,pressureAffectsWidth: true,@@ -224,6 +229,7 @@ export const DEFAULT_BRUSH_OPTIONS: BrushOptions = {/** Sensible starting eraser options. */export const DEFAULT_ERASER_OPTIONS: EraserOptions = {+ hardness: 1,opacity: 1,size: 50,};@@ -587,11 +593,12 @@ const brushOptionsEqual = (a: BrushOptions, b: BrushOptions): boolean =>a.size === b.size &&a.color === b.color &&a.opacity === b.opacity &&+ a.hardness === b.hardness &&a.pressureAffectsWidth === b.pressureAffectsWidth &&a.pressureAffectsOpacity === b.pressureAffectsOpacity;const eraserOptionsEqual = (a: EraserOptions, b: EraserOptions): boolean =>- a.size === b.size && a.opacity === b.opacity;+ a.size === b.size && a.opacity === b.opacity && a.hardness === b.hardness;const checkerColorsEqual = (a: CheckerColors, b: CheckerColors): boolean => a.a === b.a && a.b === b.b;diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/brushTool.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/brushTool.tsindex d24d6bb289..37fb7cfb3a 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/brushTool.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/brushTool.ts@@ -19,6 +19,7 @@ export const createBrushTool = (): Tool =>createPaintTool({color: (ctx) => ctx.stores.brushOptions.get().color,composite: 'source-over',+ hardness: (ctx) => ctx.stores.brushOptions.get().hardness,id: 'brush',opacity: (ctx) => ctx.stores.brushOptions.get().opacity,size: (ctx) => ctx.stores.brushOptions.get().size,diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/eraserTool.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/eraserTool.tsindex 282162f27c..50078c6bbb 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/eraserTool.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/eraserTool.ts@@ -19,6 +19,7 @@ export const createEraserTool = (): Tool =>color: () => '#000000',composite: 'destination-out',id: 'eraser',+ hardness: (ctx) => ctx.stores.eraserOptions.get().hardness,opacity: (ctx) => ctx.stores.eraserOptions.get().opacity,// Upstream keeps eraser pressure width-only too; a pressure-faded erase reads as a// failed erase rather than a soft one.diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/paintTool.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/paintTool.tsindex a06d49632e..6d329bb983 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/paintTool.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/paintTool.ts@@ -43,6 +43,8 @@ export interface PaintToolSpec {color(ctx: ToolContext): string;/** Freehand thinning for this gesture; 0 disables pressure sensitivity. */thinning(ctx: ToolContext): number;+ /** Edge hardness in [0, 1]; absent means 1 (crisp). */+ hardness?(ctx: ToolContext): number;/** Whether pen pressure modulates alpha along the stroke. Absent means never (eraser). */pressureOpacity?(ctx: ToolContext): boolean;}@@ -309,6 +311,9 @@ export const createPaintTool = (spec: PaintToolSpec): Tool => {clipRect: ctx.getStrokeClipRect?.() ?? null,color: target.color ?? spec.color(ctx),composite,+ // Mask strokes are an all-or-nothing stencil; a feathered edge would+ // silently attenuate the denoise strength.+ hardness: target.forceOpaque ? 1 : (spec.hardness?.(ctx) ?? 1),createdLayer: target.createdLayer ?? null,ctx,layerId: target.layerId,diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.browser.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.browser.test.tsindex f489457a7d..40dd62e563 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.browser.test.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.browser.test.ts@@ -23,11 +23,19 @@ const pointer = (x: number, y: number, pressure = 0.5): PointerInput => ({const paint = (path: PointerInput[],batchSize: number,- opts: { opacity: number; size: number; thinning: number }+ opts: { opacity: number; size: number; thinning: number; hardness?: number; clipMaskRect?: Rect }): { pixels: Uint8ClampedArray; rect: Rect } => {const backend = createDomRasterBackend();const layers = createLayerCacheStore(backend);layers.getOrCreate('L', 0, 0);+ const clipMask = opts.clipMaskRect+ ? (() => {+ const surface = backend.createSurface(opts.clipMaskRect.width, opts.clipMaskRect.height);+ surface.ctx.fillStyle = '#fff';+ surface.ctx.fillRect(0, 0, opts.clipMaskRect.width, opts.clipMaskRect.height);+ return { rect: opts.clipMaskRect, surface };+ })()+ : null;const ctx = {backend,createPath2D: (d?: string) => new Path2D(d),@@ -37,8 +45,10 @@ const paint = (notifyLayerPainted: vi.fn(),} as unknown as ToolContext;const session = createStrokeSession({+ clipMask,color: '#3b82f6',composite: 'source-over',+ hardness: opts.hardness ?? 1,ctx,layerId: 'L',opacity: opts.opacity,@@ -63,7 +73,7 @@ const ROUNDING_TOLERANCE = 6;const tapCoverage = (composite: 'source-over' | 'destination-out',- options: { pressure?: number; pressureOpacity?: boolean; size?: number } = {}+ options: { hardness?: number; pressure?: number; pressureOpacity?: boolean; size?: number } = {}): { max: number; sum: number } => {const backend = createDomRasterBackend();const layers = createLayerCacheStore(backend);@@ -85,6 +95,7 @@ const tapCoverage = (color: '#3b82f6',composite,ctx,+ hardness: options.hardness ?? 1,layerId: 'L',opacity: 1,pressureOpacity: options.pressureOpacity ?? false,@@ -122,6 +133,55 @@ describe('sub-pixel taps', () => {});});+describe('hardness', () => {+ it('a feathered stroke clipped to a selection never bleeds past the mask and keeps its soft edge inside', () => {+ const result = paint([pointer(40, 64), pointer(40.01, 64)], 2, {+ clipMaskRect: { height: 128, width: 64, x: 0, y: 0 },+ hardness: 0.2,+ opacity: 1,+ size: 48,+ thinning: 0,+ });+ const alphaAt = (x: number, y: number): number => {+ if (x < result.rect.x || x >= result.rect.x + result.rect.width) {+ return 0;+ }+ return result.pixels[((y - result.rect.y) * result.rect.width + (x - result.rect.x)) * 4 + 3]!;+ };+ expect(alphaAt(40, 64)).toBeGreaterThan(200);+ // Soft edge survives the mask inside it.+ expect(alphaAt(20, 64)).toBeGreaterThan(8);+ expect(alphaAt(20, 64)).toBeLessThan(250);+ // The blur's bleed is cut hard at the mask boundary.+ for (const x of [64, 66, 72, 80]) {+ expect(alphaAt(x, 64)).toBe(0);+ }+ });++ const alphaAt = (result: { pixels: Uint8ClampedArray; rect: Rect }, x: number, y: number): number =>+ result.pixels[((y - result.rect.y) * result.rect.width + (x - result.rect.x)) * 4 + 3]!;+ const dab = (hardness: number) =>+ paint([pointer(64, 64), pointer(64.01, 64)], 2, { hardness, opacity: 1, size: 48, thinning: 0 });++ it('feathers the edge without touching the core, and hardness 1 stays crisp', () => {+ const hard = dab(1);+ const softDab = dab(0.2);+ expect(alphaAt(softDab, 64, 64)).toBeGreaterThan(235);+ expect(alphaAt(hard, 64, 64)).toBeGreaterThan(250);++ // Just inside the 24px radius: crisp is near-opaque, feathered is midway.+ const edgeHard = alphaAt(hard, 64 + 22, 64);+ const edgeSoft = alphaAt(softDab, 64 + 22, 64);+ expect(edgeHard).toBeGreaterThan(200);+ expect(edgeSoft).toBeGreaterThan(8);+ expect(edgeSoft).toBeLessThan(edgeHard - 60);++ // Just outside: the feather carries alpha past the crisp silhouette.+ expect(alphaAt(hard, 64 + 27, 64)).toBe(0);+ expect(alphaAt(softDab, 64 + 27, 64)).toBeGreaterThan(4);+ });+});+const sweep = (): PointerInput[] => {const points: PointerInput[] = [];for (let i = 0; i < 240; i++) {diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.test.tsindex 5c9077b607..4562d6b298 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.test.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.test.ts@@ -62,6 +62,7 @@ const runStroke = (opts: { withMask: boolean }) => {const session = createStrokeSession({clipMask,color: '#ff0000',+ hardness: 1,composite: 'source-over',ctx,layerId: 'L',@@ -138,6 +139,7 @@ describe('strokeSession: bbox-clipped painting', () => {const session = createStrokeSession({clipRect,color: '#ff0000',+ hardness: 1,composite: 'source-over',ctx,layerId: 'L',@@ -221,6 +223,7 @@ describe('strokeSession: content-sized cache growth', () => {const session = createStrokeSession({clipMask: null,color: '#ff0000',+ hardness: 1,composite: 'source-over',ctx,layerId: 'L',@@ -343,6 +346,7 @@ describe('strokeSession: cache version bump (live adjusted-surface invalidation)const session = createStrokeSession({clipMask: null,color: '#ff0000',+ hardness: 1,composite: 'source-over',ctx,layerId: 'L',@@ -395,6 +399,7 @@ describe('incremental "before" snapshot', () => {} as unknown as ToolContext;const session = createStrokeSession({color: '#ff0000',+ hardness: 1,composite: 'source-over',ctx,layerId: 'L',@@ -483,6 +488,7 @@ describe('strokeSession: pressure-dependent opacity', () => {const session = createStrokeSession({clipMask: null,color: '#ff0000',+ hardness: 1,composite: 'source-over',ctx,layerId: 'L',@@ -569,6 +575,7 @@ describe('layer transforms', () => {} as unknown as ToolContext;const session = createStrokeSession({color: '#ff0000',+ hardness: 1,composite: 'source-over',ctx,layerId: 'L',diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.tsindex 4534a62ed2..60bb781204 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/strokeSession.ts@@ -68,6 +68,8 @@ export interface StrokeSessionConfig {pressureOpacity: boolean;/** Fill color (brush only; ignored for the eraser). */color: string;+ /** Edge hardness in [0, 1]: 1 keeps the crisp hot path; lower feathers the silhouette. */+ hardness: number;/*** Cache composite operation: `source-over` (brush), `destination-out` (eraser),* or `source-atop` (transparency-locked brush — colour only where the layer is@@ -328,6 +330,11 @@ export const createStrokeSession = (config: StrokeSessionConfig): StrokeSession// the inverse (exact under rotation and uniform scale, the geometric mean// under non-uniform — the stroke then stretches with the layer's own pixels).const localSize = size * getScale(toLocal);+ // Blurring the one filled silhouette keeps soft edges uniform and non-compounding.+ // Sub-quarter-pixel sigma is invisible; treating it as crisp keeps the banded hot path.+ const rawSigma = ((1 - Math.min(1, Math.max(0, config.hardness))) * localSize) / 4;+ const featherSigma = rawSigma < 0.25 ? 0 : rawSigma;+ const featherBleed = Math.ceil(featherSigma * 3);const clipMaskLocalRect = clipMask ? roundOut(transformBounds(toLocal, clipMask.rect)) : null;const clipRectLocal = clipRect ? roundOut(transformBounds(toLocal, clipRect)) : null;// Axis-aligned layers get the rect clip for free from the region clamp; a@@ -340,6 +347,8 @@ export const createStrokeSession = (config: StrokeSessionConfig): StrokeSession};// A per-frame scratch surface for the filled stroke, sized to the paint region.let stroke: RasterSurface | null = null;+ // The feathered copy of the silhouette; allocated only when hardness < 1.+ let soft: RasterSurface | null = null;const points: StrokeSamplePoint[] = [];// `beforeImageData` holds the pristine (pre-stroke) pixels of `accumRect`, in@@ -360,12 +369,21 @@ export const createStrokeSession = (config: StrokeSessionConfig): StrokeSessionreturn stroke;};+ const ensureSoft = (w: number, h: number): RasterSurface => {+ if (!soft) {+ soft = ctx.backend.createSurface(w, h);+ } else if (soft.width < w || soft.height < h) {+ soft.resize(Math.max(soft.width, w), Math.max(soft.height, h));+ }+ return soft;+ };+const paint = (last: boolean): void => {if (points.length === 0) {return;}const { bounds, path, polygon } = strokeToPath(points, { last, size: localSize, thinning }, ctx.createPath2D);- let dirty: Rect | null = roundOut(bounds);+ let dirty: Rect | null = roundOut(featherBleed > 0 ? expand(bounds, featherBleed) : bounds);// Selection clip: only the region inside the selection can ever change, so// bound the dirty/growth region to the mask extent (and skip empty results).if (clipMaskLocalRect) {@@ -433,7 +451,8 @@ export const createStrokeSession = (config: StrokeSessionConfig): StrokeSession// would only cost time — and rewriting the whole accumulated region every// frame is what made a long stroke get slower the longer it got.const moved = previousPolygon ? changedVertexBounds(previousPolygon, polygon) : null;- const touched = previousRect && moved ? intersect(roundOut(expand(moved, CHANGE_MARGIN)), region) : region;+ const touched =+ previousRect && moved ? intersect(roundOut(expand(moved, CHANGE_MARGIN + featherBleed)), region) : region;// No intersection means the change fell outside the paintable region (a clip// can do that); fall back to the whole region rather than skip the frame.const changed = touched && !isEmpty(touched) ? touched : region;@@ -473,7 +492,8 @@ export const createStrokeSession = (config: StrokeSessionConfig): StrokeSession// refill and lose its earlier half. Refilling whole keeps the band sequence intact,// at the cost of the per-frame saving above — which is why it stays opt-in.const scratchCleared = !previousRect || !sameRect(previousRect, region);- const refresh = scratchCleared || pressureOpacity ? region : changed;+ // The blur reads the whole silhouette; a band-only refill would seam.+ const refresh = scratchCleared || pressureOpacity || featherSigma > 0 ? region : changed;const scratch = ensureStroke(region.width, region.height);const strokeCtx = scratch.ctx;strokeCtx.setTransform(1, 0, 0, 1, -region.x, -region.y);@@ -522,43 +542,58 @@ export const createStrokeSession = (config: StrokeSessionConfig): StrokeSessionstrokeCtx.restore();+ // 4a. Feather before the clips — blurring after would bleed masked pixels+ // back outside the selection. Without `filter` support the stroke stays crisp.+ let paintSurface = scratch;+ if (featherSigma > 0) {+ const softScratch = ensureSoft(region.width, region.height);+ const softCtx = softScratch.ctx;+ softCtx.setTransform(1, 0, 0, 1, 0, 0);+ softCtx.clearRect(0, 0, softScratch.width, softScratch.height);+ softCtx.filter = `blur(${featherSigma}px)`;+ softCtx.drawImage(scratch.canvas, 0, 0);+ softCtx.filter = 'none';+ paintSurface = softScratch;+ }+ const paintCtx = paintSurface.ctx;+// 4b. Selection clip: keep only the stroke pixels inside the selection mask.// The mask is a placed surface; draw it at (maskOrigin - regionOrigin) in// the scratch's region-local space. Confined to the same band — masking// already-masked pixels a second time would multiply their alpha again.if (clipMask) {- strokeCtx.setTransform(1, 0, 0, 1, 0, 0);- strokeCtx.save();- strokeCtx.beginPath();- strokeCtx.rect(refresh.x - region.x, refresh.y - region.y, refresh.width, refresh.height);- strokeCtx.clip();- strokeCtx.globalCompositeOperation = 'destination-in';- strokeCtx.globalAlpha = 1;+ paintCtx.setTransform(1, 0, 0, 1, 0, 0);+ paintCtx.save();+ paintCtx.beginPath();+ paintCtx.rect(refresh.x - region.x, refresh.y - region.y, refresh.width, refresh.height);+ paintCtx.clip();+ paintCtx.globalCompositeOperation = 'destination-in';+ paintCtx.globalAlpha = 1;// The mask is document-space; drawing it through the layer inverse keeps// its exact shape clipping even on a rotated or scaled layer.const maskMatrix = multiply({ a: 1, b: 0, c: 0, d: 1, e: -region.x, f: -region.y }, toLocal);- strokeCtx.setTransform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.e, maskMatrix.f);- strokeCtx.drawImage(clipMask.surface.canvas, clipMask.rect.x, clipMask.rect.y);- strokeCtx.restore();+ paintCtx.setTransform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.e, maskMatrix.f);+ paintCtx.drawImage(clipMask.surface.canvas, clipMask.rect.x, clipMask.rect.y);+ paintCtx.restore();}// 4c. Bbox clip on a rotated/sheared layer: the region clamp above only// bounds the AABB, so keep exactly the pixels inside the document-space// rect, drawn through the same inverse the mask uses.if (clipRect && clipRectNeedsMask) {- strokeCtx.setTransform(1, 0, 0, 1, 0, 0);- strokeCtx.save();- strokeCtx.beginPath();- strokeCtx.rect(refresh.x - region.x, refresh.y - region.y, refresh.width, refresh.height);- strokeCtx.clip();- strokeCtx.globalCompositeOperation = 'destination-in';- strokeCtx.globalAlpha = 1;+ paintCtx.setTransform(1, 0, 0, 1, 0, 0);+ paintCtx.save();+ paintCtx.beginPath();+ paintCtx.rect(refresh.x - region.x, refresh.y - region.y, refresh.width, refresh.height);+ paintCtx.clip();+ paintCtx.globalCompositeOperation = 'destination-in';+ paintCtx.globalAlpha = 1;const rectMatrix = multiply({ a: 1, b: 0, c: 0, d: 1, e: -region.x, f: -region.y }, toLocal);- strokeCtx.setTransform(rectMatrix.a, rectMatrix.b, rectMatrix.c, rectMatrix.d, rectMatrix.e, rectMatrix.f);- strokeCtx.beginPath();- strokeCtx.rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);- strokeCtx.fill();- strokeCtx.restore();+ paintCtx.setTransform(rectMatrix.a, rectMatrix.b, rectMatrix.c, rectMatrix.d, rectMatrix.e, rectMatrix.f);+ paintCtx.beginPath();+ paintCtx.rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);+ paintCtx.fill();+ paintCtx.restore();}// 5. Composite the scratch stroke into the cache at the stroke opacity, using@@ -572,7 +607,7 @@ export const createStrokeSession = (config: StrokeSessionConfig): StrokeSessiontargetCtx.clip();targetCtx.globalAlpha = opacity;targetCtx.globalCompositeOperation = composite;- targetCtx.drawImage(scratch.canvas, region.x - ox, region.y - oy);+ targetCtx.drawImage(paintSurface.canvas, region.x - ox, region.y - oy);targetCtx.restore();// The cache pixels changed THIS frame — bump the version, WITH the band theydiff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/BrushOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/BrushOptions.tsxindex a4c1317383..c9d7807041 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/BrushOptions.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/BrushOptions.tsx@@ -2,11 +2,12 @@ import type { NumberInput as ChakraNumberInput } from '@chakra-ui/react';import type { BrushOptions as BrushOptionsState } from '@workbench/canvas-engine/api';import type {ToolbarRegionProps,+ ToolbarStatusProps,ToolPresentationAdapter,} from '@workbench/widgets/canvas/tool-presentation/toolbarContracts';import type { KeyboardEvent } from 'react';-import { HStack } from '@chakra-ui/react';+import { chakra, HStack } from '@chakra-ui/react';import { ToggleIconButton } from '@platform/ui/Button';import { ColorPicker } from '@platform/ui/ColorPicker';import { MAX_BRUSH_SIZE, MIN_BRUSH_SIZE } from '@workbench/canvas-engine/api';@@ -19,7 +20,7 @@ import {} from '@workbench/widgets/canvas/tool-presentation/ToolbarPrimitives';import { useColorSampler } from '@workbench/widgets/canvas/useColorSampler';import { DropletIcon, PenLineIcon } from 'lucide-react';-import { useCallback } from 'react';+import { useLayoutEffect, useRef, useCallback } from 'react';import { useTranslation } from 'react-i18next';export const BRUSH_SIZE_SLIDER_MAX_SIZE = 600;@@ -178,6 +179,119 @@ export const PaintOpacityControl = ({);};+/** Hardness slider plus a percent field, shared by the brush and eraser. */+export const PaintHardnessControl = ({+ hardness,+ setHardness,+}: {+ hardness: number;+ setHardness: (hardness: number) => void;+}) => {+ const { t } = useTranslation();+ const label = t('widgets.canvas.toolOptions.hardness');+ const percent = Math.round(hardness * 100);+ const onSlider = useCallback((value: number) => setHardness(value / 100), [setHardness]);+ const onNumber = useCallback(+ ({ valueAsNumber }: ChakraNumberInput.ValueChangeDetails) => {+ if (Number.isFinite(valueAsNumber)) {+ setHardness(Math.max(0, Math.min(100, valueAsNumber)) / 100);+ }+ },+ [setHardness]+ );+ return (+ <>+ <ToolbarSlider+ aria-label={label}+ formatValue={formatPercent}+ max={100}+ min={0}+ value={percent}+ onValueChange={onSlider}+ />+ <ToolbarNumberField+ aria-label={label}+ max={100}+ min={0}+ suffix="%"+ value={String(percent)}+ onValueChange={onNumber}+ />+ </>+ );+};++/** Live stroke preview; the edge uses the stroke session's feather formula (sigma = (1 − hardness) · d / 4). */+export const PaintStrokePreview = ({+ color,+ hardness,+ opacity,+ size,+}: {+ color: string;+ hardness: number;+ opacity: number;+ size: number;+}) => {+ const { t } = useTranslation();+ const canvasRef = useRef<HTMLCanvasElement | null>(null);+ useLayoutEffect(() => {+ const canvas = canvasRef.current;+ const ctx = canvas?.getContext('2d');+ if (!canvas || !ctx) {+ return;+ }+ const dpr = globalThis.devicePixelRatio || 1;+ const width = canvas.clientWidth;+ const height = canvas.clientHeight;+ canvas.width = Math.max(1, Math.round(width * dpr));+ canvas.height = Math.max(1, Math.round(height * dpr));+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);+ ctx.clearRect(0, 0, width, height);+ // Fit radius + curve swing + the full 3-sigma feather inside the box, so+ // softness has room to demonstrate instead of clipping at the edges.+ const swing = height * 0.14;+ const featherFactor = 1 + 1.5 * (1 - hardness);+ const drawn = Math.max(1, Math.min(size, (height - 2 * swing - 8) / featherFactor));+ const sigma = ((1 - hardness) * drawn) / 4;+ ctx.filter = sigma > 0 ? `blur(${sigma}px)` : 'none';+ ctx.globalAlpha = opacity;+ ctx.strokeStyle = color;+ ctx.lineWidth = drawn;+ ctx.lineCap = 'round';+ ctx.beginPath();+ const inset = Math.max(12, drawn / 2 + sigma * 3);+ const mid = height / 2;+ ctx.moveTo(inset, mid + swing);+ ctx.bezierCurveTo(width * 0.35, mid - swing * 2, width * 0.65, mid + swing * 2, width - inset, mid - swing);+ ctx.stroke();+ ctx.filter = 'none';+ }, [color, hardness, opacity, size]);+ return (+ <chakra.canvas+ ref={canvasRef}+ aria-label={t('widgets.canvas.toolOptions.strokePreview')}+ bg="bg.inset"+ h="28"+ role="img"+ rounded="sm"+ w="full"+ />+ );+};++const BrushPreview = ({ engine }: ToolbarStatusProps) => {+ const options = useBrushOptions(engine);+ return (+ <PaintStrokePreview+ color={options.color}+ hardness={options.hardness}+ opacity={options.opacity}+ size={options.size}+ />+ );+};+const useBrushPatch = (engine: ToolbarRegionProps['engine']) => {const options = useBrushOptions(engine);const patch = useCallback(@@ -200,6 +314,12 @@ const BrushOpacity = ({ engine }: ToolbarRegionProps) => {return <PaintOpacityControl opacity={options.opacity} setOpacity={setOpacity} />;};+const BrushHardness = ({ engine }: ToolbarRegionProps) => {+ const [options, set] = useBrushPatch(engine);+ const setHardness = useCallback((hardness: number) => set({ hardness }), [set]);+ return <PaintHardnessControl hardness={options.hardness} setHardness={setHardness} />;+};+/** A mirror of the project foreground, not brush-owned state: the pair feeds the engine's brush color. */const BrushColor = ({ engine }: ToolbarRegionProps) => {const { t } = useTranslation();@@ -245,12 +365,15 @@ export const brushAdapter: ToolPresentationAdapter = {rowLabels: {geometry: 'widgets.canvas.toolOptions.size',intensity: 'widgets.canvas.toolOptions.opacity',+ modes: 'widgets.canvas.toolOptions.hardness',more: 'widgets.canvas.toolOptions.pressure',},color: BrushColor,geometry: BrushSize,id: 'brush',intensity: BrushOpacity,+ modes: BrushHardness,more: BrushPressure,paintsLeaf: true,+ status: BrushPreview,};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/EraserOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/EraserOptions.tsxindex a407e9d07c..aae2f8defe 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/EraserOptions.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/EraserOptions.tsx@@ -1,5 +1,6 @@import type {ToolbarRegionProps,+ ToolbarStatusProps,ToolPresentationAdapter,} from '@workbench/widgets/canvas/tool-presentation/toolbarContracts';@@ -7,7 +8,13 @@ import { useEraserOptions } from '@workbench/widgets/canvas/engineStoreHooks';import { useCallback } from 'react';import { useTranslation } from 'react-i18next';-import { clampBrushSize, PaintOpacityControl, PaintSizeControl } from './BrushOptions';+import {+ clampBrushSize,+ PaintHardnessControl,+ PaintOpacityControl,+ PaintSizeControl,+ PaintStrokePreview,+} from './BrushOptions';const EraserSize = ({ engine }: ToolbarRegionProps) => {const { t } = useTranslation();@@ -28,10 +35,32 @@ const EraserOpacity = ({ engine }: ToolbarRegionProps) => {return <PaintOpacityControl opacity={options.opacity} setOpacity={setOpacity} />;};+const EraserHardness = ({ engine }: ToolbarRegionProps) => {+ const options = useEraserOptions(engine);+ const setHardness = useCallback(+ (hardness: number) => engine.interaction.set('eraserOptions', { ...options, hardness }),+ [engine, options]+ );+ return <PaintHardnessControl hardness={options.hardness} setHardness={setHardness} />;+};++const EraserPreview = ({ engine }: ToolbarStatusProps) => {+ const options = useEraserOptions(engine);+ return (+ <PaintStrokePreview color="#9aa2b1" hardness={options.hardness} opacity={options.opacity} size={options.size} />+ );+};+export const eraserAdapter: ToolPresentationAdapter = {- rowLabels: { geometry: 'widgets.canvas.toolOptions.size', intensity: 'widgets.canvas.toolOptions.opacity' },+ rowLabels: {+ geometry: 'widgets.canvas.toolOptions.size',+ intensity: 'widgets.canvas.toolOptions.opacity',+ modes: 'widgets.canvas.toolOptions.hardness',+ },geometry: EraserSize,id: 'eraser',intensity: EraserOpacity,+ modes: EraserHardness,paintsLeaf: true,+ status: EraserPreview,};