kangax/fabricjs.com — pull request #4 by oklemencic (2012-12-26 15:42:31+00:00)
Title: Added scaling by specified origin

I extended the fabric.js file to support scaling by a specified origin. This works when performed via mouse and when performed programmatically using target.scale(..), target.scaleToWidth(...) and target.scaleToHeight(...).

The following code shows such an example (also checked-in in the demo folder)

img.set({
left: img.width / 2,
top: img.height / 2,
lockUniScaling: true,
hasRotatingPoint: true,
useSideAsScalingOrigin: true
});
img.scaleToWidth(800, fabric.ScaleOrigin.TopLeft);
img.scaleToWidth(600, fabric.ScaleOrigin.BottomRight);