line to polygon시 길이 안맞는 현상 수정

This commit is contained in:
hyojun.choi 2024-10-29 10:13:16 +09:00
parent 09abb897ac
commit b362ba8b63
2 changed files with 3 additions and 5 deletions

View File

@ -21,9 +21,7 @@ export const QLine = fabric.util.createClass(fabric.Line, {
}
this.line = this
// 소수점 전부 제거
points.forEach((point) => {
point = Math.round(point)
})
points = points.map((point) => Math.round(point))
this.idx = options.idx ?? 0
this.direction = options.direction ?? getDirectionByPoint({ x: this.x1, y: this.y1 }, { x: this.x2, y: this.y2 })

View File

@ -24,8 +24,8 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
initialize: function (points, options, canvas) {
// 소수점 전부 제거
points.forEach((point) => {
point.x = Math.round(point.x)
point.y = Math.round(point.y)
point.x = Number(point.x.toFixed(1))
point.y = Number(point.y.toFixed(1))
})
options.selectable = options.selectable ?? true
options.sort = options.sort ?? true