首页 > 开发 > HTML > 正文

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

2019-10-27 21:45:01
字体:
来源:转载
供稿:网友

点评:想必大家已对HTML5如雷贯耳了吧,利用HTML5可以做很多事情,下面与大家分享下利用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();


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表