forked from Latreth/Projet_WebDev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTerrain.js
More file actions
38 lines (36 loc) · 844 Bytes
/
Terrain.js
File metadata and controls
38 lines (36 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
var text=["a","b","c","d","e","f","g","h"];
var nbr=["1","2","3","4","5","6","7","8"];
ctx.font = "20px Georgia";
for (i=0;i<8;i++){
for(j=0;j<8;j++){
if (i%2==0) {
if (j%2==0){
ctx.fillStyle='white';
ctx.fillRect(i*40,j*40,40,40);
}
else {
ctx.fillStyle = 'black';
ctx.fillRect(i*40,j*40,40,40);
}
}
else {
if (j%2==0){
ctx.fillStyle = 'black';
ctx.fillRect(i*40,j*40,40,40);
}
else {
ctx.fillStyle='white';
ctx.fillRect(i*40,j*40,40,40);
}
}
if (j==7){
ctx.strokeText(text[i],(i+0.5)*40,(j+1.5)*40);
}
if(i==7){
ctx.strokeText(nbr[j],(i+1.2)*40,(j+0.7)*40);
}
}
}
ctx.strokeRect(0,0,320,320);