refactor: 프리티어 적용
This commit is contained in:
parent
5e548210bc
commit
002a895910
@ -2,7 +2,11 @@ import { useEffect, useRef, useState } from 'react'
|
||||
import QLine from '@/components/fabric/QLine'
|
||||
import QRect from '@/components/fabric/QRect'
|
||||
import QPolygon from '@/components/fabric/QPolygon'
|
||||
import { getStartIndex, rearrangeArray, findTopTwoIndexesByDistance } from '@/util/canvas-util'
|
||||
import {
|
||||
getStartIndex,
|
||||
rearrangeArray,
|
||||
findTopTwoIndexesByDistance,
|
||||
} from '@/util/canvas-util'
|
||||
import { useRecoilState } from 'recoil'
|
||||
import { fontSizeState, sortedPolygonArray } from '@/store/canvasAtom'
|
||||
|
||||
@ -383,39 +387,43 @@ export function useMode() {
|
||||
const makePolygon = (otherLines) => {
|
||||
// 캔버스에서 모든 라인 객체를 찾습니다.
|
||||
const lines = otherLines || historyLines.current
|
||||
if (!otherLines) { //외각선 기준
|
||||
if (!otherLines) {
|
||||
//외각선 기준
|
||||
const sortedIndex = getStartIndex(lines)
|
||||
let tmpArraySorted = rearrangeArray(lines, sortedIndex)
|
||||
|
||||
if(tmpArraySorted[0].direction === 'right') { //시계방향
|
||||
|
||||
if (tmpArraySorted[0].direction === 'right') {
|
||||
//시계방향
|
||||
tmpArraySorted = tmpArraySorted.reverse() //그럼 배열을 거꾸로 만들어서 무조건 반시계방향으로 배열 보정
|
||||
|
||||
}
|
||||
|
||||
setSortedArray(tmpArraySorted) //recoil에 넣음
|
||||
const topIndex = findTopTwoIndexesByDistance(tmpArraySorted) //배열중에 큰 2값을 가져옴 TODO: 나중에는 인자로 받아서 다각으로 수정 해야됨
|
||||
|
||||
//일단 배열 6개 짜리 기준의 선 번호
|
||||
if (topIndex[0] === 4) {
|
||||
if (topIndex[1] === 5){ //1번
|
||||
if (topIndex[0] === 4) {
|
||||
if (topIndex[1] === 5) {
|
||||
//1번
|
||||
setShape(1)
|
||||
console.log('shape :: ', 1)
|
||||
}
|
||||
} else if (topIndex[0] === 1) { //4번
|
||||
if (topIndex[1] === 2){
|
||||
}
|
||||
} else if (topIndex[0] === 1) {
|
||||
//4번
|
||||
if (topIndex[1] === 2) {
|
||||
console.log('shape :: ', 4)
|
||||
setShape(4)
|
||||
}
|
||||
}else if (topIndex[0] === 0) {
|
||||
if(topIndex[1] === 1) { //2번
|
||||
}
|
||||
} else if (topIndex[0] === 0) {
|
||||
if (topIndex[1] === 1) {
|
||||
//2번
|
||||
console.log('shape :: ', 2)
|
||||
setShape(2)
|
||||
}else if(topIndex[1] === 5){
|
||||
} else if (topIndex[1] === 5) {
|
||||
console.log('shape :: ', 3)
|
||||
setShape(3)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
historyLines.current = []
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user