import { fabric } from 'fabric'
import { QLine } from '@/components/fabric/QLine'

export const defineQLine = () => {
  fabric.QLine.fromObject = function (object, callback) {
    function _callback(instance) {
      delete instance.points
      callback && callback(instance)
    }
    const options = fabric.util.object.clone(object, true)
    options.points = [object.x1, object.y1, object.x2, object.y2]

    fabric.Object._fromObject('QLine', options, _callback, 'points')
  }
}
