Sayed's Blog

drawlang > docs > users > examples > chessboard

Chess Board

var canvas = getCanvas();
var black = Color(0, 0, 0, 255);
var white = Color(255, 255, 255, 255);
var size = 45;

for (var row = 0; row < 8; row++) {
	for (var col = 0; col < 8; col++) {
		var tile = (row+col) % 2 == 0 ? black : white;
		canvas.setColor(tile);
		canvas.fillRect(col*size, row*size, size, size);
	}
}

    © 2023