- After changing the resolution, the canvas background image will reset.
+ Changing the canvas size.
diff --git a/src/components/CanvasSetting.jsx b/src/components/CanvasSetting.jsx
index 4d4211a..6f0cefe 100644
--- a/src/components/CanvasSetting.jsx
+++ b/src/components/CanvasSetting.jsx
@@ -29,13 +29,37 @@ const CanvasSetting = () => {
[key]: value,
}));
- // Use the value directly for canvas updates
+ // Update canvas dimensions
if (key === 'width') {
- canvas.setWidth(value);
+ canvas.setWidth(value); // Update canvas width
} else if (key === 'height') {
- canvas.setHeight(value);
+ canvas.setHeight(value); // Update canvas height
+ }
+
+ // Adjust the background image to fit the updated canvas
+ const bgImage = canvas.backgroundImage;
+ if (bgImage) {
+ const canvasWidth = canvas.width;
+ const canvasHeight = canvas.height;
+
+ // Calculate scaling factors for width and height
+ const scaleX = canvasWidth / bgImage.width;
+ const scaleY = canvasHeight / bgImage.height;
+
+ // Choose the larger scale to cover the entire canvas
+ const scale = Math.max(scaleX, scaleY);
+
+ // Apply the scale and center the image
+ bgImage.scaleX = scale;
+ bgImage.scaleY = scale;
+ bgImage.left = 0; // Align left
+ bgImage.top = 0; // Align top
+
+ // Mark the background image as needing an update
+ canvas.setBackgroundImage(bgImage, canvas.renderAll.bind(canvas));
+ } else {
+ canvas.renderAll(); // Render if no background image
}
- canvas.renderAll();
};
const setBackgroundImage = (e) => {
diff --git a/src/components/EachComponent/Icons/AllIcons.jsx b/src/components/EachComponent/Icons/AllIcons.jsx
index aaaad89..ae7d45f 100644
--- a/src/components/EachComponent/Icons/AllIcons.jsx
+++ b/src/components/EachComponent/Icons/AllIcons.jsx
@@ -1,6 +1,6 @@
import { useContext, useState } from "react";
import { FixedSizeGrid as Grid } from "react-window";
-import { Card, CardTitle } from "@/components/ui/card";
+import { Card, CardDescription, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import * as lucideIcons from "lucide-react";
import CanvasContext from "@/components/Context/canvasContext/CanvasContext";
@@ -107,6 +107,7 @@ const AllIconsPage = () => {
return (