HTML5学习记录之canvas03

<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
       body{background-color:black;}
       #c1{ background-color:white;}
       span{background-color:white;}
    </style>
    <script type="text/javascript">
     window.onload = function()
     {
       var  oC= document.getElementById("c1");
       var oGC = oC.getContext("2d");
      //对比1:先画oGC.fillRect再画 oGC.strokeRect
       oGC.fillStyle = "red";              //----默认黑色填充改为红色
       oGC.fillRect(10.5,30.5 ,100, 100);  /*  填充(默认黑色填充改为红色)的实心方块:参数:left  top  width height */
       oGC.strokeStyle = "blue";    //----默认黑色边框改为红色
       oGC.lineWidth = 10;       //----默认1px边框改为10px            //
       oGC.strokeRect(10.5,30.5 ,100, 100);  /* 带边框(1px边框改为10px )(默认黑色边框改为红色)的空心方块:参数:left  top  width height */ //
     //对比2:先画oGC.strokeRect 再画oGC.fillRect
     /*
       oGC.strokeStyle = "blue";    //----默认黑色边框改为红色
       oGC.lineWidth = 10;       //----默认1px边框改为10px            //
       oGC.strokeRect(10.5,30.5 ,100, 100);
       oGC.fillStyle = "red";              //----默认黑色填充改为红色
       oGC.fillRect(10.5,30.5 ,100, 100);  // 填充(默认黑色填充改为红色)的实心方块:参数:left  top  width height
    
     */
    
    
    
     };
    </script>
    
</head>
<body>
    <canvas id="c1" width="400" height="400">
        <span>不支持canvas标签的浏览器。</span>
    </canvas>   <!--  canvas :默认 宽300高150  -->
</body>
</html>

 

 

浏览器效果(      //对比1:先画oGC.fillRect再画 oGC.strokeRect  )

 

 

浏览器效果(      //对比2   )

 

posted @ 2015-05-17 10:28  July_Zheng  阅读(134)  评论(0)    收藏  举报