Last active
November 1, 2018 18:44
-
-
Save primats/99b3aed05326440cbff7 to your computer and use it in GitHub Desktop.
Шахматная доска на канве
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Шахматная доска на канве</title> | |
</head> | |
<body> | |
<canvas id='example'>Обновите браузер</canvas> | |
<script> | |
var example = document.getElementById("example"); | |
var ctx = example.getContext('2d'); | |
example.width = 300; | |
example.height = 300; | |
ctx.strokeStyle = '#B70A02'; // меняем цвет рамки | |
ctx.strokeRect(15, 15, 266, 266); | |
ctx.strokeRect(18, 18, 260, 260); | |
ctx.fillStyle = '#AF5200'; // меняем цвет клеток | |
ctx.fillRect(20, 20, 256, 256); | |
for (i=0; i<8; i+=2) | |
for (j=0; j<8; j+=2) { | |
ctx.clearRect(20+i*32, 20+j*32, 32, 32); | |
ctx.clearRect(20+(i+1)*32, 20+(j+1)*32, 32, 32); | |
} | |
</script> | |
</body> | |
<⁄html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment