用HTML5 Canvas API中的clearRect()方法实现橡皮擦功能

2020-04-21 23:47:31易采站长站整理

</div>   
  
<script>   
    window.onload = function(){   
        var canvas = document.getElementById("canvas");   
        canvas.width = 800;   
        canvas.height = 600;   
        var context = canvas.getContext("2d");   
        context.fillStyle = "#FFF";   
        context.fillRect(0,0,800,600);   
  
        //清空画布   
        context.clearRect(0,0,canvas.width,canvas.height);   
  
    };   
</script>   
</body>   
</html>  

2016315111932638.jpg (1235×714)