diff --git a/next.config.mjs b/next.config.mjs index 107c5460..8cc4c040 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,6 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - // reactStrictMode: false, + reactStrictMode: false, webpack: (config) => { config.externals.push({ "utf-8-validate": "commonjs utf-8-validate", diff --git a/src/app/error.jsx b/src/app/error.jsx new file mode 100644 index 00000000..07d75e7e --- /dev/null +++ b/src/app/error.jsx @@ -0,0 +1,15 @@ +'use client' + +export default function ServerError() { + return ( +
+
+
+

500

+

Internal Server Error.

+

We are already working to solve the problem.

+
+
+
+ ) +} diff --git a/src/app/not-found.jsx b/src/app/not-found.jsx new file mode 100644 index 00000000..8127943b --- /dev/null +++ b/src/app/not-found.jsx @@ -0,0 +1,25 @@ +'use client' + +import Link from 'next/link' + +export default function NotFound() { + return ( +
+
+
+

404

+

Something's missing.

+

+ Sorry, we can't find that page. You'll find lots to explore on the home page.{' '} +

+ + Back to Homepage + +
+
+
+ ) +} diff --git a/src/components/Roof2.jsx b/src/components/Roof2.jsx index fa730830..76a64e93 100644 --- a/src/components/Roof2.jsx +++ b/src/components/Roof2.jsx @@ -5,11 +5,11 @@ import { Button } from '@nextui-org/react' import QRect from '@/components/fabric/QRect' import RangeSlider from './ui/RangeSlider' -import { useRecoilState } from 'recoil' -import { canvasSizeState, fontSizeState, sortedPolygonArray } from '@/store/canvasAtom' +import { useRecoilState, useRecoilValue } from 'recoil' +import { canvasSizeState, fontSizeState, roofState, sortedPolygonArray } from '@/store/canvasAtom' import { QLine } from '@/components/fabric/QLine' import { getCanvasState, insertCanvasState } from '@/lib/canvas' -import { calculateIntersection2 } from '@/util/canvas-util' +import { calculateIntersection } from '@/util/canvas-util' import { QPolygon } from '@/components/fabric/QPolygon' export default function Roof2() { @@ -107,28 +107,24 @@ export default function Roof2() { } } - /** - * canvas 사이즈 변경 함수 - */ - const canvasSizeMode = () => { - if (canvas) { - canvas.setWidth(horizontalSize) - canvas.setHeight(verticalSize) - canvas.renderAll() - - setCanvasSize(() => ({ - vertical: verticalSize, - horizontal: horizontalSize, - })) - } - } + useEffect(() => { + setCanvasSize({ ...canvasSize, vertical: verticalSize, horizontal: horizontalSize }) + }, [verticalSize, horizontalSize]) /** * 값 변경시 */ + // useEffect(() => { + // canvasSizeMode() + // }, [verticalSize, horizontalSize]) useEffect(() => { - canvasSizeMode() - }, [verticalSize, horizontalSize]) + const { vertical, horizontal } = canvasSize + if (vertical !== verticalSize || horizontal !== horizontalSize) { + canvas.setWidth(horizontalSize) + canvas.setHeight(verticalSize) + canvas.renderAll() + } + }, [canvasSize, canvas]) const makeQPolygon = () => { const type1 = [ @@ -207,14 +203,14 @@ export default function Roof2() { ] const eightPoint3 = [ - { x: 200, y: 200 }, - { x: 200, y: 1000 }, - { x: 1000, y: 1000 }, - { x: 1000, y: 800 }, - { x: 600, y: 800 }, - { x: 600, y: 350 }, - { x: 1000, y: 350 }, - { x: 1000, y: 200 }, + { x: 190, y: 147 }, + { x: 190, y: 747 }, + { x: 490, y: 747 }, + { x: 490, y: 497 }, + { x: 640, y: 497 }, + { x: 640, y: 747 }, + { x: 1090, y: 747 }, + { x: 1090, y: 147 }, ] const eightPoint4 = [ @@ -270,25 +266,39 @@ export default function Roof2() { { x: 300, y: 100 }, ] - if (canvas) { - const polygon = new QPolygon(diagonalType, { - // const polygon = new QPolygon(eightPoint, { - fill: 'transparent', - stroke: 'green', - strokeWidth: 1, - selectable: true, - fontSize: fontSize, - name: 'QPolygon1', - }) + const twelvePoint = [ + { x: 195, y: 166 }, + { x: 195, y: 466 }, + { x: 395, y: 466 }, + { x: 395, y: 766 }, + { x: 545, y: 766 }, + { x: 545, y: 466 }, + { x: 695, y: 466 }, + { x: 695, y: 666 }, + { x: 845, y: 666 }, + { x: 845, y: 466 }, + { x: 995, y: 466 }, + { x: 995, y: 166 }, + ] + + const types = [type1, type2, type3, type4, type1A, type1B, eightPoint, eightPoint2, eightPoint3, eightPoint4, twelvePoint] + + const polygon = new QPolygon(type1B, { + fill: 'transparent', + stroke: 'black', + strokeWidth: 1, + selectable: true, + fontSize: fontSize, + name: 'QPolygon1', + }) canvas?.add(polygon) drawRoofPolygon(polygon) // handleOuterlinesTest2(polygon) - // const lines = togglePolygonLine(polygon) - // togglePolygonLine(lines[0]) - } + // const lines = togglePolygonLine(polygon) + // togglePolygonLine(lines[0]) } const rotateShape = () => { @@ -321,7 +331,7 @@ export default function Roof2() { canvas?.add(line) canvas?.add(line2) - const interSectionPoint = calculateIntersection2(line, line2) + const interSectionPoint = calculateIntersection(line, line2) if (interSectionPoint) { const circle = new fabric.Circle({ @@ -429,8 +439,12 @@ export default function Roof2() { -