Cod1ngFree
Cod1ngFree

Reputation: 1913

setTransform stage method, Easeljs

I'm trying to resize a canvas using EaselJS each time I click on a link. I'm doing this:

function resizeCanvas(){
    console.log("Resizing...")
    stage.setTransform(0,0,1.5,1.5,1,1,1,1,1);

    stage.update();
}

But it seems that it is only resized one time. The documentation says that setTransform returns a DisplayObject: http://www.createjs.com/Docs/EaselJS/classes/Stage.html#method_setTransform

Does it mean that It returns an stage object that I should asign to my old stage variable? How could I resize it properly?

Thanks!

Upvotes: 0

Views: 2640

Answers (2)

Lanny
Lanny

Reputation: 11294

Many display object methods return "this" so the methods can be chained, something like:

container.addChild(new Bitmap(src).set({alpha:0.5}).setTransform(100,200));

Upvotes: 1

Olaf Horstmann
Olaf Horstmann

Reputation: 16892

setTransform() SETs the transform-properties to the given values, it doesn't add it, a way to zoom further would be to save the transform-values in separate variables/object and increase those before calling the setTransform() with it.

But if you just want to zoom the Stage and don't want to save the values separatly you could do something like:

function resizeCanvas() {
    stage.scaleX *= 1.5;
    stage.scaleY *= 1.5;
    // but beware this is exponetial, maybe you want to use this linear method:
    // stage.scaleX/Y += 0.5;

    stage.update();
}

Upvotes: 1

Related Questions