지붕 외곽선 자동 그려주기 - 디버깅중

This commit is contained in:
yoosangwook 2024-07-01 14:26:31 +09:00
parent 8a9d95cd1b
commit 5adf049095

View File

@ -400,76 +400,150 @@ export function useMode() {
const handleOuterlines = () => { const handleOuterlines = () => {
const newOuterlines = [] const newOuterlines = []
for (let i = 0; i < historyLines.current.length; i++) { for (let i = 0; i < historyLines.current.length; i++) {
const tmp = historyLines.current[i + 1] const next = historyLines.current[i + 1]
if (tmp !== undefined) { const prev = historyLines.current[i - 1] ?? historyLines.current[historyLines.current.length - 1]
if (tmp.direction === 'right') { if (next) {
if (next.direction === 'right') {
// 다름 라인이 오른쪽으로 이동 // 다름 라인이 오른쪽으로 이동
if (historyLines.current[i].direction === 'top') { if (historyLines.current[i].direction === 'top') {
newOuterlines.push({ if(prev.direction !== 'right') {
x1: historyLines.current[i].x1 - 50, newOuterlines.push({
y1: historyLines.current[i].y1 + 50, x1: historyLines.current[i].x1 + 50,
x2: historyLines.current[i].x2 - 50, y1: historyLines.current[i].y1 - 50,
y2: historyLines.current[i].y2 - 50, x2: historyLines.current[i].x2 + 50,
}) y2: historyLines.current[i].y2 + 50,
})
} else {
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 { } else {
// bottom // bottom
newOuterlines.push({ if(prev?.direction !== 'right') {
x1: historyLines.current[i].x1 - 50, newOuterlines.push({
y1: historyLines.current[i].y1 - 50, x1: historyLines.current[i].x1 - 50,
x2: historyLines.current[i].x2 - 50, y1: historyLines.current[i].y1 - 50,
y2: historyLines.current[i].y2 + 50, x2: historyLines.current[i].x2 + 50,
}) y2: historyLines.current[i].y2 + 50,
})
} else {
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 (tmp.direction === 'left') { } else if (next.direction === 'left') {
if (historyLines.current[i].direction === 'top') { if (historyLines.current[i].direction === 'top') {
newOuterlines.push({ if(prev?.direction !== 'left') {
x1: historyLines.current[i].x1 + 50, newOuterlines.push({
y1: historyLines.current[i].y1 + 50, x1: historyLines.current[i].x1 + 50,
x2: historyLines.current[i].x2 + 50, y1: historyLines.current[i].y1 + 50,
y2: historyLines.current[i].y2 - 50, x2: historyLines.current[i].x2 + 50,
}) y2: historyLines.current[i].y2 - 50,
})
} else {
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 { } else {
// bottom // bottom
newOuterlines.push({ if(prev?.direction !== 'left') {
x1: historyLines.current[i].x1 + 50, newOuterlines.push({
y1: historyLines.current[i].y1 - 50, x1: historyLines.current[i].x1 + 50,
x2: historyLines.current[i].x2 + 50, y1: historyLines.current[i].y1 - 50,
y2: historyLines.current[i].y2 + 50, x2: historyLines.current[i].x2 + 50,
}) y2: historyLines.current[i].y2 + 50,
})
} else {
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 (tmp.direction === 'top') { } else if (next.direction === 'top') {
if (historyLines.current[i].direction === 'right') { if (historyLines.current[i].direction === 'right') {
newOuterlines.push({ if(prev?.direction !== 'top') {
x1: historyLines.current[i].x1 - 50, newOuterlines.push({
y1: historyLines.current[i].y1 + 50, x1: historyLines.current[i].x1 - 50,
x2: historyLines.current[i].x2 + 50, y1: historyLines.current[i].y1 + 50,
y2: historyLines.current[i].y2 + 50, x2: historyLines.current[i].x2 + 50,
}) y2: historyLines.current[i].y2 + 50,
})
} else {
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 { } else {
// left // left
newOuterlines.push({ if(prev?.direction !== 'top') {
x1: historyLines.current[i].x1 + 50, newOuterlines.push({
y1: historyLines.current[i].y1 + 50, x1: historyLines.current[i].x1 - 50,
x2: historyLines.current[i].x2 - 50, y1: historyLines.current[i].y1 - 50,
y2: historyLines.current[i].y2 + 50, x2: historyLines.current[i].x2 + 50,
}) y2: historyLines.current[i].y2 - 50,
})
} else {
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 (tmp.direction === 'bottom') { } else if (next.direction === 'bottom') {
if (historyLines.current[i].direction === 'right') { if (historyLines.current[i].direction === 'right') {
newOuterlines.push({ if(prev?.direction !== 'bottom') {
x1: historyLines.current[i].x1 - 50, newOuterlines.push({
y1: historyLines.current[i].y1 - 50, x1: historyLines.current[i].x1 - 50,
x2: historyLines.current[i].x2 + 50, y1: historyLines.current[i].y1 - 50,
y2: historyLines.current[i].y2 - 50, x2: historyLines.current[i].x2 + 50,
}) y2: historyLines.current[i].y2 - 50,
})
} else {
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 { } else {
// left // left
newOuterlines.push({ if(prev.direction !== 'bottom') {
x1: historyLines.current[i].x1 + 50, newOuterlines.push({
y1: historyLines.current[i].y1 - 50, x1: historyLines.current[i].x1 + 50,
x2: historyLines.current[i].x2 - 50, y1: historyLines.current[i].y1 + 50,
y2: historyLines.current[i].y2 - 50, x2: historyLines.current[i].x2 - 50,
}) y2: historyLines.current[i].y2 + 50,
})
} else {
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 { } else {