diff --git a/lama_cleaner/app/src/components/Editor/Editor.tsx b/lama_cleaner/app/src/components/Editor/Editor.tsx index 38a0058..6112632 100644 --- a/lama_cleaner/app/src/components/Editor/Editor.tsx +++ b/lama_cleaner/app/src/components/Editor/Editor.tsx @@ -37,6 +37,7 @@ import { } from '../../utils' import { appState, + brushSizeState, croperState, enableFileManagerState, fileState, @@ -138,7 +139,8 @@ export default function Editor() { const [clicks, setClicks] = useRecoilState(interactiveSegClicksState) - const [brushSize, setBrushSize] = useState(40) + const [brushSize, setBrushSize] = useRecoilState(brushSizeState) + const [original, isOriginalLoaded] = useImage(file) const [renders, setRenders] = useState([]) const [context, setContext] = useState() @@ -1176,7 +1178,7 @@ export default function Editor() { // Standard Hotkeys for Brush Size useHotKey('[', () => { - setBrushSize(currentBrushSize => { + setBrushSize((currentBrushSize: number) => { if (currentBrushSize > 10) { return currentBrushSize - 10 } @@ -1188,7 +1190,7 @@ export default function Editor() { }) useHotKey(']', () => { - setBrushSize(currentBrushSize => { + setBrushSize((currentBrushSize: number) => { return currentBrushSize + 10 }) }) diff --git a/lama_cleaner/app/src/store/Atoms.tsx b/lama_cleaner/app/src/store/Atoms.tsx index d0a52ec..f383955 100644 --- a/lama_cleaner/app/src/store/Atoms.tsx +++ b/lama_cleaner/app/src/store/Atoms.tsx @@ -48,6 +48,7 @@ interface AppState { showFileManager: boolean enableFileManager: boolean gifImage: HTMLImageElement | undefined + brushSize: number } export const appState = atom({ @@ -66,6 +67,7 @@ export const appState = atom({ showFileManager: false, enableFileManager: false, gifImage: undefined, + brushSize: 40, }, }) @@ -91,6 +93,18 @@ export const isInpaintingState = selector({ }, }) +export const brushSizeState = selector({ + key: 'brushSizeState', + get: ({ get }) => { + const app = get(appState) + return app.brushSize + }, + set: ({ get, set }, newValue: any) => { + const app = get(appState) + set(appState, { ...app, brushSize: newValue }) + }, +}) + export const imageHeightState = selector({ key: 'imageHeightState', get: ({ get }) => {