Spaces:
Runtime error
Runtime error
about page
Browse files- frontend/src/lib/App.svelte +20 -3
- frontend/src/lib/Buttons/AboutButton.svelte +16 -0
- frontend/src/lib/Menu.svelte +4 -10
- frontend/src/lib/PaintCanvas.svelte +3 -2
- frontend/src/lib/PaintFrame.svelte +5 -4
- frontend/src/lib/constants.ts +6 -1
- frontend/src/lib/utils.ts +2 -1
- stablediffusion-infinity/rooms.db +0 -0
frontend/src/lib/App.svelte
CHANGED
|
@@ -14,6 +14,8 @@
|
|
| 14 |
import { useMyPresence, useObject, useOthers } from '$lib/liveblocks';
|
| 15 |
import { base64ToBlob, uploadImage } from '$lib/utils';
|
| 16 |
import { nanoid } from 'nanoid';
|
|
|
|
|
|
|
| 17 |
|
| 18 |
/**
|
| 19 |
* The main Liveblocks code for the example.
|
|
@@ -27,8 +29,8 @@
|
|
| 27 |
const initialPresence: Presence = {
|
| 28 |
cursor: null,
|
| 29 |
frame: {
|
| 30 |
-
x:
|
| 31 |
-
y:
|
| 32 |
},
|
| 33 |
status: Status.dragging,
|
| 34 |
currentPrompt: ''
|
|
@@ -167,12 +169,27 @@
|
|
| 167 |
}
|
| 168 |
};
|
| 169 |
}
|
|
|
|
| 170 |
</script>
|
| 171 |
|
| 172 |
<!-- Show the current user's cursor location -->
|
| 173 |
<div class="text touch-none pointer-events-none">
|
| 174 |
{$loadingState}
|
| 175 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
{#if showModal}
|
| 177 |
<PromptModal on:paint={onPaint} on:close={onClose} initPrompt={$myPresence?.currentPrompt} />
|
| 178 |
{/if}
|
|
@@ -209,7 +226,7 @@
|
|
| 209 |
<ShareWithCommunity />
|
| 210 |
</div>
|
| 211 |
<div class="fixed bottom-0 left-0 right-0 z-10 my-2">
|
| 212 |
-
<Menu on:prompt={onPrompt} {isLoading} />
|
| 213 |
</div>
|
| 214 |
|
| 215 |
<style lang="postcss" scoped>
|
|
|
|
| 14 |
import { useMyPresence, useObject, useOthers } from '$lib/liveblocks';
|
| 15 |
import { base64ToBlob, uploadImage } from '$lib/utils';
|
| 16 |
import { nanoid } from 'nanoid';
|
| 17 |
+
import LiveBlocks from '$lib/Icons/LiveBlocks.svelte';
|
| 18 |
+
import { CANVAS_SIZE } from '$lib/constants';
|
| 19 |
|
| 20 |
/**
|
| 21 |
* The main Liveblocks code for the example.
|
|
|
|
| 29 |
const initialPresence: Presence = {
|
| 30 |
cursor: null,
|
| 31 |
frame: {
|
| 32 |
+
x: CANVAS_SIZE.width / 2 - 512 / 2,
|
| 33 |
+
y: CANVAS_SIZE.height / 2 - 512 / 2
|
| 34 |
},
|
| 35 |
status: Status.dragging,
|
| 36 |
currentPrompt: ''
|
|
|
|
| 169 |
}
|
| 170 |
};
|
| 171 |
}
|
| 172 |
+
let showAbout = false;
|
| 173 |
</script>
|
| 174 |
|
| 175 |
<!-- Show the current user's cursor location -->
|
| 176 |
<div class="text touch-none pointer-events-none">
|
| 177 |
{$loadingState}
|
| 178 |
</div>
|
| 179 |
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
| 180 |
+
<div
|
| 181 |
+
class="fixed w-screen top-0 left-0 bottom-0 right-0 max-h-screen z-50 items-center justify-center bg-black text-white bg-opacity-80 px-3 overflow-y-scroll
|
| 182 |
+
{showAbout ? 'flex' : 'hidden'}"
|
| 183 |
+
on:click={() => (showAbout = false)}
|
| 184 |
+
>
|
| 185 |
+
<div class="max-w-md">
|
| 186 |
+
<h2 class="font-bold text-xl font-mono">Stable Difussion Multiplayer</h2>
|
| 187 |
+
<p class="text-base">
|
| 188 |
+
Multiplayer API backed by Liveblocks
|
| 189 |
+
<LiveBlocks />
|
| 190 |
+
</p>
|
| 191 |
+
</div>
|
| 192 |
+
</div>
|
| 193 |
{#if showModal}
|
| 194 |
<PromptModal on:paint={onPaint} on:close={onClose} initPrompt={$myPresence?.currentPrompt} />
|
| 195 |
{/if}
|
|
|
|
| 226 |
<ShareWithCommunity />
|
| 227 |
</div>
|
| 228 |
<div class="fixed bottom-0 left-0 right-0 z-10 my-2">
|
| 229 |
+
<Menu on:prompt={onPrompt} {isLoading} on:toggleAbout={() => (showAbout = !showAbout)} />
|
| 230 |
</div>
|
| 231 |
|
| 232 |
<style lang="postcss" scoped>
|
frontend/src/lib/Buttons/AboutButton.svelte
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<button
|
| 2 |
+
on:click
|
| 3 |
+
class="button-paint"
|
| 4 |
+
title="Prompt and Paint"
|
| 5 |
+
>
|
| 6 |
+
<span>About</span>
|
| 7 |
+
</button>
|
| 8 |
+
|
| 9 |
+
<style lang="postcss" scoped>
|
| 10 |
+
/* .button {
|
| 11 |
+
@apply disabled:opacity-50 dark:bg-white dark:text-black bg-black text-white rounded-2xl text-xs shadow-sm focus:outline-none focus:border-gray-400;
|
| 12 |
+
} */
|
| 13 |
+
.button-paint {
|
| 14 |
+
@apply text-xs md:text-sm font-mono bg-violet-100 text-violet-900 min-w-[25ch] flex justify-center items-center disabled:opacity-50 rounded-xl px-3 py-1 shadow-sm focus:outline-none focus:border-gray-400;
|
| 15 |
+
}
|
| 16 |
+
</style>
|
frontend/src/lib/Menu.svelte
CHANGED
|
@@ -2,9 +2,10 @@
|
|
| 2 |
import { onMount, createEventDispatcher } from 'svelte';
|
| 3 |
import PPButton from '$lib/Buttons/PPButton.svelte';
|
| 4 |
import RoomsSelector from '$lib/Buttons/RoomsSelector.svelte';
|
| 5 |
-
import
|
|
|
|
| 6 |
const dispatch = createEventDispatcher();
|
| 7 |
-
|
| 8 |
export let isLoading = false;
|
| 9 |
|
| 10 |
const onKeyup = (e: KeyboardEvent) => {
|
|
@@ -23,12 +24,5 @@
|
|
| 23 |
<div class="grid grid-cols-1 gap-1 w-max mx-auto place-items-center">
|
| 24 |
<PPButton {isLoading} on:click={() => dispatch('prompt')} />
|
| 25 |
<RoomsSelector {isLoading} />
|
| 26 |
-
<
|
| 27 |
-
href="https://liveblocks.io"
|
| 28 |
-
target="_blank"
|
| 29 |
-
rel="noopener noreferrer"
|
| 30 |
-
title="Multiplayer backend by LiveBlocks.io"
|
| 31 |
-
>
|
| 32 |
-
<LiveBlocks classList="max-h-8 md:max-h-fit" />
|
| 33 |
-
</a>
|
| 34 |
</div>
|
|
|
|
| 2 |
import { onMount, createEventDispatcher } from 'svelte';
|
| 3 |
import PPButton from '$lib/Buttons/PPButton.svelte';
|
| 4 |
import RoomsSelector from '$lib/Buttons/RoomsSelector.svelte';
|
| 5 |
+
import AboutButton from '$lib/Buttons/AboutButton.svelte';
|
| 6 |
+
|
| 7 |
const dispatch = createEventDispatcher();
|
| 8 |
+
|
| 9 |
export let isLoading = false;
|
| 10 |
|
| 11 |
const onKeyup = (e: KeyboardEvent) => {
|
|
|
|
| 24 |
<div class="grid grid-cols-1 gap-1 w-max mx-auto place-items-center">
|
| 25 |
<PPButton {isLoading} on:click={() => dispatch('prompt')} />
|
| 26 |
<RoomsSelector {isLoading} />
|
| 27 |
+
<AboutButton on:click={() => dispatch('toggleAbout')} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
</div>
|
frontend/src/lib/PaintCanvas.svelte
CHANGED
|
@@ -7,12 +7,13 @@
|
|
| 7 |
|
| 8 |
import { useMyPresence, useObject } from '$lib/liveblocks';
|
| 9 |
import type { PromptImgObject } from '$lib/types';
|
|
|
|
| 10 |
|
| 11 |
const myPresence = useMyPresence();
|
| 12 |
const promptImgStorage = useObject('promptImgStorage');
|
| 13 |
|
| 14 |
-
const height =
|
| 15 |
-
const width =
|
| 16 |
|
| 17 |
let containerEl: HTMLDivElement;
|
| 18 |
let canvasCtx: CanvasRenderingContext2D;
|
|
|
|
| 7 |
|
| 8 |
import { useMyPresence, useObject } from '$lib/liveblocks';
|
| 9 |
import type { PromptImgObject } from '$lib/types';
|
| 10 |
+
import { CANVAS_SIZE } from '$lib/constants';
|
| 11 |
|
| 12 |
const myPresence = useMyPresence();
|
| 13 |
const promptImgStorage = useObject('promptImgStorage');
|
| 14 |
|
| 15 |
+
const height = CANVAS_SIZE.height;
|
| 16 |
+
const width = CANVAS_SIZE.width;
|
| 17 |
|
| 18 |
let containerEl: HTMLDivElement;
|
| 19 |
let canvasCtx: CanvasRenderingContext2D;
|
frontend/src/lib/PaintFrame.svelte
CHANGED
|
@@ -4,6 +4,7 @@
|
|
| 4 |
import MaskButton from '$lib/Buttons/MaskButton.svelte';
|
| 5 |
import UndoButton from '$lib/Buttons/UndoButton.svelte';
|
| 6 |
import LoadingIcon from '$lib/Icons/LoadingIcon.svelte';
|
|
|
|
| 7 |
|
| 8 |
import { drag } from 'd3-drag';
|
| 9 |
import { select } from 'd3-selection';
|
|
@@ -25,8 +26,8 @@
|
|
| 25 |
let maskCtx: CanvasRenderingContext2D;
|
| 26 |
|
| 27 |
let position = {
|
| 28 |
-
x:
|
| 29 |
-
y:
|
| 30 |
};
|
| 31 |
|
| 32 |
let frameElement: HTMLDivElement;
|
|
@@ -213,7 +214,7 @@
|
|
| 213 |
{#if !isDragging}
|
| 214 |
<div
|
| 215 |
class="absolute top-full"
|
| 216 |
-
style={`transform: scale(${Math.max(2 - transform.k, 1)}); transform-origin: 0 0;`}
|
| 217 |
>
|
| 218 |
<div class="py-3">
|
| 219 |
<PPButton {isLoading} on:click={() => dispatch('prompt')} />
|
|
@@ -232,7 +233,7 @@
|
|
| 232 |
</div>
|
| 233 |
<div
|
| 234 |
class="absolute left-full"
|
| 235 |
-
style={`transform: scale(${Math.max(2 - transform.k, 1)}); transform-origin: 0 0;`}
|
| 236 |
>
|
| 237 |
<div class="mx-4">
|
| 238 |
<DragButton
|
|
|
|
| 4 |
import MaskButton from '$lib/Buttons/MaskButton.svelte';
|
| 5 |
import UndoButton from '$lib/Buttons/UndoButton.svelte';
|
| 6 |
import LoadingIcon from '$lib/Icons/LoadingIcon.svelte';
|
| 7 |
+
import { CANVAS_SIZE } from '$lib/constants';
|
| 8 |
|
| 9 |
import { drag } from 'd3-drag';
|
| 10 |
import { select } from 'd3-selection';
|
|
|
|
| 26 |
let maskCtx: CanvasRenderingContext2D;
|
| 27 |
|
| 28 |
let position = {
|
| 29 |
+
x: CANVAS_SIZE.width / 2 - 512 / 2,
|
| 30 |
+
y: CANVAS_SIZE.height / 2 - 512 / 2
|
| 31 |
};
|
| 32 |
|
| 33 |
let frameElement: HTMLDivElement;
|
|
|
|
| 214 |
{#if !isDragging}
|
| 215 |
<div
|
| 216 |
class="absolute top-full"
|
| 217 |
+
style={`transform: scale(${Math.max(2.5 - transform.k, 1)}); transform-origin: 0 0;`}
|
| 218 |
>
|
| 219 |
<div class="py-3">
|
| 220 |
<PPButton {isLoading} on:click={() => dispatch('prompt')} />
|
|
|
|
| 233 |
</div>
|
| 234 |
<div
|
| 235 |
class="absolute left-full"
|
| 236 |
+
style={`transform: scale(${Math.max(2.5 - transform.k, 1)}); transform-origin: 0 0;`}
|
| 237 |
>
|
| 238 |
<div class="mx-4">
|
| 239 |
<DragButton
|
frontend/src/lib/constants.ts
CHANGED
|
@@ -8,4 +8,9 @@ export const COLORS = Object.values(colors)
|
|
| 8 |
export const EMOJIS = ['π', 'π', 'π', 'π', 'π¦', 'π', 'π', 'π', 'π¦', 'π¦', 'π·', 'π¦', 'π’', 'π', 'π¦', 'π¦', 'π¦', 'π', 'π¦', 'π ', 'π', 'π‘', 'π¬', 'π¦', 'π³', 'π', 'π', 'π
', 'π', 'π¦', 'π¦', 'π¦§', 'π', 'π¦', 'π¦', 'πͺ', 'π«', 'π¦', 'π', 'π', 'π', 'π', 'π',
|
| 9 |
'π', 'π', 'π', 'π', 'π©', 'π', 'π', 'π¦', 'π¦
', 'π¦', 'π¦’', 'π¦', 'π¦', 'π¦', 'π¦', 'π', 'π', 'πΏ', 'π', 'πΏ', 'π¦', 'π¦', 'π»', 'π»', 'π¨', 'πΌ', 'π΅', 'π', 'π', 'π', 'π', 'π', 'π²', 'π¦', 'π¦', 'π', 'π’', 'π¦', 'π', 'π¦', 'π§', 'π¦
', 'π¦', 'π¦', 'π¦']
|
| 10 |
|
| 11 |
-
export const MAX_CAPACITY = 20;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
export const EMOJIS = ['π', 'π', 'π', 'π', 'π¦', 'π', 'π', 'π', 'π¦', 'π¦', 'π·', 'π¦', 'π’', 'π', 'π¦', 'π¦', 'π¦', 'π', 'π¦', 'π ', 'π', 'π‘', 'π¬', 'π¦', 'π³', 'π', 'π', 'π
', 'π', 'π¦', 'π¦', 'π¦§', 'π', 'π¦', 'π¦', 'πͺ', 'π«', 'π¦', 'π', 'π', 'π', 'π', 'π',
|
| 9 |
'π', 'π', 'π', 'π', 'π©', 'π', 'π', 'π¦', 'π¦
', 'π¦', 'π¦’', 'π¦', 'π¦', 'π¦', 'π¦', 'π', 'π', 'πΏ', 'π', 'πΏ', 'π¦', 'π¦', 'π»', 'π»', 'π¨', 'πΌ', 'π΅', 'π', 'π', 'π', 'π', 'π', 'π²', 'π¦', 'π¦', 'π', 'π’', 'π¦', 'π', 'π¦', 'π§', 'π¦
', 'π¦', 'π¦', 'π¦']
|
| 10 |
|
| 11 |
+
export const MAX_CAPACITY = 20;
|
| 12 |
+
|
| 13 |
+
export const CANVAS_SIZE = {
|
| 14 |
+
width: 512 * 6,
|
| 15 |
+
height: 512 * 6,
|
| 16 |
+
}
|
frontend/src/lib/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import { PUBLIC_API_BASE } from '$env/static/public';
|
|
|
|
| 2 |
|
| 3 |
export function base64ToBlob(base64image: string): Promise<Blob> {
|
| 4 |
return new Promise((resolve) => {
|
|
@@ -43,7 +44,7 @@ export async function uploadImage(imagBlob: Blob, prompt: string, key: string):
|
|
| 43 |
|
| 44 |
return res;
|
| 45 |
}
|
| 46 |
-
const MAX =
|
| 47 |
|
| 48 |
export function round(pos: number, size = 32) {
|
| 49 |
const value = pos % size < size / 2 ? pos - (pos % size) : pos + size - (pos % size);
|
|
|
|
| 1 |
import { PUBLIC_API_BASE } from '$env/static/public';
|
| 2 |
+
import { CANVAS_SIZE } from '$lib/constants';
|
| 3 |
|
| 4 |
export function base64ToBlob(base64image: string): Promise<Blob> {
|
| 5 |
return new Promise((resolve) => {
|
|
|
|
| 44 |
|
| 45 |
return res;
|
| 46 |
}
|
| 47 |
+
const MAX = CANVAS_SIZE.width - 512
|
| 48 |
|
| 49 |
export function round(pos: number, size = 32) {
|
| 50 |
const value = pos % size < size / 2 ? pos - (pos % size) : pos + size - (pos % size);
|
stablediffusion-infinity/rooms.db
CHANGED
|
Binary files a/stablediffusion-infinity/rooms.db and b/stablediffusion-infinity/rooms.db differ
|
|
|