점 8개 오류
This commit is contained in:
parent
e34f3c002a
commit
ae5009ba2b
@ -38,7 +38,7 @@ export function actionHandler(eventData, transform, x, y) {
|
|||||||
|
|
||||||
// define a function that can keep the polygon in the same position when we change its width/height/top/left
|
// define a function that can keep the polygon in the same position when we change its width/height/top/left
|
||||||
export function anchorWrapper(anchorIndex, fn) {
|
export function anchorWrapper(anchorIndex, fn) {
|
||||||
return function(eventData, transform, x, y) {
|
return function (eventData, transform, x, y) {
|
||||||
let fabricObject = transform.target
|
let fabricObject = transform.target
|
||||||
let originX = fabricObject?.points[anchorIndex].x - fabricObject.pathOffset.x
|
let originX = fabricObject?.points[anchorIndex].x - fabricObject.pathOffset.x
|
||||||
let originY = fabricObject.points[anchorIndex].y - fabricObject.pathOffset.y
|
let originY = fabricObject.points[anchorIndex].y - fabricObject.pathOffset.y
|
||||||
@ -365,11 +365,11 @@ export const sortedPoints = (points) => {
|
|||||||
for (let i = 0; i < copyPoints.length; i++) {
|
for (let i = 0; i < copyPoints.length; i++) {
|
||||||
// y값이 같은 point가 많은 경우 그 중 x값이 가장 큰걸 찾는다.
|
// y값이 같은 point가 많은 경우 그 중 x값이 가장 큰걸 찾는다.
|
||||||
const temp = copyPoints.filter((point) => point.y === currentPoint.y)
|
const temp = copyPoints.filter((point) => point.y === currentPoint.y)
|
||||||
// temp중 x값이 가장 큰 값
|
// temp중 x값이 가장 큰 값 copyPoint보다 큰값
|
||||||
const max = temp.reduce((prev, current) => (prev.x >= current.x ? prev : current))
|
const min = temp.reduce((prev, current) => (prev.x <= current.x ? prev : current))
|
||||||
resultPoints.push(max)
|
resultPoints.push(min)
|
||||||
currentPoint = max
|
currentPoint = min
|
||||||
copyPoints.splice(copyPoints.indexOf(max), 1)
|
copyPoints.splice(copyPoints.indexOf(min), 1)
|
||||||
index++
|
index++
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -378,12 +378,12 @@ export const sortedPoints = (points) => {
|
|||||||
for (let i = 0; i < copyPoints.length; i++) {
|
for (let i = 0; i < copyPoints.length; i++) {
|
||||||
// x값이 같은 point가 많은 경우 그 중 y값이 가장 큰걸 찾는다.
|
// x값이 같은 point가 많은 경우 그 중 y값이 가장 큰걸 찾는다.
|
||||||
const temp = copyPoints.filter((point) => point.x === currentPoint.x)
|
const temp = copyPoints.filter((point) => point.x === currentPoint.x)
|
||||||
// temp중 y값이 가장 큰 값
|
// temp중 y값이 가장 작은 값
|
||||||
const max = temp.reduce((prev, current) => (prev.y >= current.y ? prev : current))
|
const min = temp.reduce((prev, current) => (prev.y <= current.y ? prev : current))
|
||||||
|
|
||||||
resultPoints.push(max)
|
resultPoints.push(min)
|
||||||
currentPoint = max
|
currentPoint = min
|
||||||
copyPoints.splice(copyPoints.indexOf(max), 1)
|
copyPoints.splice(copyPoints.indexOf(min), 1)
|
||||||
index++
|
index++
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -447,4 +447,4 @@ export function calculateDistance(point, line) {
|
|||||||
const numerator = Math.abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1)
|
const numerator = Math.abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1)
|
||||||
const denominator = Math.sqrt(Math.pow(y2 - y1, 2) + Math.pow(x2 - x1, 2))
|
const denominator = Math.sqrt(Math.pow(y2 - y1, 2) + Math.pow(x2 - x1, 2))
|
||||||
return numerator / denominator
|
return numerator / denominator
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user