利用HTML5畫出一個(gè)坦克的形狀具體實(shí)現(xiàn)代碼

字號(hào):


    想必大家已對(duì)HTML5如雷貫耳了吧,利用HTML5可以做很多事情,下面與大家分享下利用html5畫出一個(gè)坦克的形狀,具體代碼如下,感興趣的各位可以參考下
    代碼如下:
    var canvas=document.getElementById('myCanvas');
    var ctx= canvas.getContext('2d');
    ctx.fillStyle="#99FF66";
    ctx.fillRect(10,10,15,80);
    //ctx.fillRect(10,80,15,80);
    var canvas=document.getElementById('myCanvas');
    var ctx= canvas.getContext('2d');
    ctx.fillStyle="#99FF66";
    ctx.fillRect(60,10,15,80);
    var canvas=document.getElementById('myCanvas');
    var ctx= canvas.getContext('2d');
    ctx.fillStyle="#0033CC";
    ctx.fillRect(26,27,33,50);
    ctx.fillStyle="red";
    ctx.beginPath();
    ctx.arc(43,52,17,0,Math.PI*2,true);
    ctx.closePath();
    ctx.fill();
    ctx.strokeTyle="#CCCC00";
    ctx.lineWidth=2;
    ctx.moveTo(43,52);
    ctx.lineTo(43,10);
    ctx.stroke();