
Szachownica
Listing
function drawChessboard(x,y,size) {
for (var i = 0; i < 8; i++) {
for (var j = 0; j < 8; j++) {
if ((i + j) % 2 == 0) {
} else {
ctx.fillRect(x, y, size / 8.0, size / 8.0);
}
ctx.translate(size / 8.0, 0);
}
ctx.translate(-size, size / 8.0);
}
ctx.strokeRect(x,y-size,size,size);
};
var cv = document.getElementById("canvas");
var ctx = cv.getContext("2d");
//ctx.fillStyle="red";
//ctx.fillRect(0,0, cv.width,cv.height);
ctx.fillStyle="black";
ctx.strokeStyle="black";
drawChessboard(40, 40, 300);
