refactor: Add PlaygroundImageGen component to PlaygroundMenu

This commit is contained in:
kwaroran
2024-05-31 13:31:02 +09:00
parent 622854489e
commit 774b597573
3 changed files with 90 additions and 6 deletions

View File

@@ -0,0 +1,49 @@
<script lang="ts">
import { language } from "src/lang";
import TextAreaInput from "../UI/GUI/TextAreaInput.svelte";
import Button from "../UI/GUI/Button.svelte";
import { generateAIImage } from "src/ts/process/stableDiff";
import { createBlankChar } from "src/ts/characters";
let prompt = "";
let negPrompt = "";
let img = "";
let generating = false
const run = async () => {
console.log('running')
if(generating){
return
}
generating = true
const gen = await generateAIImage(prompt, createBlankChar(), negPrompt, 'inlay')
generating = false
if(gen){
img = gen
}
}
</script>
<h2 class="text-4xl text-textcolor my-6 font-black relative">{language.imageGeneration}</h2>
<span class="text-textcolor text-lg">Prompt</span>
<TextAreaInput bind:value={prompt} />
<span class="text-textcolor text-lg">Neg. Prompt</span>
<TextAreaInput bind:value={negPrompt} />
{#if img}
<span class="text-textcolor text-lg">Generated</span>
<img src={img} class="max-w-full mt-4" alt="Generated"/>
{/if}
<Button className="mt-6" on:click={run}>
{#if generating}
<div class="loadmove" />
{:else}
Generate
{/if}
</Button>

View File

@@ -10,6 +10,7 @@
import { characterFormatUpdate, createBlankChar } from "src/ts/characters";
import { get } from "svelte/store";
import { DataBase, setDatabase, type character } from "src/ts/storage/database";
import PlaygroundImageGen from "./PlaygroundImageGen.svelte";
const playgroundChat = () => {
let db = get(DataBase)
@@ -69,6 +70,11 @@
}}>
<h1 class="text-2xl font-bold text-start">Jinja</h1>
</button>
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => {
PlaygroundStore.set(7)
}}>
<h1 class="text-2xl font-bold text-start">{language.imageGeneration}</h1>
</button>
</div>
{:else}
{#if $SizeStore.w < 1024}
@@ -96,6 +102,9 @@
{#if $PlaygroundStore === 6}
<PlaygroundJinja/>
{/if}
{#if $PlaygroundStore === 7}
<PlaygroundImageGen/>
{/if}
</div>
{/if}
</div>