html5 canvas怎么以某个中心点旋转图片

2025-01-04 23:37:54
推荐回答(1个)
回答1:

var a = 10,wWidth = innerWidth, wHeight = innerHeight;
function drawImg(){
context.save();
context.translate(wWidth/2,wHeight/2);
a++;
context.rotate(a*Math.PI/360);
context.drawImage(img,0-wWidth/2,0-wHeight/2,wWidth,wHeight);
context.restore();
setTimeout(drawImg,20);
}
以图片中心点旋转