路径错误位置的边界框

时间:2015-03-09 16:37:27

标签: javascript fabricjs

我在数据库中保存了几条路径的问题。事实证明,边界框完全偏离了对象。有人帮帮我吗?

enter image description here

路径示例:

{"objects":[{"type":"path","originX":"center","originY":"center","left":200,"top":100,"width":162.33,"height":162.33,"fill":"#D1D3D4","overlayFill":null,"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,"scaleX":0.84,"scaleY":0.84,"angle":0,"flipX":false,"flipY":false,"opacity":1,"shadow":null,"visible":true,"clipTo":null,"path":[["M",162.329,81.164],["c",0,44.826,-36.338,81.165,-81.164,81.165],["C",36.338,162.329,0,125.99,0,81.164],["C",0,36.338,36.338,0,81.165,0],["C",125.99,0,162.329,36.338,162.329,81.164],["z"]],"pathOffset":{"x":-81.165,"y":-81.165}}],"background":"#f7f7f7"}

这是一个小提琴:http://jsfiddle.net/3q61vmef/1/

1 个答案:

答案 0 :(得分:0)

发现错误。错误在pathOffset属性中。需要将xy值更改为零,方法如下:

"pathOffset":{"x":0,"y":-81.165}

为:

"pathOffset":{"x":0,"y":0}

谢谢。