Use Matrix of rotate +MozOrientation
Categories: FireFox, Javascript on Jan.24, 2010
Previous post is simple example of usage MozOrientation. But now i use Matrix of rotate and i have nice animation.
You can read many information about Matrix of rotate here. These methods are used in game development, make animations and many others.
- var context = drawingCanvas.getContext('2d');
- var xc = 75;
- var yc = 75;
- var xi = 0;
- var yi = 0;
- var myImage = new Image();
- var angle = (Math.PI/2)*-o.x;
- myImage.onload = function() {
- context.clearRect(0,0,150,150);
- context.save();
- xi = xi*Math.cos(angle)-yi*Math.sin(angle)-xc;
- yi = yi*Math.sin(angle)+yi*Math.cos(angle)-yc;
- context.translate( xc , yc);
- context.rotate(angle);
- context.scale(1+o.y,1+o.y);
- context.drawImage(myImage, xi, yi);
- context.restore();
- }
- myImage.src = "feedme.png";
Result:
Similar posts:



Оставить отзыв