Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.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 HTML5中形状的旋转_Javascript_Canvas_Html5 Canvas_Easeljs - Fatal编程技术网

Javascript HTML5中形状的旋转

Javascript HTML5中形状的旋转,javascript,canvas,html5-canvas,easeljs,Javascript,Canvas,Html5 Canvas,Easeljs,我想创建一个与水平线成此角度的数组。这是创建箭头的函数的代码 var offset; if (this.dLength < 10) offset = this.dLength; else offset = Math.min(this.dLength * 0.1, 10); this.shape = new createjs.Shape(); //rotation this.canvasId = this.stage.canvas.id;

我想创建一个与水平线成此角度的数组。这是创建箭头的函数的代码

var offset;

    if (this.dLength < 10) offset = this.dLength;
    else offset = Math.min(this.dLength * 0.1, 10);

    this.shape = new createjs.Shape();

    //rotation

    this.canvasId = this.stage.canvas.id;
    this.canvas = document.getElementById(this.canvasId);
    if(this.canvas) {
        this.ctx = this.canvas.getContext("2d");    
    }
    if(this.ctx) {
        console.log('rotate');
        this.ctx.save();
        this.ctx.rotate(this.dAngle);
    }

    this.canvasId = this.stage.canvas.id;
    this.canvas = document.getElementById(this.canvasId);
    this.ctx = this.canvas.getContext("2d");

    this.shape.graphics.clear();
    this.shape.graphics.beginStroke("black");

    this.shape.graphics.moveTo(0, 50);
    this.shape.graphics.lineTo(this.dLength, 50);

    this.shape.graphics.moveTo((this.dLength - offset), 50+(offset / 2));
    this.shape.graphics.lineTo(this.dLength, 50);
    this.shape.graphics.lineTo((this.dLength - offset), 50+(-offset / 2));

    this.ctx.restore();
var偏移量;
如果(此.dLength<10)偏移量=此.dLength;
else offset=数学最小值(此.dLength*0.1,10);
this.shape=new createjs.shape();
//轮换
this.canvasId=this.stage.canvas.id;
this.canvas=document.getElementById(this.canvasId);
if(this.canvas){
this.ctx=this.canvas.getContext(“2d”);
}
if(this.ctx){
console.log('rotate');
这个.ctx.save();
this.ctx.rotate(this.dAngle);
}
this.canvasId=this.stage.canvas.id;
this.canvas=document.getElementById(this.canvasId);
this.ctx=this.canvas.getContext(“2d”);
this.shape.graphics.clear();
this.shape.graphics.beginStroke(“黑色”);
this.shape.graphics.moveTo(0,50);
this.shape.graphics.lineTo(this.dlelength,50);
this.shape.graphics.moveTo((this.dleength-offset),50+(offset/2));
this.shape.graphics.lineTo(this.dlelength,50);
this.shape.graphics.lineTo((this.dleength-offset),50+(-offset/2));
这个.ctx.restore();

但目前还没有进行轮换。有解决方案吗?

当easeljs的形状具有旋转权限时,您可以直接使用画布,也可以通过easeljs使用画布。选择你的武器!;-)是的,我通过使用画架创建形状,然后使用旋转属性来解决它。