在HTML5中旋转形状

时间:2014-06-11 08:53:08

标签: javascript canvas html5-canvas easeljs

我想创建一个数字,该角度为this.dAngle与水平线。这是我创建箭头的函数的代码。

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();

但轮换没有完成。任何解决方案?

0 个答案:

没有答案