suisuyy commited on
Commit
7df968b
·
1 Parent(s): 387a205

Update image rendering in AiEditModal and hooks to draw at top-left corner; adjust text area size for better usability

Browse files
components/AiEditModal.tsx CHANGED
@@ -49,7 +49,7 @@ const AiEditModal: React.FC<AiEditModalProps> = ({
49
  <img
50
  src={imageUrl}
51
  alt="Uploaded image preview"
52
- className="max-w-full h-auto max-h-48 rounded border border-slate-300 object-contain mx-auto"
53
  />
54
  </div>
55
 
@@ -63,7 +63,7 @@ const AiEditModal: React.FC<AiEditModalProps> = ({
63
  onChange={(e) => onPromptChange(e.target.value)}
64
  placeholder="e.g., 'make the cat wear a party hat', 'change background to a beach'"
65
  rows={3}
66
- className="w-full p-2 border border-slate-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-shadow text-sm"
67
  disabled={isLoading}
68
  aria-describedby={error ? "ai-edit-error" : undefined}
69
  />
 
49
  <img
50
  src={imageUrl}
51
  alt="Uploaded image preview"
52
+ className="w-auto h-40 rounded border border-slate-300 object-contain mx-auto"
53
  />
54
  </div>
55
 
 
63
  onChange={(e) => onPromptChange(e.target.value)}
64
  placeholder="e.g., 'make the cat wear a party hat', 'change background to a beach'"
65
  rows={3}
66
+ className="w-full p-2 border border-slate-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-shadow text-xl"
67
  disabled={isLoading}
68
  aria-describedby={error ? "ai-edit-error" : undefined}
69
  />
hooks/useAiFeatures.ts CHANGED
@@ -81,9 +81,9 @@ export const useAiFeatures = ({
81
  drawWidth = Math.max(1, Math.floor(drawWidth));
82
  drawHeight = Math.max(1, Math.floor(drawHeight));
83
 
84
- // Calculate coordinates to center the image
85
- const drawX = (currentCanvasWidth - drawWidth) / 2;
86
- const drawY = (currentCanvasHeight - drawHeight) / 2;
87
 
88
  tempCtx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
89
 
@@ -264,4 +264,4 @@ export const useAiFeatures = ({
264
  handleCancelAiEdit,
265
  setAiPrompt,
266
  };
267
- };
 
81
  drawWidth = Math.max(1, Math.floor(drawWidth));
82
  drawHeight = Math.max(1, Math.floor(drawHeight));
83
 
84
+ // Change: Draw image at top-left (0,0)
85
+ const drawX = 0;
86
+ const drawY = 0;
87
 
88
  tempCtx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
89
 
 
264
  handleCancelAiEdit,
265
  setAiPrompt,
266
  };
267
+ };
hooks/useCanvasFileUtils.ts CHANGED
@@ -73,8 +73,9 @@ export const useCanvasFileUtils = ({
73
  tempCtx.fillStyle = '#FFFFFF';
74
  tempCtx.fillRect(0, 0, finalCanvasWidth, finalCanvasHeight);
75
 
76
- const drawX = (finalCanvasWidth - imageToDrawWidth) / 2;
77
- const drawY = (finalCanvasHeight - imageToDrawHeight) / 2;
 
78
 
79
  tempCtx.drawImage(img, drawX, drawY, imageToDrawWidth, imageToDrawHeight);
80
  const compositeDataURL = tempCanvas.toDataURL('image/png');
@@ -140,4 +141,4 @@ export const useCanvasFileUtils = ({
140
  }, [canvasWidth, canvasHeight, requestConfirmation, updateCanvasState, setZoomLevel, showToast]);
141
 
142
  return { handleLoadImageFile, handleExportImage, handleClearCanvas, handleCanvasSizeChange };
143
- };
 
73
  tempCtx.fillStyle = '#FFFFFF';
74
  tempCtx.fillRect(0, 0, finalCanvasWidth, finalCanvasHeight);
75
 
76
+ // Change: Draw image at top-left (0,0)
77
+ const drawX = 0;
78
+ const drawY = 0;
79
 
80
  tempCtx.drawImage(img, drawX, drawY, imageToDrawWidth, imageToDrawHeight);
81
  const compositeDataURL = tempCanvas.toDataURL('image/png');
 
141
  }, [canvasWidth, canvasHeight, requestConfirmation, updateCanvasState, setZoomLevel, showToast]);
142
 
143
  return { handleLoadImageFile, handleExportImage, handleClearCanvas, handleCanvasSizeChange };
144
+ };