import { useEffect, useRef, useState } from "react"; import { Layer, Stage } from "react-konva"; import { Menubar, MenubarContent, MenubarItem, MenubarMenu, MenubarSeparator, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, } from "@/components/ui/menubar"; import ThemeChanger from "./components/menubar/theme-changer"; import Blocks from "./components/blocks"; import Cursor from "./components/cursor"; function App() { const stageContainerRef = useRef(null); const stageRef = useRef(null); const [stageSize, setStageSize] = useState({ width: 0, height: 0, }); const [stageScale, setStageScale] = useState(1); const [stageCoords, setStageCoords] = useState({ x: 0, y: 0 }); const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 }); const onMouseMove = (e) => { const stage = e.target.getStage(); const oldScale = stage.scaleX(); const pointer = stage.getPointerPosition(); setMousePosition({ x: (pointer.x - stage.x()) / oldScale, y: (pointer.y - stage.y()) / oldScale, }); }; const onWheel = (e) => { const stage = e.target.getStage(); const oldScale = stage.scaleX(); const pointer = stage.getPointerPosition(); const newScale = e.evt.deltaY < 0 ? oldScale * 1.05 : oldScale / 1.05; setStageScale(newScale); setStageCoords({ x: pointer.x - mousePosition.x * newScale, y: pointer.y - mousePosition.y * newScale, }); }; useEffect(() => { if (stageContainerRef.current && stageRef.current) { setStageSize({ width: stageContainerRef.current.offsetWidth, height: stageContainerRef.current.offsetHeight, }); } }, []); return (
File Open Schematic Open Image Export to... .schematic .litematic image More
); } export default App;