add toFixed attribute in QPolygon

This commit is contained in:
hyojun.choi 2025-03-14 17:06:57 +09:00
parent c1ee05138b
commit b57c3fe943
2 changed files with 5 additions and 2 deletions

View File

@ -202,6 +202,7 @@ export const SAVE_KEY = [
'fontStyle',
'fontWeight',
'dormerAttributes',
'toFixed',
]
export const OBJECT_PROTOTYPE = [fabric.Line.prototype, fabric.Polygon.prototype, fabric.Triangle.prototype, fabric.Group.prototype]

View File

@ -23,6 +23,7 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
initOptions: null,
direction: null,
arrow: null,
toFixed: 1,
initialize: function (points, options, canvas) {
this.lines = []
this.texts = []
@ -33,11 +34,12 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
this.innerLines = []
this.children = []
this.separatePolygon = []
this.toFixed = options.toFixed ?? 1
// 소수점 전부 제거
points.forEach((point) => {
point.x = Number(point.x.toFixed(1))
point.y = Number(point.y.toFixed(1))
point.x = Number(point.x.toFixed(this.toFixed))
point.y = Number(point.y.toFixed(this.toFixed))
})
options.selectable = options.selectable ?? true
options.sort = options.sort ?? true