mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-01-27 16:50:45 +01:00
organized draw image
This commit is contained in:
parent
7c31dbb3d6
commit
0ddff9d551
@ -18,6 +18,10 @@ export default function SeedImage(_props: any) {
|
|||||||
const init_image = useImageCreate((state) =>
|
const init_image = useImageCreate((state) =>
|
||||||
state.getValueForRequestKey("init_image")
|
state.getValueForRequestKey("init_image")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isInPaintingMode = useImageCreate((state) => state.isInpainting);
|
||||||
|
|
||||||
|
|
||||||
const setRequestOption = useImageCreate((state) => state.setRequestOptions);
|
const setRequestOption = useImageCreate((state) => state.setRequestOptions);
|
||||||
|
|
||||||
const _startFileSelect = () => {
|
const _startFileSelect = () => {
|
||||||
@ -38,10 +42,17 @@ export default function SeedImage(_props: any) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleInpainting = useImageCreate((state) => state.toggleInpainting);
|
||||||
|
|
||||||
const _handleClearImage = () => {
|
const _handleClearImage = () => {
|
||||||
setRequestOption("init_image", undefined);
|
setRequestOption("init_image", undefined);
|
||||||
|
|
||||||
|
if (isInPaintingMode) {
|
||||||
|
toggleInpainting();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={ImageInputDisplay}>
|
<div className={ImageInputDisplay}>
|
||||||
<div>
|
<div>
|
||||||
@ -63,10 +74,23 @@ export default function SeedImage(_props: any) {
|
|||||||
<div className={ImageFixer}>
|
<div className={ImageFixer}>
|
||||||
{init_image && (
|
{init_image && (
|
||||||
<>
|
<>
|
||||||
|
<div>
|
||||||
<img src={init_image} width="100" height="100" />
|
<img src={init_image} width="100" height="100" />
|
||||||
<button className={XButton} onClick={_handleClearImage}>
|
<button className={XButton} onClick={_handleClearImage}>
|
||||||
X
|
X
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
onChange={(e) => {
|
||||||
|
toggleInpainting()
|
||||||
|
}}
|
||||||
|
checked={isInPaintingMode}
|
||||||
|
>
|
||||||
|
</input>
|
||||||
|
Use for Inpainting
|
||||||
|
</label>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,7 +10,7 @@ import { doMakeImage, MakeImageKey } from "../../../api";
|
|||||||
import AudioDing from "./audioDing";
|
import AudioDing from "./audioDing";
|
||||||
|
|
||||||
import GeneratedImage from "../../molecules/generatedImage";
|
import GeneratedImage from "../../molecules/generatedImage";
|
||||||
// import DrawImage from "../../molecules/drawImage";
|
import DrawImage from "../../molecules/drawImage";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
displayPanel,
|
displayPanel,
|
||||||
@ -29,6 +29,9 @@ export default function DisplayPanel() {
|
|||||||
const dingRef = useRef<HTMLAudioElement>(null);
|
const dingRef = useRef<HTMLAudioElement>(null);
|
||||||
const isSoundEnabled = useImageCreate((state) => state.isSoundEnabled());
|
const isSoundEnabled = useImageCreate((state) => state.isSoundEnabled());
|
||||||
|
|
||||||
|
const isInPaintingMode = useImageCreate((state) => state.isInpainting);
|
||||||
|
|
||||||
|
|
||||||
/* FETCHING */
|
/* FETCHING */
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const { id, options } = useImageQueue((state) => state.firstInQueue());
|
const { id, options } = useImageQueue((state) => state.firstInQueue());
|
||||||
@ -62,6 +65,11 @@ export default function DisplayPanel() {
|
|||||||
);
|
);
|
||||||
const completedIds = useImageQueue((state) => state.completedImageIds);
|
const completedIds = useImageQueue((state) => state.completedImageIds);
|
||||||
|
|
||||||
|
|
||||||
|
const init_image = useImageCreate((state) =>
|
||||||
|
state.getValueForRequestKey("init_image")
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const testReq = {} as ImageRequest;
|
const testReq = {} as ImageRequest;
|
||||||
const completedQueries = completedIds.map((id) => {
|
const completedQueries = completedIds.map((id) => {
|
||||||
@ -98,11 +106,17 @@ export default function DisplayPanel() {
|
|||||||
return (
|
return (
|
||||||
<div className={displayPanel}>
|
<div className={displayPanel}>
|
||||||
<AudioDing ref={dingRef}></AudioDing>
|
<AudioDing ref={dingRef}></AudioDing>
|
||||||
{completedImages.length > 0 && (
|
|
||||||
<div className={displayContainer}>
|
<div className={displayContainer}>
|
||||||
|
{isInPaintingMode &&
|
||||||
|
<DrawImage imageData={init_image}></DrawImage>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{completedImages.length > 0 && (
|
||||||
|
<>
|
||||||
<div className={CurrentDisplay}>
|
<div className={CurrentDisplay}>
|
||||||
{/* TODO Put the in painting controls here */}
|
|
||||||
{/* <DrawImage imageData={completedImages[0].data}></DrawImage> */}
|
|
||||||
|
|
||||||
<GeneratedImage
|
<GeneratedImage
|
||||||
key={completedImages[0].id}
|
key={completedImages[0].id}
|
||||||
@ -132,8 +146,11 @@ export default function DisplayPanel() {
|
|||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ import { devtools } from "zustand/middleware";
|
|||||||
import { useRandomSeed } from "../utils";
|
import { useRandomSeed } from "../utils";
|
||||||
|
|
||||||
export type ImageCreationUiOptions = {
|
export type ImageCreationUiOptions = {
|
||||||
// isCheckedUseUpscaling: boolean;
|
|
||||||
// isCheckUseFaceCorrection: boolean;
|
|
||||||
isUseRandomSeed: boolean;
|
isUseRandomSeed: boolean;
|
||||||
isUseAutoSave: boolean;
|
isUseAutoSave: boolean;
|
||||||
isSoundEnabled: boolean;
|
isSoundEnabled: boolean;
|
||||||
@ -71,6 +69,7 @@ interface ImageCreateState {
|
|||||||
requestOptions: ImageRequest;
|
requestOptions: ImageRequest;
|
||||||
allModifiers: ModifiersOptionList;
|
allModifiers: ModifiersOptionList;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
|
isInpainting: boolean;
|
||||||
|
|
||||||
setParallelCount: (count: number) => void;
|
setParallelCount: (count: number) => void;
|
||||||
setRequestOptions: (key: keyof ImageRequest, value: any) => void;
|
setRequestOptions: (key: keyof ImageRequest, value: any) => void;
|
||||||
@ -94,6 +93,7 @@ interface ImageCreateState {
|
|||||||
isUseAutoSave: () => boolean;
|
isUseAutoSave: () => boolean;
|
||||||
toggleSoundEnabled: () => void;
|
toggleSoundEnabled: () => void;
|
||||||
isSoundEnabled: () => boolean;
|
isSoundEnabled: () => boolean;
|
||||||
|
toggleInpainting: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
// devtools breaks TS
|
// devtools breaks TS
|
||||||
@ -134,6 +134,8 @@ export const useImageCreate = create<ImageCreateState>(
|
|||||||
|
|
||||||
allModifiers: [[[]]] as ModifiersOptionList,
|
allModifiers: [[[]]] as ModifiersOptionList,
|
||||||
|
|
||||||
|
isInpainting: false,
|
||||||
|
|
||||||
setParallelCount: (count: number) =>
|
setParallelCount: (count: number) =>
|
||||||
set(
|
set(
|
||||||
produce((state) => {
|
produce((state) => {
|
||||||
@ -280,5 +282,14 @@ export const useImageCreate = create<ImageCreateState>(
|
|||||||
isSoundEnabled: () => {
|
isSoundEnabled: () => {
|
||||||
return get().uiOptions.isSoundEnabled;
|
return get().uiOptions.isSoundEnabled;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleInpainting: () => {
|
||||||
|
set(
|
||||||
|
produce((state) => {
|
||||||
|
state.isInpainting = !state.isInpainting;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user