forked from bdsword/MatlabGo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateChessBoard.m
31 lines (31 loc) · 1.07 KB
/
updateChessBoard.m
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
function updateChessBoard(chessPaintBoard)
global chessBoard;
global chessRadius;
%global history;
global lastSetChess;
cla(chessPaintBoard);
oldGca=gca;
set(gcf,'CurrentAxes',chessPaintBoard);
for i=1:19
for j=1:19
if chessBoard(i,j)==1
circle(i,j,chessRadius,[0,0,0],[0,0,0],'-',.5);
elseif chessBoard(i,j)==2
circle(i,j,chessRadius,[1,1,1],[0,0,0],'-',.5);
end
if i==lastSetChess(1)&&j==lastSetChess(2)
circle(i,j,chessRadius,'none',[.1,.6,.2],'-',2);
end
end
end
set(gcf,'CurrentAxes',oldGca);
function circleHandle = circle(x,y,r,color,edgeColor,lineStyle,lineWidth)
global blocksWidth;
global origin;
xDraw = origin(1)+blocksWidth(1)*(x-1);
yDraw = origin(2)+blocksWidth(2)*(y-1);
circleHandle=rectangle('Curvature',[1 1], ...
'Position',[xDraw-r/2 yDraw-r/2 r r], ...
'FaceColor',color,'EdgeColor',edgeColor,'LineStyle',lineStyle,'LineWidth',lineWidth);
end
end