canvas最简程序

<html>
<head>
    <script>
    window.onload = function(){
        var canvas = document.getElementById("cc");
        var context = canvas.getContext("2d");
        context.fillStyle = "red";
        context.fillRect(0, 0, 1000, 1000);
        context.fillStyle = "black";
        context.fillRect(10,10,100,100);
    }
    </script>
</head>
<body>
    <canvas id="cc" width=300 height=300></canvas>
</body>
</html>
原文地址:https://www.cnblogs.com/wangjixianyun/p/3066598.html