Rotation with Pixastic

2.1k Views Asked by At

I have a canvas element with an image into.

Now I try to rotate the image in the canvas when I click a button:

$("#rotateC").live('click',function(e) {
        e.preventDefault();
        console.log("rotateC");

        Pixastic.process(firstImg, 'rotate',
            { 
                'angle': +90,
                'leaveDOM': true            
            },
            function(firstImg) {
                ctx.drawImage(firstImg, 0, 0);
            }
        );
    });

The image will rotate once and then if I click the button again, nothing happens.

Do you know what the problem is?

1

There are 1 best solutions below

0
On BEST ANSWER

You can look at How to rotate with pixastic jquery and his demo to solve your problem in jquery! (hope that is okay for you)

$(function(){ 
   $('#rotate').live('click',function() {
     $("#img1").pixastic("rotate", {angle:90});                 
   });
});

should be working if your button has the id rotate and your image the id img1