Merge branch 'feature/test' of https://git.jetbrains.space/nalpari/q-cast-iii/qcast-front into feature/test

This commit is contained in:
yoosangwook 2024-07-17 13:54:03 +09:00
commit dbd58d9eca

View File

@ -199,6 +199,32 @@ export default class QPolygon extends fabric.Group {
this.canvas.renderAll()
}
/**
* this.lines의 direction이 top line의 모든 합이 bottom line의 모든 합과 같은지 확인
* this.lines의 direction이 left line의 모든 합이 right line의 모든 합과 같은지 확인
* return {boolean}
*/
isValid() {
const leftLinesLengthSum = this.lines
.filter((line) => line.direction === 'left')
.reduce((sum, line) => sum + line.length, 0)
const rightLinesLengthSum = this.lines
.filter((line) => line.direction === 'right')
.reduce((sum, line) => sum + line.length, 0)
const topLinesLengthSum = this.lines
.filter((line) => line.direction === 'top')
.reduce((sum, line) => sum + line.length, 0)
const bottomLinesLengthSum = this.lines
.filter((line) => line.direction === 'bottom')
.reduce((sum, line) => sum + line.length, 0)
return (
leftLinesLengthSum === rightLinesLengthSum &&
topLinesLengthSum === bottomLinesLengthSum
)
}
inPolygon(point) {
const vertices = this.getCurrentPoints()
let intersects = 0
@ -302,6 +328,10 @@ export default class QPolygon extends fabric.Group {
// 보조선 그리기 사각형에서만
drawHelpLine(chon = 4) {
if (!this.isValid()) {
return
}
if (this.lines.length === 4) {
this.#drawHelpLineInRect(chon)
} else if (this.lines.length === 6) {