Reputation: 65
In the example in the jsbin, if you click the button once, the rect gets scaled, but the 2nd time, it doesn't scale.
I thought, if you keep calling scale(0.75) then it would scale the rect 75% of its current size, so it would basically keep getting smaller and smaller.
I'm sure I'm missing something very basic since my example is very simple, but I've read so much documentation, and I still can't figure it out. Any ideas?
Upvotes: 0
Views: 55
Reputation: 2415
It's because the rect is scaled from original size, you set once you created it (350x350).
If you want to scale it from actual size every time, you need to recalculate the argument to the rect.scale
method. E.g. save the previous value and multiply it on 0.75 every time:
var ratio = 1;
function resize() {
ratio = ratio * 0.75;
rect.scale(ratio);
canvas.renderAll();
}
Upvotes: 1