html5 canvas画图

实现这样一个页面,5条线一共5项,每条线上5个点,一个点1分,点完5项后可以连成一个区域,可计分,求大神指导,

情况说明: 图像绘制,使用setInterval闪,没图像;

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<!-- TemplateBeginEditable name="doctitle" -->
<title>我图片</title>

</head>

<body>
<canvas id="Map" width="500" height="500" style="background:gray;"></canvas>

<script>
// 设置绘图环境
var myMap = document.getElementById("Map");
var cxt=myMap.getContext('2d');

// 设置图像位置初始位置变量
var x=20;
var y=20;

// 创建绘图象,并且画
var img =new Image();
img.src="image/gun.png";
draw();
function draw()
{
cxt.clearRect(0,0,500,500);
x+=10;
y+=50;
img.onload=function()
{
cxt.drawImage(img,x,y,80,80);
}
}

window.setInterval("draw()",100);
</script>
</body>
</html>
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

大家正在搜

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网