amit gupta
amit gupta

Reputation: 1330

Re-sizing and rotating is not working in fabricjs while using ctx.scale() method in canvas?

I am trying to set canvas shape to oval using ctx.scale() method in canvas.clipTo function while doing this my re-size and dragging properties are not working properly in fabric.js. anyone have any idea how to resolve this issue ? here is my code //html

<canvas id="c" width="400" height="200"></canvas>

//script

var w=canvas.width / 4;
var h=canvas.height / 2;
canvas.clipTo = function(ctx) {

 ctx.scale(2, 1);
 ctx.arc(w, h, 90, 0, 2 * Math.PI, true);

};
 canvas.renderAll();

Here is my Fiddle Demo

Upvotes: 0

Views: 170

Answers (1)

Tom
Tom

Reputation: 4652

Save and restore it as well in clipTo function -

ctx.save();
ctx.scale(2, 1);
ctx.arc(w, h, 90, 0, 2 * Math.PI, true);
ctx.restore();

Upvotes: 1

Related Questions