refactor: 라인4개 케이스 계산 추가

징글징글
This commit is contained in:
nalpari 2024-07-05 13:42:01 +09:00
parent d8379dcfa2
commit 20f8c30bd5

View File

@ -490,7 +490,14 @@ export function useMode() {
// 다름 라인이 오른쪽으로 이동
if (historyLines.current[i].direction === 'top') {
if (prev.direction !== 'right') {
if (historyLines.current.length === 6) {
if (historyLines.current.length === 4) {
newOuterlines.push({
x1: historyLines.current[i].x1 - 50,
y1: historyLines.current[i].y1 + 50,
x2: historyLines.current[i].x2 - 50,
y2: historyLines.current[i].y2 - 50,
})
} else if (historyLines.current.length === 6) {
newOuterlines.push({
x1: historyLines.current[i].x1 - 50,
y1: historyLines.current[i].y1 + 50,
@ -516,7 +523,14 @@ export function useMode() {
} else {
// bottom
if (prev?.direction !== 'right') {
if (historyLines.current.length === 6) {
if (historyLines.current.length === 4) {
newOuterlines.push({
x1: historyLines.current[i].x1 - 50,
y1: historyLines.current[i].y1 - 50,
x2: historyLines.current[i].x2 - 50,
y2: historyLines.current[i].y2 + 50,
})
} else if (historyLines.current.length === 6) {
newOuterlines.push({
x1: historyLines.current[i].x1 - 50,
y1: historyLines.current[i].y1 - 50,
@ -543,7 +557,14 @@ export function useMode() {
} else if (next.direction === 'left') {
if (historyLines.current[i].direction === 'top') {
if (prev?.direction !== 'left') {
if (historyLines.current.length === 6) {
if (historyLines.current.length === 4) {
newOuterlines.push({
x1: historyLines.current[i].x1 + 50,
y1: historyLines.current[i].y1 + 50,
x2: historyLines.current[i].x2 + 50,
y2: historyLines.current[i].y2 - 50,
})
} else if (historyLines.current.length === 6) {
newOuterlines.push({
x1: historyLines.current[i].x1 + 50,
y1: historyLines.current[i].y1 + 50,
@ -569,7 +590,14 @@ export function useMode() {
} else {
// bottom
if (prev?.direction !== 'left') {
if (historyLines.current.length === 6) {
if (historyLines.current.length === 4) {
newOuterlines.push({
x1: historyLines.current[i].x1 + 50,
y1: historyLines.current[i].y1 - 50,
x2: historyLines.current[i].x2 + 50,
y2: historyLines.current[i].y2 + 50,
})
} else if (historyLines.current.length === 6) {
newOuterlines.push({
x1: historyLines.current[i].x1 + 50,
y1: historyLines.current[i].y1 - 50,
@ -596,7 +624,14 @@ export function useMode() {
} else if (next.direction === 'top') {
if (historyLines.current[i].direction === 'right') {
if (prev?.direction !== 'top') {
if (historyLines.current.length === 6) {
if (historyLines.current.length === 4) {
newOuterlines.push({
x1: historyLines.current[i].x1 - 50,
y1: historyLines.current[i].y1 + 50,
x2: historyLines.current[i].x2 + 50,
y2: historyLines.current[i].y2 + 50,
})
} else if (historyLines.current.length === 6) {
newOuterlines.push({
x1: historyLines.current[i].x1 - 50,
y1: historyLines.current[i].y1 + 50,
@ -622,7 +657,14 @@ export function useMode() {
} else {
// left
if (prev?.direction !== 'top') {
if (historyLines.current.length === 6) {
if (historyLines.current.length === 4) {
newOuterlines.push({
x1: historyLines.current[i].x1 + 50,
y1: historyLines.current[i].y1 + 50,
x2: historyLines.current[i].x2 - 50,
y2: historyLines.current[i].y2 + 50,
})
} else if (historyLines.current.length === 6) {
newOuterlines.push({
x1: historyLines.current[i].x1 + 50,
y1: historyLines.current[i].y1 + 50,
@ -649,7 +691,14 @@ export function useMode() {
} else if (next.direction === 'bottom') {
if (historyLines.current[i].direction === 'right') {
if (prev?.direction !== 'bottom') {
if (historyLines.current.length === 6) {
if (historyLines.current.length === 4) {
newOuterlines.push({
x1: historyLines.current[i].x1 - 50,
y1: historyLines.current[i].y1 - 50,
x2: historyLines.current[i].x2 + 50,
y2: historyLines.current[i].y2 - 50,
})
} else if (historyLines.current.length === 6) {
newOuterlines.push({
x1: historyLines.current[i].x1 - 50,
y1: historyLines.current[i].y1 - 50,
@ -675,7 +724,14 @@ export function useMode() {
} else {
// left
if (prev.direction !== 'bottom') {
if (historyLines.current.length === 6) {
if (historyLines.current.length === 4) {
newOuterlines.push({
x1: historyLines.current[i].x1 + 50,
y1: historyLines.current[i].y1 - 50,
x2: historyLines.current[i].x2 - 50,
y2: historyLines.current[i].y2 - 50,
})
} else if (historyLines.current.length === 6) {
newOuterlines.push({
x1: historyLines.current[i].x1 + 50,
y1: historyLines.current[i].y1 - 50,
@ -711,6 +767,7 @@ export function useMode() {
}
}
console.log(newOuterlines)
makePolygon(newOuterlines)
}