How does transforming points with a transformMatrix work in fabricJS?

后端 未结 3 1995
耶瑟儿~
耶瑟儿~ 2020-12-01 17:54

I\'m trying to place points (made via fabric.Circle) on the corners of a fabric.Polygon. The polygon may be moved, scaled or rotated by the user. H

3条回答
  •  情深已故
    2020-12-01 18:15

    The above code was working and saving to database properly, but still the offset persisted in the points while I enlarged and moved. So, I decided to set the width and height along with setting the points.

    var width = self.polygon.width;
    var height = polygon.height;
    var scaleX = polygon.scaleX;
    var scaleY = polygon.scaleY;
    
    polygon.set({
        width: width * scaleX,
        height: height * scaleY,
        scaleX: 1,
        scaleY: 1
    });
    

提交回复
热议问题