diff --git a/README.md b/README.md
index 69ed67c8..916119e2 100644
--- a/README.md
+++ b/README.md
@@ -12,4 +12,4 @@
### type4
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/components/Roof2.jsx b/src/components/Roof2.jsx
index 4acc9712..496d6639 100644
--- a/src/components/Roof2.jsx
+++ b/src/components/Roof2.jsx
@@ -4,13 +4,19 @@ import { Mode, useMode } from '@/hooks/useMode'
import QRect from '@/components/fabric/QRect'
import QLine from '@/components/fabric/QLine'
import QPolygon from '@/components/fabric/QPolygon'
+import QPolygon2 from '@/components/fabric/QPolygon2'
import RangeSlider from './ui/RangeSlider'
import { useRecoilState } from 'recoil'
import { fontSizeState, canvasSizeState } from '@/store/canvasAtom'
export default function Roof2() {
- const { canvas, handleRedo, handleUndo, setCanvasBackgroundWithDots } =
- useCanvas('canvas')
+ const {
+ canvas,
+ handleRedo,
+ handleUndo,
+ setCanvasBackgroundWithDots,
+ saveImage,
+ } = useCanvas('canvas')
//canvas 기본 사이즈
const [canvasSize, setCanvasSize] = useRecoilState(canvasSizeState)
@@ -86,6 +92,9 @@ export default function Roof2() {
)
canvas?.add(polygon)
+ console.log(polygon)
+
+ // polygon.fillCell({ width: 50, height: 30, padding: 10 })
}
}
@@ -112,6 +121,70 @@ export default function Roof2() {
canvasSizeMode()
}, [verticalSize, horizontalSize])
+ const addPolygonType1 = () => {
+ if (canvas) {
+ const polygon = new QPolygon(
+ [
+ { x: 100, y: 100 },
+ { x: 800, y: 100 },
+ { x: 800, y: 800 },
+ { x: 500, y: 800 },
+ { x: 500, y: 400 },
+ { x: 100, y: 400 },
+ ],
+ {
+ fill: 'transparent',
+ stroke: 'black',
+ strokeWidth: 2,
+ selectable: true,
+ fontSize: fontSize,
+ },
+ )
+
+ canvas?.add(polygon)
+
+ polygon.fillCell({ width: 20, height: 20, padding: 10 })
+ }
+ }
+
+ const rotate = () => {
+ const rect = canvas?.getObjects().find((obj) => obj.type === 'QRect')
+ if (!rect) {
+ alert('사각형을 먼저 만들어주세요.')
+ return
+ }
+ const angle = prompt('각도를 입력해주세요.', '0')
+ if (rect) {
+ rect.angle = parseInt(angle)
+ canvas?.renderAll()
+ }
+ }
+
+ const makeQPolygon2 = () => {
+ if (canvas) {
+ const polygon2 = new QPolygon2(
+ [
+ { x: 100, y: 100 },
+ { x: 800, y: 100 },
+ { x: 800, y: 800 },
+ { x: 500, y: 800 },
+ { x: 500, y: 400 },
+ { x: 100, y: 400 },
+ ],
+ {
+ fill: 'transparent',
+ stroke: 'black',
+ strokeWidth: 2,
+ selectable: true,
+ fontSize: fontSize,
+ },
+ canvas,
+ )
+
+ canvas?.add(polygon2)
+ }
+ }
+
return (
<>
{canvas && (
@@ -230,6 +303,34 @@ export default function Roof2() {
>
점선 추가
+
+
+
+