diff options
-rw-r--r-- | index.html | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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){ |