利用HTML5画出一个坦克的形状具体实现代码



复制代码
代码如下:

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();

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3