diff --git a/dist/index.html b/dist/index.html
index d03278a..1e38d81 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -5,7 +5,7 @@
furniture-app
-
+
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsx
index c031499..565131c 100644
--- a/src/components/ControlPanel.tsx
+++ b/src/components/ControlPanel.tsx
@@ -308,11 +308,23 @@ export function ControlPanel({
diff --git a/src/components/RoomCanvas.tsx b/src/components/RoomCanvas.tsx
index 75986ad..f0eeb4a 100644
--- a/src/components/RoomCanvas.tsx
+++ b/src/components/RoomCanvas.tsx
@@ -33,6 +33,38 @@ export function RoomCanvas({ state, onStateChange, mode, selectedId, onSelect, s
return () => clearInterval(t);
}, [showPaths]);
+ const [viewport, setViewport] = useState({ width: 1200, height: 800 });
+ const containerRef = useRef(null);
+
+ useEffect(() => {
+ const resize = () => {
+ if (containerRef.current) {
+ setViewport({
+ width: Math.floor(containerRef.current.clientWidth),
+ height: Math.floor(containerRef.current.clientHeight),
+ });
+ }
+ };
+ resize();
+ window.addEventListener('resize', resize);
+ return () => window.removeEventListener('resize', resize);
+ }, []);
+
+ useEffect(() => {
+ const canvas = canvasRef.current;
+ if (!canvas) return;
+ const dpr = Math.max(1, window.devicePixelRatio || 1);
+ const baseW = Math.min(state.room.width, viewport.width || state.room.width);
+ const baseH = Math.min(state.room.height, viewport.height || state.room.height);
+ canvas.style.width = `${baseW}px`;
+ canvas.style.height = `${baseH}px`;
+ canvas.width = baseW * dpr;
+ canvas.height = baseH * dpr;
+ const ctx = canvas.getContext('2d');
+ if (ctx) ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
+ draw();
+ }, [state.room.width, state.room.height, zoom, viewport]);
+
useEffect(() => {
draw();
}, [state, selectedId, mode, zoom, showPaths, phase]);
@@ -42,9 +74,14 @@ export function RoomCanvas({ state, onStateChange, mode, selectedId, onSelect, s
if (!canvas) return;
const ctx = canvas.getContext('2d');
if (!ctx) return;
- ctx.clearRect(0, 0, canvas.width, canvas.height);
+ const dpr = Math.max(1, window.devicePixelRatio || 1);
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
+ ctx.clearRect(0, 0, canvas.width / dpr, canvas.height / dpr);
ctx.save();
- ctx.scale(zoom, zoom);
+ const scaleX = (canvas.width / dpr) / state.room.width;
+ const scaleY = (canvas.height / dpr) / state.room.height;
+ const s = Math.min(scaleX, scaleY);
+ ctx.scale(s, s);
ctx.fillStyle = '#12151b';
ctx.fillRect(0, 0, state.room.width, state.room.height);
@@ -308,17 +345,19 @@ export function RoomCanvas({ state, onStateChange, mode, selectedId, onSelect, s
};
return (
-
+
+
+
);
}