diff options
| author | eleanor-park <eleanor_park@brown.edu> | 2024-12-14 14:13:59 -0500 |
|---|---|---|
| committer | eleanor-park <eleanor_park@brown.edu> | 2024-12-14 14:13:59 -0500 |
| commit | e7162baa77a851d73037c63b75fac6a5c07f9b61 (patch) | |
| tree | daa0ed49a471f67ad7641a90aea6d1aebbfaadfa /src/client/views/nodes/imageEditor | |
| parent | e6a4b7c05899ee6d6a821666b72023856081d5ca (diff) | |
replaced await in loop, added a componentWillUnmount to reset sticker palette
Diffstat (limited to 'src/client/views/nodes/imageEditor')
3 files changed, 9 insertions, 10 deletions
diff --git a/src/client/views/nodes/imageEditor/ImageEditor.tsx b/src/client/views/nodes/imageEditor/ImageEditor.tsx index a742673e0..a39878924 100644 --- a/src/client/views/nodes/imageEditor/ImageEditor.tsx +++ b/src/client/views/nodes/imageEditor/ImageEditor.tsx @@ -28,9 +28,6 @@ import { PointerHandler } from './imageEditorUtils/PointerHandler'; import { activeColor, bgColor, brushWidthOffset, canvasSize, eraserColor, freeformRenderSize, newCollectionSize, offsetDistanceY, offsetX } from './imageEditorUtils/imageEditorConstants'; import { CutMode, CursorData, ImageDimensions, ImageEditTool, ImageToolType, Point } from './imageEditorUtils/imageEditorInterfaces'; import { DocumentView } from '../DocumentView'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { ImageField } from '../../../../fields/URLField'; -import { resolve } from 'url'; import { DocData } from '../../../../fields/DocSymbols'; import { SettingsManager } from '../../../util/SettingsManager'; @@ -43,6 +40,13 @@ interface GenerativeFillProps { // Added field on image doc: gen_fill_children: List of children Docs +/** + * The image editor interface can be accessed by opening a document's context menu, then going to Options --> Open Image Editor. + * The image editor supports various operations on images. Currently, there is a Generative Fill feature that allows users to erase + * part of an image, add an optional prompt, and send this to GPT. GPT then returns a newly generated image that replaces the erased + * portion based on the optional prompt. There is also an image cutting tool that allows users to cut images in different ways to + * reshape the images, take out portions of images, and overall use them more creatively (see the header comment for cutImage() for more information). + */ const ImageEditor = ({ imageEditorOpen, imageEditorSource, imageRootDoc, addDoc }: GenerativeFillProps) => { const canvasRef = useRef<HTMLCanvasElement>(null); const canvasBackgroundRef = useRef<HTMLCanvasElement>(null); diff --git a/src/client/views/nodes/imageEditor/imageEditorUtils/BrushHandler.ts b/src/client/views/nodes/imageEditor/imageEditorUtils/BrushHandler.ts index a9fe02d4f..ed39375e0 100644 --- a/src/client/views/nodes/imageEditor/imageEditorUtils/BrushHandler.ts +++ b/src/client/views/nodes/imageEditor/imageEditorUtils/BrushHandler.ts @@ -1,12 +1,6 @@ import { GenerativeFillMathHelpers } from './GenerativeFillMathHelpers'; import { eraserColor } from './imageEditorConstants'; import { Point } from './imageEditorInterfaces'; -import { points } from '@turf/turf'; - -export enum BrushType { - GEN_FILL, - CUT, -} export class BrushHandler { static brushCircleOverlay = (x: number, y: number, brushRadius: number, ctx: CanvasRenderingContext2D, fillColor: string /* , erase: boolean */) => { @@ -20,7 +14,7 @@ export class BrushHandler { ctx.closePath(); }; - static createBrushPathOverlay = (startPoint: Point, endPoint: Point, brushRadius: number, ctx: CanvasRenderingContext2D, fillColor: string, brushType: BrushType) => { + static createBrushPathOverlay = (startPoint: Point, endPoint: Point, brushRadius: number, ctx: CanvasRenderingContext2D, fillColor: string) => { const dist = GenerativeFillMathHelpers.distanceBetween(startPoint, endPoint); const pts: Point[] = []; for (let i = 0; i < dist; i += 5) { diff --git a/src/client/views/nodes/imageEditor/imageEditorUtils/imageEditorConstants.ts b/src/client/views/nodes/imageEditor/imageEditorUtils/imageEditorConstants.ts index 4772304bc..594d6d9fc 100644 --- a/src/client/views/nodes/imageEditor/imageEditorUtils/imageEditorConstants.ts +++ b/src/client/views/nodes/imageEditor/imageEditorUtils/imageEditorConstants.ts @@ -3,6 +3,7 @@ export const freeformRenderSize = 300; export const offsetDistanceY = freeformRenderSize + 400; export const offsetX = 200; export const newCollectionSize = 500; +export const brushWidthOffset = 10; export const activeColor = '#1976d2'; export const eraserColor = '#e1e9ec'; |
