-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathboard.js
53 lines (43 loc) · 1.22 KB
/
board.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
let wight = 700;
let height = 700;
let screenSize = window.innerWidth;
if (screenSize < 500) {
wight = 345;
height = 345;
}
// set the board
let board = new WGo.Board(document.getElementById("board"), {
width: wight,
height: height,
size: 7,
});
// coordiates
var coordinates = {
// draw on grid layer
grid: {
draw: function (args, board) {
var ch, t, xright, xleft, ytop, ybottom;
this.fillStyle = "rgba(0,0,0,0.7)";
this.textBaseline = "middle";
this.textAlign = "center";
this.font = board.stoneRadius + "px " + (board.font || "");
xright = board.getX(-0.5);
xleft = board.getX(board.size - 0.5);
ytop = board.getY(-0.5);
ybottom = board.getY(board.size - 0.5);
for (var i = 0; i < board.size; i++) {
ch = i + "A".charCodeAt(0);
if (ch >= "I".charCodeAt(0)) ch++;
t = board.getY(i);
this.fillText(board.size - i, xright, t);
this.fillText(board.size - i, xleft, t);
t = board.getX(i);
this.fillText(String.fromCharCode(ch), t, ytop);
this.fillText(String.fromCharCode(ch), t, ybottom);
}
this.fillStyle = "black";
},
},
};
board.addCustomObject(coordinates);
export default board;