Search code examples
createjs

createjs - way to initialize rotated rectangle?


Is there a way to initialized a rotated rectangle without animating its rotation first?

stage = new createjs.Stage("demoCanvas");
//Create a Shape DisplayObject.
rect = new createjs.Shape();
rect.graphics.beginFill("red").drawRect(100, 100, 40, 40);//these are the x, y, w, and h. But no arguments for rotating?

Thanks,


Solution

  • You want to rotate the graphics themselves? There is not really a way to do this - the rect simply proxies the canvas2d methods.

    You can set rotation on initialization of any shape you want...

    var s = new createjs.Shape(rect).set({rotation: 45});
    

    I am not sure the benefit of rotating the actual coordinates themselves.