Answer the question
In order to leave comments, you need to log in
Html5 canvas, how to draw a chessboard-like object?
Need to draw such an unusual board
function init() {
let canvas = document.querySelector(".canvas");
canvas.width = 760;
canvas.height = 690;
let ctx = canvas.getContext("2d");
ctx.fillStyle = 'grey'; // меняем цвет клеток
ctx.fillRect(0, 0, 760, 690);
for (i=0; i<8; i+=2) {
for (j = 0; j < 8; j += 2) {
ctx.clearRect(0 + i * 32, 0 + j * 32, 32, 32);
ctx.clearRect(0 + (i + 1) * 32, 0 + (j + 1) * 32, 32, 32);
}
}
}
init();
Answer the question
In order to leave comments, you need to log in
split the square into 2, big 8x8 and small 4x4. 8x8 already done, now change the color to white in the 4x4 square.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question