首页javascriptvideoCanvas - 如何在动画中旋转图像

Canvas - 如何在动画中旋转图像

我们想知道如何在动画中旋转图像。



<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>//<![CDATA[ 
window.onload=function(){
    var can = document.getElementById('canvas1');
    var ctx = can.getContext('2d');
    var myVideo = document.createElement('video');
    // Video tags usually have more than one source. Not all browsers can play Ogg/Theora
    myVideo.src = "http://upload.wikimedia.org/wikipedia/commons/2/2f/Mockingbird_Spring.ogv";
    myVideo.autoplay = true;
    myVideo.loop = true;
    setInterval(function(){
        ctx.drawImage(myVideo, 0, 0, 400, 400);
    }, 60);
}//]]>  
</script>
</head>
<body>
  <canvas id="canvas1" width="400" height="400"></canvas>
</body>
</html>