为啥不管输入黑棋白棋,都是黑棋
window.onload=function(){
var chess=document.getElementById('chess');
var context=chess.getContext('2d');
context.strokeStyle="#BFBFBF"
drawChessBoard(context);
oneStep(1,1,true,context);
oneStep(2,1,false,context);
}
function drawChessBoard(cxt){
for(var i=0;i<15;i++){
cxt.moveTo(15+i*30,15);
cxt.lineTo(15+i*30,435);
cxt.stroke();
cxt.moveTo(15,15+i*30);
cxt.lineTo(435,15+i*30);
cxt.stroke();
}}
var oneStep=function(i,j,me,cxt){
cxt.beginPath();
cxt.arc(15+i*30,15+j*30,13,0,2*Math.PI);
cxt.closePath();
var gradient=cxt.createRadialGradient(15+i*30+2,15+j*30-2,15,15+i*30+2,15+j*30-2,0);
if (me=true){
gradient.addColorStop(0,"#0A0A0A");
gradient.addColorStop(1,"#636766");
}
else{
gradient.addColorStop(0,"#D1D1D1");
gradient.addColorStop(1,"#F9F9F9");
}
cxt.fillStyle=gradient;
cxt.fill ();
}