Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/432.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用缩放上下文重置旋转?_Javascript_Canvas_Html5 Canvas_Fabricjs - Fatal编程技术网

Javascript 如何使用缩放上下文重置旋转?

Javascript 如何使用缩放上下文重置旋转?,javascript,canvas,html5-canvas,fabricjs,Javascript,Canvas,Html5 Canvas,Fabricjs,Fabric.js的示例: 最后一项,保持缩放,但如何重置 // how reset rotate with scale ? I dont' know var itemS=new fabric.Rect(); itemS.set({originX:'left',originY:'top',width:50,height:50,left:145,top:135, fill: '#E14B17',hasControls:false,selectable:false,angle:30,scaleX

Fabric.js的示例:

最后一项,保持缩放,但如何重置

// how reset rotate with scale ? I dont' know

var itemS=new fabric.Rect();
itemS.set({originX:'left',originY:'top',width:50,height:50,left:145,top:135, fill: '#E14B17',hasControls:false,selectable:false,angle:30,scaleX:1.5});
canvas.add(itemS);

itemS.clipTo = function (ctx)
{
      ctx.save();
    // how reset rotate with scale ?
      ctx.rotate((this.angle* -1) * (Math.PI / 180));   
      ctx.rect((-this.width/2),(-this.height/2),this.width,this.height);    
      ctx.restore();
      ctx.stroke();
}

canvas.renderAll();