[1267] 500에러 - str => Number 변환 #289
@ -17,7 +17,7 @@ export const QLine = fabric.util.createClass(fabric.Line, {
|
|||||||
initialize: function (points, options, length = 0) {
|
initialize: function (points, options, length = 0) {
|
||||||
// 소수점 전부 제거
|
// 소수점 전부 제거
|
||||||
|
|
||||||
points = points.map((point) => Number(point?.toFixed(1)))
|
points = points.map((point) => Number(point).toFixed(1))
|
||||||
|
|
||||||
this.callSuper('initialize', points, { ...options, selectable: options.selectable ?? true })
|
this.callSuper('initialize', points, { ...options, selectable: options.selectable ?? true })
|
||||||
if (options.id) {
|
if (options.id) {
|
||||||
|
|||||||
@ -710,14 +710,14 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
|
|||||||
inPolygonImproved(point) {
|
inPolygonImproved(point) {
|
||||||
const vertices = this.points
|
const vertices = this.points
|
||||||
let inside = false
|
let inside = false
|
||||||
const testX = Number(point.x.toFixed(this.toFixed))
|
const testX = Number(point.x).toFixed(this.toFixed)
|
||||||
const testY = Number(point.y.toFixed(this.toFixed))
|
const testY = Number(point.y).toFixed(this.toFixed)
|
||||||
|
|
||||||
for (let i = 0, j = vertices.length - 1; i < vertices.length; j = i++) {
|
for (let i = 0, j = vertices.length - 1; i < vertices.length; j = i++) {
|
||||||
const xi = Number(vertices[i].x.toFixed(this.toFixed))
|
const xi = Number(vertices[i].x).toFixed(this.toFixed)
|
||||||
const yi = Number(vertices[i].y.toFixed(this.toFixed))
|
const yi = Number(vertices[i].y).toFixed(this.toFixed)
|
||||||
const xj = Number(vertices[j].x.toFixed(this.toFixed))
|
const xj = Number(vertices[j].x).toFixed(this.toFixed)
|
||||||
const yj = Number(vertices[j].y.toFixed(this.toFixed))
|
const yj = Number(vertices[j].y).toFixed(this.toFixed)
|
||||||
|
|
||||||
// 점이 정점 위에 있는지 확인
|
// 점이 정점 위에 있는지 확인
|
||||||
if (Math.abs(xi - testX) < 0.01 && Math.abs(yi - testY) < 0.01) {
|
if (Math.abs(xi - testX) < 0.01 && Math.abs(yi - testY) < 0.01) {
|
||||||
|
|||||||
@ -342,6 +342,14 @@ export const findIntersection1 = (line1, line2) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const calculateIntersection = (line1, line2) => {
|
export const calculateIntersection = (line1, line2) => {
|
||||||
|
line1.x1 = Number(line1.x1)
|
||||||
|
line1.y1 = Number(line1.y1)
|
||||||
|
line1.x2 = Number(line1.x2)
|
||||||
|
line1.y2 = Number(line1.y2)
|
||||||
|
line2.x1 = Number(line2.x1)
|
||||||
|
line2.y1 = Number(line2.y1)
|
||||||
|
line2.x2 = Number(line2.x2)
|
||||||
|
line2.y2 = Number(line2.y2)
|
||||||
const result = intersect([line1.x1, line1.y1], [line1.x2, line1.y2], [line2.x1, line2.y1], [line2.x2, line2.y2])
|
const result = intersect([line1.x1, line1.y1], [line1.x2, line1.y2], [line2.x1, line2.y1], [line2.x2, line2.y2])
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return null
|
return null
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user