aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/smartdraw/SmartDrawHandler.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/smartdraw/SmartDrawHandler.tsx')
-rw-r--r--src/client/views/smartdraw/SmartDrawHandler.tsx34
1 files changed, 5 insertions, 29 deletions
diff --git a/src/client/views/smartdraw/SmartDrawHandler.tsx b/src/client/views/smartdraw/SmartDrawHandler.tsx
index 8cff2174f..6c9470480 100644
--- a/src/client/views/smartdraw/SmartDrawHandler.tsx
+++ b/src/client/views/smartdraw/SmartDrawHandler.tsx
@@ -25,6 +25,7 @@ import { ActiveInkArrowEnd, ActiveInkArrowStart, ActiveInkDash, ActiveInkFillCol
import './SmartDrawHandler.scss';
import { Networking } from '../../Network';
import { OpenWhere } from '../nodes/OpenWhere';
+import { FireflyDimensionsMap, FireflyImageDimensions } from './FireflyConstants';
export interface DrawingOptions {
text: string;
@@ -35,13 +36,6 @@ export interface DrawingOptions {
y: number;
}
-enum FireflyImageDimensions {
- Square = 'square',
- Landscape = 'landscape',
- Portrait = 'portrait',
- Widescreen = 'widescreen',
-}
-
/**
* The SmartDrawHandler allows users to generate drawings with GPT from text input. Users are able to enter
* the item to draw, how complex they want the drawing to be, how large the drawing should be, and whether
@@ -274,30 +268,12 @@ export class SmartDrawHandler extends ObservableReactComponent<object> {
*/
createImageWithFirefly = (input: string, seed?: number) => {
this._lastInput.text = input;
- let width = 0;
- let height = 0;
- switch (this._imgDims) {
- case FireflyImageDimensions.Square:
- width = 2048;
- height = 2048;
- break;
- case FireflyImageDimensions.Landscape:
- width = 2304;
- height = 1792;
- case FireflyImageDimensions.Portrait:
- width = 1792;
- height = 2304;
- break;
- case FireflyImageDimensions.Widescreen:
- width = 2688;
- height = 1536;
- break;
- }
- return Networking.PostToServer('/queryFireflyImage', { prompt: input, width: width, height: height, seed: seed }).then(img => {
+ const dims = FireflyDimensionsMap[this._imgDims];
+ return Networking.PostToServer('/queryFireflyImage', { prompt: input, width: dims.width, height: dims.height, seed: seed }).then(img => {
const imgDoc: Doc = Docs.Create.ImageDocument(img.accessPaths.agnostic.client, {
title: input.match(/^(.*?)~~~.*$/)?.[1] || input,
- nativeWidth: width,
- nativeHeight: height,
+ nativeWidth: dims.width,
+ nativeHeight: dims.height,
ai_generated: true,
firefly_seed: img.accessPaths.agnostic.client.match(/\/(\d+)upload/)[1],
firefly_prompt: input,