summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.html12
1 files changed, 12 insertions, 0 deletions
diff --git a/index.html b/index.html
index 405e6f8..a2223dc 100644
--- a/index.html
+++ b/index.html
@@ -120,6 +120,9 @@ function boardY(idx){
return (~~(idx/currentGame.size)+0.5)*CELL_WID;
}
+var _redrawBoard_cache_board=null;
+var _redrawBoard_cache_canvas=null;
+
function redrawBoard(){
if(currentGame==null){
interfaceSwitch("connect");
@@ -127,6 +130,12 @@ function redrawBoard(){
}
var G=currentGame;
+ var GboardJSON=JSON.stringify(G.board);
+
+ if(_redrawBoard_cache_board&&GboardJSON==_redrawBoard_cache_board){
+ ctx.putImageData(_redrawBoard_cache_canvas,0,0);
+ return;
+ }
var bsz=G.size*CELL_WID;
if(cvs.width!=bsz||cvs.height!=bsz){cvs.width=bsz; cvs.height=bsz;}
@@ -164,6 +173,9 @@ function redrawBoard(){
ctx.arc(boardX(i),boardY(i),STONE_SIZE,0,2*Math.PI,true);
ctx.fill();
}
+
+ _redrawBoard_cache_board=GboardJSON;
+ _redrawBoard_cache_canvas=ctx.getImageData(0,0,cvs.width,cvs.height);
}
function interfaceGameState(state){