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使用画布。选择你的武器!;-)是的,我通过使用画架创建形状,然后使用旋转属性来解决它。