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', 'fontStyle',
'fontWeight', 'fontWeight',
'dormerAttributes', 'dormerAttributes',
'toFixed',
] ]
export const OBJECT_PROTOTYPE = [fabric.Line.prototype, fabric.Polygon.prototype, fabric.Triangle.prototype, fabric.Group.prototype] 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, initOptions: null,
direction: null, direction: null,
arrow: null, arrow: null,
toFixed: 1,
initialize: function (points, options, canvas) { initialize: function (points, options, canvas) {
this.lines = [] this.lines = []
this.texts = [] this.texts = []
@ -33,11 +34,12 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
this.innerLines = [] this.innerLines = []
this.children = [] this.children = []
this.separatePolygon = [] this.separatePolygon = []
this.toFixed = options.toFixed ?? 1
// 소수점 전부 제거 // 소수점 전부 제거
points.forEach((point) => { points.forEach((point) => {
point.x = Number(point.x.toFixed(1)) point.x = Number(point.x.toFixed(this.toFixed))
point.y = Number(point.y.toFixed(1)) point.y = Number(point.y.toFixed(this.toFixed))
}) })
options.selectable = options.selectable ?? true options.selectable = options.selectable ?? true
options.sort = options.sort ?? true options.sort = options.sort ?? true