<style>
*{margin:0;}/*解决浏览器的兼容问题*/
#canvas{background:#f4f4f4;
margin:100px auto auto auto;
display:block;
border:7px solid #3d3d3d;
box-shadow:0 0 30px;
}
body{
background:url(http://img.zcool.cn/community/018d4e554967920000019ae9df1533.jpg@900w_1l_2o_100sh.jpg);
background-size:cover;;
}
button{
height:40px;
width:100px;
display:block;
margin:45px auto ;
border-radius: 25px;
}
</style>
</head>
<body>
<canvas id="canvas" height="450" width="450"></canvas>
<button id="restart">重新开始</button>
</body>
一、以上是界面的代码
二、js的部分代码
//获得画板
var chess=document.getElementById("canvas");
//获得画笔(上下文)
var context=c