我正在尝试制作多个可编辑的多边形,结构中是否有一个功能可以选择对象并使之可编辑,或者我必须手工实现。绘制多个多边形的代码示例如下:https://codepen.io/durga598/pen/gXQjdw
generatePolygon : function(pointArray){
var points = new Array();
$.each(pointArray,function(index,point){
points.push({
x:point.left,
y:point.top
});
canvas.remove(point);
});
$.each(lineArray,function(index,line){
canvas.remove(line);
});
canvas.remove(activeShape).remove(activeLine);
var polygon = new fabric.Polygon(points,{
stroke:'#333333',
strokeWidth:0.5,
fill: 'red',
opacity: 1,
hasBorders: false,
hasControls: false
});
canvas.add(polygon);
activeLine = null;
activeShape = null;
polygonMode = false;
canvas.selection = true;
}
};