javascript - FabricJS: using object controls on canvas to resize, but not scale -
the problem update actual object.width, object.height
, keep object.scalex = 1
, object.scaley = 1
when using visual controls on canvas.
the origin of problem when manipulating object using controls, fabric.js changes scale of object, scaling stroke of paths, of same width always.
so make more adobe illustrator-like, , not scale width of stroke along width of rectalngular, example.
i have found solution question formulated in different manner here:
rect stroke, stroke line mis-transformed when scaled
the idea calculate new would-be width , height using new scale factors, set new dimensions , reset scale factors 1.
here's code example answer:
el.on({ 'scaling': function(e) { var obj = this, w = obj.width * obj.scalex, h = obj.height * obj.scaley, s = obj.strokewidth; obj.set({ 'height' : h, 'width' : w, 'scalex' : 1, 'scaley' : 1 }); } });
Comments
Post a Comment