7.HTML5 高级Canvas技术-基本动画

来源:互联网 发布:cdma是什么网络 编辑:程序博客网 时间:2024/05/01 12:51
<body><script>var canvas;var context;  window.onload=function(){  canvas=document.getElementById("drawingCanvas");  context=canvas.getContext("2d");    drawFrame();  };    var squareX=0;  var squareY=0;    function drawFrame(){  context.clearRect(0, 0, canvas.width, canvas.height);  context.beginPath();    context.rect(squareX,squareY,20,20);  context.lineStyle="black";  context.lineWidth=1;  context.fillStyle="red";  context.fill();  context.stroke();    squareX++;  squareY++;    setTimeout("drawFrame()",20);  } </script> <canvas id="drawingCanvas" width="600px" height="600px"></canvas>  </body>

0 0
原创粉丝点击