how to get new position of polygon points after resize & move the polygon

Viewed 132

I am working on a fabricjs project in that, I created dynamic polygon.so i am using fabric.util.transformPoint(point, matrix); to get the new position of polygon points after resize and move it. but if we draw more than 1 polygon then transformPoint only update the last polygon points. how to get previous or other polygon updated points?

//code to draw a polygon 
roof =  new fabric.Polygon(newroofpoint, {
    fill: 'rgba(0,0,0,0)',
    strokeWidth: 1,
    roi_id:id,
    stroke:'blue',
    selectable: true
});
//code to get updated points of polygon
var matrix = roof.calcTransformMatrix();
var transformedPoints = roof.get("points").map(function(o){
    return new fabric.Point(o.x - roof.pathOffset.x, o.y - roof.pathOffset.y);
}).map(function(o){
    freehand_move_points.push(fabric.util.transformPoint(o, matrix));
    return fabric.util.transformPoint(o, matrix);
});
0 Answers
Related